From: "Asbjørn Sloth Tønnesen" <ast@fiberby.dk>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org,
"Asbjørn Sloth Tønnesen" <ast@fiberby.dk>
Subject: [PATCH conntrack 1/4] conntrack: split up nfct_set_addr_from_opt()
Date: Mon, 1 Feb 2016 13:30:04 +0000 [thread overview]
Message-ID: <1454333407-6335-1-git-send-email-ast@fiberby.dk> (raw)
Prepare for CIDR support, by splitting nfct_set_addr_from_opt()
into nfct_parse_addr_from_opt() for parsing
and nfct_set_addr_opt() for storing.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.dk>
---
src/conntrack.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/src/conntrack.c b/src/conntrack.c
index 34785f3..a656b84 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -2083,18 +2083,10 @@ static void merge_bitmasks(struct nfct_bitmask **current,
}
static void
-nfct_set_addr_from_opt(int opt, struct nf_conntrack *ct, union ct_address *ad,
- int *family)
+nfct_set_addr_opt(int opt, struct nf_conntrack *ct, union ct_address *ad,
+ int l3protonum)
{
- int l3protonum;
-
options |= opt2type[opt];
- l3protonum = parse_addr(optarg, ad);
- if (l3protonum == AF_UNSPEC) {
- exit_error(PARAMETER_PROBLEM,
- "Invalid IP address `%s'", optarg);
- }
- set_family(family, l3protonum);
switch(l3protonum) {
case AF_INET:
nfct_set_attr_u32(ct,
@@ -2110,6 +2102,21 @@ nfct_set_addr_from_opt(int opt, struct nf_conntrack *ct, union ct_address *ad,
nfct_set_attr_u8(ct, opt2attr[opt], l3protonum);
}
+static void
+nfct_parse_addr_from_opt(int opt, struct nf_conntrack *ct,
+ union ct_address *ad, int *family)
+{
+ int l3protonum;
+
+ l3protonum = parse_addr(optarg, ad);
+ if (l3protonum == AF_UNSPEC) {
+ exit_error(PARAMETER_PROBLEM,
+ "Invalid IP address `%s'", optarg);
+ }
+ set_family(family, l3protonum);
+ nfct_set_addr_opt(opt, ct, ad, l3protonum);
+}
+
int main(int argc, char *argv[])
{
int c, cmd;
@@ -2188,15 +2195,15 @@ int main(int argc, char *argv[])
case 'd':
case 'r':
case 'q':
- nfct_set_addr_from_opt(c, tmpl.ct, &ad, &family);
+ nfct_parse_addr_from_opt(c, tmpl.ct, &ad, &family);
break;
case '[':
case ']':
- nfct_set_addr_from_opt(c, tmpl.exptuple, &ad, &family);
+ nfct_parse_addr_from_opt(c, tmpl.exptuple, &ad, &family);
break;
case '{':
case '}':
- nfct_set_addr_from_opt(c, tmpl.mask, &ad, &family);
+ nfct_parse_addr_from_opt(c, tmpl.mask, &ad, &family);
break;
case 'p':
options |= CT_OPT_PROTO;
--
2.6.4
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2016-02-01 13:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-01 13:30 Asbjørn Sloth Tønnesen [this message]
2016-02-01 13:30 ` [PATCH conntrack 2/4 v2] conntrack: extend parse_addr() with CIDR support Asbjørn Sloth Tønnesen
2016-02-16 18:19 ` Pablo Neira Ayuso
2016-02-01 13:30 ` [PATCH conntrack 3/4 v2] conntrack: add support for CIDR notation Asbjørn Sloth Tønnesen
2016-02-16 18:19 ` Pablo Neira Ayuso
2016-02-01 13:30 ` [PATCH conntrack 4/4] tests: conntrack: add tests " Asbjørn Sloth Tønnesen
2016-02-16 18:20 ` Pablo Neira Ayuso
2016-02-16 18:18 ` [PATCH conntrack 1/4] conntrack: split up nfct_set_addr_from_opt() 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=1454333407-6335-1-git-send-email-ast@fiberby.dk \
--to=ast@fiberby.dk \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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).