tcpdump mailing list archives
Re: Libpcap - pcapfindalldevs
From: Benoit <benpaka.spam () gmail com>
Date: Mon, 2 Feb 2009 15:21:33 +0100
Yeah this is true, however you could try a simple loop on the interface, If there are NULL you must run as root. /* Retrieve the device list on the local machine */ if (pcap_findalldevs(&alldevs, errbuf) == -1) { printf("Error in pcap_findalldevs: %s\n", errbuf); return -1; } for(d=alldevs; d; d=d->next) { printf("\t%d. %s\n", ++i, d->name); #ifdef WIN32 if (d->description) printf(" (%s)\n", d->description); else printf(" (No description available)\n"); #endif } if (i==0) { #ifdef WIN32 fprintf(stderr," \tNo interfaces found! Exiting.\n"); #else fprintf(stderr," \tThis software must be run as root: No interfaces found!"); #endif exit(EXIT_FAILURE); } -- Benoit RAT www.neub.co.nr On Mon, Feb 2, 2009 at 2:39 PM, Johan Mazel <johan.mazel () gmail com> wrote:
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.
- This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- Libpcap - pcapfindalldevs Johan Mazel (Feb 02)
- Re: Libpcap - pcapfindalldevs Benoit (Feb 02)
- Re: Libpcap - pcapfindalldevs Johan Mazel (Feb 02)
- Re: Libpcap - pcapfindalldevs Guy Harris (Feb 02)
- Re: Libpcap - pcapfindalldevs Benoit (Feb 02)