summaryrefslogtreecommitdiffstats
path: root/extensions/libct_proto_udp.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-11-18 10:33:35 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2008-11-18 10:33:35 +0100
commit40efc1ebb15be022453f8c820c31099a8a0ebebd (patch)
tree2a99ebde272d6b7d36bbb2118b5637f48e0ae422 /extensions/libct_proto_udp.c
parent6d8903cbf33ac10e8e03f884a58e374adc366887 (diff)
conntrack: cleanup command line tool protocol extensions
This patch cleans up the protocol extensions. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'extensions/libct_proto_udp.c')
-rw-r--r--extensions/libct_proto_udp.c81
1 files changed, 17 insertions, 64 deletions
diff --git a/extensions/libct_proto_udp.c b/extensions/libct_proto_udp.c
index f9793d0..0f8bf5c 100644
--- a/extensions/libct_proto_udp.c
+++ b/extensions/libct_proto_udp.c
@@ -77,104 +77,57 @@ static int parse_options(char c,
unsigned int *flags)
{
switch(c) {
+ u_int16_t port;
case '1':
- if (!optarg)
- break;
-
- nfct_set_attr_u16(ct,
- ATTR_ORIG_PORT_SRC,
- htons(atoi(optarg)));
-
+ port = htons(atoi(optarg));
+ nfct_set_attr_u16(ct, ATTR_ORIG_PORT_SRC, port);
nfct_set_attr_u8(ct, ATTR_ORIG_L4PROTO, IPPROTO_UDP);
-
*flags |= UDP_ORIG_SPORT;
break;
case '2':
- if (!optarg)
- break;
-
- nfct_set_attr_u16(ct,
- ATTR_ORIG_PORT_DST,
- htons(atoi(optarg)));
-
+ port = htons(atoi(optarg));
+ nfct_set_attr_u16(ct, ATTR_ORIG_PORT_DST, port);
nfct_set_attr_u8(ct, ATTR_ORIG_L4PROTO, IPPROTO_UDP);
-
*flags |= UDP_ORIG_DPORT;
break;
case '3':
- if (!optarg)
- break;
-
- nfct_set_attr_u16(ct,
- ATTR_REPL_PORT_SRC,
- htons(atoi(optarg)));
-
+ port = htons(atoi(optarg));
+ nfct_set_attr_u16(ct, ATTR_REPL_PORT_SRC, port);
nfct_set_attr_u8(ct, ATTR_REPL_L4PROTO, IPPROTO_UDP);
-
*flags |= UDP_REPL_SPORT;
break;
case '4':
- if (!optarg)
- break;
-
- nfct_set_attr_u16(ct,
- ATTR_REPL_PORT_DST,
- htons(atoi(optarg)));
-
+ port = htons(atoi(optarg));
+ nfct_set_attr_u16(ct, ATTR_REPL_PORT_DST, port);
nfct_set_attr_u8(ct, ATTR_REPL_L4PROTO, IPPROTO_UDP);
-
*flags |= UDP_REPL_DPORT;
break;
case '5':
- if (!optarg)
- break;
-
- nfct_set_attr_u16(mask,
- ATTR_ORIG_PORT_SRC,
- htons(atoi(optarg)));
-
+ port = htons(atoi(optarg));
+ nfct_set_attr_u16(mask, ATTR_ORIG_PORT_SRC, port);
nfct_set_attr_u8(mask, ATTR_ORIG_L4PROTO, IPPROTO_UDP);
-
*flags |= UDP_MASK_SPORT;
break;
case '6':
- if (!optarg)
- break;
-
- nfct_set_attr_u16(mask,
- ATTR_ORIG_PORT_DST,
- htons(atoi(optarg)));
-
+ port = htons(atoi(optarg));
+ nfct_set_attr_u16(mask, ATTR_ORIG_PORT_DST, port);
nfct_set_attr_u8(mask, ATTR_ORIG_L4PROTO, IPPROTO_UDP);
-
*flags |= UDP_MASK_DPORT;
break;
case '7':
- if (!optarg)
- break;
-
- nfct_set_attr_u16(exptuple,
- ATTR_ORIG_PORT_SRC,
- htons(atoi(optarg)));
-
+ port = htons(atoi(optarg));
+ nfct_set_attr_u16(exptuple, ATTR_ORIG_PORT_SRC, port);
nfct_set_attr_u8(exptuple,
ATTR_ORIG_L4PROTO,
IPPROTO_UDP);
-
*flags |= UDP_EXPTUPLE_SPORT;
break;
case '8':
- if (!optarg)
- break;
-
- nfct_set_attr_u16(exptuple,
- ATTR_ORIG_PORT_DST,
- htons(atoi(optarg)));
-
+ port = htons(atoi(optarg));
+ nfct_set_attr_u16(exptuple, ATTR_ORIG_PORT_DST, port);
nfct_set_attr_u8(exptuple,
ATTR_ORIG_L4PROTO,
IPPROTO_UDP);
-
*flags |= UDP_EXPTUPLE_DPORT;
break;
}