tcpdump mailing list archives

Libpcap - pcapfindalldevs


From: Johan Mazel <johan.mazel () gmail com>
Date: Mon, 2 Feb 2009 14:39:52 +0100

Hi
I'm trying to use pcap_findalldevs in order to scan the device available on
my host to capture.

My code (in C++) looks like that:
result = pcap_findalldevs(&found_devices, errbuf);
if(result < 0)
{
        FindAllDevsException myFindAllDevsException(errbuf);
        cout << "Scan error" << endl;
        throw(myFindAllDevsException);
}

My problem is that when I'm not running the program as root, I got the
"Erreur de bus" in French (or "Bus Error" in english I guess) and my program
suddenly stops.
And it looks like I cannot catch the error through the value of result.

The pcap manpage say for pcap_findalldevs:
-1 is returned on failure, in which case errbuf is filled  in  with  an
appropriate error message; 0 is returned on success.
Apparently, this case of failure do not include the fact that the program
might not be runned as root.

My question is the following one, is there anyway to catch this error ?

Thanks in adavnce for the help.
Johan
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: