summaryrefslogtreecommitdiffstats
path: root/lib/netfilter/queue_msg.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/netfilter/queue_msg.c')
-rw-r--r--lib/netfilter/queue_msg.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/netfilter/queue_msg.c b/lib/netfilter/queue_msg.c
index af50fa0..ab0a58b 100644
--- a/lib/netfilter/queue_msg.c
+++ b/lib/netfilter/queue_msg.c
@@ -7,6 +7,7 @@
* of the License.
*
* Copyright (c) 2007, 2008 Patrick McHardy <kaber@trash.net>
+ * Copyright (c) 2010 Karl Hiramoto <karl@hiramoto.org>
*/
/**
@@ -189,6 +190,12 @@ nla_put_failure:
return NULL;
}
+/**
+* Send a message verdict/mark
+* @arg nlh netlink messsage header
+* @arg msg queue msg
+* @return 0 on OK or error code
+*/
int nfnl_queue_msg_send_verdict(struct nl_sock *nlh,
const struct nfnl_queue_msg *msg)
{
@@ -206,6 +213,51 @@ int nfnl_queue_msg_send_verdict(struct nl_sock *nlh,
return wait_for_ack(nlh);
}
+/**
+* Send a message verdict including the payload
+* @arg nlh netlink messsage header
+* @arg msg queue msg
+* @arg payload_data packet payload data
+* @arg payload_len payload length
+* @return 0 on OK or error code
+*/
+int nfnl_queue_msg_send_verdict_payload(struct nl_sock *nlh,
+ const struct nfnl_queue_msg *msg,
+ const void *payload_data, unsigned payload_len)
+{
+ struct nl_msg *nlmsg;
+ int err;
+ struct iovec iov[3];
+ struct nlattr nla;
+
+ nlmsg = nfnl_queue_msg_build_verdict(msg);
+ if (nlmsg == NULL)
+ return -NLE_NOMEM;
+
+ memset(iov, 0, sizeof(iov));
+
+ iov[0].iov_base = (void *) nlmsg_hdr(nlmsg);
+ iov[0].iov_len = nlmsg_hdr(nlmsg)->nlmsg_len;
+
+ nla.nla_type = NFQA_PAYLOAD;
+ nla.nla_len = payload_len + sizeof(nla);
+ nlmsg_hdr(nlmsg)->nlmsg_len += nla.nla_len;
+
+ iov[1].iov_base = (void *) &nla;
+ iov[1].iov_len = sizeof(nla);
+
+ iov[2].iov_base = (void *) payload_data;
+ iov[2].iov_len = NLA_ALIGN(payload_len);
+
+ nl_auto_complete(nlh, nlmsg);
+ err = nl_send_iovec(nlh, nlmsg, iov, 3);
+
+ nlmsg_free(nlmsg);
+ if (err < 0)
+ return err;
+ return wait_for_ack(nlh);
+}
+
#define NFNLMSG_QUEUE_TYPE(type) NFNLMSG_TYPE(NFNL_SUBSYS_QUEUE, (type))
static struct nl_cache_ops nfnl_queue_msg_ops = {
.co_name = "netfilter/queue_msg",