tcpdump mailing list archives
Checking for specific return errors in libpcap I/O functions
From: Fernando Gont <fernando () gont com ar>
Date: Thu, 29 Dec 2011 18:58:50 -0300
Folks, I was trying to check for specific errors in libpcap I/O functions such as pcap_next_ex() and pcap_inject(). However, the relevant manpages indicate that these functions return -1 on error, and don't mention the setting of any "errno-like" variable that specifies the specific error that occurred. While there exist functions such as pcap_geterr() to print an error-specific message, I'm rather interested in obtaining an error code such that my program can act differently depending on the specific return error. If that's possible? If so, how? FWIW, I've checked /usr/include/pcap/pcap.h, and while there exist error codes such as: #define PCAP_ERROR -1 /* generic error code */ #define PCAP_ERROR_BREAK -2 /* loop terminated by pcap_breakloop */ [....] #define PCAP_ERROR_IFACE_NOT_UP -9 /* interface isn't up */ they don't seem to be returned when the corresponding error condition occurs in pcap_next_ex() or other libpcap I/O functions. For instance, if I take an interface down with ifconfig, pcap_next_ex() returns -1, and not -9 (PCAP_ERROR_IFACE_NOT_UP). Thanks! Best regards, -- Fernando Gont e-mail: fernando () gont com ar || fgont () si6networks com PGP Fingerprint: 7809 84F5 322E 45C7 F1C9 3945 96EE A9EF D076 FFF1 - This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- Checking for specific return errors in libpcap I/O functions Fernando Gont (Dec 29)
- Re: Checking for specific return errors in libpcap I/O functions Guy Harris (Dec 29)
- Re: Checking for specific return errors in libpcap Fernando Gont (Dec 29)
- Re: Checking for specific return errors in libpcap Fernando Gont (Dec 30)
- Re: Checking for specific return errors in libpcap I/O functions Guy Harris (Dec 30)
- Re: Checking for specific return errors in libpcap I/O functions Guy Harris (Dec 29)