用 WinPcap 获取网络接口列表
来源:互联网 发布:有少女感的长相 知乎 编辑:程序博客网 时间:2024/06/14 06:24
在 WinPcap SDK 中,有一个函数:pcap_findalldevs_ex,这个函数可以获得网络接口列表。
示例程序:
// SimpleSniffer.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <pcap.h>int _tmain(){ pcap_if_t *alldevs = nullptr; pcap_if_t *d = nullptr; char errbuf[PCAP_ERRBUF_SIZE]; int count = 0; // retrieve the adapters from the computer if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */, &alldevs, errbuf) == -1) { _ftprintf(stderr, _T("Error in pcap_findalldevs_ex: %s\n"), errbuf); exit(1); } // if there are no adapters, print an error if (alldevs == nullptr) { _ftprintf(stderr, _T("\nNo adapters found! Make sure WinPcap is installed.\n"), errbuf); exit(2); } // print the list of adapters along with basic information about an adapter for (d = alldevs; d != NULL; d = d->next) { printf("%2d. %s\n", ++count, d->name); if (d->description) { printf(" %s\n\n", d->description); } else { printf(" (No description available)\n"); } } if (count == 0) { _tprintf(_T("\nNo interfaces found! Make sure WinPcap is installed.\n")); } // free the network adapter list pcap_freealldevs(alldevs); return 0;}
运行结果:
0 0
- 用 WinPcap 获取网络接口列表
- winpcap获取设备列表
- winpcap获取适配器列表
- winpcap--枚举网络接口
- Winpcap网络编程五之Winpcap学习教程,获取设备列表
- 使用Winpcap 获取设备列表
- 利用WinPcap获取网卡列表
- WinPcap教程(1):获取网卡列表
- WinPcap编程【2】--获取设备列表
- windows下使用WinPcap获取网卡列表
- 使用Winpcap 获取设备列表 2
- WinPcap教程(1):获取网卡列表
- WinPcap编程【2】--获取设备列表
- winpcap学习(二)获取设备列表
- WinPcap笔记(2):获取设备列表
- WinPcap. 获取本地驱动设备列表
- WinPcap教程:(1)获取设备列表
- WinPcap编程3——获取网络适配器列表
- CodeForces 339B (贪心模拟)
- 安装PIL等库出现Python version2.7 required,which was not found in the registry.
- WebP 探寻之路 --- SDWebImage支持webp格式的图片
- 数据库查询
- 谈谈乐观锁和悲观锁
- 用 WinPcap 获取网络接口列表
- Android发送短信验证码
- Java Integer问题
- 工厂模式,策略模式,适配器模式
- Java的类加载机制
- HP ALM使用简介
- 空头发力,账面亏损变为盈利
- 多线程 生产者&消费者 哲学家进餐 & random & synchronized & Thread & Sleep
- http 文件头详解