tcpdump mailing list archives

Re: Devices and adresses in libpcap


From: Guy Harris <guy () alum mit edu>
Date: Sat, 12 Apr 2008 14:05:15 -0700

David Rosal wrote:

As far as I know, each network interface (for example eth0), can have
different adresses, because in pcap_findalldevs(), a pcap_if_t does not hold
a single pcap_addr_t but a linked list of all  addresses for each
interface/device.

Yes, it can have multiple addresses, and, yes, pcap_findalldevs() returns all of the ones it can get.

But pcap_lookupnet() only returns one address for a given
device.

Yes, it returns only one address.

So the question is: If pcap_lookupnet() only returns one address
(and its netmask), does it mean that it discards all the other addresses
for that device?

Yes, it discards any other addresses for the interface. On UN*X, it returns the IP address and mask you get from an SIOCGIFADDR and SIOCGIFNETMASK ioctl, which is probably the first of the IP addresses; on Windows, it gets the entire set of address/mask pairs and returns only the first one.
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: