netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: [PATCH 5/5] extensions: libxt_state: add translation to nft
Date: Mon, 14 Apr 2014 12:41:06 +0200	[thread overview]
Message-ID: <1397472066-13011-6-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1397472066-13011-1-git-send-email-pablo@netfilter.org>

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 extensions/libxt_conntrack.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/extensions/libxt_conntrack.c b/extensions/libxt_conntrack.c
index 128bbd2..4154464 100644
--- a/extensions/libxt_conntrack.c
+++ b/extensions/libxt_conntrack.c
@@ -1156,6 +1156,43 @@ static void state_save(const void *ip, const struct xt_entry_match *match)
 	state_print_state(sinfo->statemask);
 }
 
+static void state_xlate_print(struct xt_buf *buf, unsigned int statemask)
+{
+	const char *sep = "";
+
+	if (statemask & XT_CONNTRACK_STATE_INVALID) {
+		xt_buf_add(buf, "%s%s", sep, "invalid");
+		sep = ",";
+	}
+	if (statemask & XT_CONNTRACK_STATE_BIT(IP_CT_NEW)) {
+		xt_buf_add(buf, "%s%s", sep, "new");
+		sep = ",";
+	}
+	if (statemask & XT_CONNTRACK_STATE_BIT(IP_CT_RELATED)) {
+		xt_buf_add(buf, "%s%s", sep, "related");
+		sep = ",";
+	}
+	if (statemask & XT_CONNTRACK_STATE_BIT(IP_CT_ESTABLISHED)) {
+		xt_buf_add(buf, "%s%s", sep, "established");
+		sep = ",";
+	}
+	if (statemask & XT_CONNTRACK_STATE_UNTRACKED) {
+		xt_buf_add(buf, "%s%s", sep, "untracked");
+		sep = ",";
+	}
+}
+
+static int state_xlate(const struct xt_entry_match *match, struct xt_buf *buf)
+{
+	const struct xt_conntrack_mtinfo3 *sinfo = (const void *)match->data;
+
+	xt_buf_add(buf, "ct state %s", sinfo->invert_flags & XT_CONNTRACK_STATE ?
+					"!= " : "");
+	state_xlate_print(buf, sinfo->state_mask);
+	xt_buf_add(buf, " ");
+	return 1;
+}
+
 static struct xtables_match conntrack_mt_reg[] = {
 	{
 		.version       = XTABLES_VERSION,
@@ -1306,6 +1343,7 @@ static struct xtables_match conntrack_mt_reg[] = {
 		.save          = state_save,
 		.x6_parse      = state_ct23_parse,
 		.x6_options    = state_opts,
+		.xlate         = state_xlate,
 	},
 	{
 		.family        = NFPROTO_UNSPEC,
-- 
1.7.10.4


      parent reply	other threads:[~2014-04-14 10:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-14 10:41 [RFC PATCH 0/5] translations from iptables to nft Pablo Neira Ayuso
2014-04-14 10:41 ` [PATCH 1/5] nft: xtables: add generic parsing infrastructure to interpret commands Pablo Neira Ayuso
2014-04-14 10:41 ` [PATCH 2/5] nft: xtables-restore: add generic parsing infrastructure Pablo Neira Ayuso
2014-04-14 10:41 ` [PATCH 3/5] nft: xtables: add the infrastructure to translate from iptables to nft Pablo Neira Ayuso
2014-04-14 10:41 ` [PATCH 4/5] extensions: libxt_tcp: add translation " Pablo Neira Ayuso
2014-04-14 10:41 ` Pablo Neira Ayuso [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397472066-13011-6-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).