Table 12–1: Network ioctl Commands (cont.)

ioctl Command

Required

Description

For More Information

SIOCSIFFLAGS

Yes

Ensures that the

Section 12.12

 

 

interface is operating

 

 

 

correctly according

 

 

 

to the interface flags

 

 

 

(if_flags).

 

SIOCSIPMTU

Yes

Sets the IP maximum

Section 12.13

 

 

transmission unit

 

 

 

(MTU).

 

SIOCSMACSPEED

Yes

Sets the media speed. Section 12.14

SIOCIFRESET

No

Resets the device.

Section 12.15

SIOCIFSETCHAR

Yes

Sets network device

Section 12.16

 

 

characteristics, such

 

as full duplex or promiscuous mode.

12.1 Setting Up the el_ioctl Routine

The following code shows how to set up the el_ioctl( ) routine:

static int el_ioctl(struct ifnet *ifp, 1 u_int cmd, 2 caddr_t data) 3

{

register struct el_softc *sc

= el_softc[ifp->if_unit];

4

register unit = ifp->if_unit;

 

 

 

 

 

 

 

 

 

 

5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

struct ifreq *ifr = (struct ifreq *)data;

6

 

 

 

 

 

 

struct ifdevea *ifd = (struct ifdevea *)data;

 

 

 

 

 

7

 

 

 

 

 

 

 

 

 

struct ctrreq *ctr = (struct

ctrreq *)data;

 

8

 

 

 

 

 

 

 

 

 

 

 

struct ifchar *ifc = (struct

ifchar *)data;

 

9

 

 

 

 

int s, i, j, need_reset, lock_on = 1, status = ESUCCESS; unsigned short ifmtu, speed; 11

u_char mclist_buf[NET_SZ_MCLIST]; 12

10

1

2

3

4

5

6

Specifies a pointer to the ifnet data structure for an if_el device.

Specifies the ioctl command.

Specifies a pointer to ioctl command-specific data to be passed to or initialized by the device driver.

Declares a pointer to the el_softc data structure that is called sc and initializes it to the el_softc data structure for this device.

Declares a unit variable and initializes it to the unit number for the device.

Casts the data argument to a data structure of type ifreq for use with the SIOCPHYSADDR, SIOCADDMULTI, SIOCDELMULTI, SIOCSIPMTU, and SIOCSMACSPEED ioctl commands.

12–2Implementing the ioctl Section

Page 126
Image 126
Compaq AA-RNG2A-TE manual Setting Up the elioctl Routine, Following code shows how to set up the elioctl routine