FreeBSD kernel netgraph code
|
#include <sys/param.h>
#include <sys/ctype.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/socket.h>
#include <net/ethernet.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
#include "ng_macfilter.h"
Go to the source code of this file.
Data Structures | |
struct | macfilter_p |
Macros | |
#define | M_NETGRAPH_MACFILTER M_NETGRAPH |
#define | MACTABLE_BLOCKSIZE 128 /* block size for incrementing table */ |
#define | MACFILTER_DEBUG(fmt, ...) |
#define | MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" |
#define | MAC_S_ARGS(v) (v)[0], (v)[1], (v)[2], (v)[3], (v)[4], (v)[5] |
Typedefs | |
typedef struct ngm_macfilter_mac * | mf_mac_p |
Functions | |
static int | macfilter_get_macs_count (const struct ng_parse_type *type, const u_char *start, const u_char *buf) |
static int | macfilter_get_upper_hook_count (const struct ng_parse_type *type, const u_char *start, const u_char *buf) |
NETGRAPH_INIT (macfilter, &typestruct) | |
static int | macfilter_mactable_resize (macfilter_p mfp) |
static void | macfilter_reset (macfilter_p mfp) |
static void | macfilter_reset_stats (macfilter_p mfp) |
static int | macfilter_mac_count (macfilter_p mfp, int hookid) |
static u_int | macfilter_find_mac (macfilter_p mfp, const u_char *ether, u_int *ri) |
static int | macfilter_mactable_change (macfilter_p mfp, u_char *ether, int hookid) |
static int | macfilter_mactable_remove_by_hookid (macfilter_p mfp, int hookid) |
static int | macfilter_find_hook (macfilter_p mfp, const char *hookname) |
static int | macfilter_direct (macfilter_p mfp, struct ngm_macfilter_direct *md) |
static int | macfilter_direct_hookid (macfilter_p mfp, struct ngm_macfilter_direct_hookid *mdi) |
static int | macfilter_ether_output (hook_p hook, macfilter_p mfp, struct mbuf *m, hook_p *next_hook) |
static int | macfilter_ether_input (hook_p hook, macfilter_p mfp, struct mbuf *m, hook_p *next_hook) |
static int | ng_macfilter_constructor (node_p node) |
static int | ng_macfilter_newhook (node_p node, hook_p hook, const char *hookname) |
static int | ng_macfilter_rcvmsg (node_p node, item_p item, hook_p lasthook) |
static int | ng_macfilter_rcvdata (hook_p hook, item_p item) |
static int | ng_macfilter_disconnect (hook_p hook) |
static int | ng_macfilter_shutdown (node_p node) |
#define M_NETGRAPH_MACFILTER M_NETGRAPH |
Definition at line 73 of file ng_macfilter.c.
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" |
Definition at line 83 of file ng_macfilter.c.
#define MAC_S_ARGS | ( | v | ) | (v)[0], (v)[1], (v)[2], (v)[3], (v)[4], (v)[5] |
Definition at line 84 of file ng_macfilter.c.
#define MACFILTER_DEBUG | ( | fmt, | |
... | |||
) |
Definition at line 81 of file ng_macfilter.c.
#define MACTABLE_BLOCKSIZE 128 /* block size for incrementing table */ |
Definition at line 76 of file ng_macfilter.c.
typedef struct ngm_macfilter_mac* mf_mac_p |
Definition at line 261 of file ng_macfilter.c.
|
static |
Definition at line 494 of file ng_macfilter.c.
References ngm_macfilter_direct::ether, ngm_macfilter_direct::hookname, MAC_FMT, MAC_S_ARGS, MACFILTER_DEBUG, macfilter_find_hook(), and macfilter_mactable_change().
Referenced by ng_macfilter_rcvmsg().
|
static |
Definition at line 507 of file ng_macfilter.c.
References ngm_macfilter_direct_hookid::ether, ngm_macfilter_direct_hookid::hookid, MAC_FMT, MAC_S_ARGS, MACFILTER_DEBUG, macfilter_mactable_change(), macfilter_p::mf_upper, and macfilter_p::mf_upper_cnt.
Referenced by ng_macfilter_rcvmsg().
|
static |
Definition at line 570 of file ng_macfilter.c.
References ngm_macfilter_mac::bytes_in, ngm_macfilter_mac::hookid, MAC_FMT, MAC_S_ARGS, MACFILTER_DEBUG, macfilter_find_mac(), macfilter_p::mf_macs, macfilter_p::mf_upper, macfilter_p::mf_upper_cnt, macfilter_p::mtx, NG_HOOK_NAME, NG_MACFILTER_HOOK_DEFAULT_ID, and ngm_macfilter_mac::packets_in.
Referenced by ng_macfilter_rcvdata().
|
static |
Definition at line 529 of file ng_macfilter.c.
References ngm_macfilter_mac::bytes_out, MAC_FMT, MAC_S_ARGS, MACFILTER_DEBUG, macfilter_find_mac(), macfilter_p::mf_ether_hook, macfilter_p::mf_macs, macfilter_p::mtx, NG_HOOK_NAME, and ngm_macfilter_mac::packets_out.
Referenced by ng_macfilter_rcvdata().
|
static |
Definition at line 477 of file ng_macfilter.c.
References macfilter_p::mf_upper, macfilter_p::mf_upper_cnt, NG_HOOK_NAME, and NG_HOOKSIZ.
Referenced by macfilter_direct().
|
static |
Definition at line 373 of file ng_macfilter.c.
References macfilter_p::mf_mac_used, and macfilter_p::mf_macs.
Referenced by macfilter_ether_input(), macfilter_ether_output(), and macfilter_mactable_change().
|
static |
Definition at line 112 of file ng_macfilter.c.
References ngm_macfilter_macs::macs, ngm_macfilter_macs::n, and OFFSETOF.
|
static |
Definition at line 145 of file ng_macfilter.c.
References ngm_macfilter_hooks::hooks, MACFILTER_DEBUG, ngm_macfilter_hooks::n, and OFFSETOF.
|
static |
Definition at line 351 of file ng_macfilter.c.
References ngm_macfilter_mac::hookid, macfilter_p::mf_mac_used, and macfilter_p::mf_macs.
Referenced by ng_macfilter_rcvmsg().
|
static |
Definition at line 406 of file ng_macfilter.c.
References ngm_macfilter_mac::hookid, MAC_FMT, MAC_S_ARGS, MACFILTER_DEBUG, macfilter_find_mac(), macfilter_mactable_resize(), macfilter_p::mf_mac_allocated, macfilter_p::mf_mac_used, macfilter_p::mf_macs, and NG_MACFILTER_HOOK_DEFAULT_ID.
Referenced by macfilter_direct(), and macfilter_direct_hookid().
|
static |
Definition at line 457 of file ng_macfilter.c.
References ngm_macfilter_mac::hookid, macfilter_mactable_resize(), macfilter_p::mf_mac_used, and macfilter_p::mf_macs.
Referenced by ng_macfilter_disconnect().
|
static |
Definition at line 284 of file ng_macfilter.c.
References MACFILTER_DEBUG, MACTABLE_BLOCKSIZE, macfilter_p::mf_mac_allocated, macfilter_p::mf_mac_used, and macfilter_p::mf_macs.
Referenced by macfilter_mactable_change(), macfilter_mactable_remove_by_hookid(), macfilter_reset(), and ng_macfilter_constructor().
|
static |
Definition at line 321 of file ng_macfilter.c.
References macfilter_mactable_resize(), and macfilter_p::mf_mac_used.
Referenced by ng_macfilter_rcvmsg().
|
static |
Definition at line 334 of file ng_macfilter.c.
References ngm_macfilter_mac::bytes_in, ngm_macfilter_mac::bytes_out, macfilter_p::mf_mac_used, macfilter_p::mf_macs, ngm_macfilter_mac::packets_in, and ngm_macfilter_mac::packets_out.
Referenced by ng_macfilter_rcvmsg().
NETGRAPH_INIT | ( | macfilter | , |
& | typestruct | ||
) |
|
static |
Definition at line 623 of file ng_macfilter.c.
References macfilter_mactable_resize(), macfilter_p::mtx, and NG_NODE_SET_PRIVATE.
|
static |
Definition at line 814 of file ng_macfilter.c.
References MACFILTER_DEBUG, macfilter_mactable_remove_by_hookid(), macfilter_p::mf_ether_hook, macfilter_p::mf_upper, macfilter_p::mf_upper_cnt, macfilter_p::mtx, NG_HOOK_NAME, NG_HOOK_NODE, NG_NODE_IS_VALID, NG_NODE_NUMHOOKS, NG_NODE_PRIVATE, and ng_rmnode_self().
Definition at line 641 of file ng_macfilter.c.
References MACFILTER_DEBUG, macfilter_p::mf_ether_hook, macfilter_p::mf_upper, macfilter_p::mf_upper_cnt, NG_MACFILTER_HOOK_DEFAULT, NG_MACFILTER_HOOK_DEFAULT_ID, NG_MACFILTER_HOOK_ETHER, and NG_NODE_PRIVATE.
Definition at line 788 of file ng_macfilter.c.
References MACFILTER_DEBUG, macfilter_ether_input(), macfilter_ether_output(), macfilter_p::mf_ether_hook, NG_FREE_ITEM, NG_FWD_ITEM_HOOK, NG_HOOK_NAME, NG_HOOK_NODE, NG_NODE_PRIVATE, and NGI_M.
Definition at line 675 of file ng_macfilter.c.
References ng_mesg::ng_msghdr::arglen, ng_mesg::ng_msghdr::cmd, ng_mesg::data, ng_mesg::header, ngm_macfilter_direct_hookid::hookid, ngm_macfilter_hook::hookid, ngm_macfilter_hook::hookname, ngm_macfilter_hooks::hooks, ngm_macfilter_hook::maccnt, MACFILTER_DEBUG, macfilter_direct(), macfilter_direct_hookid(), macfilter_mac_count(), macfilter_reset(), macfilter_reset_stats(), ngm_macfilter_macs::macs, macfilter_p::mf_mac_used, macfilter_p::mf_macs, macfilter_p::mf_upper, macfilter_p::mf_upper_cnt, macfilter_p::mtx, ngm_macfilter_macs::n, ngm_macfilter_hooks::n, NG_FREE_MSG, NG_HOOK_NAME, NG_HOOKSIZ, NG_MKRESPONSE, NG_NODE_PRIVATE, NG_RESPOND_MSG, NGI_GET_MSG, NGM_MACFILTER_CLR_MACS, NGM_MACFILTER_COOKIE, NGM_MACFILTER_DIRECT, NGM_MACFILTER_DIRECT_HOOKID, NGM_MACFILTER_GET_HOOKS, NGM_MACFILTER_GET_MACS, NGM_MACFILTER_GETCLR_MACS, NGM_MACFILTER_RESET, and ng_mesg::ng_msghdr::typecookie.
|
static |
Definition at line 866 of file ng_macfilter.c.
References macfilter_p::mf_macs, macfilter_p::mf_upper, macfilter_p::mtx, NG_NODE_PRIVATE, and NG_NODE_UNREF.
|
static |
Definition at line 90 of file ng_macfilter.c.
|
static |
Definition at line 101 of file ng_macfilter.c.
|
static |
Definition at line 180 of file ng_macfilter.c.
|
static |
Definition at line 236 of file ng_macfilter.c.
|
static |
Definition at line 103 of file ng_macfilter.c.
|
static |
Definition at line 92 of file ng_macfilter.c.
|
static |
Definition at line 241 of file ng_macfilter.c.
|
static |
Definition at line 156 of file ng_macfilter.c.
|
static |
Definition at line 158 of file ng_macfilter.c.
|
static |
Definition at line 162 of file ng_macfilter.c.
|
static |
Definition at line 166 of file ng_macfilter.c.
|
static |
Definition at line 170 of file ng_macfilter.c.
|
static |
Definition at line 172 of file ng_macfilter.c.
|
static |
Definition at line 120 of file ng_macfilter.c.
|
static |
Definition at line 122 of file ng_macfilter.c.
|
static |
Definition at line 126 of file ng_macfilter.c.
|
static |
Definition at line 130 of file ng_macfilter.c.
|
static |
Definition at line 134 of file ng_macfilter.c.
|
static |
Definition at line 136 of file ng_macfilter.c.
|
static |
Definition at line 239 of file ng_macfilter.c.
|
static |
Definition at line 240 of file ng_macfilter.c.
|
static |
Definition at line 237 of file ng_macfilter.c.
|
static |
Definition at line 238 of file ng_macfilter.c.
|
static |
Definition at line 243 of file ng_macfilter.c.