module for getting underlying ethernet hardware and IP address...

From: Tej Parkash
Date: Fri Jun 22 2007 - 06:05:41 EST


hi
i have written small code which find out the MAC and IP address of any
underlying ethernet device. I have written it as a module. I just want
to know at any codition this code will fail and give me some kind of
error.

code is as follows:
{
struct in_device *in_dev;
struct in_ifaddr **ifap=NULL;
struct in_ifaddr *ifrr=NULL;
struct net_device *device;
ifra.ifr_ifindex=2;
printk("module is inserted\n");
device = __dev_get_by_index(ifra.ifr_ifindex);
if(!device)
{
printk("could not receive the netdevice interface references");
}

printk("Interafce Name = %s\n",device->name);
in_dev=(struct in_device*)device->ip_ptr;
if(!in_dev)
{
printk("could not get the reference of the in_device");
}

ifap =&in_dev->ifa_list;
if(!ifap)
{
printk("I am getting the refernce of the ifa_list");
}

ifrr=*ifap;
printk("%u.%u.%u.%u", NIPQUAD(ifrr->ifa_local));

}

thanks
TEJ
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html