[PATCH conntrack 1/4] conntrack: split up nfct_set_addr_from_opt()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux