Macchanger-查看Linux的当前临时有效的mac地址和永久物理的mac地址

#macchanger -s eth0可以获得mac的真实mac地址 Current MAC: 00:07:3e:90:45:92 (China Great-Wall Computer Shenzhen Co., Ltd.) Permanent MAC: 00:07:3e:90:45:7f (China Great-Wall Computer Shenzhen Co., Ltd.) #include "maclist.h" #include "netinfo.h" //ljc 18/11/21 查看mac地址的原始值和临时值 int Get_CP_Mac(char *device_name, char *Current_Mac, char *Permanent_Mac) { if((device_name == NULL) || (Current_Mac == NULL) || (Permanent_Mac == NULL)) { printf("*Get_CP_Mac start init failed!!!!\n"); return EXIT_ERROR; } net_info_t *net; mac_t *mac; mac_t *mac_permanent; /* Read the MAC lists */ if (mc_maclist_init() < 0) { printf("*MAC lists init failed!!!!"); return EXIT_ERROR; } printf("*device_name :%s\n\n",device_name); if ((net = mc_net_info_new(device_name)) == NULL) { printf("*mc_net_info failed!!!!"); return EXIT_ERROR; } printf("*+++++++++malloc++++ net %p\n",net); mac = mc_net_info_get_mac(net); printf("*+++++++++malloc++++ mac %p\n",mac); mac_permanent = mc_net_info_get_permanent_mac(net); printf("*+++++++++malloc++++ mac_permanent %p\n",mac_permanent); //获得临时mac地址 int is_wireless; is_wireless = mc_maclist_is_wireless(mac); mc_mac_into_string (mac, Current_Mac); //获得永久mac地址 is_wireless = mc_maclist_is_wireless(mac_permanent); mc_mac_into_string (mac_permanent, Permanent_Mac); printf("temp——mac:%s\n", Current_Mac); printf("Permanent——mac:%s\n", Permanent_Mac); printf("\n*1---free--- net %p\n",net); mc_net_info_free (net); printf("*2---free--- mac %p\n",mac); mc_mac_free (mac); printf("*3---free--- mac_permanent %p\n\n",mac_permanent); mc_mac_free (mac_permanent); mc_maclist_free(); return EXIT_OK; } //ljc 18/11/21 char Current_Mac[MAC_LEN]; char Permanent_Mac[MAC_LEN]; int Ret = Get_CP_Mac(mac_Info_name,Current_Mac, Permanent_Mac); if(Ret == EXIT_ERROR) { return -1; } printf("temp——mac:%s\n", Current_Mac); printf("Permanent——mac:%s\n", Permanent_Mac);

转载于:https://www.cnblogs.com/Lijcyy/p/9994848.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值