From 692b1175e4d0493fcda0fbe8dd71ca33c2773a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Thu, 31 Aug 2017 18:49:15 +0100 Subject: Have a single IPv6 tap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Optimize code and open possibility for enriching IPv6 tap data. Change-Id: I5a204d7464cde32123d5bfe664cc9b6bcf08dbe1 Reviewed-on: https://code.wireshark.org/review/23340 Petri-Dish: João Valverde Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde --- epan/dissectors/Makefile.am | 1 - epan/dissectors/packet-6lowpan.c | 2 +- epan/dissectors/packet-fr.c | 1 - epan/dissectors/packet-icmp.c | 2 +- epan/dissectors/packet-icmpv6.c | 5 ++- epan/dissectors/packet-ip.c | 28 +++++++-------- epan/dissectors/packet-ip.h | 71 +++++++++++++++++++++++++++++------- epan/dissectors/packet-ipsec.c | 4 +-- epan/dissectors/packet-ipv6.c | 77 ++++++++++++++++------------------------ epan/dissectors/packet-ipv6.h | 68 ----------------------------------- epan/dissectors/packet-mip6.c | 6 ++-- epan/dissectors/packet-null.c | 1 - epan/dissectors/packet-shim6.c | 4 +-- epan/dissectors/packet-stt.c | 6 ++-- epan/dissectors/packet-tapa.c | 8 ++--- epan/wslua/taps | 2 +- 16 files changed, 120 insertions(+), 166 deletions(-) delete mode 100644 epan/dissectors/packet-ipv6.h (limited to 'epan') diff --git a/epan/dissectors/Makefile.am b/epan/dissectors/Makefile.am index c45cde67f5..65af80e6a5 100644 --- a/epan/dissectors/Makefile.am +++ b/epan/dissectors/Makefile.am @@ -1618,7 +1618,6 @@ DISSECTOR_INCLUDES = \ packet-ip.h \ packet-ipmi.h \ packet-ipsec.h \ - packet-ipv6.h \ packet-ipx.h \ packet-isakmp.h \ packet-isis.h \ diff --git a/epan/dissectors/packet-6lowpan.c b/epan/dissectors/packet-6lowpan.c index b7af0cdd56..70b8d33a95 100644 --- a/epan/dissectors/packet-6lowpan.c +++ b/epan/dissectors/packet-6lowpan.c @@ -31,7 +31,7 @@ #include #include #include -#include "packet-ipv6.h" +#include "packet-ip.h" #include "packet-6lowpan.h" #include "packet-btl2cap.h" #include "packet-zbee.h" diff --git a/epan/dissectors/packet-fr.c b/epan/dissectors/packet-fr.c index b6df15a0f5..985dacf920 100644 --- a/epan/dissectors/packet-fr.c +++ b/epan/dissectors/packet-fr.c @@ -44,7 +44,6 @@ #include "packet-chdlc.h" #include "packet-eth.h" #include "packet-ip.h" -#include "packet-ipv6.h" #include "packet-ppp.h" #include "packet-juniper.h" #include "packet-sflow.h" diff --git a/epan/dissectors/packet-icmp.c b/epan/dissectors/packet-icmp.c index f7ebc914e5..bd6b2658b0 100644 --- a/epan/dissectors/packet-icmp.c +++ b/epan/dissectors/packet-icmp.c @@ -1201,7 +1201,7 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data) guint32 conv_key[2]; icmp_transaction_t *trans = NULL; nstime_t ts, time_relative; - ws_ip *iph = (ws_ip*)data; + ws_ip4 *iph = WS_IP4_PTR(data); col_set_str(pinfo->cinfo, COL_PROTOCOL, "ICMP"); col_clear(pinfo->cinfo, COL_INFO); diff --git a/epan/dissectors/packet-icmpv6.c b/epan/dissectors/packet-icmpv6.c index a3f14226f6..5ba28d075a 100644 --- a/epan/dissectors/packet-icmpv6.c +++ b/epan/dissectors/packet-icmpv6.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include "packet-ber.h" @@ -3842,7 +3841,7 @@ dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) tvbuff_t *next_tvb; guint8 icmp6_type, icmp6_code; icmp_transaction_t *trans = NULL; - ws_ip *iph = (ws_ip*)data; + ws_ip6 *iph = WS_IP6_PTR(data); col_set_str(pinfo->cinfo, COL_PROTOCOL, "ICMPv6"); col_clear(pinfo->cinfo, COL_INFO); @@ -3949,7 +3948,7 @@ dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) identifier, sequence); if (iph != NULL) { col_append_fstr(pinfo->cinfo, COL_INFO, ", hop limit=%u", - iph->ip_ttl); + iph->ip6_hop); } if (pinfo->destport == 3544 && icmp6_type == ICMP6_ECHO_REQUEST) { diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index bec139c478..cc30b77ab7 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -537,7 +537,7 @@ static int ip_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) { conv_hash_t *hash = (conv_hash_t*) pct; - const ws_ip *iph=(const ws_ip *)vip; + const ws_ip4 *iph=(const ws_ip4 *)vip; add_conversation_table_data(hash, &iph->ip_src, &iph->ip_dst, 0, 0, 1, pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->abs_ts, &ip_ct_dissector_info, PT_NONE); @@ -558,7 +558,7 @@ static int ip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) { conv_hash_t *hash = (conv_hash_t*) pit; - const ws_ip *iph=(const ws_ip *)vip; + const ws_ip4 *iph=(const ws_ip4 *)vip; /* Take two "add" passes per packet, adding for each direction, ensures that all packets are counted properly (even if address is sending to itself) @@ -1527,7 +1527,7 @@ dissect_ipopt_qs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * dat proto_tree *field_tree; proto_item *tf; proto_item *ti; - ws_ip *iph = (ws_ip*)data; + ws_ip4 *iph = (ws_ip4 *)data; gint offset = 2; guint8 command = tvb_get_guint8(tvb, offset); @@ -1853,7 +1853,7 @@ static const true_false_string flags_sf_set_evil = { gboolean ip_try_dissect(gboolean heur_first, guint nxt, tvbuff_t *tvb, packet_info *pinfo, - proto_tree *tree, ws_ip *iph) + proto_tree *tree, void *iph) { heur_dtbl_entry_t *hdtbl_entry; @@ -1889,7 +1889,7 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* tvbuff_t *next_tvb; gboolean update_col_info = TRUE; gboolean save_fragmented; - ws_ip *iph; + ws_ip4 *iph; guint32 src32, dst32; proto_tree *tree; proto_item *item = NULL, *ttl_item; @@ -1912,7 +1912,7 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* }; tree = parent_tree; - iph = wmem_new0(wmem_packet_scope(), ws_ip); + iph = wmem_new0(wmem_packet_scope(), ws_ip4); col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPv4"); col_clear(pinfo->cinfo, COL_INFO); @@ -2078,7 +2078,7 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* ttl_item = NULL; } - iph->ip_nxt = tvb_get_guint8(tvb, offset + 9); + iph->ip_proto = tvb_get_guint8(tvb, offset + 9); if (tree) { proto_tree_add_item(ip_tree, hf_ip_proto, tvb, offset + 9, 1, ENC_BIG_ENDIAN); } @@ -2184,8 +2184,8 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* } else if (!is_a_multicast_addr(dst32) && /* At least BGP should appear here as well */ iph->ip_ttl < 5 && - iph->ip_nxt != IP_PROTO_PIM && - iph->ip_nxt != IP_PROTO_OSPF) { + iph->ip_proto != IP_PROTO_PIM && + iph->ip_proto != IP_PROTO_OSPF) { expert_add_info_format(pinfo, ttl_item, &ei_ip_ttl_too_small, "\"Time To Live\" only %u", iph->ip_ttl); } @@ -2243,7 +2243,7 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* dissect_ip_options(tvb, offset + 20, optlen, pinfo, field_tree, tf, iph); } - p_add_proto_data(pinfo->pool, pinfo, proto_ip, pinfo->curr_layer_num, GUINT_TO_POINTER((guint)iph->ip_nxt)); + p_add_proto_data(pinfo->pool, pinfo, proto_ip, pinfo->curr_layer_num, GUINT_TO_POINTER((guint)iph->ip_proto)); tap_queue_packet(ip_tap, pinfo, iph); /* Skip over header + options */ @@ -2260,7 +2260,7 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* ipsum == 0) { ipfd_head = fragment_add_check(&ip_reassembly_table, tvb, offset, pinfo, - iph->ip_nxt ^ iph->ip_id ^ src32 ^ dst32 ^ pinfo->vlan_id, + iph->ip_proto ^ iph->ip_id ^ src32 ^ dst32 ^ pinfo->vlan_id, NULL, (iph->ip_off & IP_OFFSET) * 8, iph->ip_len - hlen, @@ -2299,7 +2299,7 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* /* Just show this as a fragment. */ col_add_fstr(pinfo->cinfo, COL_INFO, "Fragmented IP protocol (proto=%s %u, off=%u, ID=%04x)", - ipprotostr(iph->ip_nxt), iph->ip_nxt, + ipprotostr(iph->ip_proto), iph->ip_proto, (iph->ip_off & IP_OFFSET) * 8, iph->ip_id); if ( ipfd_head && ipfd_head->reassembled_in != pinfo->num ) { col_append_fstr(pinfo->cinfo, COL_INFO, " [Reassembled in #%u]", @@ -2320,12 +2320,12 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* even be labeled as an IP frame; ideally, if a frame being dissected throws an exception, it'll be labeled as a mangled frame of the type in question. */ - if (!ip_try_dissect(try_heuristic_first, iph->ip_nxt, next_tvb, pinfo, + if (!ip_try_dissect(try_heuristic_first, iph->ip_proto, next_tvb, pinfo, parent_tree, iph)) { /* Unknown protocol */ if (update_col_info) { col_add_fstr(pinfo->cinfo, COL_INFO, "%s (%u)", - ipprotostr(iph->ip_nxt), iph->ip_nxt); + ipprotostr(iph->ip_proto), iph->ip_proto); } call_data_dissector(next_tvb, pinfo, parent_tree); } diff --git a/epan/dissectors/packet-ip.h b/epan/dissectors/packet-ip.h index de36819e34..a94b9f9fbb 100644 --- a/epan/dissectors/packet-ip.h +++ b/epan/dissectors/packet-ip.h @@ -41,20 +41,21 @@ extern const value_string ip_version_vals[]; -typedef struct _ws_ip +typedef struct _ws_ip4 { - guint8 ip_ver; /* 4 or 6 */ - guint8 ip_tos; /* IPv4: type of service; IPv6: traffic class */ - guint32 ip_flw; /* IPv4: (zero); IPv6: flow label */ - guint32 ip_len; /* IPv4: total length; IPv6: payload length */ - guint16 ip_id; /* IPv4: identification; IPv6: (zero) */ - guint16 ip_off; /* IPv4: fragment offset; IPv6: (zero) */ - guint8 ip_ttl; /* IPv4: time-to-live; IPv6: hop limit */ - guint8 ip_nxt; /* IPv4: protocol; IPv6: next header */ - guint16 ip_sum; /* IPv4: checksum; IPv6: (zero) */ + guint8 ip_ver; /* 4 */ + guint8 ip_tos; /* type of service */ + guint32 ip_len; /* total length */ + guint16 ip_id; /* identification */ + guint16 ip_off; /* fragment offset */ + guint8 ip_ttl; /* time-to-live */ + guint8 ip_proto; /* protocol */ + guint16 ip_sum; /* checksum */ address ip_src; /* source address */ address ip_dst; /* destination address */ -} ws_ip; +} ws_ip4; + +#define WS_IP4_PTR(p) ((ws_ip4 *)(((p) && *(guint8 *)(p) == 4) ? (p) : NULL)) /* Differentiated Services Codepoint */ #define IPDSFIELD_DSCP_MASK 0xFC @@ -65,7 +66,7 @@ typedef struct _ws_ip #define IPDSFIELD_ECN(dsfield) ((dsfield) & IPDSFIELD_ECN_MASK) gboolean ip_try_dissect(gboolean heur_first, guint nxt, tvbuff_t *tvb, - packet_info *pinfo, proto_tree *tree, ws_ip *iph); + packet_info *pinfo, proto_tree *tree, void *iph); /* Export the DSCP/ECN extended value-string table for other protocols */ WS_DLL_PUBLIC value_string_ext dscp_vals_ext; @@ -73,6 +74,52 @@ WS_DLL_PUBLIC value_string_ext ecn_vals_ext; WS_DLL_PUBLIC value_string_ext dscp_short_vals_ext; WS_DLL_PUBLIC value_string_ext ecn_short_vals_ext; +typedef struct _ws_ip6 +{ + guint8 ip6_ver; /* 6 */ + guint8 ip6_tc; /* traffic class */ + guint32 ip6_flw; /* flow label */ + guint32 ip6_len; /* payload length */ + guint8 ip6_nxt; /* next header */ + guint8 ip6_hop; /* hop limit */ + address ip6_src; /* source address */ + address ip6_dst; /* destination address */ +} ws_ip6; + +#define WS_IP6_PTR(p) ((ws_ip6 *)(((p) && *(guint8 *)(p) == 6) ? (p) : NULL)) + +typedef ws_ip6 ipv6_tap_info_t; + +/* Packet info for shared state between IPv6 header and extensions */ +typedef struct { + guint32 jumbo_plen; + guint16 ip6_plen; + gint frag_plen; + proto_tree *ipv6_tree; + gint ipv6_item_len; +} ipv6_pinfo_t; + +ipv6_pinfo_t *p_get_ipv6_pinfo(packet_info *pinfo); + +ipv6_pinfo_t *p_update_ipv6_pinfo(packet_info *pinfo, proto_tree **tree_ptr, gint hdr_len); + +void ipv6_dissect_next(guint nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip6 *iph); + +static inline int +ws_ip_protocol(void *iph) +{ + ws_ip4 *ip4; + ws_ip6 *ip6; + + if (iph != NULL) { + if ((ip4 = WS_IP4_PTR(iph)) != NULL) + return ip4->ip_proto; + if ((ip6 = WS_IP6_PTR(iph)) != NULL) + return ip6->ip6_nxt; + } + return -1; +} + #endif /* __PACKET_IP_H__ */ /* diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c index 790454b5b3..9de82b1e7f 100644 --- a/epan/dissectors/packet-ipsec.c +++ b/epan/dissectors/packet-ipsec.c @@ -86,7 +86,7 @@ ADD: Additional generic (non-checked) ICV length of 128, 192 and 256. #include #include "packet-ipsec.h" -#include "packet-ipv6.h" +#include "packet-ip.h" void proto_register_ipsec(void); void proto_reg_handoff_ipsec(void); @@ -1155,7 +1155,7 @@ dissect_ah(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) next_tvb = tvb_new_subset_remaining(tvb, ah_hdr_len); if (pinfo->dst.type == AT_IPv6) { - ipv6_dissect_next(ah_nxt, next_tvb, pinfo, tree, (ws_ip *)data); + ipv6_dissect_next(ah_nxt, next_tvb, pinfo, tree, (ws_ip6 *)data); } else { /* do lookup with the subdissector table */ saved_match_uint = pinfo->match_uint; diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c index 7d17ef73f1..f814433c21 100644 --- a/epan/dissectors/packet-ipv6.c +++ b/epan/dissectors/packet-ipv6.c @@ -48,7 +48,7 @@ #include #include -#include "packet-ipv6.h" +#include "packet-ip.h" #include "packet-juniper.h" #include "packet-sflow.h" #include "packet-vxlan.h" @@ -111,8 +111,7 @@ void proto_reg_handoff_ipv6(void); #define IPV6_PROTO_VALUE 1 #define IPV6_PROTO_PINFO 2 -static int ip6_hdr_tap = -1; -static int ipv6_ws_tap = -1; +static int ipv6_tap = -1; static int proto_ipv6 = -1; static int proto_ipv6_hopopts = -1; @@ -435,14 +434,9 @@ static int ipv6_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) { conv_hash_t *hash = (conv_hash_t*) pct; - const struct ws_ip6_hdr *ip6h = (const struct ws_ip6_hdr *)vip; - address src; - address dst; + const ipv6_tap_info_t *ip6 = (const ipv6_tap_info_t *)vip; - set_address_ipv6(&src, &ip6h->ip6h_src); - set_address_ipv6(&dst, &ip6h->ip6h_dst); - - add_conversation_table_data(hash, &src, &dst, 0, 0, 1, + add_conversation_table_data(hash, &ip6->ip6_src, &ip6->ip6_dst, 0, 0, 1, pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->abs_ts, &ipv6_ct_dissector_info, PT_NONE); @@ -463,17 +457,11 @@ static int ipv6_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) { conv_hash_t *hash = (conv_hash_t*) pit; - const struct ws_ip6_hdr *ip6h = (const struct ws_ip6_hdr *)vip; - address src; - address dst; - - /* Addresses aren't implemented as 'address' type in struct ws_ip6_hdr */ - set_address_ipv6(&src, &ip6h->ip6h_src); - set_address_ipv6(&dst, &ip6h->ip6h_dst); + const ipv6_tap_info_t *ip6 = (const ipv6_tap_info_t *)vip; - add_hostlist_table_data(hash, &src, 0, TRUE, 1, + add_hostlist_table_data(hash, &ip6->ip6_src, 0, TRUE, 1, pinfo->fd->pkt_len, &ipv6_host_dissector_info, PT_NONE); - add_hostlist_table_data(hash, &dst, 0, FALSE, 1, + add_hostlist_table_data(hash, &ip6->ip6_dst, 0, FALSE, 1, pinfo->fd->pkt_len, &ipv6_host_dissector_info, PT_NONE); return 1; @@ -1245,7 +1233,7 @@ dissect_routing6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data p_add_ipv6_nxt(pinfo, rt.ip6r_nxt); next_tvb = tvb_new_subset_remaining(tvb, len); - ipv6_dissect_next(rt.ip6r_nxt, next_tvb, pinfo, tree, (ws_ip *)data); + ipv6_dissect_next(rt.ip6r_nxt, next_tvb, pinfo, tree, (ws_ip6 *)data); return tvb_captured_length(tvb); } @@ -1312,7 +1300,7 @@ dissect_fraghdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) if (reassembled) { ipv6_pinfo->frag_plen = 0; next_tvb = tvb_new_subset_remaining(tvb, offset); - ipv6_dissect_next(nxt, next_tvb, pinfo, tree, (ws_ip *)data); + ipv6_dissect_next(nxt, next_tvb, pinfo, tree, (ws_ip6 *)data); return tvb_captured_length(tvb); } } @@ -1321,7 +1309,7 @@ dissect_fraghdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) p_add_ipv6_nxt(pinfo, nxt); next_tvb = tvb_new_subset_remaining(tvb, offset); - ipv6_dissect_next(nxt, next_tvb, pinfo, tree, (ws_ip *)data); + ipv6_dissect_next(nxt, next_tvb, pinfo, tree, (ws_ip6 *)data); return tvb_captured_length(tvb); } @@ -1464,7 +1452,7 @@ dissect_opt_rtalert(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree * */ static gint dissect_opt_quickstart(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree, - struct opt_proto_item *opt_ti, guint8 opt_len, ws_ip *iph) + struct opt_proto_item *opt_ti, guint8 opt_len, ws_ip6 *iph) { proto_item *pi = proto_tree_get_parent(opt_tree); proto_item *ti; @@ -1493,7 +1481,7 @@ dissect_opt_quickstart(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tre if (iph != NULL) { guint8 ttl_diff; - ttl_diff = (iph->ip_ttl - qs_ttl) % 256; + ttl_diff = (iph->ip6_hop - qs_ttl) % 256; ti = proto_tree_add_uint(opt_tree, hf_ipv6_opt_qs_ttl_diff, tvb, offset, 1, ttl_diff); PROTO_ITEM_SET_GENERATED(ti); proto_item_append_text(pi, ", QS TTL diff %u", ttl_diff); @@ -1801,7 +1789,7 @@ dissect_opt_unknown(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree * } static int -dissect_opts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info *pinfo, ws_ip *iph, const int exthdr_proto) +dissect_opts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info *pinfo, ws_ip6 *iph, const int exthdr_proto) { gint len, offset_end; guint8 nxt; @@ -1991,7 +1979,7 @@ dissect_hopopts(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { col_append_sep_str(pinfo->cinfo, COL_INFO, " , ", "IPv6 hop-by-hop options"); - return dissect_opts(tvb, 0, tree, pinfo, (ws_ip *)data, proto_ipv6_hopopts); + return dissect_opts(tvb, 0, tree, pinfo, (ws_ip6 *)data, proto_ipv6_hopopts); } static int @@ -1999,7 +1987,7 @@ dissect_dstopts(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { col_append_sep_str(pinfo->cinfo, COL_INFO, " , ", "IPv6 destination options"); - return dissect_opts(tvb, 0, tree, pinfo, (ws_ip *)data, proto_ipv6_dstopts); + return dissect_opts(tvb, 0, tree, pinfo, (ws_ip6 *)data, proto_ipv6_dstopts); } /* return value is > G_MAXUINT16, else zero */ @@ -2198,8 +2186,7 @@ dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ gboolean save_fragmented; ipv6_pinfo_t *ipv6_pinfo; int version; - ws_ip *iph; - struct ws_ip6_hdr *ip6_hdr; + ws_ip6 *iph; offset = 0; @@ -2320,9 +2307,6 @@ dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ } #endif - ip6_hdr = (struct ws_ip6_hdr *)tvb_memdup(wmem_packet_scope(), tvb, offset, IPv6_HDR_SIZE); - tap_queue_packet(ip6_hdr_tap, pinfo, ip6_hdr); - /* Increment offset to point to next header (may be an extension header) */ offset += IPv6_HDR_SIZE; @@ -2347,15 +2331,15 @@ dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ } /* Fill in IP header fields for subdissectors */ - iph = wmem_new0(wmem_packet_scope(), ws_ip); - iph->ip_ver = 6; - iph->ip_tos = ip6_tcls; - iph->ip_flw = ip6_flow; - iph->ip_len = plen; - iph->ip_nxt = ip6_nxt; - iph->ip_ttl = ip6_hlim; - alloc_address_wmem_ipv6(wmem_packet_scope(), &iph->ip_src, ip6_src); - alloc_address_wmem_ipv6(wmem_packet_scope(), &iph->ip_dst, ip6_dst); + iph = wmem_new0(wmem_packet_scope(), ws_ip6); + iph->ip6_ver = 6; + iph->ip6_tc = ip6_tcls; + iph->ip6_flw = ip6_flow; + iph->ip6_len = plen; + iph->ip6_nxt = ip6_nxt; + iph->ip6_hop = ip6_hlim; + alloc_address_wmem_ipv6(wmem_packet_scope(), &iph->ip6_src, ip6_src); + alloc_address_wmem_ipv6(wmem_packet_scope(), &iph->ip6_dst, ip6_dst); /* Adjust the length of this tvbuff to include only the IPv6 datagram. */ set_actual_length(tvb, IPv6_HDR_SIZE + plen); @@ -2371,7 +2355,7 @@ dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ } void -ipv6_dissect_next(guint nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip *iph) +ipv6_dissect_next(guint nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip6 *iph) { dissector_handle_t nxt_handle; ipv6_pinfo_t *ipv6_pinfo = p_get_ipv6_pinfo(pinfo); @@ -2405,9 +2389,9 @@ ipv6_dissect_next(guint nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ipv6_pinfo->ipv6_tree = NULL; } - if (iph != NULL && iph->ip_ver == 6) { - iph->ip_nxt = nxt; /* upper-layer protocol more useful */ - tap_queue_packet(ipv6_ws_tap, pinfo, iph); + if (iph != NULL && iph->ip6_ver == 6) { + iph->ip6_nxt = nxt; /* upper-layer protocol more useful */ + tap_queue_packet(ipv6_tap, pinfo, iph); } if (nxt == IP_PROTO_NONE) { @@ -3515,8 +3499,7 @@ proto_register_ipv6(void) ipv6_handle = register_dissector("ipv6", dissect_ipv6, proto_ipv6); reassembly_table_register(&ipv6_reassembly_table, &addresses_reassembly_table_functions); - ip6_hdr_tap = register_tap("ipv6"); - ipv6_ws_tap = register_tap("ipv6_ws"); + ipv6_tap = register_tap("ipv6"); register_decode_as(&ipv6_da); register_decode_as(&ipv6_hopopts_da); diff --git a/epan/dissectors/packet-ipv6.h b/epan/dissectors/packet-ipv6.h deleted file mode 100644 index a9f8f02f6b..0000000000 --- a/epan/dissectors/packet-ipv6.h +++ /dev/null @@ -1,68 +0,0 @@ -/* packet-ipv6.h - * Definitions for IPv6 packet disassembly - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __PACKET_IPV6_H_DEFINED__ -#define __PACKET_IPV6_H_DEFINED__ - -#include -#include "packet-ip.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef ws_ip ipv6_ws_tap_info_t; - -/* Packet info for shared state between IPv6 header and extensions */ -typedef struct { - guint32 jumbo_plen; - guint16 ip6_plen; - gint frag_plen; - proto_tree *ipv6_tree; - gint ipv6_item_len; -} ipv6_pinfo_t; - -ipv6_pinfo_t *p_get_ipv6_pinfo(packet_info *pinfo); - -ipv6_pinfo_t *p_update_ipv6_pinfo(packet_info *pinfo, proto_tree **tree_ptr, gint hdr_len); - -void ipv6_dissect_next(guint nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip *iph); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __PACKET_IPV6_H_DEFINED__ */ - -/* - * Editor modelines - * - * Local Variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * ex: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/epan/dissectors/packet-mip6.c b/epan/dissectors/packet-mip6.c index 81cc2a49f0..00deaad81e 100644 --- a/epan/dissectors/packet-mip6.c +++ b/epan/dissectors/packet-mip6.c @@ -66,7 +66,7 @@ #include "packet-e164.h" #include "packet-e212.h" #include "packet-gsm_a_common.h" -#include "packet-ipv6.h" +#include "packet-ip.h" void proto_register_mip6(void); void proto_reg_handoff_mip6(void); @@ -3944,13 +3944,13 @@ dissect_mip6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) if ((type == MIP6_FNA) && (pproto == IP_PROTO_IPV6)) { col_set_str(pinfo->cinfo, COL_INFO, "Fast Neighbor Advertisement[Fast Binding Update]"); next_tvb = tvb_new_subset_remaining(tvb, len + 8); - ipv6_dissect_next(pproto, next_tvb, pinfo, tree, (ws_ip *)data); + ipv6_dissect_next(pproto, next_tvb, pinfo, tree, (ws_ip6 *)data); } if ((type == MIP6_FBACK) && (pproto == IP_PROTO_AH)) { col_set_str(pinfo->cinfo, COL_INFO, "Fast Binding Acknowledgment"); next_tvb = tvb_new_subset_remaining(tvb, len + offset); - ipv6_dissect_next(pproto, next_tvb, pinfo, tree, (ws_ip *)data); + ipv6_dissect_next(pproto, next_tvb, pinfo, tree, (ws_ip6 *)data); } return tvb_captured_length(tvb); diff --git a/epan/dissectors/packet-null.c b/epan/dissectors/packet-null.c index 647acc0487..c9bbe7b7dd 100644 --- a/epan/dissectors/packet-null.c +++ b/epan/dissectors/packet-null.c @@ -29,7 +29,6 @@ #include #include #include "packet-ip.h" -#include "packet-ipv6.h" #include "packet-ppp.h" #include #include diff --git a/epan/dissectors/packet-shim6.c b/epan/dissectors/packet-shim6.c index 6216e09efd..00c9ed6414 100644 --- a/epan/dissectors/packet-shim6.c +++ b/epan/dissectors/packet-shim6.c @@ -31,7 +31,7 @@ #include #include -#include "packet-ipv6.h" +#include "packet-ip.h" void proto_register_shim6(void); void proto_reg_handoff_shim6(void); @@ -639,7 +639,7 @@ dissect_shim6(tvbuff_t *tvb, packet_info * pinfo, proto_tree *tree, void* data) } next_tvb = tvb_new_subset_remaining(tvb, len); - ipv6_dissect_next(shim.ip6s_nxt, next_tvb, pinfo, tree, (ws_ip *)data); + ipv6_dissect_next(shim.ip6s_nxt, next_tvb, pinfo, tree, (ws_ip6 *)data); return tvb_captured_length(tvb); } diff --git a/epan/dissectors/packet-stt.c b/epan/dissectors/packet-stt.c index 2e9fe84ada..48ef84ab8d 100644 --- a/epan/dissectors/packet-stt.c +++ b/epan/dissectors/packet-stt.c @@ -524,12 +524,10 @@ dissect_stt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) static gboolean dissect_stt_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - void *data) + void *iph) { - ws_ip *iph = (ws_ip*)data; - /* Make sure we at least have a TCP header */ - if (iph == NULL || iph->ip_nxt != IP_PROTO_TCP || + if (ws_ip_protocol(iph) != IP_PROTO_TCP || tvb_captured_length(tvb) < STT_TCP_HDR_LEN) { return FALSE; } diff --git a/epan/dissectors/packet-tapa.c b/epan/dissectors/packet-tapa.c index 67b9ebbb9b..9609f85d05 100644 --- a/epan/dissectors/packet-tapa.c +++ b/epan/dissectors/packet-tapa.c @@ -476,14 +476,12 @@ dissect_tapa_static(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d /* heuristic dissector */ static gboolean -dissect_tapa_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) +dissect_tapa_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *iph) { - ws_ip *iph = (ws_ip*)data; - /* The TAPA protocol also uses IP protocol number 4 but it isn't really IPIP */ - if (iph && (iph->ip_nxt == IP_PROTO_IPIP) && ((tvb_get_guint8(tvb, 0) & 0xF0) != 0x40) && + if ((ws_ip_protocol(iph) == IP_PROTO_IPIP) && ((tvb_get_guint8(tvb, 0) & 0xF0) != 0x40) && (tvb_get_ntohs(tvb, 2)) < 20) { - dissect_tapa_static(tvb, pinfo, tree, data); + dissect_tapa_static(tvb, pinfo, tree, iph); return TRUE; } diff --git a/epan/wslua/taps b/epan/wslua/taps index d418896062..745410499a 100644 --- a/epan/wslua/taps +++ b/epan/wslua/taps @@ -30,7 +30,7 @@ #frame ../dissectors/packet_frame.h void -ip ../dissectors/packet-ip.h ws_ip +ip ../dissectors/packet-ip.h ws_ip4 udp ../dissectors/packet-udp.h e_udphdr http ../dissectors/packet-http.h http_info_value_t # BACnet statistics -- cgit v1.2.3