tcpdump mailing list archives
Libpcap question
From: "Jacky Buyck" <jacky.buyck () wanadoo fr>
Date: Fri, 16 Apr 2004 00:17:54 +0200
Hi all.
I'm trying to play with libpcap to make a little tool and it the same
way to make a little tutorial on it.
I'm facing a question regarding pcap_if_t structure.
This last one is composed of :
- pcap_if *next (to implement the link between list's element) ;
- char *name (for the interface name) ;
- ...
- pcap_addr *addresses ;
This last one, if I've correctly understand handle all the addresses
that can be use on an interface.
For the moment I simply want to list all the interface available through
libpcap and for each one list all the available addresses on it.
I've try with the following code :
//======================================================================
======================
pcap_if_t *lst_dev = 0x00
ret = pcap_findalldevs(&lst_dev,errbuf);
if (ret == -1)
...
//Parse the list of interface
pcap_if_t *ptr_dev = lst_dev;
while (ptr_dev->next)
{
printf("Name : %s\n",ptr_dev->name);
//For each interface, list the addresses available
pcap_addr_t *ptr = ptr_dev->addresses;
while(ptr->next)
{
char *tmp = inet_ntoa(((struct
sockaddr_in*)(ptr->addr))->sin_addr);
printf("Address : %s\n",tmp);
ptr = ptr->next;
}
}
//======================================================================
======================
The problem is that I obtain something completely différent from my
config :
Ouput of the program is :
Name : wlan0
Address : 20.0.0.1
Name : eth0
Address : 192.168.0.1
Address : 30.0.0.1
Name : eth1
Address : 10.0.0.1
Name : eth2
Name : Any
Address : 127.0.0.1
My config is :
wlan0 : 10.0.10.1
eth0 : 20.0.0.1
eth1 : 192.168.0.1 and 30.0.0.1
eth2 : 10.0.0.1
What I've misunderstand ?????
I'm using libpcap 0.7.2 under RH 9.0
Thanks.
-
This is the tcpdump-workers list.
Visit https://lists.sandelman.ca/ to unsubscribe.
Current thread:
- Re: Proposed new pcap format, (continued)
- Re: Proposed new pcap format Jefferson Ogata (Apr 14)
- Re: Proposed new pcap format Ronnie Sahlberg (Apr 14)
- Re: Proposed new pcap format Jefferson Ogata (Apr 14)
- Re: Proposed new pcap format Ronnie Sahlberg (Apr 14)
- Re: Proposed new pcap format Fulvio Risso (Apr 14)
- Re: Proposed new pcap format Stephen Donnelly (Apr 14)
- Re: Proposed new pcap format Christian Kreibich (Apr 13)
- Re: Proposed new pcap format Jefferson Ogata (Apr 14)
- Re: Proposed new pcap format Christian Kreibich (Apr 14)
- Re: Proposed new pcap format Hannes Gredler (Apr 14)
- Libpcap question Jacky Buyck (Apr 15)
- Re: Libpcap question Guy Harris (Apr 16)
- RE : Libpcap question Jacky Buyck (Apr 18)
- Re: Proposed new pcap format Guy Harris (Apr 14)
- Re: Proposed new pcap format Fulvio Risso (Apr 14)
- Re: Proposed new pcap format Ronnie Sahlberg (Apr 14)
- Re: Proposed new pcap format Jefferson Ogata (Apr 14)
- Re: Proposed new pcap format Fulvio Risso (Apr 14)
- Re: Proposed new pcap format Guy Harris (Apr 14)
- Re: Proposed new pcap format Fulvio Risso (Apr 13)
- Re: Proposed new pcap format Michael Richardson (Apr 16)
