* Perform common duties while attaching to interface list */
| 965 | * Perform common duties while attaching to interface list |
| 966 | */ |
| 967 | void |
| 968 | ether_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 |
no test coverage detected