【发布时间】:2010-12-18 00:49:21
【问题描述】:
我正在使用 pcap 库,但我不知道为什么我总是得到这个输出:
新数据包大小:udata= 8 hdr=8 pkt=8
这是代码:
void handle_pcap(u_char *udata, const struct pcap_pkthdr *hdr, const u_char *pkt)
{
DEBUG("DANY new packet with size: udata= %d hdr=%d pkt=%d", (int) sizeof(udata),(int) sizeof(hdr),(int) sizeof(pkt) );
...
stuff
}
在我使用的另一个文件中:
status = pcap_loop (pcap_obj,
-1 /* How many packets it should sniff for before returning (a negative value
means it should sniff until an error occurs (loop forever) ) */,
handle_pcap /* Callback that will be called*/,
NULL /* Arguments to send to the callback (NULL is nothing) */);
输出正常吗?
我认为不是因为有时我的程序可以正常工作,有时却不行..
【问题讨论】:
-
您需要将答案标记为正确。