Table 12–1: Network ioctl Commands (cont.)
ioctl Command
Required
Description
For More Information
SIOCSIFFLAGS
Yes
Ensures that the
interface is operating
correctly according
to the interface flags
(
if_flags
).
Section 12.12
SIOCSIPMTU
Yes
Sets the IP maximum
transmission unit
(MTU).
Section 12.13
SIOCSMACSPEED
Yes
Sets the media speed. Section 12.14
SIOCIFRESET
No
Resets the device.
Section 12.15
SIOCIFSETCHAR
Yes
Sets network device
characteristics, such
as full duplex or
promiscuous mode.
Section 12.16
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;
10
unsigned short ifmtu, speed;
11
u_char mclist_buf[NET_SZ_MCLIST];
12
1
Specifies a pointer to the
ifnet
data structure for an
if_el
device.
2
Specifies the
ioctl
command.
3
Specifies a pointer to
ioctl
command-specific data to be passed to
or initialized by the device driver.
4
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.
5
Declares a
unit
variable and initializes it to the unit number for the
device.
6
Casts the
data
argument to a data structure of type
ifreq
for use with
the
SIOCPHYSADDR
,
SIOCADDMULTI
,
SIOCDELMULTI
,
SIOCSIPMTU
, and
SIOCSMACSPEED ioctl
commands.
12–2 Implementing the ioctl Section