Reading Current And Default Mac Addresses (Siocrphysaddr Ioctl Command); Setting The Local Mac Address - Compaq Tru64 UNIX Installation Manual

Writing network device drivers
Table of Contents

Advertisement

12.6 Reading Current and Default MAC Addresses
(SIOCRPHYSADDR ioctl Command)
The following code shows how the el_ioctl( ) routine implements the
SIOCRPHYSADDR ioctl command to read the current and default MAC
addresses when an application requests them:
case SIOCRPHYSADDR:
bcopy(sc->is_addr, ifd->current_pa, 6);
for (i=0; i<3; i++) {
j = sc->eeprom.addr[i];
ifd->default_pa[(i*2)] = (j>>8) & 0xff;
ifd->default_pa[(i*2)+1] = (j) & 0xff;
}
break;
Determines whether the cmd argument is SIOCRPHYSADDR.
1
Copies the current MAC address that is stored in the el_softc data
2
structure for this device to the ifd data structure, a command-specific
data structure of type ifdevea.
Copies the default MAC address that is stored in the driver's el_softc
3
data structure for this device to the ifd data structure.
12.7 Setting the Local MAC Address (SIOCSPHYSADDR
ioctl Command)
The following code shows how the el_ioctl( ) routine implements the
SIOCSPHYSADDR ioctl command to set the local MAC address:
case SIOCSPHYSADDR:
bcopy(ifr->ifr_addr.sa_data, sc->is_addr, 6);
pfilt_newaddress(sc->is_ed.ess_enetunit, sc->is_addr);
if (ifp->if_flags & IFF_RUNNING) {
el_reset_locked(sc, ifp, unit);
}
simple_unlock(&sc->el_softc_lock);
splx(s);
6
lock_on = 0;
if (((struct arpcom *)ifp)->ac_flag & AC_IPUP) {
rearpwhohas((struct arpcom *)ifp);
}
if_sphyaddr(ifp, ifr);
break;
Determines whether the cmd argument is SIOCSPHYSADDR ioctl.
1
Copies the new MAC address to the ifnet data structure.
2
Calls the pfilt_newaddress( ) routine to copy the new address to
3
the packet filter.
1
2
3
1
4
5
7
9
2
3
8
Implementing the ioctl Section 12–5

Advertisement

Table of Contents
loading

Table of Contents