Wireshark-users: Re: [Wireshark-users] Problem regarding using the libpcap libraries
On May 13, 2009, at 5:49 AM, adapa.ajith@xxxxxxxxx wrote:
Sorry I dont know whether to ask this question in this mailing list
or not. Please tell me appropriate mailing list if I am at wrong
place.
The right mailing list for libpcap questions is tcpdump-workers@xxxxxxxxxxx
.
I am using libpcap libraries to write a basic C program to print the
network interface details. So I am using the following C code
dev = pcap_lookupdev(errbuf);
/* error checking */
if(dev == NULL)
{
printf("%s\n",errbuf);
exit(1);
}
But it is showing an ERROR message - "no suitable device found"
But I do have a network interface since I am able to access Internet
on my Linux Machine.
Yes, but there are no devices that libpcap can open, because...
I am running the app in normal user mode as I dont have the ROOT
user permission.
...Linux, as far as I know, requires root permission to create a
PF_PACKET socket and bind a device to it (which is how libpcap works
on Linux).
pcap_findalldevs(), and routines such as pcap_lookupdev() that call
it, are intended to be used to get a list of devices on which you can
capture; not all network interfaces on a machine will support
capturing - for example, in current versions of Solaris, you can't
capture on the loopback device. Therefore, pcap_findalldevs() only
returns the devices that it can open.
If you just want to print network interface details, and aren't going
to be capturing on those interfaces - for example, if you want to make
a program like ifconfig - libpcap isn't the right choice.