tcpdump mailing list archives
Compatibility Libpcap/Winpcap and timout of pcap_next_ex().
From: Benoit <benpaka.spam () gmail com>
Date: Tue, 27 Jan 2009 18:17:00 +0100
Hello,
I've start a simple protocol to communicate with FPGA using only MAC layer.
This software should run under linux and windows, however i've a problem
with the timeout of pcap_next_ex() function under linux.
With winpcap when a packet is not coming the pcap_next_ex() return 0 but in
linux this function continue looping, and never return if no packet are
coming. Moreover sometimes I need to loop 10 times to be sure to receive
correctly the packet, .
The library used is the one in ubuntu 8.10:
libpcap0.8, libpcap0.8-dev, libpcap0.8-dbg (Version 0.9.8-5)
Here you have a sample of my code:
//Opening interface
timeout=10;
adhandle = pcap_open_live(ifname, // name of the device
SIZEIB_MTU, // portion of the packet to
capture
FALSE, // promiscuous mode
timeout, // read timeout
(char*)errbuf // error buffer
);
//Setting filter
if(pcap_compile(adhandle,&(fp),(char*)filter,0,netp) == -1) {
fprintf(stderr,"Error calling pcap_compile\n");
return EXIT_FAILURE;
}
if(pcap_setfilter(adhandle,&(fp)) == -1) {
fprintf(stderr,"Error setting filter\n");
return EXIT_FAILURE;
}
//Send a packet
pcap_sendpacket(adhandle,(const u_char*)buff, SIZEIB_HDR_PKT+size_inB);
//Loop 10 times on pcap_next_ex() to receive at least 1 packet.
for(i=0;i<10;i++) {
ret=pcap_next_ex(adhandle, &(header), (const u_char**)(&p_buff));
if(ret>0) {
nofB=ifhard->header->len;
memcpy(buff,p_buff,nofB);
break;
}
}
Can you help me to make the timeout of pcap_next_ex() works under linux?
Thanks
--
Benoit RAT
www.neub.co.nr
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- Compatibility Libpcap/Winpcap and timout of pcap_next_ex(). Benoit (Jan 27)
- Re: Compatibility Libpcap/Winpcap and timout of pcap_next_ex(). Guy Harris (Jan 27)
- Re: Compatibility Libpcap/Winpcap and timout of Matthew Luckie (Jan 27)
- Re: Compatibility Libpcap/Winpcap and timout of Guy Harris (Jan 27)
- Re: Compatibility Libpcap/Winpcap and timout of Aaron Turner (Jan 27)
- Re: Compatibility Libpcap/Winpcap and timout of Guy Harris (Jan 27)
- Re: Compatibility Libpcap/Winpcap and timout of Benoit (Jan 28)
- Re: Compatibility Libpcap/Winpcap and timout of Guy Harris (Jan 28)
- Re: Compatibility Libpcap/Winpcap and timout of Matthew Luckie (Jan 27)
- Re: Compatibility Libpcap/Winpcap and timout of pcap_next_ex(). Guy Harris (Jan 27)
