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 --- src/expect/api.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/expect/api.c') diff --git a/src/expect/api.c b/src/expect/api.c index 127846a..5c3868c 100644 --- a/src/expect/api.c +++ b/src/expect/api.c @@ -42,6 +42,35 @@ void nfexp_destroy(struct nf_expect *exp) exp = NULL; /* bugtrap */ } +/** + * nfexp_sizeof - return the size in bytes of a certain expect object + * @exp: pointer to the expect object + */ +size_t nfexp_sizeof(const struct nf_expect *exp) +{ + assert(exp != NULL); + return sizeof(*exp); +} + +/** + * nfexp_maxsize - return the maximum size in bytes of a expect object + * + * Use this function if you want to allocate a expect object in the stack + * instead of the heap. For example: + * + * char buf[nfexp_maxsize()]; + * struct nf_expect *exp = (struct nf_expect *) buf; + * memset(exp, 0, nfexp_maxsize()); + * + * Note: As for now this function returns the same size that nfexp_sizeof(exp) + * does although _this could change in the future_. Therefore, do not assume + * that nfexp_sizeof(exp) == nfexp_maxsize(). + */ +size_t nfexp_maxsize() +{ + return sizeof(struct nf_expect); +} + /** * nfexp_clone - clone a expectation object * @exp: pointer to a valid expectation object -- cgit v1.2.3