Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netgraph/ng_eiface.c
Show First 20 Lines • Show All 379 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Constructor for a node | * Constructor for a node | ||||
*/ | */ | ||||
static int | static int | ||||
ng_eiface_constructor(node_p node) | ng_eiface_constructor(node_p node) | ||||
{ | { | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
priv_p priv; | priv_p priv; | ||||
u_char eaddr[6] = {0,0,0,0,0,0}; | struct ether_addr eaddr; | ||||
/* Allocate node and interface private structures */ | /* Allocate node and interface private structures */ | ||||
priv = malloc(sizeof(*priv), M_NETGRAPH, M_WAITOK | M_ZERO); | priv = malloc(sizeof(*priv), M_NETGRAPH, M_WAITOK | M_ZERO); | ||||
ifp = priv->ifp = if_alloc(IFT_ETHER); | ifp = priv->ifp = if_alloc(IFT_ETHER); | ||||
if (ifp == NULL) { | if (ifp == NULL) { | ||||
free(priv, M_NETGRAPH); | free(priv, M_NETGRAPH); | ||||
return (ENOSPC); | return (ENOSPC); | ||||
Show All 33 Lines | ng_eiface_constructor(node_p node) | ||||
priv->link_status = IFM_AVALID; | priv->link_status = IFM_AVALID; | ||||
/* Give this node the same name as the interface (if possible) */ | /* Give this node the same name as the interface (if possible) */ | ||||
if (ng_name_node(node, ifp->if_xname) != 0) | if (ng_name_node(node, ifp->if_xname) != 0) | ||||
log(LOG_WARNING, "%s: can't acquire netgraph name\n", | log(LOG_WARNING, "%s: can't acquire netgraph name\n", | ||||
ifp->if_xname); | ifp->if_xname); | ||||
/* Attach the interface */ | /* Attach the interface */ | ||||
ether_ifattach(ifp, eaddr); | ether_gen_addr(ifp, &eaddr); | ||||
ether_ifattach(ifp, eaddr.octet); | |||||
ifp->if_baudrate = ifmedia_baudrate(IFM_ETHER | IFM_1000_T); | ifp->if_baudrate = ifmedia_baudrate(IFM_ETHER | IFM_1000_T); | ||||
/* Done */ | /* Done */ | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Give our ok for a hook to be added | * Give our ok for a hook to be added | ||||
▲ Show 20 Lines • Show All 241 Lines • Show Last 20 Lines |