Subject: Re: Implementing interface media type autodetection?
To: John Hawkinson <email@example.com>
From: Chris G Demetriou <Chris_G_Demetriou@ux2.sp.cs.cmu.edu>
Date: 06/09/1996 00:56:19
> I remembered this peripherally but sort of hoped I could get away with
> not mentioning it in the interest of expediency. Alas...
"muhahahahah! your evil plans have been foiled!"
> > Consider SIOCSIFMEDIA and SIOCGIFMEDIA ioctls, which set and get the
> > media type of the device. You could then have media types like:
> So how do we go about doing this transition? As the person to open my
> mouth about this, I'm certainly willing to do some work, but I'm
> somewhat reluctant to go and send in change-requests for all the
> drivers in the tree [perhaps an interim solution would be to have
> SIOCSIFMEDIA know about the link flags for various interfaces that
> don't understand it yet?]...
That's easy! (says he who's not implemented it... 8-)
make if_media a member of struct ifnet.
have SIOCGIFMEDIA be handled entirely in ifioctl().
in ifioctl(), pass SIOCSIFMEDIA down to the driver's ioctl function.
return whatever value is returned. (drivers that don't implement it
will return the appropriate 'ioctl not supported' code.)
OK, so, there we have setting and getting, now all you need to do is
make sure the drivers do something sane with the initial value of the
I can think of a couple of possibilities here:
(1) hack every driver to set the value to 'unknown', or
(2) make '0' be unknown, and assume that every driver
zero-fills the ifnet structure before if_attach()
(or that it's allocated from zero-filled storage).
The latter seems sleazy, no? However, it's apparently already assumed
(note where if_pcount is used and initialized... oh, wait, you say
it's not initialized!?), and there's no reason that I can think of to
not use that assumption, especially since (in the fullness of time)
all drivers will be setting that field...
looks to me like the 'proper' long-term solution may be as easy as, if
not easier than, a short term hack. 8-)