of the controller. The bus configuration code passes this initialized
controller
data structure to the driver’s
probe
and
attach
interfaces.
2
Declares a
unit
variable and initializes it to the controller number for
this controller. This controller number identifies the specific 3Com
3C5x9 controller that is being attached. The controller number is
contained in the
ctlr_num
member of the
controller
data structure
for this device.
3
Declares a pointer to the
el_softc
data structure called
sc
and
initializes it to the
el_softc
data structure for this device. The
controller number (which is stored in the
unit
variable) is used as an
index into the array of
el_softc
data structures to determine which
el_softc
data structure is associated with this device.
4
Declares a pointer to an
ifnet
data structure called
ifp
and initializes
it to the address of the
ifnet
data structure for this device.
5
Declares a pointer to a
sockaddr_in
data structure called
sin
.
6.2 Initializing the Media Address and Media Header
Lengths
The
el_attach( )
routine sets up the media’s address length and header
length, as follows:
if (!sc->reprobe) {
1
ctlr->alive |= ALV_STATIC;
2
ifp->if_addrlen = 6;
3
ifp->if_hdrlen =
4
sizeof(struct ether_header) + 8;
1
Examines the value of the
reprobe
member of the driver’s
softc
data
structure to determine whether the user has reinserted the PCMCIA
card. If the card has been reinserted, the driver skips to the code in
Section 6.10.
2
Because the
if_el
device driver must always be linked into the kernel,
sets the ALV_STATIC bit. If your driver can be dynamically loaded, set
the ALV_NOSIZER bit instead.
3
Sets the
if_addrlen
member of the
ifnet
data structure for this
device to the media address length, which in this case is 6 bytes (the
IEEE standard 48-bit address).
4
Sets the
if_hdrlen
member of the
ifnet
data structure for this
device to the media header length. The
el_attach( )
routine uses the
sizeof
operator to return the size of the data structure because it can
differ from one network type to another. In this example, the media
6–2 Implementing the Autoconfiguration Support Section (attach)