diff options
author | /C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org> | 2008-04-09 12:09:04 +0000 |
---|---|---|
committer | /C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org> | 2008-04-09 12:09:04 +0000 |
commit | 721a93769a15c0f579a389ad58d82d14d13f7f93 (patch) | |
tree | c3dc5bc3d3b684c11639e4467334610c7d9177b5 /src | |
parent | b3c0b86b7a01fe9683026c774d3f1c29183ab0c1 (diff) |
add nfct_send
Diffstat (limited to 'src')
-rw-r--r-- | src/conntrack/api.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/conntrack/api.c b/src/conntrack/api.c index f2f3cb5..04f78ed 100644 --- a/src/conntrack/api.c +++ b/src/conntrack/api.c @@ -548,7 +548,7 @@ int nfct_parse_conntrack(enum nf_conntrack_msg_type type, } /** - * nfct_query - send a query to ctnetlin + * nfct_query - send a query to ctnetlink and handle the reply * @h: library handler * @qt: query type * @data: data required to send the query @@ -574,6 +574,37 @@ int nfct_query(struct nfct_handle *h, } /** + * nfct_send - send a query to ctnetlink + * @h: library handler + * @qt: query type + * @data: data required to send the query + * + * Like nfct_query but we do not wait for the reply from ctnetlink. + * You can use nfct_send() and nfct_catch() to emulate nfct_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 nfct_send(struct nfct_handle *h, + const enum nf_conntrack_query qt, + const void *data) +{ + size_t size = 4096; /* enough for now */ + char buffer[4096]; + struct nfnlhdr *req = (struct nfnlhdr *) buffer; + + assert(h != NULL); + assert(data != NULL); + + if (nfct_build_query(h->nfnlssh_ct, qt, data, req, size) == -1) + return -1; + + return nfnl_send(h->nfnlh, &req->nlh); +} + + +/** * nfct_catch - catch events * @h: library handler * |