FreeBSD kernel netgraph code
ng_ether.c File Reference
#include <sys/param.h>
#include <sys/eventhandler.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/errno.h>
#include <sys/proc.h>
#include <sys/syslog.h>
#include <sys/socket.h>
#include <sys/taskqueue.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/if_arp.h>
#include <net/if_var.h>
#include <net/ethernet.h>
#include <net/if_bridgevar.h>
#include <net/vnet.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
#include <netgraph/ng_ether.h>
Include dependency graph for ng_ether.c:

Go to the source code of this file.

Data Structures

struct  private
 

Macros

#define IFP2NG(ifp)   ((ifp)->if_l2com)
 

Typedefs

typedef struct privatepriv_p
 

Functions

 MODULE_VERSION (ng_ether, 1)
 
static void ng_ether_input (struct ifnet *ifp, struct mbuf **mp)
 
static void ng_ether_input_orphan (struct ifnet *ifp, struct mbuf *m)
 
static int ng_ether_output (struct ifnet *ifp, struct mbuf **mp)
 
static void ng_ether_attach (struct ifnet *ifp)
 
static void ng_ether_detach (struct ifnet *ifp)
 
static void ng_ether_link_state (struct ifnet *ifp, int state)
 
static int ng_ether_rcv_lower (hook_p node, item_p item)
 
static int ng_ether_rcv_upper (hook_p node, item_p item)
 
static int ng_ether_mod_event (module_t mod, int event, void *data)
 
 NETGRAPH_INIT (ether, &ng_ether_typestruct)
 
static void ng_ether_sanitize_ifname (const char *ifname, char *name)
 
static void ng_ether_ifnet_arrival_event (void *arg __unused, struct ifnet *ifp)
 
static int ng_ether_constructor (node_p node)
 
static int ng_ether_newhook (node_p node, hook_p hook, const char *name)
 
static int ng_ether_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static int ng_ether_rcvdata (hook_p hook, item_p item)
 
static int ng_ether_shutdown (node_p node)
 
static int ng_ether_disconnect (hook_p hook)
 
static void vnet_ng_ether_init (const void *unused)
 
 VNET_SYSINIT (vnet_ng_ether_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_ng_ether_init, NULL)
 

Variables

void(* ng_ether_input_p )(struct ifnet *ifp, struct mbuf **mp)
 
void(* ng_ether_input_orphan_p )(struct ifnet *ifp, struct mbuf *m)
 
int(* ng_ether_output_p )(struct ifnet *ifp, struct mbuf **mp)
 
void(* ng_ether_attach_p )(struct ifnet *ifp)
 
void(* ng_ether_detach_p )(struct ifnet *ifp)
 
void(* ng_ether_link_state_p )(struct ifnet *ifp, int state)
 
static ng_constructor_t ng_ether_constructor
 
static ng_rcvmsg_t ng_ether_rcvmsg
 
static ng_shutdown_t ng_ether_shutdown
 
static ng_newhook_t ng_ether_newhook
 
static ng_rcvdata_t ng_ether_rcvdata
 
static ng_disconnect_t ng_ether_disconnect
 
static eventhandler_tag ng_ether_ifnet_arrival_cookie
 
static const struct ng_cmdlist ng_ether_cmdlist []
 
static struct ng_type ng_ether_typestruct
 

Macro Definition Documentation

◆ IFP2NG

#define IFP2NG (   ifp)    ((ifp)->if_l2com)

Definition at line 77 of file ng_ether.c.

Typedef Documentation

◆ priv_p

typedef struct private* priv_p

Definition at line 90 of file ng_ether.c.

Function Documentation

◆ MODULE_VERSION()

MODULE_VERSION ( ng_ether  ,
 
)

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( ether  ,
ng_ether_typestruct 
)

◆ ng_ether_attach()

static void ng_ether_attach ( struct ifnet *  ifp)
static

Definition at line 304 of file ng_ether.c.

References IFP2NG, name, ng_ether_sanitize_ifname(), ng_ether_typestruct, ng_make_node_common(), ng_name2noderef(), ng_name_node(), NG_NODE_SET_PRIVATE, and NG_NODE_UNREF.

Referenced by ng_ether_mod_event(), and vnet_ng_ether_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ng_ether_constructor()

static int ng_ether_constructor ( node_p  node)
static

Definition at line 445 of file ng_ether.c.

◆ ng_ether_detach()

static void ng_ether_detach ( struct ifnet *  ifp)
static

Definition at line 354 of file ng_ether.c.

References IFP2NG, NG_NODE_PRIVATE, NG_NODE_REALLY_DIE, and ng_rmnode_self().

Referenced by ng_ether_mod_event(), and ng_ether_rcvmsg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ng_ether_disconnect()

static int ng_ether_disconnect ( hook_p  hook)
static

Definition at line 780 of file ng_ether.c.

References priv::lower, NG_HOOK_NODE, NG_NODE_IS_VALID, NG_NODE_NUMHOOKS, NG_NODE_PRIVATE, ng_rmnode_self(), and priv::upper.

Here is the call graph for this function:

◆ ng_ether_ifnet_arrival_event()

static void ng_ether_ifnet_arrival_event ( void *arg  __unused,
struct ifnet *  ifp 
)
static

Definition at line 411 of file ng_ether.c.

References IFP2NG, name, ng_ether_sanitize_ifname(), and ng_name_node().

Referenced by ng_ether_mod_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ng_ether_input()

static void ng_ether_input ( struct ifnet *  ifp,
struct mbuf **  mp 
)
static

Definition at line 246 of file ng_ether.c.

References IFP2NG, priv::lower, NG_NODE_PRIVATE, and NG_SEND_DATA_ONLY.

Referenced by ng_ether_mod_event().

Here is the caller graph for this function:

◆ ng_ether_input_orphan()

static void ng_ether_input_orphan ( struct ifnet *  ifp,
struct mbuf *  m 
)
static

Definition at line 263 of file ng_ether.c.

References IFP2NG, NG_NODE_PRIVATE, and NG_SEND_DATA_ONLY.

Referenced by ng_ether_mod_event().

Here is the caller graph for this function:

◆ ng_ether_link_state()

static void ng_ether_link_state ( struct ifnet *  ifp,
int  state 
)
static

Definition at line 376 of file ng_ether.c.

References IFP2NG, priv::lower, NG_MKMESSAGE, NG_NODE_PRIVATE, NG_SEND_MSG_HOOK, NGM_FLOW_COOKIE, NGM_LINK_IS_DOWN, and NGM_LINK_IS_UP.

Referenced by ng_ether_mod_event().

Here is the caller graph for this function:

◆ ng_ether_mod_event()

static int ng_ether_mod_event ( module_t  mod,
int  event,
void *  data 
)
static

◆ ng_ether_newhook()

static int ng_ether_newhook ( node_p  node,
hook_p  hook,
const char *  name 
)
static

◆ ng_ether_output()

static int ng_ether_output ( struct ifnet *  ifp,
struct mbuf **  mp 
)
static

Definition at line 282 of file ng_ether.c.

References IFP2NG, NG_NODE_PRIVATE, NG_OUTBOUND_THREAD_REF, NG_OUTBOUND_THREAD_UNREF, NG_SEND_DATA_ONLY, and priv::upper.

Referenced by ng_ether_mod_event().

Here is the caller graph for this function:

◆ ng_ether_rcv_lower()

static int ng_ether_rcv_lower ( hook_p  node,
item_p  item 
)
static

Definition at line 665 of file ng_ether.c.

References NG_FREE_ITEM, NG_FREE_M, NG_HOOK_NODE, NG_NODE_PRIVATE, and NGI_GET_M.

Referenced by ng_ether_newhook().

Here is the caller graph for this function:

◆ ng_ether_rcv_upper()

static int ng_ether_rcv_upper ( hook_p  node,
item_p  item 
)
static

Definition at line 713 of file ng_ether.c.

References NG_FREE_ITEM, NG_FREE_M, NG_HOOK_NODE, NG_NODE_PRIVATE, and NGI_GET_M.

Referenced by ng_ether_newhook().

Here is the caller graph for this function:

◆ ng_ether_rcvdata()

static int ng_ether_rcvdata ( hook_p  hook,
item_p  item 
)
static

Definition at line 654 of file ng_ether.c.

References NG_FREE_ITEM.

◆ ng_ether_rcvmsg()

◆ ng_ether_sanitize_ifname()

static void ng_ether_sanitize_ifname ( const char *  ifname,
char *  name 
)
static

Definition at line 223 of file ng_ether.c.

References name.

Referenced by ng_ether_attach(), and ng_ether_ifnet_arrival_event().

Here is the caller graph for this function:

◆ ng_ether_shutdown()

static int ng_ether_shutdown ( node_p  node)
static

◆ vnet_ng_ether_init()

static void vnet_ng_ether_init ( const void *  unused)
static

Definition at line 862 of file ng_ether.c.

References ng_ether_attach(), and ng_ether_attach_p.

Here is the call graph for this function:

◆ VNET_SYSINIT()

VNET_SYSINIT ( vnet_ng_ether_init  ,
SI_SUB_PSEUDO  ,
SI_ORDER_ANY  ,
vnet_ng_ether_init  ,
NULL   
)

Variable Documentation

◆ ng_ether_attach_p

void(* ng_ether_attach_p) (struct ifnet *ifp) ( struct ifnet *  ifp)
extern

◆ ng_ether_cmdlist

const struct ng_cmdlist ng_ether_cmdlist[]
static

Definition at line 124 of file ng_ether.c.

◆ ng_ether_constructor

ng_constructor_t ng_ether_constructor
static

Definition at line 113 of file ng_ether.c.

◆ ng_ether_detach_p

void(* ng_ether_detach_p) (struct ifnet *ifp) ( struct ifnet *  ifp)
extern

Referenced by ng_ether_mod_event().

◆ ng_ether_disconnect

ng_disconnect_t ng_ether_disconnect
static

Definition at line 118 of file ng_ether.c.

◆ ng_ether_ifnet_arrival_cookie

eventhandler_tag ng_ether_ifnet_arrival_cookie
static

Definition at line 121 of file ng_ether.c.

Referenced by ng_ether_mod_event().

◆ ng_ether_input_orphan_p

void(* ng_ether_input_orphan_p) (struct ifnet *ifp, struct mbuf *m) ( struct ifnet *  ifp,
struct mbuf *  m 
)
extern

Referenced by ng_ether_mod_event().

◆ ng_ether_input_p

void(* ng_ether_input_p) (struct ifnet *ifp, struct mbuf **mp) ( struct ifnet *  ifp,
struct mbuf **  mp 
)
extern

Referenced by ng_ether_mod_event().

◆ ng_ether_link_state_p

void(* ng_ether_link_state_p) (struct ifnet *ifp, int state) ( struct ifnet *  ifp,
int  state 
)
extern

Referenced by ng_ether_mod_event().

◆ ng_ether_newhook

ng_newhook_t ng_ether_newhook
static

Definition at line 116 of file ng_ether.c.

◆ ng_ether_output_p

int(* ng_ether_output_p) (struct ifnet *ifp, struct mbuf **mp) ( struct ifnet *  ifp,
struct mbuf **  mp 
)
extern

Referenced by ng_ether_mod_event().

◆ ng_ether_rcvdata

ng_rcvdata_t ng_ether_rcvdata
static

Definition at line 117 of file ng_ether.c.

◆ ng_ether_rcvmsg

ng_rcvmsg_t ng_ether_rcvmsg
static

Definition at line 114 of file ng_ether.c.

◆ ng_ether_shutdown

ng_shutdown_t ng_ether_shutdown
static

Definition at line 115 of file ng_ether.c.

◆ ng_ether_typestruct

struct ng_type ng_ether_typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.mod_event = ng_ether_mod_event,
.constructor = ng_ether_constructor,
.rcvmsg = ng_ether_rcvmsg,
.shutdown = ng_ether_shutdown,
.newhook = ng_ether_newhook,
.rcvdata = ng_ether_rcvdata,
.disconnect = ng_ether_disconnect,
.cmdlist = ng_ether_cmdlist,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_rcvmsg_t ng_ether_rcvmsg
Definition: ng_ether.c:114
static int ng_ether_mod_event(module_t mod, int event, void *data)
Definition: ng_ether.c:808
static ng_newhook_t ng_ether_newhook
Definition: ng_ether.c:116
static const struct ng_cmdlist ng_ether_cmdlist[]
Definition: ng_ether.c:124
static ng_constructor_t ng_ether_constructor
Definition: ng_ether.c:113
static ng_shutdown_t ng_ether_shutdown
Definition: ng_ether.c:115
static ng_rcvdata_t ng_ether_rcvdata
Definition: ng_ether.c:117
static ng_disconnect_t ng_ether_disconnect
Definition: ng_ether.c:118
#define NG_ETHER_NODE_TYPE
Definition: ng_ether.h:49

Definition at line 205 of file ng_ether.c.

Referenced by ng_ether_attach().