libpcap

libpcap是unix/linux平台下的网络数据包捕获函数包,

大多数网络监控软件都以它为基础。
Libpcap可以在绝大多数类unix平台下工作.
Libpcap应用程序框架
Libpcap提供了系统独立的用户级别网络数据包捕获接口,并充分考虑到应用程序的可移植 性。Libpcap可以在绝大多数类unix平台下工作,参考资料 A 中是对基于 libpcap 的网络应用程序的一个详细列表。在windows平台下,一个与libpcap 很类似的函数包 winpcap 提供捕获功能


可以参考tcpdump,snort的使用方式!


To open a handle for a live capture, given the name of the network or other interface on which the capture should be done, call  pcap_create (), set the appropriate options on the handle, and then activate it with  pcap_activate ().

To obtain a list of devices that can be opened for a live capture, call pcap_findalldevs(); to free the list returned by pcap_findalldevs(), call pcap_freealldevs(). pcap_lookupdev() will return the first device on that list that is not a ``loopback`` network interface.

To open a handle for a ``savefile'' from which to read packets, given the pathname of the ``savefile'', call pcap_open_offline(); to set up a handle for a ``savefile'', given a FILE * referring to a file already opened for reading, call pcap_fopen_offline().

In order to get a ``fake'' pcap_t for use in routines that require a pcap_t as an argument, such as routines to open a ``savefile'' for writing and to compile a filter expression, call pcap_open_dead().

pcap_create(), pcap_open_offline(), pcap_fopen_offline(), and pcap_open_dead() return a pointer to a pcap_t, which is the handle used for reading packets from the capture stream or the ``savefile'', and for finding out information about the capture stream or ``savefile''. To close a handle, use pcap_close().


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值