From 830f07e2bb10a224ec24dd578f885b30fdf1c5f4 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 24 Jan 2013 08:46:17 +0100 Subject: [PATCH] ipv6: Move struct ipv6hdr definition to separate header proto_ipv6.c and trie.c both define the exact same struct ipv6hdr, so get rid of the duplication and move the definition to a separate header. Signed-off-by: Tobias Klauser --- src/ipv6.h | 40 ++++++++++++++++++++++++++++++++++++++++ src/proto_ipv6.c | 27 +-------------------------- src/trie.c | 20 +------------------- 3 files changed, 42 insertions(+), 45 deletions(-) create mode 100644 src/ipv6.h diff --git a/src/ipv6.h b/src/ipv6.h new file mode 100644 index 00000000..405220f8 --- /dev/null +++ b/src/ipv6.h @@ -0,0 +1,40 @@ +/* + * netsniff-ng - the packet sniffing beast + * By Daniel Borkmann . + * Copyright (C) 2009, 2010 Daniel Borkmann + * Copyright (C) 2012 Christoph Jaeger + * Subject to the GPL, version 2. + */ + +#ifndef IPV6_H +#define IPV6_H + +#include + +#include "built_in.h" + +/* + * IPv6 fixed header + * + * BEWARE, it is incorrect. The first 4 bits of flow_lbl + * are glued to priority now, forming "class". + */ +struct ipv6hdr { +#if defined(__LITTLE_ENDIAN_BITFIELD) + __extension__ uint8_t priority:4, + version:4; +#elif defined(__BIG_ENDIAN_BITFIELD) + __extension__ uint8_t version:4, + priority:4; +#else +# error "Please fix " +#endif + uint8_t flow_lbl[3]; + uint16_t payload_len; + uint8_t nexthdr; + uint8_t hop_limit; + struct in6_addr saddr; + struct in6_addr daddr; +} __packed; + +#endif /* IPV6_H */ diff --git a/src/proto_ipv6.c b/src/proto_ipv6.c index f682fbe4..f9dab016 100644 --- a/src/proto_ipv6.c +++ b/src/proto_ipv6.c @@ -10,38 +10,13 @@ #include #include /* for ntohs() */ #include /* for inet_ntop() */ -#include #include "proto.h" #include "protos.h" #include "csum.h" #include "dissector_eth.h" +#include "ipv6.h" #include "pkt_buff.h" -#include "built_in.h" - -/* - * IPv6 fixed header - * - * BEWARE, it is incorrect. The first 4 bits of flow_lbl - * are glued to priority now, forming "class". - */ -struct ipv6hdr { -#if defined(__LITTLE_ENDIAN_BITFIELD) - __extension__ uint8_t priority:4, - version:4; -#elif defined(__BIG_ENDIAN_BITFIELD) - __extension__ uint8_t version:4, - priority:4; -#else -# error "Please fix " -#endif - uint8_t flow_lbl[3]; - uint16_t payload_len; - uint8_t nexthdr; - uint8_t hop_limit; - struct in6_addr saddr; - struct in6_addr daddr; -} __packed; extern void ipv6(struct pkt_buff *pkt); extern void ipv6_less(struct pkt_buff *pkt); diff --git a/src/trie.c b/src/trie.c index f0af2760..85277a89 100644 --- a/src/trie.c +++ b/src/trie.c @@ -8,30 +8,12 @@ #include #include #include -#include #include "patricia.h" #include "locking.h" #include "trie.h" #include "ipv4.h" - -struct ipv6hdr { -#if defined(__LITTLE_ENDIAN_BITFIELD) - __extension__ uint8_t priority:4, - version:4; -#elif defined(__BIG_ENDIAN_BITFIELD) - __extension__ uint8_t version:4, - priority:4; -#else -# error "Please fix " -#endif - uint8_t flow_lbl[3]; - uint16_t payload_len; - uint8_t nexthdr; - uint8_t hop_limit; - struct in6_addr saddr; - struct in6_addr daddr; -} __attribute__((packed)); +#include "ipv6.h" static struct patricia_node *tree = NULL; -- 2.11.4.GIT