36#include <sys/kernel.h>
39#include <sys/malloc.h>
42#include <sys/rwlock.h>
43#include <sys/socket.h>
44#include <sys/syslog.h>
47#include <net/if_var.h>
49#include <netinet/in.h>
50#include <netinet/in_systm.h>
51#include <netinet/in_var.h>
52#include <netinet/ip_var.h>
53#include <netinet/ip_fw.h>
54#include <netinet/ip.h>
55#include <netinet/ip6.h>
56#include <netinet6/ip6_var.h>
58#include <netpfil/ipfw/ip_fw_private.h>
75static int ng_ipfw_input(
struct mbuf **,
struct ip_fw_args *,
bool);
111 if (ng_ipfw_input_p != NULL) {
119 log(LOG_ERR,
"%s: can't create ng_ipfw node", __func__);
125 log(LOG_WARNING,
"%s: failed to name node \"ipfw\"",
162 if (
name[0] ==
'0' &&
name[1] !=
'\0')
166 for (cp =
name; *cp !=
'\0'; cp++)
176 hpriv = malloc(
sizeof(*hpriv), M_NETGRAPH, M_NOWAIT | M_ZERO);
206 n = (u_int16_t)strtol(
name, &endptr, 10);
219 LIST_FOREACH(
hook, &node->nd_hooks, hk_hooks) {
232 struct ipfw_rule_ref *
r;
239 tag = m_tag_locate(m, MTAG_IPFW_RULE, 0, NULL);
245 if (m->m_len <
sizeof(
struct ip) &&
246 (m = m_pullup(m,
sizeof(
struct ip))) == NULL)
249 ip = mtod(m,
struct ip *);
251 r = (
struct ipfw_rule_ref *)(tag + 1);
252 if (
r->info & IPFW_INFO_IN) {
260 case IPV6_VERSION >> 4:
269 return (ip_output(m, NULL, NULL, IP_FORWARDING,
273 case IPV6_VERSION >> 4:
274 return (ip6_output(m, NULL, NULL, 0, NULL,
282 return (EPROTONOSUPPORT);
306 struct ipfw_rule_ref *
r;
310 tag = m_tag_alloc(MTAG_IPFW_RULE, 0,
sizeof(*
r),
316 r = (
struct ipfw_rule_ref *)(tag + 1);
318 r->info &= IPFW_ONEPASS;
319 r->info |= (fwa->flags & IPFW_ARGS_IN) ?
320 IPFW_INFO_IN : IPFW_INFO_OUT;
321 m_tag_prepend(m, tag);
324 if ((m = m_dup(*m0, M_NOWAIT)) == NULL)
327 if (m->m_len <
sizeof(
struct ip) &&
328 (m = m_pullup(m,
sizeof(
struct ip))) == NULL)
345 ng_ipfw_input_p = NULL;
355 free(hpriv, M_NETGRAPH);
struct netflow_v5_record r[NETFLOW_V5_MAX_RECORDS]
int ng_connect_t(hook_p hook)
hook_p ng_findhook_t(node_p node, const char *name)
int ng_disconnect_t(hook_p hook)
#define NG_NODE_UNREF(node)
#define NG_HOOK_SET_PRIVATE(hook, val)
#define NG_SEND_DATA_ONLY(error, hook, m)
#define NG_HOOK_FORCE_QUEUE(hook)
int ng_rcvdata_t(hook_p hook, item_p item)
int ng_shutdown_t(node_p node)
#define NG_FREE_ITEM(item)
int ng_make_node_common(struct ng_type *typep, node_p *nodep)
int ng_name_node(node_p node, const char *name)
int ng_constructor_t(node_p node)
#define NG_HOOK_IS_VALID(hook)
int ng_newhook_t(node_p node, hook_p hook, const char *name)
#define NG_HOOK_PRIVATE(hook)
NETGRAPH_INIT(ipfw, &ng_ipfw_typestruct)
static ng_connect_t ng_ipfw_connect
static ng_shutdown_t ng_ipfw_shutdown
static ng_newhook_t ng_ipfw_newhook
static struct ng_type ng_ipfw_typestruct
static ng_disconnect_t ng_ipfw_disconnect
static int ng_ipfw_mod_event(module_t mod, int event, void *data)
static ng_rcvdata_t ng_ipfw_rcvdata
static ng_constructor_t ng_ipfw_constructor
static int ng_ipfw_input(struct mbuf **, struct ip_fw_args *, bool)
static hook_p ng_ipfw_findhook1(node_p, u_int16_t)
MODULE_DEPEND(ng_ipfw, ipfw, 3, 3, 3)
struct ng_ipfw_hook_priv * hpriv_p
static ng_findhook_t ng_ipfw_findhook
#define NG_IPFW_NODE_TYPE