From: Shivani Bhardwaj <shivanib134@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH] extensions: libip6t_ah: Add translation to nft
Date: Thu, 31 Dec 2015 22:55:28 +0530 [thread overview]
Message-ID: <20151231172528.GA11909@gmail.com> (raw)
Add translation for AH to nftables.
Examples:
$ sudo ip6tables-translate -A INPUT -m ah --ahspi 500 -j DROP
nft add rule ip6 filter INPUT ah spi 500 counter drop
$ sudo ip6tables-translate -A INPUT -m ah --ahspi 500:550 -j DROP
nft add rule ip6 filter INPUT ah spi 500-550 counter drop
$ sudo ip6tables-translate -A INPUT -m ah ! --ahlen 120
nft add rule ip6 filter INPUT ah hdrlength != 120 counter
$ sudo ip6tables-translate -A INPUT -m ah --ahres
nft add rule ip6 filter INPUT ah reserved 1 counter
Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
extensions/libip6t_ah.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/extensions/libip6t_ah.c b/extensions/libip6t_ah.c
index 174d6d1..f7c30f4 100644
--- a/extensions/libip6t_ah.c
+++ b/extensions/libip6t_ah.c
@@ -128,6 +128,32 @@ static void ah_save(const void *ip, const struct xt_entry_match *match)
printf(" --ahres");
}
+static int ah_xlate(const struct xt_entry_match *match,
+ struct xt_buf *buf, int numeric)
+{
+ const struct ip6t_ah *ahinfo = (struct ip6t_ah *)match->data;
+
+ if (!(ahinfo->spis[0] == 0 && ahinfo->spis[1] == 0xFFFFFFFF)) {
+ xt_buf_add(buf, "ah spi%s ",
+ (ahinfo->invflags & IP6T_AH_INV_SPI) ? " !=" : "");
+ if (ahinfo->spis[0] != ahinfo->spis[1])
+ xt_buf_add(buf, "%u-%u ", ahinfo->spis[0], ahinfo->spis[1]);
+ else
+ xt_buf_add(buf, "%u ", ahinfo->spis[0]);
+ }
+
+ if (ahinfo->hdrlen != 0 || (ahinfo->invflags & IP6T_AH_INV_LEN)) {
+ xt_buf_add(buf, "ah hdrlength%s %u ",
+ (ahinfo->invflags & IP6T_AH_INV_LEN) ? " !=" : "",
+ ahinfo->hdrlen);
+ }
+
+ if (ahinfo->hdrres != 0)
+ xt_buf_add(buf, "ah reserved %u ", ahinfo->hdrres);
+
+ return 1;
+}
+
static struct xtables_match ah_mt6_reg = {
.name = "ah",
.version = XTABLES_VERSION,
@@ -140,6 +166,7 @@ static struct xtables_match ah_mt6_reg = {
.save = ah_save,
.x6_parse = ah_parse,
.x6_options = ah_opts,
+ .xlate = ah_xlate,
};
void
--
1.9.1
next reply other threads:[~2015-12-31 17:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-31 17:25 Shivani Bhardwaj [this message]
2016-01-03 20:22 ` [PATCH] extensions: libip6t_ah: Add translation to nft Pablo Neira Ayuso
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=20151231172528.GA11909@gmail.com \
--to=shivanib134@gmail.com \
--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).