summaryrefslogtreecommitdiffstats
path: root/src/expect
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2011-12-08 02:06:53 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2011-12-08 02:06:53 +0100
commit7843632196fd959f3f8f16f3d533c72d315a7e08 (patch)
treedfb1cfce46557b245d1c99c23a49ebf756e78388 /src/expect
parentb3c288427f1906e2b7c7f6e8c5747db8ccc5f62a (diff)
expect: add nfexp_send()
It is like nfct_send() but for expectations, for API symmetry. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expect')
-rw-r--r--src/expect/api.c32
1 files changed, 32 insertions, 0 deletions
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
@@ -646,6 +646,38 @@ int nfexp_query(struct nfct_handle *h,
}
/**
+ * 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
*