/* ARGSUSED */ int loioctl(struct ifnet *ifp, u_long cmd, void *data) { struct ifaddr *ifa; struct ifreq *ifr = data; int error = 0; switch (cmd) { case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; ifa = (struct ifaddr *)data; if (ifa != NULL /*&& ifa->ifa_addr->sa_family == AF_ISO*/) ifa->ifa_rtrequest = lortrequest; /* * Everything else is done at a higher level. */ break; case SIOCSIFMTU: if ((unsigned)ifr->ifr_mtu > LOMTU_MAX) error = EINVAL; else if ((error = ifioctl_common(ifp, cmd, data)) == ENETRESET){ /* XXX update rt mtu for AF_ISO? */ error = 0; } break; case SIOCADDMULTI: case SIOCDELMULTI: if (ifr == NULL) { error = EAFNOSUPPORT; /* XXX */ break; } switch (ifreq_getaddr(cmd, ifr)->sa_family) { #ifdef INET case AF_INET: break; #endif #ifdef INET6 case AF_INET6: break; #endif default: error = EAFNOSUPPORT; break; } break; default: error = ifioctl_common(ifp, cmd, data); } return (error); }
/* * Process an ioctl request. */ static int tun_ioctl(struct ifnet *ifp, u_long cmd, void *data) { int error = 0, s; struct tun_softc *tp = (struct tun_softc *)(ifp->if_softc); struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; s = splnet(); switch (cmd) { case SIOCINITIFADDR: tuninit(tp); ifa->ifa_rtrequest = p2p_rtrequest; TUNDEBUG("%s: address set\n", ifp->if_xname); break; case SIOCSIFBRDADDR: TUNDEBUG("%s: broadcast address set\n", ifp->if_xname); break; case SIOCSIFMTU: if (ifr->ifr_mtu > TUNMTU || ifr->ifr_mtu < 576) { error = EINVAL; break; } TUNDEBUG("%s: interface mtu set\n", ifp->if_xname); if ((error = ifioctl_common(ifp, cmd, data)) == ENETRESET) error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: if (ifr == NULL) { error = EAFNOSUPPORT; /* XXX */ break; } switch (ifreq_getaddr(cmd, ifr)->sa_family) { #ifdef INET case AF_INET: break; #endif #ifdef INET6 case AF_INET6: break; #endif default: error = EAFNOSUPPORT; break; } break; default: error = ifioctl_common(ifp, cmd, data); } splx(s); return (error); }