Subject: struct ifnet's if_softc field?
To: None <tech-kern@netbsd.org>
From: Dave McConnell <davem@eastcoast.co.za>
List: tech-kern
Date: 05/14/1999 12:29:54
Why does "struct ifnet" have a "void *if_softc" as its first field. It
seems unnecessary...
Isn't ifnet always the first field in a network drivers softc structure?
In which case the pointer to the drivers "struct softc" is also the
address of the devices "struct ifnet" (analogous to inheritence in
C++) or am I missing something here ?
Along the same lines, I also see explicit useage of the softc's ifnet
field address rather than the address of the softc structure itself
when an ifnet address is required.
e.g. from the SLIP code
if_attach(&sc->sc_if);
where IMHO
if_attach( (struct ifnet*)sc ) would do.
Essentially what I ask is is there any particular reason for doing
things the way they have been done, or would the "C++ inheritence
analogy" approach work equally well.
Dave
***********************************************************
When you don't know..use the Web to succesfully reference
a hundred others who don't know Either!!
D.J. McConnell
N.U.R. Software Architects CC
P.O. Box 268
Umdloti Beach 4350
Tel - 27-31-5681834/Cell - 27-82-7845420
davem@eastcoast.co.za