zoukankan      html  css  js  c++  java
  • 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.) 

     1 #include "maclist.h" 
     2 #include "netinfo.h" //ljc 18/11/21 查看mac地址的原始值和临时值 
     3 int Get_CP_Mac(char *device_name, char *Current_Mac, char *Permanent_Mac) 
     4 { 
     5     if((device_name == NULL) || (Current_Mac == NULL) || (Permanent_Mac == NULL)) 
     6     { 
     7         printf("*Get_CP_Mac start init failed!!!!
    "); return EXIT_ERROR; 
     8     } 
     9     net_info_t *net; 
    10     mac_t *mac; 
    11     mac_t *mac_permanent; /* Read the MAC lists */ 
    12     if (mc_maclist_init() < 0) 
    13     { printf("*MAC lists init failed!!!!"); return EXIT_ERROR; } 
    14     printf("*device_name :%s
    
    ",device_name); 
    15     if ((net = mc_net_info_new(device_name)) == NULL) 
    16     { printf("*mc_net_info failed!!!!"); return EXIT_ERROR; } 
    17     printf("*+++++++++malloc++++ net %p
    ",net); 
    18     mac = mc_net_info_get_mac(net); 
    19     printf("*+++++++++malloc++++ mac %p
    ",mac); 
    20     mac_permanent = mc_net_info_get_permanent_mac(net); 
    21     printf("*+++++++++malloc++++ mac_permanent %p
    ",mac_permanent); //获得临时mac地址 
    int is_wireless;
    is_wireless = mc_maclist_is_wireless(mac);
    22 mc_mac_into_string (mac, Current_Mac); //获得永久mac地址 23 is_wireless = mc_maclist_is_wireless(mac_permanent); 24 mc_mac_into_string (mac_permanent, Permanent_Mac); 25 printf("temp——mac:%s ", Current_Mac); 26 printf("Permanent——mac:%s ", Permanent_Mac); 27 printf(" *1---free--- net %p ",net); 28 mc_net_info_free (net); 29 printf("*2---free--- mac %p ",mac); 30 mc_mac_free (mac); 31 printf("*3---free--- mac_permanent %p ",mac_permanent); 32 mc_mac_free (mac_permanent); 33 mc_maclist_free(); 34 return EXIT_OK; 35 } //ljc 18/11/21 36 37 //(test code) 38 char Current_Mac[MAC_LEN]; 39 char Permanent_Mac[MAC_LEN]; 40 int Ret = Get_CP_Mac(mac_Info_name,Current_Mac, Permanent_Mac); 41 if(Ret == EXIT_ERROR) 42 { return -1; } 43 printf("temp——mac:%s ", Current_Mac); 44 printf("Permanent——mac:%s ", Permanent_Mac);
  • 相关阅读:
    Linux 忘记密码解决方法
    Linux 系统目录结构
    【Linux】正确的关机方法
    CentOS7设置系统/yum以及firefox web代理上网
    怎样安装CentOS 6.6之三:磁盘分区的划分和修改
    在虚拟机(VMware)中安装Linux CentOS 6.4系统(图解) 转
    LiveCD、LiveDVD和BinDVD区别在哪里
    关于对FLASH开发,starling、starling feathers、starling MVC框架的理解
    【 D3.js 进阶系列 — 1.0 】 CSV 表格文件的读取
    javascript实现代码高亮-wangHighLighter.js
  • 原文地址:https://www.cnblogs.com/Lijcyy/p/9994848.html
Copyright © 2011-2022 走看看