当前位置: 首页>>代码示例>>C++>>正文


C++ print_mac函数代码示例

本文整理汇总了C++中print_mac函数的典型用法代码示例。如果您正苦于以下问题:C++ print_mac函数的具体用法?C++ print_mac怎么用?C++ print_mac使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了print_mac函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parse_arp

static void parse_arp(arp_hdr *a)
{
	char mac1[macbuf_size];
	char mac2[macbuf_size];
	char ip1[ipbuf_size];
	char ip2[ipbuf_size];

	print_mac(mac1, &a->snd_hw_addr);
	print_mac(mac2, &a->target_hw_addr);
	print_ip(ip1, &a->snd_prot_addr);
	print_ip(ip2, &a->target_prot_addr);

	if (PA_ARP) {
		switch(ntohs(a->op))
		{
			case arp_op_request:
				printf(" REQ from %s (%s) for %s\n", mac1, ip1, ip2);
				break;
			case arp_op_reply:
				printf(" REPLY from %s (%s), target = %s (%s)\n",
						mac1, ip1, mac2, ip2);
				break;
			case arp_op_rarp_request:
				printf(" RARP REQ from %s (%s) for %s\n", mac1, ip1, ip2);
				break;
			case arp_op_rarp_reply:
				printf(" RARP REPLY from %s (%s), target = %s (%s)\n",
						mac1, ip1, mac2, ip2);
				break;
		}
	}
}
开发者ID:duli2888,项目名称:company_testwork,代码行数:32,代码来源:analyze.c

示例2: print_stuff

static void
print_stuff() {
	printf("tmr now = %ss\n", time_now_f());

	printf("SDK version: %s\n", system_get_sdk_version());
	printf("APP version: %s built: %s %s\n", BUILD_DATE, __DATE__, __TIME__);

	printf("CPU freq was %d\n", system_get_cpu_freq());
	printf("CPU freq = %d\n", set_cpu_freq(160));
	printf("tmr now = %ss\n", time_now_f());

	printf("tout    = %sV\n", ffp(3, read_tout(0)*123/10));
	printf("vdd     = %sV\n", ffp(3, read_vdd()));

	print_mac(STATION_IF);
	print_mac(SOFTAP_IF);

	print_ip_info(SOFTAP_IF);
	print_ip_info(STATION_IF);

	printf("tmr now = %ss\n", time_now_f());
	printf("sleeping 2s\n");
	system_deep_sleep(2*1000000);
	vTaskDelete(NULL);
}
开发者ID:AlwinIndraswara,项目名称:ESP8266Lib,代码行数:25,代码来源:file3.c

示例3: dissect_ether

void dissect_ether(const u_char *packet) {
    ether_hdr *hdr = (ether_hdr*) packet;
    u_char *pdu = (u_char*)(packet + 14);
    uint16 ether_type = ntohs(hdr->ether_type);

    print_line();
    printf("Dst MAC: ");
    print_mac(hdr->dst_MAC);
    printf("\n");
    printf("Src MAC: ");
    print_mac(hdr->src_MAC);
    printf("\n");

    switch(ether_type){ 
    case ETHER_TYPE_VLAN:
        dissect_vlan(pdu);
        break;
    case ETHER_TYPE_IPv4:
        dissect_ipv4(pdu);
        break;
    case ETHER_TYPE_IPv6:
        dissect_ipv6(pdu);
        break;
    case ETHER_TYPE_ARP:
        dissect_arp(pdu);
        break;
    default:
        printf("Ether type is: %x\n", ether_type);
        break;
    }
}
开发者ID:patrickzzy,项目名称:Practice,代码行数:31,代码来源:raw_pkt_sock.c

示例4: dump_ehdr

static void dump_ehdr(struct ethhdr *ehdr)
{
	DECLARE_MAC_BUF(mac);
	DECLARE_MAC_BUF(mac2);
	printk("ehdr[h_dst(%s)"
	       "h_source(%s)"
	       "h_proto(%04x)]\n",
	       print_mac(mac, ehdr->h_dest), print_mac(mac2, ehdr->h_source),
	       ehdr->h_proto);
}
开发者ID:E-LLP,项目名称:n900,代码行数:10,代码来源:myri_sbus.c

示例5: nlm_vnet_dump_ether_hdr

static inline void nlm_vnet_dump_ether_hdr(struct ethhdr* eth)
{
	DECLARE_MAC_BUF(dest);
	DECLARE_MAC_BUF(src);

	VNET_DBG("eth header: dest %s source %s proto %04x\n",
		 print_mac(dest, eth->h_dest),
		 print_mac(src, eth->h_source),
		 ntohs(eth->h_proto));
}
开发者ID:akennedy-adtran,项目名称:linux_mmc_2.6.32.9,代码行数:10,代码来源:nlm_vnet.c

示例6: update_asset_arp

short update_asset_arp(u_int8_t arp_sha[MAC_ADDR_LEN], packetinfo *pi)
{
    if (asset_lookup(pi) == SUCCESS) {
        if (pi->asset != NULL) {
            goto arp_update;
        } else {
            printf("\nBAD ERROR in update_asset_arp\n");
            return ERROR;
        }
    } else {

        add_asset(pi);
        update_asset(pi);

        if ( pi->asset == NULL ) {
            elog("update_asset(pi) failed! Asset does not exist! Cant enter MAC!!! die();\n");
            return ERROR;
        }
        if (update_asset_arp(arp_sha, pi) == SUCCESS) {
            return SUCCESS;
        } else {
            return ERROR;
        }
    }

arp_update:
    /* Check the ARP data structure for an existing entry */
    if (memcmp(pi->asset->mac_addr, arp_sha, MAC_ADDR_LEN) == 0) {
        /* UPDATE TIME STAMP */
        pi->asset->last_seen = pi->pheader->ts.tv_sec;
        return SUCCESS;
    } else {
        /* UPDATE MAC AND TIME STAMP */
        /* XXX: this handler suxx! */
        if(memcmp(pi->asset->mac_addr, "\0\0\0\0\0\0", 6)){
            printf("ACHTUNG! MAC changed! : ");
            print_mac(pi->asset->mac_addr);
            printf(" -> ");

            print_mac(arp_sha);
            printf("\n");

        }
        if(pi->asset->macentry == NULL) {
           // vendor entry did not exist.
           mac_entry *match = match_mac(config.sig_mac, arp_sha, 48);
           pi->asset->macentry = match;
        }
        memcpy(&pi->asset->mac_addr, arp_sha, MAC_ADDR_LEN);
        pi->asset->last_seen = pi->pheader->ts.tv_sec;
        log_asset_arp(pi->asset);
        return SUCCESS;
    }
}
开发者ID:Ammaro,项目名称:prads,代码行数:54,代码来源:assets.c

示例7: print_mac_and_mask

static void print_mac_and_mask(const unsigned char *mac, const unsigned char *mask, int l)
{
	int i;

	print_mac(mac, l);
	for (i = 0; i < l ; i++)
		if (mask[i] != 255)
			break;
	if (i == l)
		return;
	printf("/");
	print_mac(mask, l);
}
开发者ID:nimai,项目名称:iptables,代码行数:13,代码来源:nft-arp.c

示例8: emit_dbus_signal

void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname)
{
  DBusConnection *connection = (DBusConnection *)daemon->dbus;
  DBusMessage* message = NULL;
  DBusMessageIter args;
  char *action_str, *mac = daemon->namebuff;
  unsigned char *p;
  int i;

  if (!connection)
    return;
  
  if (!hostname)
    hostname = "";
  
#ifdef HAVE_DHCP6
   if (lease->flags & (LEASE_TA | LEASE_NA))
     {
       print_mac(mac, lease->clid, lease->clid_len);
       inet_ntop(AF_INET6, lease->hwaddr, daemon->addrbuff, ADDRSTRLEN);
     }
   else
#endif
     {
       p = extended_hwaddr(lease->hwaddr_type, lease->hwaddr_len,
			   lease->hwaddr, lease->clid_len, lease->clid, &i);
       print_mac(mac, p, i);
       inet_ntop(AF_INET, &lease->addr, daemon->addrbuff, ADDRSTRLEN);
     }

  if (action == ACTION_DEL)
    action_str = "DhcpLeaseDeleted";
  else if (action == ACTION_ADD)
    action_str = "DhcpLeaseAdded";
  else if (action == ACTION_OLD)
    action_str = "DhcpLeaseUpdated";
  else
    return;

  if (!(message = dbus_message_new_signal(DNSMASQ_PATH, daemon->dbus_name, action_str)))
    return;
  
  dbus_message_iter_init_append(message, &args);
  
  if (dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &daemon->addrbuff) &&
      dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &mac) &&
      dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &hostname))
    dbus_connection_send(connection, message, NULL);
  
  dbus_message_unref(message);
}
开发者ID:afdnlw,项目名称:dnsmasq-chinadns,代码行数:51,代码来源:dbus.c

示例9: save

/* Saves the union ipt_matchinfo in parsable form to stdout. */
static void save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
{
	if (((struct ipt_mac_info *)match->data)->invert)
		printf("! ");
	if (((struct ipt_mac_info *)match->data)->type==0)
	{
	printf("--mac-source ");
	print_mac(((struct ipt_mac_info *)match->data)->srcaddr);
	}else
	{
	printf("--mac-destination ");
	print_mac(((struct ipt_mac_info *)match->data)->srcaddr);
	}
}	
开发者ID:ebichu,项目名称:dd-wrt,代码行数:15,代码来源:libipt_mac.c

示例10: ieee80211_key_enable_hw_accel

static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
{
	const u8 *addr;
	int ret;
	DECLARE_MAC_BUF(mac);

	assert_key_lock();
	might_sleep();

	if (!key->local->ops->set_key)
		return;

	addr = get_mac_for_key(key);

	ret = key->local->ops->set_key(local_to_hw(key->local), SET_KEY,
				       key->sdata->dev->dev_addr, addr,
				       &key->conf);

	if (!ret) {
		spin_lock(&todo_lock);
		key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
		spin_unlock(&todo_lock);
	}

	if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP)
		printk(KERN_ERR "mac80211-%s: failed to set key "
		       "(%d, %s) to hardware (%d)\n",
		       wiphy_name(key->local->hw.wiphy),
		       key->conf.keyidx, print_mac(mac, addr), ret);
}
开发者ID:DINKIN,项目名称:tuo,代码行数:30,代码来源:key.c

示例11: ieee80211_sta_debugfs_add

void ieee80211_sta_debugfs_add(struct sta_info *sta)
{
	struct dentry *stations_dir = sta->local->debugfs.stations;
	DECLARE_MAC_BUF(mbuf);
	u8 *mac;

	if (!stations_dir)
		return;

	mac = print_mac(mbuf, sta->addr);

	sta->debugfs.dir = debugfs_create_dir(mac, stations_dir);
	if (!sta->debugfs.dir)
		return;

	DEBUGFS_ADD(flags);
	DEBUGFS_ADD(num_ps_buf_frames);
	DEBUGFS_ADD(inactive_ms);
	DEBUGFS_ADD(last_seq_ctrl);
#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
	DEBUGFS_ADD(wme_rx_queue);
	DEBUGFS_ADD(wme_tx_queue);
#endif
	DEBUGFS_ADD(agg_status);
}
开发者ID:maraz,项目名称:linux-2.6,代码行数:25,代码来源:debugfs_sta.c

示例12: ieee80211_key_disable_hw_accel

static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
{
	const u8 *addr;
	int ret;
	DECLARE_MAC_BUF(mac);

	assert_key_lock();
	might_sleep();

	if (!key || !key->local->ops->set_key)
		return;

	spin_lock(&todo_lock);
	if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
		spin_unlock(&todo_lock);
		return;
	}
	spin_unlock(&todo_lock);

	addr = get_mac_for_key(key);

	ret = key->local->ops->set_key(local_to_hw(key->local), DISABLE_KEY,
				       key->sdata->dev->dev_addr, addr,
				       &key->conf);

	if (ret)
		printk(KERN_ERR "mac80211-%s: failed to remove key "
		       "(%d, %s) from hardware (%d)\n",
		       wiphy_name(key->local->hw.wiphy),
		       key->conf.keyidx, print_mac(mac, addr), ret);

	spin_lock(&todo_lock);
	key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
	spin_unlock(&todo_lock);
}
开发者ID:DINKIN,项目名称:tuo,代码行数:35,代码来源:key.c

示例13: convert_mac_str2hex

//int convert_mac_str2hex(char *str1, char *hex)
int convert_mac_str2hex(void)
{
	/*
std::string mac = "00:00:12:24:36:4f";
unsigned u[6];
int c=sscanf(mac.c_str(),"%x:%x:%x:%x:%x:%x",u,u+1,u+2,u+3,u+4,u+5);
if (c!=6) raise_error("input format error");
uint64_t r=0;
for (int i=0;i<6;i++) r=(r<<8)+u[i];
 or:  for (int i=0;i<6;i++) r=(r<<8)+u[5-i];
*/
	const char *str = STR;
	unsigned u[6];
	int c = sscanf(str, "%x:%x:%x:%x:%x:%x", u, u + 1, u + 2, u + 3, u + 4, u + 5);
	if (c != 6) {
		printf("input format error\n");
	}
	
	uint64_t r = 0;
	int i = 0;
	for (i = 0; i < 6; i++) {
		r = (r << 8) + u[i];
	}
	
	printf("%02X\n", (char )u[0]);
	printf("%02X\n", u[1]);
	printf("%02X\n", u[2]);
	print_mac(u, 6);
	return 0;
}
开发者ID:JackieXie168,项目名称:connect,代码行数:31,代码来源:filter.c

示例14: zd_mac_set_mac_address

int zd_mac_set_mac_address(struct net_device *netdev, void *p)
{
	int r;
	unsigned long flags;
	struct sockaddr *addr = p;
	struct zd_mac *mac = zd_netdev_mac(netdev);
	struct zd_chip *chip = &mac->chip;
	DECLARE_MAC_BUF(mac2);

	if (!is_valid_ether_addr(addr->sa_data))
		return -EADDRNOTAVAIL;

	dev_dbg_f(zd_mac_dev(mac),
		  "Setting MAC to %s\n", print_mac(mac2, addr->sa_data));

	r = zd_write_mac_addr(chip, addr->sa_data);
	if (r)
		return r;

	spin_lock_irqsave(&mac->lock, flags);
	memcpy(netdev->dev_addr, addr->sa_data, ETH_ALEN);
	spin_unlock_irqrestore(&mac->lock, flags);

	return 0;
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:25,代码来源:zd_mac.c

示例15: save

/* Saves the union ip6t_matchinfo in parsable form to stdout. */
static void save(const struct ip6t_ip6 *ip, const struct ip6t_entry_match *match)
{
	if (((struct ip6t_mac_info *)match->data)->invert)
		printf("! ");

	printf("--mac-source ");
	print_mac(((struct ip6t_mac_info *)match->data)->srcaddr);
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:9,代码来源:libip6t_mac.c


注:本文中的print_mac函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。