/* * Mark an interface down and notify protocols of * the transition. * NOTE: must be called at splnet or eqivalent. */ void if_down(struct ifnet *ifp) { struct ifaddr *ifa; ifp->if_flags &= ~IFF_UP; microtime(&ifp->if_lastchange); for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) pfctlinput(PRC_IFDOWN, ifa->ifa_addr); if_qflush(&ifp->if_snd); rt_ifmsg(ifp); }
static int usbpf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) { int error; int unit; struct ifnet *ifp; struct usb_bus *ubus; error = ifc_name2unit(name, &unit); if (error) return (error); if (unit < 0) return (EINVAL); ubus = usbpf_ifname2ubus(name); if (ubus == NULL) return (1); if (ubus->ifp != NULL) return (1); error = ifc_alloc_unit(ifc, &unit); if (error) { ifc_free_unit(ifc, unit); device_printf(ubus->parent, "usbpf: Could not allocate " "instance\n"); return (error); } ifp = ubus->ifp = if_alloc(IFT_USB); if (ifp == NULL) { ifc_free_unit(ifc, unit); device_printf(ubus->parent, "usbpf: Could not allocate " "instance\n"); return (ENOSPC); } strlcpy(ifp->if_xname, name, sizeof(ifp->if_xname)); ifp->if_softc = ubus; ifp->if_dname = usbusname; ifp->if_dunit = unit; ifp->if_ioctl = usbpf_ioctl; if_attach(ifp); ifp->if_flags |= IFF_UP; rt_ifmsg(ifp); /* * XXX According to the specification of DLT_USB, it indicates * packets beginning with USB setup header. But not sure all * packets would be. */ bpfattach(ifp, DLT_USB, USBPF_HDR_LEN); return (0); }
/* * Mark an interface up and notify protocols of * the transition. * NOTE: must be called at splnet or eqivalent. */ void if_up(struct ifnet *ifp) { ifp->if_flags |= IFF_UP; microtime(&ifp->if_lastchange); #ifdef notyet struct ifaddr *ifa; /* this has no effect on IP, and will kill all iso connections XXX */ for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) pfctlinput(PRC_IFUP, ifa->ifa_addr); #endif rt_ifmsg(ifp); }