获得已安装网络驱动器的高级信息
在第一章中演示了如何获得已存在适配器的基本信息(名字和描述)。事实上,WinPcap同样也提供其他的高级信息,特别是 pcap_findalldevs_ex()这个函数返回的每个 pcap_if结构体都同样包含一个pcap_addr结构的列表,它包含:
- 一个地址列表
- 一个掩码列表(每一项与地址列表的条目相对应)
- 一个广播地址列表(每一项与地址列表的条目相对应)
- 一个目的地址列表(每一项与地址列表的条目相对应)
另外,pcap_findalldevs_ex()也能够返回远程的适配器和一个给出的位于本地的文件夹中的pcap列表文件
下面的例子通过一个ifprint()函数打印出了pcap_if结构的的所有字段信息,该程序对每一个pcap_findalldevs_ex()所返回的pcap_if结构循环调用ifprint()来显示详细的字段信息。
Lesson 1 (Obtaining the device list) demonstrated how to get basic information (i.e. device name and description) about available adapters. Actually, WinPcap provides also other advanced information. In particular, every pcap_if structure returned by pcap_findalldevs_ex() contains also a list of pcap_addr structures, with:
- a list of addresses for that interface.
- a list of netmasks (each of which corresponds to an entry in the addresses list).
- a list of broadcast addresses (each of which corresponds to an entry in the addresses list).
- a list of destination addresses (each of which corresponds to an entry in the addresses list).
Additionally, pcap_findalldevs_ex() can also return remote adapters and a list of pcap files that are located in a given local folder.
The following sample provides an ifprint() function that prints the complete contents of a pcap_if structure. It is invoked by the program for every entry returned by pcap_findalldevs_ex().
/* codes */
#end