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_
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
/* 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