From: Shivani Bhardwaj <shivanib134@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH v2] extensions: libipt_ttl: Add translation to nft
Date: Mon, 4 Jan 2016 23:30:02 +0530 [thread overview]
Message-ID: <20160104180002.GA10529@gmail.com> (raw)
Add translation for module ttl to nftables.
Examples:
$ sudo iptables-translate -A INPUT -m ttl --ttl-eq 3 -j ACCEPT
nft add rule ip filter INPUT ip ttl 3 counter accept
$ sudo iptables-translate -A INPUT -m ttl --ttl-gt 5 -j ACCEPT
nft add rule ip filter INPUT ip ttl \> 5 counter accept
Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
Changes in v2:
Remove the changes done in nft-ipv4
extensions/libipt_ttl.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/extensions/libipt_ttl.c b/extensions/libipt_ttl.c
index 5fe08cc..5d897a7 100644
--- a/extensions/libipt_ttl.c
+++ b/extensions/libipt_ttl.c
@@ -100,6 +100,35 @@ static void ttl_save(const void *ip, const struct xt_entry_match *match)
printf(" %u", info->ttl);
}
+static int ttl_xlate(const struct xt_entry_match *match,
+ struct xt_buf *buf, int numeric)
+{
+ const struct ipt_ttl_info *info =
+ (struct ipt_ttl_info *) match->data;
+
+ switch (info->mode) {
+ case IPT_TTL_EQ:
+ xt_buf_add(buf, "ip ttl");
+ break;
+ case IPT_TTL_NE:
+ xt_buf_add(buf, "ip ttl !=");
+ break;
+ case IPT_TTL_LT:
+ xt_buf_add(buf, "ip ttl \\<");
+ break;
+ case IPT_TTL_GT:
+ xt_buf_add(buf, "ip ttl \\>");
+ break;
+ default:
+ /* error */
+ break;
+ }
+
+ xt_buf_add(buf, " %u ", info->ttl);
+
+ return 1;
+}
+
#define s struct ipt_ttl_info
static const struct xt_option_entry ttl_opts[] = {
{.name = "ttl-lt", .id = O_TTL_LT, .excl = F_ANY, .type = XTTYPE_UINT8,
@@ -126,6 +155,7 @@ static struct xtables_match ttl_mt_reg = {
.x6_parse = ttl_parse,
.x6_fcheck = ttl_check,
.x6_options = ttl_opts,
+ .xlate = ttl_xlate,
};
--
1.9.1
next reply other threads:[~2016-01-04 18:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-04 18:00 Shivani Bhardwaj [this message]
2016-01-05 11:17 ` [PATCH v2] extensions: libipt_ttl: 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=20160104180002.GA10529@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.