From 84f120b150d14adb1cefec601e28b2522612a620 Mon Sep 17 00:00:00 2001 From: "/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org" Date: Sun, 6 May 2007 17:39:00 +0000 Subject: - add warning note to ctnl_test.c: old API is deprecated - split expect_api_test.c into small example files expect_*.c - introduce alias tags for original tuple attributes - introduce nfexp_sizeof and nfexp_maxsize - build expectation attributes iif they are set - fix l3num setting in expect/build.c --- utils/expect_events.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 utils/expect_events.c (limited to 'utils/expect_events.c') diff --git a/utils/expect_events.c b/utils/expect_events.c new file mode 100644 index 0000000..956ca42 --- /dev/null +++ b/utils/expect_events.c @@ -0,0 +1,48 @@ +#include +#include +#include + +#include + +static int event_cb(enum nf_conntrack_msg_type type, + struct nf_expect *exp, + void *data) +{ + static int n = 0; + char buf[1024]; + + nfexp_snprintf(buf, 1024, exp, type, NFCT_O_DEFAULT, 0); + printf("%s\n", buf); + + if (++n == 10) + return NFCT_CB_STOP; + + return NFCT_CB_CONTINUE; +} + +int main() +{ + int ret; + struct nfct_handle *h; + + h = nfct_open(EXPECT, NF_NETLINK_CONNTRACK_EXP_NEW); + if (!h) { + perror("nfct_open"); + return -1; + } + + nfexp_callback_register(h, NFCT_T_ALL, event_cb, NULL); + + printf("TEST: waiting for 10 expectation events...\n"); + + ret = nfexp_catch(h); + + printf("TEST: OK (%d)(%s)\n", ret, strerror(errno)); + + nfct_close(h); + + if (ret == -1) + exit(EXIT_FAILURE); + + exit(EXIT_SUCCESS); +} -- cgit v1.2.3