国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Linux下C語言獲取所有網(wǎng)卡信息的代碼
http://www.open-open.com/code/view/1432215294567
2015.05
#include <sys/ioctl.h>#include <net/if.h>#include <unistd.h>#include <netinet/in.h>#include <string.h> int main(){    struct ifreq ifr;    struct ifconf ifc;    char buf[2048];    int success = 0;     int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);    if (sock == -1) {        printf("socket error\n");        return -1;    }     ifc.ifc_len = sizeof(buf);    ifc.ifc_buf = buf;    if (ioctl(sock, SIOCGIFCONF, &ifc) == -1) {        printf("ioctl error\n");        return -1;    }     struct ifreq* it = ifc.ifc_req;    const struct ifreq* const end = it + (ifc.ifc_len / sizeof(struct ifreq));    char szMac[64];    int count = 0;    for (; it != end; ++it) {        strcpy(ifr.ifr_name, it->ifr_name);        if (ioctl(sock, SIOCGIFFLAGS, &ifr) == 0) {            if (! (ifr.ifr_flags & IFF_LOOPBACK)) { // don't count loopback                if (ioctl(sock, SIOCGIFHWADDR, &ifr) == 0) {                    count ++ ;                    unsigned char * ptr ;                    ptr = (unsigned char  *)&ifr.ifr_ifru.ifru_hwaddr.sa_data[0];                    snprintf(szMac,64,"%02X:%02X:%02X:%02X:%02X:%02X",*ptr,*(ptr+1),*(ptr+2),*(ptr+3),*(ptr+4),*(ptr+5));                    printf("%d,Interface name : %s , Mac address : %s \n",count,ifr.ifr_name,szMac);                }            }        }else{            printf("get mac info error\n");            return -1;        }    }} 

執(zhí)行結(jié)果如下
1,Interface name : eth0 , Mac address : 90:B1:1D:87:13:752,Interface name : virtac , Mac address : 52:54:00:96:E0:BF3,Interface name : map , Mac address : 52:54:00:F2:FE:9C4,Interface name : poi , Mac address : 52:54:00:1B:97:825,Interface name : vnet1 , Mac address : 52:54:00:05:14:E3

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
《Linux網(wǎng)絡(luò)接口》---------struct ifreq struct ifconf
ioctl函數(shù)詳解
linux下ioctl操作網(wǎng)絡(luò)接口
ioctl()函數(shù)
用ioctl獲得本地ip地址
幾個(gè)網(wǎng)絡(luò)編程常用的數(shù)據(jù)結(jié)構(gòu)sockaddr_in
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服