From 40efc1ebb15be022453f8c820c31099a8a0ebebd Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 18 Nov 2008 10:33:35 +0100 Subject: conntrack: cleanup command line tool protocol extensions This patch cleans up the protocol extensions. Signed-off-by: Pablo Neira Ayuso --- extensions/libct_proto_icmpv6.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'extensions/libct_proto_icmpv6.c') diff --git a/extensions/libct_proto_icmpv6.c b/extensions/libct_proto_icmpv6.c index 5346b59..388087d 100644 --- a/extensions/libct_proto_icmpv6.c +++ b/extensions/libct_proto_icmpv6.c @@ -70,42 +70,24 @@ static int parse(char c, unsigned int *flags) { switch(c) { + u_int8_t tmp; + u_int16_t id; case '1': - if (!optarg) - break; - - nfct_set_attr_u8(ct, - ATTR_ICMP_TYPE, - atoi(optarg)); - + tmp = atoi(optarg); + nfct_set_attr_u8(ct, ATTR_ICMP_TYPE, tmp); nfct_set_attr_u8(ct, ATTR_L4PROTO, IPPROTO_ICMPV6); - *flags |= ICMP_TYPE; break; - case '2': - if (!optarg) - break; - - nfct_set_attr_u8(ct, - ATTR_ICMP_CODE, - atoi(optarg)); - + tmp = atoi(optarg); + nfct_set_attr_u8(ct, ATTR_ICMP_CODE, tmp); nfct_set_attr_u8(ct, ATTR_L4PROTO, IPPROTO_ICMPV6); - *flags |= ICMP_CODE; break; - case '3': - if (!optarg) - break; - - nfct_set_attr_u16(ct, - ATTR_ICMP_ID, - htons(atoi(optarg))); - + id = htons(atoi(optarg)); + nfct_set_attr_u16(ct, ATTR_ICMP_ID, id); nfct_set_attr_u8(ct, ATTR_L4PROTO, IPPROTO_ICMPV6); - *flags |= ICMP_ID; break; } -- cgit v1.2.3