WinPcap 获取本地适配器信息
生活随笔
收集整理的這篇文章主要介紹了
WinPcap 获取本地适配器信息
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
開始學習WinPcap的相關開發
從最簡單的開始, 獲取本地的網卡信息
#include <stdio.h> #include <stdlib.h>#define HAVE_REMOTE #include <pcap.h>#pragma comment(lib,"wpcap.lib")int _tmain(int argc, _TCHAR* argv[]) {pcap_if_t *alldevs;pcap_if_t *d;int i = 0;char errbuf[PCAP_ERRBUF_SIZE];/* get local devices */if(pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1){fprintf(stderr, "Error in pcap_findalldevs_ex: %s\n", errbuf);exit(1);}/* print devices list */for(d = alldevs; d != NULL; d = d->next){printf("%d. %s", ++i, d->name);if (d->description)printf("(%s)\n", d->description);elseprintf("(No description available)\n");}if(i == 0){printf("\nNo interfaces found! Make sure Winpcap is installed.\n");return -1;}pcap_freealldevs(alldevs);getchar();return 0; }與50位技術專家面對面20年技術見證,附贈技術全景圖
總結
以上是生活随笔為你收集整理的WinPcap 获取本地适配器信息的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VS2010设置全局Include和Li
- 下一篇: WinPcap获取网卡的更多信息