#include #include #include #include #include #include MODULE_DESCRIPTION("Test Module"); MODULE_AUTHOR("Gilboa Davara"); MODULE_LICENSE("GPL"); static int ethernet_id = 0; module_param(ethernet_id,int,0400); MODULE_PARM_DESC(ethernet_id,"Ethernet device to display"); static int __init test_startup(void) { struct net_device *device; struct in_device *in_dev; struct in_ifaddr *if_info; char dev_name[20]; __u8 *addr; sprintf(dev_name,"eth%d",ethernet_id); device = dev_get_by_name(dev_name); in_dev = (struct in_device *)device->ip_ptr; if_info = in_dev->ifa_list; addr = (char *)&if_info->ifa_local; printk(KERN_WARNING "Device %s IP: %u.%u.%u.%u\n", dev_name, (__u32)addr[0], (__u32)addr[1], (__u32)addr[2], (__u32)addr[3]); return 0; } static void __exit test_exit(void) { } module_init(test_startup); module_exit(test_exit);