1

2

3

if (sc->debug) { j = 0;

printf("el%d: Dump of multicast table after DEL (%d entries)\n", unit, sc->is_multi.lan_nmulti);

for (i=0; i<sc->is_multi.lan_nmulti; i++) { unsigned char *maddr;

LAN_GET_MULTI(&sc->is_multi, maddr, j);

printf(" %d %s (muse==%d)\n", i+1, ether_sprintf(maddr), sc->is_multi.lan_mtable[j-1].muse);

}

}

lan_build_mclist (mclist_buf, NET_SZ_MCLIST, &sc->is_multi); 3

lan_set_attribute(sc->ehm.current_val, NET_MCLIST_NDX, mclist_buf); break;

Determines whether the cmd argument is SIOCDELMULTI.

Examines the type of the multicast address and decrements the appropriate counter. The el_ioctl( ) routine removes the capability from the device only when there are no more active multicast addresses.

Builds a text string that lists all currently active multicast addresses, and sets this list as an enhanced hardware management (EHM) attribute for this network device.

12.10Accessing Network Counters (SIOCRDCTRS and SIOCRDZCTRS ioctl Commands)

The SIOCRDCTRS ioctl command returns the values of network counters. The driver’s softc data structure stores a pointer to the counter information. The driver returns the information to the caller in a ctrreq data structure, which is passed into the ioctl( ) routine through the data argument.

The SIOCRDZCTRS ioctl command also zeroes the network counters.

The following code shows how the el_ioctl( ) routine implements the SIOCRDCTRS and SIOCRDZCTRS ioctl commands:

case SIOCRDCTRS: 1 case SIOCRDZCTRS:

ctr->ctr_ether = sc->ctrblk; 2 ctr->ctr_type = CTR_ETHER; 3

ctr->ctr_ether.est_seconds = (time.tv_sec - sc->ztime) > 0xfffe ? 0xffff : (time.tv_sec - sc->ztime);

if (cmd == SIOCRDZCTRS) { 5 sc->ztime = time.tv_sec; bzero(&sc->ctrblk, sizeof(struct estat));

}

break;

4

1

Determines whether the cmd argument is SIOCRDCTRS or

SIOCRDZCTRS.

12–8Implementing the ioctl Section

Page 132
Image 132
Compaq AA-RNG2A-TE manual Determines whether the cmd argument is Siocrdctrs or