Re: Get the IP address of an interface with a given name

2007-11-20 Thread Rami Rosen
Giacomo, Consider using the dev_get_by_name/() kernel method; this is a simplified example which works with device named "eth0" : struct net_device* device; struct in_device* in_dev; struct in_ifaddr* if_info; device = dev_get_by_name("eth0"); in_dev = (struct in_device *)device->ip_

Get the IP address of an interface with a given name

2007-11-20 Thread Giacomo
Good morning. I have written a kernel function which needs to get the IP address of an active network interface given its name. The actual implementation i have done is like this but i suspect this does not always work. Is there any API already provided by the kernel to do the same? Thanks

Get the IP address of an interface with a given name

2007-11-19 Thread Giacomo
/* returns in *addr the internet address having the name ifname */ int get_ifaddr_by_name(const char *ifname, __u32 * addr) { struct net_device *pnet_device; struct in_device *pin_device; struct in_ifaddr* inet_ifaddr; read_lock_bh(&dev_base_lock); #if LINUX_VER