Compaq AA-RNG2A-TE Network Card User Manual


 
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: 1
bcopy(sc->is_addr, ifd->current_pa, 6); 2
for (i=0; i<3; i++) {
3
j = sc->eeprom.addr[i];
ifd->default_pa[(i*2)] = (j>>8) & 0xff;
ifd->default_pa[(i*2)+1] = (j) & 0xff;
}
break;
1 Determines whether the cmd argument is SIOCRPHYSADDR.
2 Copies the current MAC address that is stored in the el_softc data
structure for this device to the ifd data structure, a command-specific
data structure of type ifdevea.
3 Copies the default MAC address that is stored in the drivers el_softc
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:
1
bcopy(ifr->ifr_addr.sa_data, sc->is_addr, 6); 2
pfilt_newaddress(sc->is_ed.ess_enetunit, sc->is_addr); 3
if (ifp->if_flags & IFF_RUNNING) { 4
el_reset_locked(sc, ifp, unit);
}
simple_unlock(&sc->el_softc_lock);
5
splx(s); 6
lock_on = 0; 7
if (((struct arpcom *)ifp)->ac_flag & AC_IPUP) { 8
rearpwhohas((struct arpcom *)ifp);
}
if_sphyaddr(ifp, ifr);
9
break;
1 Determines whether the cmd argument is SIOCSPHYSADDR ioctl.
2 Copies the new MAC address to the ifnet data structure.
3 Calls the pfilt_newaddress( ) routine to copy the new address to
the packet filter.
Implementing the ioctl Section 125