int gif_clone_create(struct if_clone *ifc, int unit) { struct gif_softc *sc; int s; sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO); if (!sc) return (ENOMEM); snprintf(sc->gif_if.if_xname, sizeof sc->gif_if.if_xname, "%s%d", ifc->ifc_name, unit); sc->gif_if.if_mtu = GIF_MTU; sc->gif_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->gif_if.if_ioctl = gif_ioctl; sc->gif_if.if_start = gif_start; sc->gif_if.if_output = gif_output; sc->gif_if.if_type = IFT_GIF; IFQ_SET_MAXLEN(&sc->gif_if.if_snd, ifqmaxlen); IFQ_SET_READY(&sc->gif_if.if_snd); sc->gif_if.if_softc = sc; if_attach(&sc->gif_if); if_alloc_sadl(&sc->gif_if); #if NBPFILTER > 0 bpfattach(&sc->gif_if.if_bpf, &sc->gif_if, DLT_LOOP, sizeof(u_int32_t)); #endif s = splnet(); LIST_INSERT_HEAD(&gif_softc_list, sc, gif_list); splx(s); return (0); }
static struct ifnet_en * ipxipattach() { register struct ifnet_en *m; register struct ifnet *ifp; if (ipxipif.if_mtu == 0) { ifp = &ipxipif; ifp->if_name = "ipxip"; ifp->if_mtu = LOMTU; ifp->if_ioctl = ipxipioctl; ifp->if_output = ipxipoutput; ifp->if_start = ipxipstart; ifp->if_flags = IFF_POINTOPOINT; } MALLOC((m), struct ifnet_en *, sizeof(*m), M_PCB, M_NOWAIT); if (m == NULL) return (NULL); bzero(m, sizeof(*m)); m->ifen_next = ipxip_list; ipxip_list = m; ifp = &m->ifen_ifnet; ifp->if_name = "ipxip"; ifp->if_mtu = LOMTU; ifp->if_ioctl = ipxipioctl; ifp->if_output = ipxipoutput; ifp->if_start = ipxipstart; ifp->if_flags = IFF_POINTOPOINT; ifp->if_unit = ipxipif.if_unit++; if_attach(ifp); return (m); }
/* * Called from boot code to establish ppp interfaces. */ static void pppattach(void *dummy) { struct ppp_softc *sc; int i = 0; for (sc = ppp_softc; i < NPPP; sc++) { if_initname(&(sc->sc_if), "ppp", i++); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->sc_if.if_type = IFT_PPP; sc->sc_if.if_hdrlen = PPP_HDRLEN; sc->sc_if.if_ioctl = pppsioctl; sc->sc_if.if_output = pppoutput; sc->sc_if.if_start = ppp_ifstart; ifq_set_maxlen(&sc->sc_if.if_snd, IFQ_MAXLEN); ifq_set_ready(&sc->sc_if.if_snd); sc->sc_inq.ifq_maxlen = IFQ_MAXLEN; sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN; sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; callout_init(&sc->sc_timeout); if_attach(&sc->sc_if, NULL); bpfattach(&sc->sc_if, DLT_PPP, PPP_HDRLEN); } netisr_register(NETISR_PPP, pppintr, NULL); /* * XXX layering violation - if_ppp can work over any lower level * transport that cares to attach to it. */ pppasyncattach(dummy); }
/* * Interface exists: make available by filling in network interface * record. System will initialize the interface when it is ready * to accept packets. */ void dmcattach(device_t parent, device_t self, void *aux) { struct uba_attach_args *ua = aux; struct dmc_softc *sc = device_private(self); sc->sc_dev = self; sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_dmat = ua->ua_dmat; strlcpy(sc->sc_if.if_xname, device_xname(sc->sc_dev), IFNAMSIZ); sc->sc_if.if_mtu = DMCMTU; sc->sc_if.if_init = dmcinit; sc->sc_if.if_output = dmcoutput; sc->sc_if.if_ioctl = dmcioctl; sc->sc_if.if_watchdog = dmctimeout; sc->sc_if.if_flags = IFF_POINTOPOINT; sc->sc_if.if_softc = sc; IFQ_SET_READY(&sc->sc_if.if_snd); uba_intr_establish(ua->ua_icookie, ua->ua_cvec, dmcrint, sc, &sc->sc_rintrcnt); uba_intr_establish(ua->ua_icookie, ua->ua_cvec+4, dmcxint, sc, &sc->sc_tintrcnt); uba_reset_establish(dmcreset, sc->sc_dev); evcnt_attach_dynamic(&sc->sc_rintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, device_xname(sc->sc_dev), "intr"); evcnt_attach_dynamic(&sc->sc_tintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, device_xname(sc->sc_dev), "intr"); if_attach(&sc->sc_if); }
static int lo_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct ifnet *ifp; ifp = if_alloc(IFT_LOOP); if (ifp == NULL) return (ENOSPC); if_initname(ifp, loname, unit); ifp->if_mtu = LOMTU; ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; ifp->if_ioctl = loioctl; ifp->if_output = looutput; ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_capabilities = ifp->if_capenable = IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6; ifp->if_hwassist = LO_CSUM_FEATURES | LO_CSUM_FEATURES6; if_attach(ifp); bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); if (V_loif == NULL) V_loif = ifp; return (0); }
/* * icattach() */ static int icattach(device_t dev) { struct ic_softc *sc = (struct ic_softc *)device_get_softc(dev); struct ifnet *ifp = &sc->ic_if; sc->ic_addr = iicbus_get_addr(dev); ifp->if_softc = sc; ifp->if_name = "ic"; ifp->if_unit = device_get_unit(dev); ifp->if_mtu = ICMTU; ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST; ifp->if_ioctl = icioctl; ifp->if_output = icoutput; ifp->if_type = IFT_PARA; ifp->if_hdrlen = 0; ifp->if_addrlen = 0; ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; if_attach(ifp); bpfattach(ifp, DLT_NULL, ICHDRLEN); return (0); }
void ipfw_log_bpf(int onoff) { struct ifnet *ifp; if (onoff) { if (log_if) return; ifp = if_alloc(IFT_ETHER); if (ifp == NULL) return; if_initname(ifp, "ipfw", 0); ifp->if_mtu = 65536; ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_init = (void *)log_dummy; ifp->if_ioctl = log_dummy; ifp->if_start = (void *)log_dummy; ifp->if_output = (void *)log_dummy; ifp->if_addrlen = 6; ifp->if_hdrlen = 14; if_attach(ifp); ifp->if_baudrate = IF_Mbps(10); bpfattach(ifp, DLT_EN10MB, 14); log_if = ifp; } else { if (log_if) { ether_ifdetach(log_if); if_free(log_if); } log_if = NULL; } }
int wanpipe_generic_register(sdla_t *card, struct ifnet *ifp, char *ifname) { wanpipe_common_t* common = WAN_IFP_TO_COMMON(ifp); if (ifname == NULL || strlen(ifname) > IFNAMSIZ) return (EINVAL); else bcopy(ifname, ifp->if_xname, strlen(ifname)); IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); IFQ_SET_READY(&ifp->if_snd); ifp->if_mtu = PP_MTU; ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; common->protocol = IF_PROTO_CISCO; ((struct sppp *)ifp)->pp_flags |= PP_CISCO; ((struct sppp *)ifp)->pp_flags |= PP_KEEPALIVE; ((struct sppp *)ifp)->pp_framebytes = 3; ifp->if_ioctl = wanpipe_generic_ioctl; /* Will set from new_if() */ ifp->if_start = wanpipe_generic_start; ifp->if_watchdog = wanpipe_generic_watchdog; if_attach(ifp); if_alloc_sadl(ifp); sppp_attach(ifp); #if NBPFILTER > 0 bpfattach(&ifp->if_bpf, ifp, DLT_PPP, PPP_HEADER_LEN); #endif /* NBPFILTER > 0 */ return (0); }
static int disc_clone_create(struct if_clone *ifc, int unit) { struct ifnet *ifp; struct disc_softc *sc; sc = malloc(sizeof(struct disc_softc), M_DISC, M_WAITOK | M_ZERO); ifp = &sc->sc_if; ifp->if_softc = sc; if_initname(ifp, ifc->ifc_name, unit); ifp->if_mtu = DSMTU; ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; ifp->if_ioctl = discioctl; ifp->if_output = discoutput; ifp->if_type = IFT_LOOP; ifp->if_hdrlen = 0; ifp->if_addrlen = 0; ifp->if_snd.ifq_maxlen = 20; if_attach(ifp); bpfattach(ifp, DLT_NULL, sizeof(u_int)); mtx_lock(&disc_mtx); LIST_INSERT_HEAD(&disc_softc_list, sc, sc_list); mtx_unlock(&disc_mtx); return (0); }
static void tuncreate(struct cdev *dev) { struct tun_softc *sc; struct ifnet *ifp; dev->si_flags &= ~SI_CHEAPCLONE; MALLOC(sc, struct tun_softc *, sizeof(*sc), M_TUN, M_WAITOK | M_ZERO); mtx_init(&sc->tun_mtx, "tun_mtx", NULL, MTX_DEF); sc->tun_flags = TUN_INITED; sc->tun_dev = dev; mtx_lock(&tunmtx); TAILQ_INSERT_TAIL(&tunhead, sc, tun_list); mtx_unlock(&tunmtx); ifp = &sc->tun_if; if_initname(ifp, TUNNAME, dev2unit(dev)); ifp->if_mtu = TUNMTU; ifp->if_ioctl = tunifioctl; ifp->if_output = tunoutput; ifp->if_start = tunstart; ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; ifp->if_type = IFT_PPP; ifp->if_softc = sc; IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); ifp->if_snd.ifq_drv_maxlen = 0; IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); bpfattach(ifp, DLT_NULL, sizeof(u_int)); dev->si_drv1 = sc; }
/* * icattach() */ static int icattach(device_t dev) { struct ic_softc *sc = (struct ic_softc *)device_get_softc(dev); struct ifnet *ifp; ifp = sc->ic_ifp = if_alloc(IFT_PARA); if (ifp == NULL) return (ENOSPC); mtx_init(&sc->ic_lock, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF); sc->ic_addr = PCF_MASTER_ADDRESS; /* XXX only PCF masters */ sc->ic_dev = dev; ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST; ifp->if_ioctl = icioctl; ifp->if_output = icoutput; ifp->if_hdrlen = 0; ifp->if_addrlen = 0; ifp->if_snd.ifq_maxlen = ifqmaxlen; ic_alloc_buffers(sc, ICMTU); if_attach(ifp); bpfattach(ifp, DLT_NULL, ICHDRLEN); return (0); }
eonattach() { register struct ifnet *ifp = eonif; IFDEBUG(D_EON) printf("eonattach()\n"); ENDDEBUG ifp->if_unit = 0; ifp->if_name = "eon"; ifp->if_mtu = ETHERMTU; /* since everything will go out over ether or token ring */ ifp->if_init = eoninit; ifp->if_ioctl = eonioctl; ifp->if_output = eonoutput; ifp->if_type = IFT_EON; ifp->if_addrlen = 5; ifp->if_hdrlen = EONIPLEN; ifp->if_flags = IFF_BROADCAST; if_attach(ifp); eonioctl(ifp, SIOCSIFADDR, (caddr_t)ifp->if_addrlist); eon_llinfo.el_qhdr.link = eon_llinfo.el_qhdr.rlink = &(eon_llinfo.el_qhdr); IFDEBUG(D_EON) printf("eonattach()\n"); ENDDEBUG }
void usbpf_attach(struct usb_bus *ubus) { struct ifnet *ifp; if (usb_no_pf != 0) { ubus->ifp = NULL; return; } ifp = ubus->ifp = if_alloc(IFT_USB); if (ifp == NULL) { device_printf(ubus->parent, "usbpf: Could not allocate " "instance\n"); return; } if_initname(ifp, "usbus", device_get_unit(ubus->bdev)); ifp->if_flags = IFF_CANTCONFIG; if_attach(ifp); if_up(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); if (bootverbose) device_printf(ubus->parent, "usbpf: Attached\n"); }
/* * Called from boot code to establish sl interfaces. */ void slattach() { register struct sl_softc *sc; register int i = 0; for (sc = sl_softc; i < NSL; sc++) { sc->sc_if.if_name = "sl"; sc->sc_if.if_next = NULL; sc->sc_if.if_unit = i++; sc->sc_if.if_mtu = SLMTU; sc->sc_if.if_flags = IFF_POINTOPOINT | SC_AUTOCOMP | IFF_MULTICAST; sc->sc_if.if_type = IFT_SLIP; sc->sc_if.if_ioctl = slioctl; sc->sc_if.if_output = NULL /* sloutput */; sc->sc_if.if_snd.ifq_maxlen = 50; sc->sc_fastq.ifq_maxlen = 32; if_attach(&sc->sc_if); #if NBPFILTER > 0 bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_SLIP, SLIP_HDRLEN); #endif } }
static int ipfwlog_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct ifnet *ifp; ifp = if_alloc(IFT_PFLOG); if (ifp == NULL) return (ENOSPC); if_initname(ifp, ipfwlogname, unit); ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_mtu = 65536; ifp->if_ioctl = ipfw_bpf_ioctl; ifp->if_output = ipfw_bpf_output; ifp->if_hdrlen = PFLOG_HDRLEN; if_attach(ifp); bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN); LOGIF_WLOCK(); if (V_pflog_if != NULL) { LOGIF_WUNLOCK(); bpfdetach(ifp); if_detach(ifp); if_free(ifp); return (EEXIST); } V_pflog_if = ifp; LOGIF_WUNLOCK(); return (0); }
void encattach(int nenc) { struct ifnet *ifp; int i; bzero(encif, sizeof(encif)); for (i = 0; i < NENC; i++) { ifp = &encif[i].sc_if; snprintf(ifp->if_xname, sizeof ifp->if_xname, "enc%d", i); ifp->if_softc = &encif[i]; ifp->if_mtu = ENCMTU; ifp->if_ioctl = encioctl; ifp->if_output = encoutput; ifp->if_start = encstart; ifp->if_type = IFT_ENC; ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_hdrlen = ENC_HDRLEN; if_attach(ifp); if_alloc_sadl(ifp); #if NBPFILTER > 0 bpfattach(&encif[i].sc_if.if_bpf, ifp, DLT_ENC, ENC_HDRLEN); #endif } }
static int pflog_clone_create(struct if_clone *ifc, int unit, caddr_t param) { struct ifnet *ifp; if (unit >= PFLOGIFS_MAX) return (EINVAL); ifp = if_alloc(IFT_PFLOG); if (ifp == NULL) { return (ENOSPC); } if_initname(ifp, pflogname, unit); ifp->if_mtu = PFLOGMTU; ifp->if_ioctl = pflogioctl; ifp->if_output = pflogoutput; ifp->if_start = pflogstart; ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_hdrlen = PFLOG_HDRLEN; if_attach(ifp); bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN); pflogifs[unit] = ifp; return (0); }
static int pflog_clone_create(struct if_clone *ifc, int unit) { struct pflog_softc *sc; MALLOC(sc, struct pflog_softc *, sizeof(*sc), M_PFLOG, M_WAITOK|M_ZERO); if_initname(&sc->sc_if, ifc->ifc_name, unit); sc->sc_if.if_mtu = PFLOGMTU; sc->sc_if.if_ioctl = pflogioctl; sc->sc_if.if_output = pflogoutput; sc->sc_if.if_start = pflogstart; sc->sc_if.if_type = IFT_PFLOG; sc->sc_if.if_snd.ifq_maxlen = ifqmaxlen; sc->sc_if.if_hdrlen = PFLOG_HDRLEN; sc->sc_if.if_softc = sc; if_attach(&sc->sc_if); LIST_INSERT_HEAD(&pflog_list, sc, sc_next); #if NBPFILTER > 0 bpfattach(&sc->sc_if, DLT_PFLOG, PFLOG_HDRLEN); #endif return (0); }
/* ARGSUSED */ static void loopattach(void *dummy) { struct ifnet *ifp; int i; for (i = 0, ifp = loif; i < NLOOP; i++, ifp++) { if_initname(ifp, "lo", i); ifp->if_mtu = LOMTU; ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; ifp->if_capabilities = IFCAP_HWCSUM; ifp->if_hwassist = LO_CSUM_FEATURES; ifp->if_capenable = ifp->if_capabilities; ifp->if_ioctl = loioctl; ifp->if_output = looutput; ifp->if_type = IFT_LOOP; ifq_set_maxlen(&ifp->if_snd, ifqmaxlen); ifq_set_ready(&ifp->if_snd); #ifdef ALTQ ifp->if_start = lo_altqstart; #endif if_attach(ifp, NULL); bpfattach(ifp, DLT_NULL, sizeof(u_int)); } }
/* * Does we really need this? */ IF_DRAIN(&ifp->if_snd); bpfdetach(ifp); if_detach(ifp); LIST_REMOVE(sc, sc_next); free(sc, M_PFLOG); } static int pflog_clone_create(struct if_clone *ifc, int unit) { struct pflog_softc *sc; MALLOC(sc, struct pflog_softc *, sizeof(*sc), M_PFLOG, M_WAITOK|M_ZERO); if_initname(&sc->sc_if, ifc->ifc_name, unit); sc->sc_if.if_mtu = PFLOGMTU; sc->sc_if.if_ioctl = pflogioctl; sc->sc_if.if_output = pflogoutput; sc->sc_if.if_start = pflogstart; sc->sc_if.if_type = IFT_PFLOG; sc->sc_if.if_snd.ifq_maxlen = ifqmaxlen; sc->sc_if.if_hdrlen = PFLOG_HDRLEN; sc->sc_if.if_softc = sc; if_attach(&sc->sc_if); LIST_INSERT_HEAD(&pflog_list, sc, sc_next); #if NBPFILTER > 0 bpfattach(&sc->sc_if, DLT_PFLOG, PFLOG_HDRLEN); #endif return (0); } #else /* !__FreeBSD__ */ void pflogattach(int npflog) { struct ifnet *ifp; int i; bzero(pflogif, sizeof(pflogif)); for (i = 0; i < NPFLOG; i++) { ifp = &pflogif[i].sc_if; snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflog%d", i); ifp->if_softc = &pflogif[i]; ifp->if_mtu = PFLOGMTU; ifp->if_ioctl = pflogioctl; ifp->if_output = pflogoutput; ifp->if_start = pflogstart; ifp->if_type = IFT_PFLOG; ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_hdrlen = PFLOG_HDRLEN; if_attach(ifp); if_alloc_sadl(ifp); #if NBPFILTER > 0 bpfattach(&pflogif[i].sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN); #endif } }
static int enc_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct ifnet *ifp; struct enc_softc *sc; sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO); ifp = sc->sc_ifp = if_alloc(IFT_ENC); if (ifp == NULL) { free(sc, M_DEVBUF); return (ENOSPC); } if_initname(ifp, ifc->ifc_name, unit); ifp->if_mtu = ENCMTU; ifp->if_ioctl = enc_ioctl; ifp->if_output = enc_output; ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_softc = sc; if_attach(ifp); bpfattach(ifp, DLT_ENC, sizeof(struct enchdr)); mtx_lock(&enc_mtx); /* grab a pointer to enc0, ignore the rest */ if (encif == NULL) encif = ifp; mtx_unlock(&enc_mtx); return (0); }
/* * Called from boot code to establish ppp interfaces. */ void pppattach() { register struct ppp_softc *sc; register int i = 0; IOLog("\nPPP version 2.3.8-%s for NeXTSTEP and OPENSTEP\n", PPPVERSION); IOLog("by Stephen Perkins, Philip Prindeville, and Pete French\n"); if (install_ppp_ld() < 0) { IOLog("ppp: Could not install line discipline\n"); } for (sc = ppp_softc; i < NUM_PPP; sc++, i++) { sc->sc_if = if_attach(NULL, NULL, pppoutput, pppgetbuf, pppcontrol, "ppp", i, "Serial line PPP", PPP_MTU, IFF_POINTOPOINT, NETIFCLASS_VIRTUAL, (void *) sc); nbq_init(&sc->sc_freeq, &qparms[QFREE]); nbq_init(&sc->sc_rawq, &qparms[QRAW]); nbq_init(&sc->sc_fastq, &qparms[QFAST]); nbq_init(&sc->sc_slowq, &qparms[QSLOW]); nbq_init(&sc->sc_inq, &qparms[QIN]); nbq_init(&sc->sc_npq, &qparms[QNP]); nbq_init(&sc->sc_compq, &qparms[QCACHE]); IOLog(" ppp%d successfully attached.\n", i); } ipforwarding = 1; ipsendredirects = 1; IOLog("PPP Successfully Installed.\n\n"); }
static int gif_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct gif_softc *sc; sc = malloc(sizeof(struct gif_softc), M_GIF, M_WAITOK | M_ZERO); sc->gif_fibnum = curthread->td_proc->p_fibnum; GIF2IFP(sc) = if_alloc(IFT_GIF); GIF_LOCK_INIT(sc); GIF2IFP(sc)->if_softc = sc; if_initname(GIF2IFP(sc), gifname, unit); GIF2IFP(sc)->if_addrlen = 0; GIF2IFP(sc)->if_mtu = GIF_MTU; GIF2IFP(sc)->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; #if 0 /* turn off ingress filter */ GIF2IFP(sc)->if_flags |= IFF_LINK2; #endif GIF2IFP(sc)->if_ioctl = gif_ioctl; GIF2IFP(sc)->if_transmit = gif_transmit; GIF2IFP(sc)->if_qflush = gif_qflush; GIF2IFP(sc)->if_output = gif_output; if_attach(GIF2IFP(sc)); bpfattach(GIF2IFP(sc), DLT_NULL, sizeof(u_int32_t)); if (ng_gif_attach_p != NULL) (*ng_gif_attach_p)(GIF2IFP(sc)); GIF_LIST_LOCK(); LIST_INSERT_HEAD(&V_gif_softc_list, sc, gif_list); GIF_LIST_UNLOCK(); return (0); }
static int gre_clone_create(struct if_clone *ifc, int unit, caddr_t param __unused) { struct gre_softc *sc; sc = kmalloc(sizeof(struct gre_softc), M_GRE, M_WAITOK); memset(sc, 0, sizeof(struct gre_softc)); sc->sc_if.if_softc = sc; if_initname(&(sc->sc_if), GRENAME, unit); ifq_set_maxlen(&sc->sc_if.if_snd, IFQ_MAXLEN); sc->sc_if.if_type = IFT_OTHER; sc->sc_if.if_addrlen = 0; sc->sc_if.if_hdrlen = 24; /* IP + GRE */ sc->sc_if.if_mtu = GREMTU; sc->sc_if.if_flags = IFF_POINTOPOINT|IFF_MULTICAST; sc->sc_if.if_output = gre_output; sc->sc_if.if_ioctl = gre_ioctl; sc->g_dst.s_addr = sc->g_src.s_addr = INADDR_ANY; sc->g_proto = IPPROTO_GRE; sc->sc_if.if_flags |= IFF_LINK0; sc->encap = NULL; sc->called = 0; sc->route_pcpu = kmalloc(netisr_ncpus * sizeof(struct route), M_GRE, M_WAITOK | M_ZERO); if_attach(&sc->sc_if, NULL); bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int32_t)); LIST_INSERT_HEAD(&gre_softc_list, sc, sc_list); return (0); }
static int enc_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct ifnet *ifp; struct enc_softc *sc; sc = malloc(sizeof(struct enc_softc), M_DEVBUF, M_WAITOK | M_ZERO); ifp = sc->sc_ifp = if_alloc(IFT_ENC); if (ifp == NULL) { free(sc, M_DEVBUF); return (ENOSPC); } if (V_enc_sc != NULL) { if_free(ifp); free(sc, M_DEVBUF); return (EEXIST); } V_enc_sc = sc; if_initname(ifp, encname, unit); ifp->if_mtu = ENCMTU; ifp->if_ioctl = enc_ioctl; ifp->if_output = enc_output; ifp->if_softc = sc; if_attach(ifp); bpfattach(ifp, DLT_ENC, sizeof(struct enchdr)); return (0); }
static int mpls_clone_create(struct if_clone *ifc, int unit) { struct mpls_softc *sc; atomic_inc_uint(&mpls_count); sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); if_initname(&sc->sc_if, ifc->ifc_name, unit); sc->sc_if.if_softc = sc; sc->sc_if.if_type = IFT_MPLS; sc->sc_if.if_addrlen = 0; sc->sc_if.if_hdrlen = sizeof(union mpls_shim); sc->sc_if.if_dlt = DLT_NULL; sc->sc_if.if_mtu = 1500; sc->sc_if.if_flags = 0; sc->sc_if._if_input = mpls_input; sc->sc_if.if_output = mpls_output; sc->sc_if.if_ioctl = mpls_ioctl; if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); bpf_attach(&sc->sc_if, DLT_NULL, sizeof(uint32_t)); return 0; }
/* * icattach() */ static int icattach(device_t dev) { struct ic_softc *sc = (struct ic_softc *)device_get_softc(dev); struct ifnet *ifp = &sc->ic_if; sc->ic_addr = PCF_MASTER_ADDRESS; /* XXX only PCF masters */ ifp->if_softc = sc; if_initname(ifp, "ic", device_get_unit(dev)); ifp->if_mtu = ICMTU; ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST; ifp->if_ioctl = icioctl; ifp->if_output = icoutput; ifp->if_type = IFT_PARA; ifp->if_hdrlen = 0; ifp->if_addrlen = 0; ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN); if_attach(ifp, NULL); bpfattach(ifp, DLT_NULL, ICHDRLEN); return (0); }
/* * Interface exists: make available by filling in network interface * record. System will initialize the interface when it is ready * to accept packets. A STATUS command is done to get the ethernet * address and other interesting data. */ void ilattach(device_t parent, device_t self, void *aux) { struct uba_attach_args *ua = aux; struct il_softc *sc = device_private(self); struct ifnet *ifp = &sc->sc_if; int error; sc->sc_dev = self; sc->sc_iot = ua->ua_iot; sc->sc_ioh = ua->ua_ioh; sc->sc_dmat = ua->ua_dmat; /* * Map interrupt vectors and reset function. */ uba_intr_establish(ua->ua_icookie, ua->ua_cvec, ilcint, sc, &sc->sc_cintrcnt); evcnt_attach_dynamic(&sc->sc_cintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, device_xname(sc->sc_dev), "intr"); uba_intr_establish(ua->ua_icookie, ua->ua_cvec-4, ilrint, sc, &sc->sc_rintrcnt); evcnt_attach_dynamic(&sc->sc_rintrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt, device_xname(sc->sc_dev), "intr"); uba_reset_establish(ilreset, sc->sc_dev); /* * Reset the board and map the statistics * buffer onto the Unibus. */ IL_WCSR(IL_CSR, ILC_RESET); (void)ilwait(sc, "reset"); sc->sc_ui.ui_size = sizeof(struct il_stats); sc->sc_ui.ui_vaddr = (void *)&sc->sc_stats; if ((error = uballoc(device_private(parent), &sc->sc_ui, 0))) return printf(": failed uballoc, error = %d\n", error); IL_WCSR(IL_BAR, LOWORD(sc->sc_ui.ui_baddr)); IL_WCSR(IL_BCR, sizeof(struct il_stats)); IL_WCSR(IL_CSR, ((sc->sc_ui.ui_baddr >> 2) & IL_EUA)|ILC_STAT); (void)ilwait(sc, "status"); ubfree(device_private(parent), &sc->sc_ui); printf("%s: module=%s firmware=%s\n", device_xname(sc->sc_dev), sc->sc_stats.ils_module, sc->sc_stats.ils_firmware); printf("%s: hardware address %s\n", device_xname(sc->sc_dev), ether_sprintf(sc->sc_stats.ils_addr)); strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST; ifp->if_init = ilinit; ifp->if_stop = ilstop; ifp->if_ioctl = ether_ioctl; ifp->if_start = ilstart; ifp->if_watchdog = ilwatch; IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); ether_ifattach(ifp, sc->sc_stats.ils_addr); }
static int gif_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct gif_softc *sc; sc = malloc(sizeof(struct gif_softc), M_GIF, M_WAITOK | M_ZERO); sc->gif_fibnum = curthread->td_proc->p_fibnum; GIF2IFP(sc) = if_alloc(IFT_GIF); GIF2IFP(sc)->if_softc = sc; if_initname(GIF2IFP(sc), gifname, unit); GIF2IFP(sc)->if_addrlen = 0; GIF2IFP(sc)->if_mtu = GIF_MTU; GIF2IFP(sc)->if_flags = IFF_POINTOPOINT | IFF_MULTICAST; GIF2IFP(sc)->if_ioctl = gif_ioctl; GIF2IFP(sc)->if_transmit = gif_transmit; GIF2IFP(sc)->if_qflush = gif_qflush; GIF2IFP(sc)->if_output = gif_output; GIF2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE; GIF2IFP(sc)->if_capenable |= IFCAP_LINKSTATE; if_attach(GIF2IFP(sc)); bpfattach(GIF2IFP(sc), DLT_NULL, sizeof(u_int32_t)); if (ng_gif_attach_p != NULL) (*ng_gif_attach_p)(GIF2IFP(sc)); return (0); }
static void tunattach0(struct tun_softc *tp) { struct ifnet *ifp; ifp = &tp->tun_if; ifp->if_softc = tp; ifp->if_mtu = TUNMTU; ifp->if_ioctl = tun_ioctl; ifp->if_output = tun_output; #ifdef ALTQ ifp->if_start = tunstart; #endif ifp->if_flags = IFF_POINTOPOINT; ifp->if_type = IFT_TUNNEL; ifp->if_snd.ifq_maxlen = ifqmaxlen; ifp->if_collisions = 0; ifp->if_ierrors = 0; ifp->if_oerrors = 0; ifp->if_ipackets = 0; ifp->if_opackets = 0; ifp->if_ibytes = 0; ifp->if_obytes = 0; ifp->if_dlt = DLT_NULL; IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); if_alloc_sadl(ifp); bpf_attach(ifp, DLT_NULL, sizeof(uint32_t)); }