netdev
[Top] [All Lists]

Re: Function to determine if IP exists on a net-device?

To: "David S. Miller" <davem@xxxxxxxxxx>
Subject: Re: Function to determine if IP exists on a net-device?
From: Ben Greear <greearb@xxxxxxxxxxxxxxx>
Date: Wed, 19 Nov 2003 18:05:15 -0800
Cc: netdev@xxxxxxxxxxx
In-reply-to: <20031119173103.1938bc51.davem@xxxxxxxxxx>
Organization: Candela Technologies
References: <3FBB36F2.7030402@xxxxxxxxxxxxxxx> <20031119173103.1938bc51.davem@xxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007
David S. Miller wrote:
On Wed, 19 Nov 2003 01:25:06 -0800
Ben Greear <greearb@xxxxxxxxxxxxxxx> wrote:


Is there a method already written that will tell me if an IP exists on
a netdevice?

If not, I am quite sure the answer lies in the in_ifaddr
list, but which field holds the IP address for the device?


Call getifaddrs(), walk the list finding the each and every list entry
with the 'ifa_name' name matching the device you want.  If there are
multiple addresses attached to an interface there will be multiple
in_ifaddr list entries with the 'ifa_name' of your interface.

In each of those entry, check the sockaddr pointed to by the 'ifa_addr'
field.


Is there not a more direct access if I already have the netdevice in question?
ie, can I get at the list by looking at dev->ip_ptr struct?


Thanks,
Ben


--
Ben Greear <greearb@xxxxxxxxxxxxxxx>
Candela Technologies Inc  http://www.candelatech.com



<Prev in Thread] Current Thread [Next in Thread>