winpcap中关于pcap_dispatch的一个问题!

yym314 2004-09-22 05:31:05
pcap_dispatch的回调函数中得到的那个缓冲区里存放的是一帧还是多帧数据啊?如果是多帧的话,那么怎么才能从缓冲区里得到各帧呢?另外,这个帧包不包含以太头啊?
...全文
274 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
醉马不肖 2004-09-22
  • 打赏
  • 举报
回复
int pcap_dispatch ( pcap_t * p,
int cnt,
pcap_handler callback,
u_char * user
)

Deprecated


Deprecated:
Use the pcap_next_ex() instead.
It collects a group of packets. Returns when cnt packets have been received or when the timeout set with pcap_open_live() expires.
pcap_dispatch() is used to collect and process packets. cnt specifies the maximum number of packets to process before returning. This is not a minimum number; when reading a live capture, only one bufferful of packets is read at a time, so fewer than cnt packets may be processed. A cnt of -1 processes all the packets received in one buffer when reading a live capture, or all the packets in the file when reading a "savefile". callback specifies a routine to be called with three arguments: a u_char pointer which is passed in from pcap_dispatch(), a pointer packet data.

The number of packets read is returned. 0 is returned if no packets were read from a live capture (if, for example, they were discarded because they didn't pass the packet filter, or if, on platforms that support a read timeout that starts before any packets arrive, the timeout expires before any packets arrive, or if the file descriptor for the capture device is in non-blocking mode and no packets were available to be read) or if no more packets are available in a "savefile." A return of -1 indicates an error in which case pcap_perror() or pcap_geterr() may be used to display the error text.


Note:
when reading a live capture, pcap_dispatch() will not necessarily return when the read times out; on some platforms, the read timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the read timeout should NOT be used in, for example, an interactive application, to allow the packet capture loop to "poll" for user input periodically, as there's no guarantee that pcap_dispatch() will return after the timeout expires.
See also:
pcap_loop(), pcap_next(), pcap_open_live(), pcap_open_offline(), pcap_handler
Definition at line 69 of file pcap.c.

References pcap_offline_read(), and pcap_read().

Referenced by pcap_next().

醉马不肖 2004-09-22
  • 打赏
  • 举报
回复
It collects a group of packets.

18,355

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧