Module Name: src
Committed By: rmind
Date: Wed Aug 15 19:47:39 UTC 2012
Modified Files:
src/sys/net/npf: npf_impl.h npf_state.c
src/usr.sbin/npf/npftest: npftest.c npftest.h
src/usr.sbin/npf/npftest/libnpftest: npf_test.h npf_test_subr.c
Log Message:
Add npf_state_setsampler() for _NPF_TESTING case. This also fixes the build.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/net/npf/npf_impl.h
cvs rdiff -u -r1.11 -r1.12 src/sys/net/npf/npf_state.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/npf/npftest/npftest.c \
src/usr.sbin/npf/npftest/npftest.h
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/npf/npftest/libnpftest/npf_test.h
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/npf/npf_impl.h
diff -u src/sys/net/npf/npf_impl.h:1.21 src/sys/net/npf/npf_impl.h:1.22
--- src/sys/net/npf/npf_impl.h:1.21 Sun Aug 12 03:35:14 2012
+++ src/sys/net/npf/npf_impl.h Wed Aug 15 19:47:38 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_impl.h,v 1.21 2012/08/12 03:35:14 rmind Exp $ */
+/* $NetBSD: npf_impl.h,v 1.22 2012/08/15 19:47:38 rmind Exp $ */
/*-
* Copyright (c) 2009-2012 The NetBSD Foundation, Inc.
@@ -122,13 +122,6 @@ typedef struct {
npf_tcpstate_t nst_tcpst[2];
} npf_state_t;
-#if defined(_NPF_TESTING)
-void npf_state_sample(npf_state_t *, bool);
-#define NPF_STATE_SAMPLE(n, r) npf_state_sample(n, r)
-#else
-#define NPF_STATE_SAMPLE(n, r)
-#endif
-
/*
* INTERFACES.
*/
@@ -332,5 +325,6 @@ void npf_rulenc_dump(const npf_rule_t *
void npf_sessions_dump(void);
void npf_state_dump(const npf_state_t *);
void npf_nat_dump(const npf_nat_t *);
+void npf_state_setsampler(void (*)(npf_state_t *, bool));
#endif /* _NPF_IMPL_H_ */
Index: src/sys/net/npf/npf_state.c
diff -u src/sys/net/npf/npf_state.c:1.11 src/sys/net/npf/npf_state.c:1.12
--- src/sys/net/npf/npf_state.c:1.11 Sun Aug 12 03:35:14 2012
+++ src/sys/net/npf/npf_state.c Wed Aug 15 19:47:38 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_state.c,v 1.11 2012/08/12 03:35:14 rmind Exp $ */
+/* $NetBSD: npf_state.c,v 1.12 2012/08/15 19:47:38 rmind Exp $ */
/*-
* Copyright (c) 2010-2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_state.c,v 1.11 2012/08/12 03:35:14 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_state.c,v 1.12 2012/08/15 19:47:38 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -75,6 +75,16 @@ static u_int npf_generic_timeout[] __rea
};
/*
+ * State sampler for debugging.
+ */
+#if defined(_NPF_TESTING)
+static void (*npf_state_sample)(npf_state_t *, bool) = NULL;
+#define NPF_STATE_SAMPLE(n, r) if (npf_state_sample) (*npf_state_sample)(n, r);
+#else
+#define NPF_STATE_SAMPLE(n, r)
+#endif
+
+/*
* npf_state_init: initialise the state structure.
*
* Should normally be called on a first packet, which also determines the
@@ -195,3 +205,11 @@ npf_state_dump(const npf_state_t *nst)
);
#endif
}
+
+#if defined(_NPF_TESTING)
+void
+npf_state_setsampler(void (*func)(npf_state_t *, bool))
+{
+ npf_state_sample = func;
+}
+#endif
Index: src/usr.sbin/npf/npftest/npftest.c
diff -u src/usr.sbin/npf/npftest/npftest.c:1.4 src/usr.sbin/npf/npftest/npftest.c:1.5
--- src/usr.sbin/npf/npftest/npftest.c:1.4 Sun Aug 12 03:35:14 2012
+++ src/usr.sbin/npf/npftest/npftest.c Wed Aug 15 19:47:38 2012
@@ -178,6 +178,8 @@ main(int argc, char **argv)
rump_init();
rump_schedule();
+ rumpns_npf_test_init();
+
if (config) {
load_npf_config(config);
}
Index: src/usr.sbin/npf/npftest/npftest.h
diff -u src/usr.sbin/npf/npftest/npftest.h:1.4 src/usr.sbin/npf/npftest/npftest.h:1.5
--- src/usr.sbin/npf/npftest/npftest.h:1.4 Sun Aug 12 03:35:14 2012
+++ src/usr.sbin/npf/npftest/npftest.h Wed Aug 15 19:47:38 2012
@@ -10,6 +10,7 @@
#include <stdint.h>
#include <stdbool.h>
+void rumpns_npf_test_init(void);
int rumpns_npf_test_load(const void *);
unsigned rumpns_npf_test_addif(const char *, unsigned, bool);
unsigned rumpns_npf_test_getif(const char *);
Index: src/usr.sbin/npf/npftest/libnpftest/npf_test.h
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_test.h:1.5 src/usr.sbin/npf/npftest/libnpftest/npf_test.h:1.6
--- src/usr.sbin/npf/npftest/libnpftest/npf_test.h:1.5 Sun Aug 12 03:35:14 2012
+++ src/usr.sbin/npf/npftest/libnpftest/npf_test.h Wed Aug 15 19:47:38 2012
@@ -24,6 +24,7 @@
#include <net/if_ether.h>
#include <net/ethertypes.h>
+void npf_test_init(void);
int npf_test_load(const void *);
unsigned npf_test_addif(const char *, unsigned, bool);
unsigned npf_test_getif(const char *);
Index: src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c
diff -u src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c:1.3 src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c:1.4
--- src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c:1.3 Sun Aug 12 03:35:14 2012
+++ src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c Wed Aug 15 19:47:38 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_test_subr.c,v 1.3 2012/08/12 03:35:14 rmind Exp $ */
+/* $NetBSD: npf_test_subr.c,v 1.4 2012/08/15 19:47:38 rmind Exp $ */
/*
* NPF initialisation and handler routines.
@@ -18,6 +18,14 @@ static npf_state_t cstream_state;
static void * cstream_ptr;
static bool cstream_retval;
+static void npf_state_sample(npf_state_t *, bool);
+
+void
+npf_test_init(void)
+{
+ npf_state_setsampler(npf_state_sample);
+}
+
int
npf_test_load(const void *xml)
{
@@ -54,7 +62,7 @@ npf_test_getif(const char *ifname)
/*
* State sampler - this routine is called from inside of NPF state engine.
*/
-void
+static void
npf_state_sample(npf_state_t *nst, bool retval)
{
/* Pointer will serve as an ID. */