MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ether_ifattach

Function ether_ifattach

freebsd/net/if_ethersubr.c:967–1016  ·  view source on GitHub ↗

* Perform common duties while attaching to interface list */

Source from the content-addressed store, hash-verified

965 * Perform common duties while attaching to interface list
966 */
967void
968ether_ifattach(struct ifnet *ifp, const u_int8_t *lla)
969{
970 int i;
971 struct ifaddr *ifa;
972 struct sockaddr_dl *sdl;
973
974 ifp->if_addrlen = ETHER_ADDR_LEN;
975 ifp->if_hdrlen = ETHER_HDR_LEN;
976 ifp->if_mtu = ETHERMTU;
977 if_attach(ifp);
978 ifp->if_output = ether_output;
979 ifp->if_input = ether_input;
980 ifp->if_resolvemulti = ether_resolvemulti;
981 ifp->if_requestencap = ether_requestencap;
982#ifdef VIMAGE
983 ifp->if_reassign = ether_reassign;
984#endif
985 if (ifp->if_baudrate == 0)
986 ifp->if_baudrate = IF_Mbps(10); /* just a default */
987 ifp->if_broadcastaddr = etherbroadcastaddr;
988
989 ifa = ifp->if_addr;
990 KASSERT(ifa != NULL, ("%s: no lladdr!\n", __func__));
991 sdl = (struct sockaddr_dl *)ifa->ifa_addr;
992 sdl->sdl_type = IFT_ETHER;
993 sdl->sdl_alen = ifp->if_addrlen;
994 bcopy(lla, LLADDR(sdl), ifp->if_addrlen);
995
996 if (ifp->if_hw_addr != NULL)
997 bcopy(lla, ifp->if_hw_addr, ifp->if_addrlen);
998
999 bpfattach(ifp, DLT_EN10MB, ETHER_HDR_LEN);
1000 if (ng_ether_attach_p != NULL)
1001 (*ng_ether_attach_p)(ifp);
1002
1003 /* Announce Ethernet MAC address if non-zero. */
1004 for (i = 0; i < ifp->if_addrlen; i++)
1005 if (lla[i] != 0)
1006 break;
1007 if (i != ifp->if_addrlen)
1008 if_printf(ifp, "Ethernet address: %6D\n", lla, ":");
1009
1010 uuid_ether_add(LLADDR(sdl));
1011
1012 /* Add necessary bits are setup; announce it now. */
1013 EVENTHANDLER_INVOKE(ether_ifattach_event, ifp);
1014 if (IS_DEFAULT_VNET(curvnet))
1015 devctl_notify("ETHERNET", ifp->if_xname, "IFATTACH", NULL);
1016}
1017#pragma GCC diagnostic error "-Wformat"
1018#pragma GCC diagnostic error "-Wformat-extra-args"
1019

Callers 15

ieee80211_vap_attachFunction · 0.85
arge_attachFunction · 0.85
are_attachFunction · 0.85
octm_attachFunction · 0.85
octe_attachFunction · 0.85
nlm_xlpge_ifinitFunction · 0.85
gen_attachFunction · 0.85
cpswp_attachFunction · 0.85
emac_attachFunction · 0.85
awg_attachFunction · 0.85
iflib_device_registerFunction · 0.85
iflib_pseudo_registerFunction · 0.85

Calls 5

if_attachFunction · 0.85
bpfattachFunction · 0.85
if_printfFunction · 0.85
uuid_ether_addFunction · 0.85
devctl_notifyFunction · 0.50

Tested by

no test coverage detected