Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add npf_state_setsampler() for _NPF_TESTING case. This also...



details:   https://anonhg.NetBSD.org/src/rev/ce2e0a768306
branches:  trunk
changeset: 781030:ce2e0a768306
user:      rmind <rmind%NetBSD.org@localhost>
date:      Wed Aug 15 19:47:38 2012 +0000

description:
Add npf_state_setsampler() for _NPF_TESTING case.  This also fixes the build.

diffstat:

 sys/net/npf/npf_impl.h                          |  10 ++--------
 sys/net/npf/npf_state.c                         |  22 ++++++++++++++++++++--
 usr.sbin/npf/npftest/libnpftest/npf_test.h      |   1 +
 usr.sbin/npf/npftest/libnpftest/npf_test_subr.c |  12 ++++++++++--
 usr.sbin/npf/npftest/npftest.c                  |   4 +++-
 usr.sbin/npf/npftest/npftest.h                  |   1 +
 6 files changed, 37 insertions(+), 13 deletions(-)

diffs (150 lines):

diff -r 5e1590d8c1e6 -r ce2e0a768306 sys/net/npf/npf_impl.h
--- a/sys/net/npf/npf_impl.h    Wed Aug 15 19:13:58 2012 +0000
+++ b/sys/net/npf/npf_impl.h    Wed Aug 15 19:47:38 2012 +0000
@@ -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 @@
        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_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_ */
diff -r 5e1590d8c1e6 -r ce2e0a768306 sys/net/npf/npf_state.c
--- a/sys/net/npf/npf_state.c   Wed Aug 15 19:13:58 2012 +0000
+++ b/sys/net/npf/npf_state.c   Wed Aug 15 19:47:38 2012 +0000
@@ -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 @@
 };
 
 /*
+ * 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 @@
        );
 #endif
 }
+
+#if defined(_NPF_TESTING)
+void
+npf_state_setsampler(void (*func)(npf_state_t *, bool))
+{
+       npf_state_sample = func;
+}
+#endif
diff -r 5e1590d8c1e6 -r ce2e0a768306 usr.sbin/npf/npftest/libnpftest/npf_test.h
--- a/usr.sbin/npf/npftest/libnpftest/npf_test.h        Wed Aug 15 19:13:58 2012 +0000
+++ b/usr.sbin/npf/npftest/libnpftest/npf_test.h        Wed Aug 15 19:47:38 2012 +0000
@@ -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 *);
diff -r 5e1590d8c1e6 -r ce2e0a768306 usr.sbin/npf/npftest/libnpftest/npf_test_subr.c
--- a/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c   Wed Aug 15 19:13:58 2012 +0000
+++ b/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c   Wed Aug 15 19:47:38 2012 +0000
@@ -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 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 @@
 /*
  * 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. */
diff -r 5e1590d8c1e6 -r ce2e0a768306 usr.sbin/npf/npftest/npftest.c
--- a/usr.sbin/npf/npftest/npftest.c    Wed Aug 15 19:13:58 2012 +0000
+++ b/usr.sbin/npf/npftest/npftest.c    Wed Aug 15 19:47:38 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npftest.c,v 1.4 2012/08/12 03:35:14 rmind Exp $        */
+/*     $NetBSD: npftest.c,v 1.5 2012/08/15 19:47:38 rmind Exp $        */
 
 /*
  * NPF testing framework.
@@ -178,6 +178,8 @@
        rump_init();
        rump_schedule();
 
+       rumpns_npf_test_init();
+
        if (config) {
                load_npf_config(config);
        }
diff -r 5e1590d8c1e6 -r ce2e0a768306 usr.sbin/npf/npftest/npftest.h
--- a/usr.sbin/npf/npftest/npftest.h    Wed Aug 15 19:13:58 2012 +0000
+++ b/usr.sbin/npf/npftest/npftest.h    Wed Aug 15 19:47:38 2012 +0000
@@ -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 *);



Home | Main Index | Thread Index | Old Index