[netdrivers] Re: need help on open-ioctl

Donald Becker becker@scyld.com
Fri Jan 17 08:56:02 2003


On Fri, 17 Jan 2003, Hiroshi Ito wrote:

> I would like to set/change parameters used in eepro100.c driver while it is running( I mean
> .. without compiling with new parameters). This application/control program is to be
> implemented at the user space.

Look at how 'mii-diag' works.
  http://www.scyld.com/diag/index.html
    ftp://ftp.scyld.com/pub/diag/mii-diag.c


#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>

	struct ifreq ifr;
	int skfd = socket(AF_INET, SOCK_DGRAM,0);
	strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);
	...   /* Set structure parameters. */
	ioctl(skfd, SIOCDEVPRIVATE, &ifr);

> 1. open to get "device-file" descriptor;   fd = opem( /dev/... , );

Network interfaces do not have the fixed-naming semantics of
other devices.  When first designing the network stack in 1992 we made
the decision to not have entries in /dev/*.  While controversial ("but
it's not like BSD!"), it allowed the easy implementation of features
such as interface aliases.

Even the traditional static naming of character and block devices is
becoming a problem.  /dev on a modern Linux system has over 5000 names,
and with USB disks and hot-swap RAID even that is far too few.


-- 
Donald Becker				becker@scyld.com
Scyld Computing Corporation		http://www.scyld.com
410 Severn Ave. Suite 210		Scyld Beowulf cluster system
Annapolis MD 21403			410-990-9993