int ether_ioctl(struct ifnet *ifp, struct arpcom *arp, u_long cmd, caddr_t data) { struct ifreq *ifr = (struct ifreq *)data; int error = 0; switch (cmd) { case SIOCSIFADDR: break; case SIOCSIFMTU: if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ifp->if_hardmtu) error = EINVAL; else ifp->if_mtu = ifr->ifr_mtu; break; case SIOCADDMULTI: case SIOCDELMULTI: if (ifp->if_flags & IFF_MULTICAST) { error = (cmd == SIOCADDMULTI) ? ether_addmulti(ifr, arp) : ether_delmulti(ifr, arp); } else error = ENOTTY; break; default: error = ENOTTY; } return (error); }
int xilTemacIoctl(struct ifnet* ifp, ioctl_command_t aCommand, caddr_t aData) { struct XilTemac* xilTemac = ifp->if_softc; int32_t error = 0; switch(aCommand) { case SIOCGIFADDR: case SIOCSIFADDR: ether_ioctl(ifp, aCommand, aData); break; case SIOCSIFFLAGS: switch(ifp->if_flags & (IFF_UP | IFF_RUNNING)) { case IFF_RUNNING: xilTemacStop(ifp); break; case IFF_UP: xilTemacStart(ifp); break; case IFF_UP | IFF_RUNNING: xilTemacReset(ifp); break; default: break; } break; case SIOCADDMULTI: case SIOCDELMULTI: { struct ifreq* ifr = (struct ifreq*) aData; error = ((aCommand == SIOCADDMULTI) ? ( ether_addmulti(ifr, &(xilTemac->iArpcom)) ) : ( ether_delmulti(ifr, &(xilTemac->iArpcom))) ); /* ENETRESET indicates that driver should update its multicast filters */ if(error == ENETRESET) { error = xilTemacSetMulticastFilter( ifp ); } break; } case SIO_RTEMS_SHOW_STATS: xilTemacPrintStats( ifp ); break; default: error = EINVAL; break; } return error; }
int ether_ioctl(struct ifnet *ifp, struct arpcom *arp, u_long cmd, caddr_t data) { struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int error = 0; switch (cmd) { case SIOCSIFADDR: switch (ifa->ifa_addr->sa_family) { #ifdef NETATALK case AF_APPLETALK: /* Nothing to do. */ break; #endif /* NETATALK */ } break; case SIOCSIFMTU: if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ifp->if_hardmtu) error = EINVAL; else ifp->if_mtu = ifr->ifr_mtu; break; case SIOCADDMULTI: case SIOCDELMULTI: if (ifp->if_flags & IFF_MULTICAST) { error = (cmd == SIOCADDMULTI) ? ether_addmulti(ifr, arp) : ether_delmulti(ifr, arp); } else error = ENOTTY; break; default: error = ENOTTY; } return (error); }
/* * Process an ioctl request. */ int cas_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct cas_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; s = splnet(); if ((error = ether_ioctl(ifp, &sc->sc_arpcom, cmd, data)) > 0) { splx(s); return (error); } switch (cmd) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; if ((ifp->if_flags & IFF_RUNNING) == 0) cas_init(ifp); #ifdef INET if (ifa->ifa_addr->sa_family == AF_INET) arp_ifinit(&sc->sc_arpcom, ifa); #endif break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if ((ifp->if_flags & IFF_RUNNING) && ((ifp->if_flags ^ sc->sc_if_flags) & (IFF_ALLMULTI | IFF_PROMISC)) != 0) cas_setladrf(sc); else { if ((ifp->if_flags & IFF_RUNNING) == 0) cas_init(ifp); } } else { if (ifp->if_flags & IFF_RUNNING) cas_stop(ifp, 1); } sc->sc_if_flags = ifp->if_flags; #ifdef CAS_DEBUG sc->sc_debug = (ifp->if_flags & IFF_DEBUG) != 0 ? 1 : 0; #endif break; case SIOCSIFMTU: if (ifr->ifr_mtu > ETHERMTU || ifr->ifr_mtu < ETHERMIN) { error = EINVAL; } else if (ifp->if_mtu != ifr->ifr_mtu) { ifp->if_mtu = ifr->ifr_mtu; } break; case SIOCADDMULTI: case SIOCDELMULTI: error = (cmd == SIOCADDMULTI) ? ether_addmulti(ifr, &sc->sc_arpcom) : ether_delmulti(ifr, &sc->sc_arpcom); if (error == ENETRESET) { /* * Multicast list has changed; set the hardware filter * accordingly. */ if (ifp->if_flags & IFF_RUNNING) cas_setladrf(sc); error = 0; } break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); break; default: error = ENOTTY; break; } splx(s); return (error); }
int nfe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct nfe_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; int s, error = 0; s = splnet(); if ((error = ether_ioctl(ifp, &sc->sc_arpcom, cmd, data)) > 0) { splx(s); return error; } switch (cmd) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; if (!(ifp->if_flags & IFF_RUNNING)) nfe_init(ifp); #ifdef INET if (ifa->ifa_addr->sa_family == AF_INET) arp_ifinit(&sc->sc_arpcom, ifa); #endif break; case SIOCSIFMTU: if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ifp->if_hardmtu) error = EINVAL; else if (ifp->if_mtu != ifr->ifr_mtu) ifp->if_mtu = ifr->ifr_mtu; break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { /* * If only the PROMISC or ALLMULTI flag changes, then * don't do a full re-init of the chip, just update * the Rx filter. */ if ((ifp->if_flags & IFF_RUNNING) && ((ifp->if_flags ^ sc->sc_if_flags) & (IFF_ALLMULTI | IFF_PROMISC)) != 0) { nfe_setmulti(sc); } else { if (!(ifp->if_flags & IFF_RUNNING)) nfe_init(ifp); } } else { if (ifp->if_flags & IFF_RUNNING) nfe_stop(ifp, 1); } sc->sc_if_flags = ifp->if_flags; break; case SIOCADDMULTI: case SIOCDELMULTI: error = (cmd == SIOCADDMULTI) ? ether_addmulti(ifr, &sc->sc_arpcom) : ether_delmulti(ifr, &sc->sc_arpcom); if (error == ENETRESET) { if (ifp->if_flags & IFF_RUNNING) nfe_setmulti(sc); error = 0; } break; case SIOCSIFMEDIA: case SIOCGIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd); break; default: error = ENOTTY; } splx(s); return error; }
/* handle media, and ethernet requests */ int bce_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct bce_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; struct ifaddr *ifa = (struct ifaddr *)data; int s, error = 0; s = splnet(); if ((error = ether_ioctl(ifp, &sc->bce_ac, cmd, data)) > 0) { splx(s); return (error); } switch (cmd) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: bce_init(ifp); arp_ifinit(&sc->bce_ac, ifa); break; #endif /* INET */ default: bce_init(ifp); break; } break; case SIOCSIFMTU: if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU) error = EINVAL; else if (ifp->if_mtu != ifr->ifr_mtu) ifp->if_mtu = ifr->ifr_mtu; break; case SIOCSIFFLAGS: if(ifp->if_flags & IFF_UP) if(ifp->if_flags & IFF_RUNNING) bce_set_filter(ifp); else bce_init(ifp); else if(ifp->if_flags & IFF_RUNNING) bce_stop(ifp, 0); break; case SIOCADDMULTI: case SIOCDELMULTI: error = (cmd == SIOCADDMULTI) ? ether_addmulti(ifr, &sc->bce_ac) : ether_delmulti(ifr, &sc->bce_ac); if (error == ENETRESET) { /* * Multicast list has changed; set the hardware * filter accordingly. */ if (ifp->if_flags & IFF_RUNNING) bce_set_filter(ifp); error = 0; } break; case SIOCSIFMEDIA: case SIOCGIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->bce_mii.mii_media, cmd); break; default: error = ENOTTY; break; } if (error == 0) { /* Try to get more packets going. */ bce_start(ifp); } splx(s); return error; }
int mec_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct mec_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; int s, error; s = splnet(); if ((error = ether_ioctl(ifp, &sc->sc_ac, cmd, data)) > 0) { splx(s); return (error); } switch (cmd) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: mec_init(ifp); arp_ifinit(&sc->sc_ac, ifa); break; #endif default: mec_init(ifp); break; } break; case SIOCSIFMTU: if (ifr->ifr_mtu > ETHERMTU || ifr->ifr_mtu < ETHERMIN) error = EINVAL; else if (ifp->if_mtu != ifr->ifr_mtu) ifp->if_mtu = ifr->ifr_mtu; break; case SIOCSIFFLAGS: /* * If interface is marked up and not running, then start it. * If it is marked down and running, stop it. * XXX If it's up then re-initialize it. This is so flags * such as IFF_PROMISC are handled. */ if (ifp->if_flags & IFF_UP) mec_init(ifp); else if (ifp->if_flags & IFF_RUNNING) mec_stop(ifp); break; case SIOCADDMULTI: case SIOCDELMULTI: error = (cmd == SIOCADDMULTI) ? ether_addmulti(ifr, &sc->sc_ac) : ether_delmulti(ifr, &sc->sc_ac); if (error == ENETRESET) { /* * Multicast list has changed; set the hardware * filter accordingly. */ if (ifp->if_flags & IFF_RUNNING) mec_init(ifp); error = 0; } break; case SIOCSIFMEDIA: case SIOCGIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd); break; default: error = ENXIO; break; } splx(s); return error; }
Static int url_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct url_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; struct mii_data *mii; int s, error = 0; DPRINTF(("%s: %s: enter\n", USBDEVNAME(sc->sc_dev), __func__)); if (sc->sc_dying) return (EIO); s = splnet(); switch (cmd) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; url_init(ifp); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: arp_ifinit(&sc->sc_ac, ifa); break; #endif /* INET */ } break; case SIOCSIFMTU: if (ifr->ifr_mtu > ETHERMTU) error = EINVAL; else ifp->if_mtu = ifr->ifr_mtu; break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC) { URL_SETBIT2(sc, URL_RCR, URL_RCR_AAM|URL_RCR_AAP); } else if (ifp->if_flags & IFF_RUNNING && !(ifp->if_flags & IFF_PROMISC)) { URL_CLRBIT2(sc, URL_RCR, URL_RCR_AAM|URL_RCR_AAP); } else if (!(ifp->if_flags & IFF_RUNNING)) url_init(ifp); } else { if (ifp->if_flags & IFF_RUNNING) url_stop(ifp, 1); } error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: error = (cmd == SIOCADDMULTI) ? ether_addmulti(ifr, &sc->sc_ac) : ether_delmulti(ifr, &sc->sc_ac); if (error == ENETRESET) { if (ifp->if_flags & IFF_RUNNING) url_setmulti(sc); error = 0; } break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: mii = GET_MII(sc); error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd); break; default: error = EINVAL; break; } splx(s); return (error); }
Static int kue_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { struct kue_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; DPRINTFN(5,("%s: %s: enter\n", USBDEVNAME(sc->kue_dev),__func__)); if (sc->kue_dying) return (EIO); #ifdef DIAGNOSTIC if (!curproc) { printf("%s: no proc!!\n", USBDEVNAME(sc->kue_dev)); return EIO; } #endif s = splnet(); switch(command) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; kue_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: #if defined(__NetBSD__) arp_ifinit(ifp, ifa); #else arp_ifinit(&sc->arpcom, ifa); #endif break; #endif /* INET */ } break; case SIOCSIFMTU: if (ifr->ifr_mtu > ETHERMTU) error = EINVAL; else ifp->if_mtu = ifr->ifr_mtu; break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC && !(sc->kue_if_flags & IFF_PROMISC)) { sc->kue_rxfilt |= KUE_RXFILT_PROMISC; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); } else if (ifp->if_flags & IFF_RUNNING && !(ifp->if_flags & IFF_PROMISC) && sc->kue_if_flags & IFF_PROMISC) { sc->kue_rxfilt &= ~KUE_RXFILT_PROMISC; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); } else if (!(ifp->if_flags & IFF_RUNNING)) kue_init(sc); } else { if (ifp->if_flags & IFF_RUNNING) kue_stop(sc); } sc->kue_if_flags = ifp->if_flags; error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: error = (command == SIOCADDMULTI) ? ether_addmulti(ifr, &sc->arpcom) : ether_delmulti(ifr, &sc->arpcom); if (error == ENETRESET) { /* * Multicast list has changed; set the hardware * filter accordingly. */ if (ifp->if_flags & IFF_RUNNING) kue_setmulti(sc); error = 0; } break; default: error = EINVAL; break; } splx(s); return (error); }
int pdq_ifioctl( struct ifnet *ifp, ioctl_cmd_t cmd, caddr_t data) { pdq_softc_t *sc = (pdq_softc_t *) ((caddr_t) ifp - offsetof(pdq_softc_t, sc_arpcom.ac_if)); int s, error = 0; s = splnet(); switch (cmd) { case SIOCSIFADDR: { struct ifaddr *ifa = (struct ifaddr *)data; ifp->if_flags |= IFF_UP; switch(ifa->ifa_addr->sa_family) { #if defined(INET) case AF_INET: { pdq_ifinit(sc); arp_ifinit(&sc->sc_arpcom, ifa); break; } #endif /* INET */ #if defined(NS) /* This magic copied from if_is.c; I don't use XNS, * so I have no way of telling if this actually * works or not. */ case AF_NS: { struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); if (ns_nullhost(*ina)) { ina->x_host = *(union ns_host *)(sc->sc_arpcom.ac_enaddr); } else { ifp->if_flags &= ~IFF_RUNNING; bcopy((caddr_t)ina->x_host.c_host, (caddr_t)sc->sc_arpcom.ac_enaddr, sizeof sc->sc_arpcom.ac_enaddr); } pdq_ifinit(sc); break; } #endif /* NS */ default: { pdq_ifinit(sc); break; } } break; } case SIOCSIFFLAGS: { pdq_ifinit(sc); break; } case SIOCADDMULTI: case SIOCDELMULTI: { /* * Update multicast listeners */ if (cmd == SIOCADDMULTI) error = ether_addmulti((struct ifreq *)data, &sc->sc_arpcom); else error = ether_delmulti((struct ifreq *)data, &sc->sc_arpcom); if (error == ENETRESET) { if (sc->sc_if.if_flags & IFF_RUNNING) pdq_run(sc->sc_pdq); error = 0; } break; } default: { error = EINVAL; break; } } splx(s); return error; }
int bmac_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct bmac_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; s = splnet(); switch (cmd) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: bmac_init(sc); arp_ifinit(&sc->arpcom, ifa); break; #endif default: bmac_init(sc); break; } break; case SIOCSIFFLAGS: if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { /* * If interface is marked down and it is running, then * stop it. */ bmac_stop(sc); ifp->if_flags &= ~IFF_RUNNING; } else if ((ifp->if_flags & IFF_UP) != 0 && (ifp->if_flags & IFF_RUNNING) == 0) { /* * If interface is marked up and it is stopped, then * start it. */ bmac_init(sc); } else { /* * Reset the interface to pick up changes in any other * flags that affect hardware registers. */ /*bmac_stop(sc);*/ bmac_init(sc); } #ifdef BMAC_DEBUG if (ifp->if_flags & IFF_DEBUG) sc->sc_debug = 1; else sc->sc_debug = 0; #endif break; case SIOCADDMULTI: case SIOCDELMULTI: error = (cmd == SIOCADDMULTI) ? ether_addmulti(ifr, &sc->arpcom) : ether_delmulti(ifr, &sc->arpcom); if (error == ENETRESET) { /* * Multicast list has changed; set the hardware filter * accordingly. */ if (ifp->if_flags & IFF_RUNNING) { bmac_init(sc); bmac_setladrf(sc); } error = 0; } break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd); break; default: error = EINVAL; } splx(s); return (error); }