Note that:
"pcap_compile()" and "pcap_compile_nopcap()" return -1 on
failure;
if "pcap_compile()" or "pcap_setfilter()" fails, you can get the
error string with "pcap_geterr()";
if "pcap_compile_nopcap()" fails, you can't get the error
string, but, as it's just a wrapper around "pcap_open_dead()",
"pcap_compile()", and "pcap_close()", you can use those routines
yourself if you want the error string;
you have to use, or copy, the string you get back from
"pcap_geterr()" before closing the "pcap_t" you hand to
"pcap_geterr()", as the string you got back from "pcap_geterr()"
doesn't remain valid after the "pcap_t" whence you got it is
closed.
1 file changed