diff -r e4a5b7478f81 sys/modules/khelp/Makefile --- a/sys/modules/khelp/Makefile Sun Dec 12 01:00:56 2010 +1100 +++ b/sys/modules/khelp/Makefile Sun Dec 12 01:01:08 2010 +1100 @@ -1,5 +1,7 @@ # $FreeBSD$ -SUBDIR= h_ertt +SUBDIR= h_ertt \ + h_test1 \ + h_test2 .include diff -r e4a5b7478f81 sys/modules/khelp/h_test1/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/modules/khelp/h_test1/Makefile Sun Dec 12 01:01:08 2010 +1100 @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.include + +.PATH: ${.CURDIR}/../../../netinet +KMOD= h_test1 +SRCS= h_test1.c + +.include diff -r e4a5b7478f81 sys/modules/khelp/h_test2/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/modules/khelp/h_test2/Makefile Sun Dec 12 01:01:08 2010 +1100 @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.include + +.PATH: ${.CURDIR}/../../../netinet +KMOD= h_test2 +SRCS= h_test2.c + +.include diff -r e4a5b7478f81 sys/netinet/h_test1.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/netinet/h_test1.c Sun Dec 12 01:01:08 2010 +1100 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed at the Centre for Advanced Internet + * Architectures, Swinburne University of Technology, Melbourne, Australia by + * Lawrence Stewart under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +static void test1_hook(int hhook_type, int hhook_id, void *udata, + void *ctx_data, void *hdata, struct osd *hosd); + +struct test1 { + uint32_t est_in_count; + uint32_t est_out_count; +}; + +struct hook test1_hooks[] = { + { HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN, NULL, &test1_hook }, + { HHOOK_TYPE_TCP, HHOOK_TCP_EST_OUT, NULL, &test1_hook }, +}; + +struct helper test1_helper = { + .h_flags = HELPER_NEEDS_OSD, + .h_classes = HELPER_CLASS_TCP, + .h_hooks = test1_hooks, + .h_nhooks = sizeof(test1_hooks) / sizeof(struct hook), +}; + +static void +test1_hook(int hhook_type, int hhook_id, void *udata, + void *ctx_data, void *hdata, struct osd *hosd) +{ + struct test1 *data; + + data = hdata; + + if (hhook_id == HHOOK_TCP_EST_IN) + data->est_in_count++; + else if (hhook_id == HHOOK_TCP_EST_OUT) + data->est_out_count++; +} + + +DECLARE_HELPER_UMA(test1, &test1_helper, 1, sizeof(struct test1), NULL, NULL); diff -r e4a5b7478f81 sys/netinet/h_test2.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/netinet/h_test2.c Sun Dec 12 01:01:08 2010 +1100 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed at the Centre for Advanced Internet + * Architectures, Swinburne University of Technology, Melbourne, Australia by + * Lawrence Stewart under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +static void test2_hook(int hhook_type, int hhook_id, void *udata, + void *ctx_data, void *hdata, struct osd *hosd); + +struct test2 { + uint32_t est_in_count; + uint32_t est_out_count; +}; + +struct hook test2_hooks[] = { + { HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN, NULL, &test2_hook }, + { HHOOK_TYPE_TCP, HHOOK_TCP_EST_OUT, NULL, &test2_hook }, +}; + +struct helper test2_helper = { + .h_flags = HELPER_NEEDS_OSD, + .h_classes = HELPER_CLASS_TCP, + .h_hooks = test2_hooks, + .h_nhooks = sizeof(test2_hooks) / sizeof(struct hook), +}; + +static void +test2_hook(int hhook_type, int hhook_id, void *udata, + void *ctx_data, void *hdata, struct osd *hosd) +{ + struct test2 *data; + + data = hdata; + + if (hhook_id == HHOOK_TCP_EST_IN) + data->est_in_count++; + else if (hhook_id == HHOOK_TCP_EST_OUT) + data->est_out_count++; +} + + +DECLARE_HELPER_UMA(test2, &test2_helper, 1, sizeof(struct test2), NULL, NULL);