//------------------------------------------------------------------- // mac.c // // This module creates a pseudo-file named '/proc/mac' which // lets applications view the RealTek adapter's MAC address. // // NOTE: Written and tested for Linux kernel version 2.6.10. // // programmer: ALLAN CRUSE // written on: 17 APR 2005 //------------------------------------------------------------------- #include // for init_module() #include // for create_proc_info_entry() #include // for pci_find_device() #define VENDOR_ID 0x10EC #define DEVICE_ID 0x8139 char modname[] = "mac"; int iobase; int my_get_info( char *buf, char **start, off_t off, int count ) { int i, len = 0; len += sprintf( buf+len, "\nRealTek RTL-8139 Network Controller " ); len += sprintf( buf+len, "\nHardware Address: " ); for (i = 0; i < 6; i++) { char ch = ( i == 5 ) ? ' ' : ':'; len += sprintf( buf+len, "%02X%c", inb( iobase+i ), ch ); } len += sprintf( buf+len, "\nModule Author: Allan B. Cruse\n\n" ); return len; } int init_module( void ) { struct pci_dev *devp; printk( "<1>\nInstalling \'%s\' module\n", modname ); devp = pci_find_device( VENDOR_ID, DEVICE_ID, NULL ); if ( !devp ) return -ENODEV; iobase = pci_resource_start( devp, 0 ); create_proc_info_entry( modname, 0, NULL, my_get_info ); return 0; //SUCCESS } void cleanup_module( void ) { remove_proc_entry( modname, NULL ); printk( "<1>Removing \'%s\' module\n", modname ); } MODULE_LICENSE("GPL");