Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]interface name - module name assoc SOLVED
- To: "Tokyo Linux Users' Group" <tlug@example.com>
- Subject: interface name - module name assoc SOLVED
- From: "Scott M. Stone" <sstone@example.com>
- Date: Tue, 4 Sep 2001 16:04:13 -0700 (PDT)
- Content-Type: TEXT/PLAIN; charset=US-ASCII
- Delivered-To: tlug@example.com
- List-Help: <mailto:tlug-request@example.comsubject=help>
- List-Post: <mailto:tlug@example.com>
- List-Subscribe: <mailto:tlug-request@example.comsubject=subscribe>
- List-Unsubscribe: <mailto:tlug-request@example.comsubject=unsubscribe>
- Old-Return-Path: <sstone@example.com>
- Reply-To: tlug@example.com
- Resent-From: tlug@example.com
- Resent-Message-ID: <1kyFTB.A.XLD.53Vl7@example.com>
- Resent-Sender: tlug-request@example.com
Ok, well, I did have to write a kernel module, but this should work on all machines and reliably tell you "what driver module is the owner of the interface", assuming you're using dynamic modules for your network drivers. Amazingly enough, I did NOT manage to crash my system while testing this thing, I guess I got lucky this time :) compile with: gcc -Wall -DMODULE -D__KERNEL__ -DLINUX -o ndmassoc.o -c ndmassoc.c then, insmod ./ndmassoc.o then cat /proc/ndmassoc the number is the "interface index number" as seen by the kernel, if you're wondering. rmmod ndmassoc will get rid of it. --cut here-- /* ndmassoc.c this driver provides /proc/ndmassoc, which lets you associate network devices with the module that owns it. this code released under the terms of the GNU GPL (C) 2001 by Scott Stone <sstone@example.com> This module comes with NO WARRANTY - if it breaks your kernel, reboot and don't load it again, or try it again, and be angry. It's really up to you, but I take no responsibility either way. */ #include <linux/kernel.h> #include <linux/module.h> #if CONFIG_MODVERSIONS==1 #define MODVERSIONS #include <linux/modversions.h> #endif #include <linux/proc_fs.h> #include <linux/netdevice.h> #define MODNAME "ndmassoc" #define VERSION "1.0.0" #define COPYRIGHT "(C) 2001 by Scott Stone <sstone@example.com>" #define MAX_INTERFACES 50 #define BUFFER_SIZE ((MAX_INTERFACES * 80) + 1) int procfile_read(char *buffer, char **buffer_location, off_t offset, int buffer_length, int *eof, void *data) { int len=0; static char my_buffer[BUFFER_SIZE]; struct net_device *nd=NULL; static int zz; memset(my_buffer,0,BUFFER_SIZE); strcpy(my_buffer,":Interfaces:\n"); if (offset > 0) return 0; for (zz=0;zz < MAX_INTERFACES;zz++) { nd=dev_get_by_index(zz); if (nd && (nd->owner) && (nd->owner->name)) { sprintf(my_buffer,"%s%d:%s:%s\n", my_buffer, zz, nd->name, nd->owner->name); } } len=strlen(my_buffer); *buffer_location=my_buffer; return len; } int init_module(void) { struct proc_dir_entry *p=NULL; printk("%s v%s - %s\n", MODNAME, VERSION, COPYRIGHT); p=create_proc_entry(MODNAME,(S_IFREG | S_IRUGO),&proc_root); if (!p) { printk("%s: error registering /proc/%s !!\n",MODNAME,MODNAME); return -1; } p->read_proc=procfile_read; p->data=NULL; return 0; } void cleanup_module(void) { remove_proc_entry(MODNAME,&proc_root); printk("%s unloaded successfully.\n",MODNAME); }
- Follow-Ups:
- Re: interface name - module name assoc SOLVED
- From: "roylo" <roylo@example.com>
Home | Main Index | Thread Index
- Prev by Date: Re: FreeWNN questions
- Next by Date: Re: interface name - module name assoc SOLVED
- Prev by thread: Re: KDE, unicode messege files, non-unicode font?
- Next by thread: Re: interface name - module name assoc SOLVED
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links