循序渐进学习使用WINPCAP(二)

获得已安装网络驱动器的高级信息

在第一章中演示了如何获得已存在适配器的基本信息(名字和描述)。事实上,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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值