From 7843632196fd959f3f8f16f3d533c72d315a7e08 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 8 Dec 2011 02:06:53 +0100 Subject: expect: add nfexp_send() It is like nfct_send() but for expectations, for API symmetry. Signed-off-by: Pablo Neira Ayuso --- src/expect/api.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/expect/api.c b/src/expect/api.c index 2daa15a..863f4c0 100644 --- a/src/expect/api.c +++ b/src/expect/api.c @@ -645,6 +645,38 @@ int nfexp_query(struct nfct_handle *h, return nfnl_query(h->nfnlh, &u.req.nlh); } +/** + * nfexp_send - send a query to ctnetlink + * \param h library handler + * \param qt query type + * \param data data required to send the query + * + * Like nfexp_query but we do not wait for the reply from ctnetlink. + * You can use nfexp_send() and nfexp_catch() to emulate nfexp_query(). + * This is particularly useful when the socket is non-blocking. + * + * On error, -1 is returned and errno is explicitely set. On success, 0 + * is returned. + */ +int nfexp_send(struct nfct_handle *h, + const enum nf_conntrack_query qt, + const void *data) +{ + size_t size = 4096; /* enough for now */ + union { + char buffer[size]; + struct nfnlhdr req; + } u; + + assert(h != NULL); + assert(data != NULL); + + if (__build_query_exp(h->nfnlssh_exp, qt, data, &u.req, size) == -1) + return -1; + + return nfnl_send(h->nfnlh, &u.req.nlh); +} + /** * nfexp_catch - catch events * \param h library handler -- cgit v1.2.3