libpcap获取网卡名称

#include <pcap/pcap.h>
#include <stdio.h>

int main()
{
    char errbuf[PCAP_ERRBUF_SIZE], *device;

    device = pcap_lookupdev(errbuf);

    if(device)
    {
        printf("Success: device: %s\n",device);
    }
    else
    {
        printf("Error: %s\n",errbuf);
    }

    return 0;

}

 

posted on 2021-01-19 15:09  lydstory  阅读(175)  评论(0)    收藏  举报

导航