diff options
28 files changed, 199 insertions, 236 deletions
diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index f378a5471c..ebd9e2decf 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -1605,7 +1605,6 @@ DISSECTOR_INCLUDES = \ packet-ndps.h \ packet-netbios.h \ packet-netlink.h \ - packet-netrom.h \ packet-nfs.h \ packet-nisplus.h \ packet-nlm.h \ diff --git a/epan/dissectors/packet-arcnet.c b/epan/dissectors/packet-arcnet.c index 7749aee0e3..403d8a6e07 100644 --- a/epan/dissectors/packet-arcnet.c +++ b/epan/dissectors/packet-arcnet.c @@ -30,6 +30,7 @@ #include <epan/arcnet_pids.h> #include <epan/to_str.h> #include "packet-ip.h" +#include "packet-arp.h" void proto_register_arcnet(void); void proto_reg_handoff_arcnet(void); @@ -139,7 +140,7 @@ capture_arcnet_common(const guchar *pd, int offset, int len, packet_counts *ld, /* * XXX - do we have to worry about fragmentation for ARP? */ - ld->arp++; + capture_arp(pd, offset + 1, len, ld, pseudo_header); break; case ARCNET_PROTO_IPX: diff --git a/epan/dissectors/packet-arp.c b/epan/dissectors/packet-arp.c index 2df7ec2a8e..bf313821f7 100644 --- a/epan/dissectors/packet-arp.c +++ b/epan/dissectors/packet-arp.c @@ -2022,6 +2022,7 @@ proto_reg_handoff_arp(void) dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_RARP_1201, arp_handle); dissector_add_uint("ax25.pid", AX25_P_ARP, arp_handle); register_capture_dissector("ethertype", ETHERTYPE_ARP, capture_arp, proto_arp); + register_capture_dissector("ax25.pid", AX25_P_ARP, capture_arp, proto_arp); } /* diff --git a/epan/dissectors/packet-arp.h b/epan/dissectors/packet-arp.h index e7a386e276..b686cac7a8 100644 --- a/epan/dissectors/packet-arp.h +++ b/epan/dissectors/packet-arp.h @@ -27,6 +27,7 @@ const gchar *tvb_arphrdaddr_to_str(tvbuff_t *tvb, gint offset, int ad_len, guint16 type); void dissect_atm_nsap(tvbuff_t *tvb, packet_info* pinfo, int offset, int len, proto_tree *tree); +gboolean capture_arp(const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header); extern const value_string arp_hrd_vals[]; diff --git a/epan/dissectors/packet-atm.c b/epan/dissectors/packet-atm.c index ece373ceff..acddf5bde2 100644 --- a/epan/dissectors/packet-atm.c +++ b/epan/dissectors/packet-atm.c @@ -668,20 +668,7 @@ capture_lane(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header) { /* Is it LE Control, 802.3, 802.5, or "none of the above"? */ - switch (pseudo_header->atm.subtype) { - - case TRAF_ST_LANE_802_3: - case TRAF_ST_LANE_802_3_MC: - /* Dissect as Ethernet */ - return capture_eth(pd, 2, len, ld, pseudo_header); - - case TRAF_ST_LANE_802_5: - case TRAF_ST_LANE_802_5_MC: - /* Dissect as Token-Ring */ - return capture_tr(pd, 2, len, ld, pseudo_header); - } - - return FALSE; + return try_capture_dissector("atm_lane", pseudo_header->atm.subtype, pd, 2, len, ld, pseudo_header); } static int @@ -806,17 +793,7 @@ capture_atm(const guchar *pd, int offset _U_, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header) { if (pseudo_header->atm.aal == AAL_5) { - switch (pseudo_header->atm.type) { - - case TRAF_LLCMX: - /* Dissect as WTAP_ENCAP_ATM_RFC1483 */ - /* The ATM iptrace capture that we have shows LLC at this point, - * so that's what I'm calling */ - return capture_llc(pd, 0, len, ld, pseudo_header); - - case TRAF_LANE: - return capture_lane(pd, offset, len, ld, pseudo_header); - } + return try_capture_dissector("atm.aal5.type", pseudo_header->atm.type, pd, offset, len, ld, pseudo_header); } return FALSE; } @@ -1991,6 +1968,9 @@ proto_register_atm(void) atm_type_aal2_table = register_dissector_table("atm.aal2.type", "ATM AAL_2 type subdissector", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE); atm_type_aal5_table = register_dissector_table("atm.aal5.type", "ATM AAL_5 type subdissector", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE); + register_capture_dissector_table("atm.aal5.type", "ATM AAL_5"); + register_capture_dissector_table("atm_lane", "ATM LAN Emulation"); + atm_handle = register_dissector("atm_truncated", dissect_atm_truncated, proto_atm); register_dissector("atm_pw_truncated", dissect_atm_pw_truncated, proto_atm); atm_untruncated_handle = register_dissector("atm_untruncated", dissect_atm_untruncated, proto_atm); @@ -2033,6 +2013,7 @@ proto_reg_handoff_atm(void) dissector_add_uint("wtap_encap", WTAP_ENCAP_ATM_PDUS_UNTRUNCATED, atm_untruncated_handle); register_capture_dissector("wtap_encap", WTAP_ENCAP_ATM_PDUS, capture_atm, proto_atm); + register_capture_dissector("atm.aal5.type", TRAF_LANE, capture_lane, proto_atm_lane); } /* diff --git a/epan/dissectors/packet-ax25.c b/epan/dissectors/packet-ax25.c index 03d28b09f3..c5f3885e54 100644 --- a/epan/dissectors/packet-ax25.c +++ b/epan/dissectors/packet-ax25.c @@ -51,9 +51,7 @@ #include <epan/xdlc.h> #include <epan/ax25_pids.h> #include <epan/ipproto.h> -#include "packet-ip.h" #include "packet-ax25.h" -#include "packet-netrom.h" #define STRLEN 80 @@ -279,16 +277,7 @@ capture_ax25( const guchar *pd, int offset, int len, packet_counts *ld, const un pid = pd[ l_offset ]; l_offset += 1; /* step over the pid and point to the first byte of the payload */ - switch ( pid & 0x0ff ) - { - case AX25_P_NETROM : - return capture_netrom( pd, l_offset, len, ld, pseudo_header ); - case AX25_P_IP : - return capture_ip( pd, l_offset, len, ld, pseudo_header ); - case AX25_P_ARP : - ld->arp++; - return TRUE; - } + return try_capture_dissector("ax25.pid", pid & 0x0ff, pd, l_offset, len, ld, pseudo_header); } return FALSE; } @@ -430,6 +419,7 @@ proto_register_ax25(void) /* Register dissector table for protocol IDs */ ax25_dissector_table = register_dissector_table("ax25.pid", "AX.25 protocol ID", FT_UINT8, BASE_HEX, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE); + register_capture_dissector_table("ax25.pid", "AX.25"); } void diff --git a/epan/dissectors/packet-clip.c b/epan/dissectors/packet-clip.c index 634ff224b0..50b0d53777 100644 --- a/epan/dissectors/packet-clip.c +++ b/epan/dissectors/packet-clip.c @@ -43,12 +43,6 @@ static expert_field ei_no_link_info = EI_INIT; static dissector_handle_t ip_handle; -static gboolean -capture_clip( const guchar *pd, int offset, int len, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_ ) { - - return capture_ip(pd, offset, len, ld, pseudo_header); -} - static int dissect_clip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { @@ -125,7 +119,7 @@ proto_reg_handoff_clip(void) /* XXX - no protocol, can't be disabled */ dissector_add_uint("wtap_encap", WTAP_ENCAP_LINUX_ATM_CLIP, clip_handle); - register_capture_dissector("wtap_encap", WTAP_ENCAP_LINUX_ATM_CLIP, capture_clip, proto_clip); + register_capture_dissector("wtap_encap", WTAP_ENCAP_LINUX_ATM_CLIP, capture_ip, proto_clip); } /* diff --git a/epan/dissectors/packet-enc.c b/epan/dissectors/packet-enc.c index 029fd2baad..63d6490527 100644 --- a/epan/dissectors/packet-enc.c +++ b/epan/dissectors/packet-enc.c @@ -27,20 +27,12 @@ #include <epan/packet.h> #include <epan/capture_dissectors.h> -#include <epan/addr_resolv.h> #include <epan/aftypes.h> #include <wsutil/pint.h> -#include "packet-ip.h" -#include "packet-ipv6.h" void proto_register_enc(void); void proto_reg_handoff_enc(void); -#ifndef offsetof -/* Can't trust stddef.h to be there for us */ -# define offsetof(type, member) ((size_t)(&((type *)0)->member)) -#endif - /* The header in OpenBSD Encapsulating Interface files. */ struct enchdr { @@ -48,14 +40,15 @@ struct enchdr { guint32 spi; guint32 flags; }; -#define BSD_ENC_HDRLEN sizeof(struct enchdr) +#define BSD_ENC_HDRLEN 12 -# define BSD_ENC_M_CONF 0x0400 /* payload encrypted */ -# define BSD_ENC_M_AUTH 0x0800 /* payload authenticated */ -# define BSD_ENC_M_COMP 0x1000 /* payload compressed */ -# define BSD_ENC_M_AUTH_AH 0x2000 /* header authenticated */ +#define BSD_ENC_M_CONF 0x0400 /* payload encrypted */ +#define BSD_ENC_M_AUTH 0x0800 /* payload authenticated */ +#define BSD_ENC_M_COMP 0x1000 /* payload compressed */ +#define BSD_ENC_M_AUTH_AH 0x2000 /* header authenticated */ -static dissector_handle_t data_handle, ip_handle, ipv6_handle; +static dissector_table_t enc_dissector_table; +static dissector_handle_t data_handle; /* header fields */ static int proto_enc = -1; @@ -70,20 +63,11 @@ capture_enc(const guchar *pd, int offset _U_, int len, packet_counts *ld, const { guint32 af; - if (!BYTES_ARE_IN_FRAME(0, len, (int)BSD_ENC_HDRLEN)) + if (!BYTES_ARE_IN_FRAME(0, len, BSD_ENC_HDRLEN)) return FALSE; - af = pntoh32(pd + offsetof(struct enchdr, af)); - switch (af) { - - case BSD_AF_INET: - return capture_ip(pd, BSD_ENC_HDRLEN, len, ld, pseudo_header); - - case BSD_AF_INET6_BSD: - return capture_ipv6(pd, BSD_ENC_HDRLEN, len, ld, pseudo_header); - } - - return FALSE; + af = pntoh32(pd); + return try_capture_dissector("enc", af, pd, BSD_ENC_HDRLEN, len, ld, pseudo_header); } static const value_string af_vals[] = { @@ -124,34 +108,16 @@ dissect_enc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) ); enc_tree = proto_item_add_subtree(ti, ett_enc); - proto_tree_add_uint(enc_tree, hf_enc_af, tvb, - offsetof(struct enchdr, af), sizeof(ench.af), - ench.af); - proto_tree_add_uint(enc_tree, hf_enc_spi, tvb, - offsetof(struct enchdr, spi), sizeof(ench.spi), - ench.spi); - proto_tree_add_uint(enc_tree, hf_enc_flags, tvb, - offsetof(struct enchdr, flags), sizeof(ench.flags), - ench.flags); + proto_tree_add_item(enc_tree, hf_enc_af, tvb, 0, 4, ENC_BIG_ENDIAN); + proto_tree_add_item(enc_tree, hf_enc_spi, tvb, 4, 4, ENC_BIG_ENDIAN); + proto_tree_add_item(enc_tree, hf_enc_flags, tvb, 8, 4, ENC_BIG_ENDIAN); } /* Set the tvbuff for the payload after the header */ next_tvb = tvb_new_subset_remaining(tvb, BSD_ENC_HDRLEN); - - switch (ench.af) { - - case BSD_AF_INET: - call_dissector(ip_handle, next_tvb, pinfo, tree); - break; - - case BSD_AF_INET6_BSD: - call_dissector(ipv6_handle, next_tvb, pinfo, tree); - break; - - default: + if (!dissector_try_uint(enc_dissector_table, ench.af, next_tvb, pinfo, tree)) call_dissector(data_handle, next_tvb, pinfo, tree); - break; - } + return tvb_captured_length(tvb); } @@ -175,6 +141,9 @@ proto_register_enc(void) "ENC", "enc"); proto_register_field_array(proto_enc, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + + enc_dissector_table = register_dissector_table("enc", "OpenBSD Encapsulating device", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE); + register_capture_dissector_table("enc", "ENC"); } void @@ -182,8 +151,6 @@ proto_reg_handoff_enc(void) { dissector_handle_t enc_handle; - ip_handle = find_dissector("ip"); - ipv6_handle = find_dissector("ipv6"); data_handle = find_dissector("data"); enc_handle = create_dissector_handle(dissect_enc, proto_enc); diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c index 390bb0b783..8f5735b650 100644 --- a/epan/dissectors/packet-eth.c +++ b/epan/dissectors/packet-eth.c @@ -1052,6 +1052,10 @@ proto_reg_handoff_eth(void) dissector_add_for_decode_as("pcli.payload", eth_withoutfcs_handle); register_capture_dissector("wtap_encap", WTAP_ENCAP_ETHERNET, capture_eth, proto_eth); + register_capture_dissector("atm_lane", TRAF_ST_LANE_802_3, capture_eth, proto_eth); + register_capture_dissector("atm_lane", TRAF_ST_LANE_802_3_MC, capture_eth, proto_eth); + register_capture_dissector("ppi", 1 /* DLT_EN10MB */, capture_eth, proto_eth); + register_capture_dissector("sll.ltype", LINUX_SLL_P_ETHERNET, capture_eth, proto_eth); } /* diff --git a/epan/dissectors/packet-gre.c b/epan/dissectors/packet-gre.c index ea2a44105a..a7a20936d1 100644 --- a/epan/dissectors/packet-gre.c +++ b/epan/dissectors/packet-gre.c @@ -24,6 +24,7 @@ #include "config.h" #include <epan/packet.h> +#include <epan/capture_dissectors.h> #include <epan/etypes.h> #include <epan/in_cksum.h> #include <epan/expert.h> @@ -310,6 +311,13 @@ dissect_gre_wccp2_redirect_header(tvbuff_t *tvb, int offset, proto_tree *tree) proto_tree_add_item(rh_tree, hf_gre_wccp_primary_bucket, tvb, offset +3, 1, ENC_BIG_ENDIAN); } +static gboolean +capture_gre(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) +{ + ld->gre++; + return TRUE; +} + static int dissect_gre(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { @@ -747,6 +755,8 @@ proto_reg_handoff_gre(void) gre_handle = create_dissector_handle(dissect_gre, proto_gre); dissector_add_uint("ip.proto", IP_PROTO_GRE, gre_handle); + register_capture_dissector("ip.proto", IP_PROTO_GRE, capture_gre, proto_gre); + register_capture_dissector("ipv6.nxt", IP_PROTO_GRE, capture_gre, proto_gre); data_handle = find_dissector("data"); } diff --git a/epan/dissectors/packet-icmp.c b/epan/dissectors/packet-icmp.c index e5d46039d1..e523be9424 100644 --- a/epan/dissectors/packet-icmp.c +++ b/epan/dissectors/packet-icmp.c @@ -41,6 +41,7 @@ #include <epan/conversation.h> #include <epan/tap.h> #include <epan/ipproto.h> +#include <epan/capture_dissectors.h> #include "packet-ip.h" #include "packet-icmp.h" @@ -1163,6 +1164,13 @@ get_best_guess_mstimeofday(tvbuff_t * tvb, gint offset, guint32 comp_ts) return le_ts; } /* get_best_guess_mstimeofday() */ +static gboolean +capture_icmp(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) +{ + ld->icmp++; + return TRUE; +} + /* * RFC 792 for basic ICMP. * RFC 1191 for ICMP_FRAG_NEEDED (with MTU of next hop). @@ -2043,6 +2051,8 @@ void proto_reg_handoff_icmp(void) data_handle = find_dissector("data"); dissector_add_uint("ip.proto", IP_PROTO_ICMP, icmp_handle); + register_capture_dissector("ip.proto", IP_PROTO_ICMP, capture_icmp, proto_icmp); + register_capture_dissector("ipv6.nxt", IP_PROTO_ICMP, capture_icmp, proto_icmp); } /* diff --git a/epan/dissectors/packet-icmpv6.c b/epan/dissectors/packet-icmpv6.c index 2cf3a2c92b..7cd6dae472 100644 --- a/epan/dissectors/packet-icmpv6.c +++ b/epan/dissectors/packet-icmpv6.c @@ -43,6 +43,7 @@ #include <epan/expert.h> #include <epan/conversation.h> #include <epan/tap.h> +#include <epan/capture_dissectors.h> #include "packet-ber.h" #include "packet-dns.h" @@ -3450,6 +3451,12 @@ dissect_mldrv2( tvbuff_t *tvb, guint32 offset, packet_info *pinfo _U_, proto_tre return mldr_offset; } +static gboolean +capture_icmpv6(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) +{ + ld->icmp++; + return TRUE; +} static int dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) @@ -5356,6 +5363,8 @@ void proto_reg_handoff_icmpv6(void) { dissector_add_uint("ip.proto", IP_PROTO_ICMPV6, icmpv6_handle); + register_capture_dissector("ip.proto", IP_PROTO_ICMPV6, capture_icmpv6, proto_icmpv6); + register_capture_dissector("ipv6.nxt", IP_PROTO_ICMPV6, capture_icmpv6, proto_icmpv6); /* * Get a handle for the IPv6 dissector. diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index 1cd76a9e9e..be7dbc2774 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -27294,6 +27294,7 @@ proto_reg_handoff_ieee80211(void) register_capture_dissector("wtap_encap", WTAP_ENCAP_IEEE_802_11, capture_ieee80211, proto_wlan); register_capture_dissector("wtap_encap", WTAP_ENCAP_IEEE_802_11_WITH_RADIO, capture_ieee80211, proto_wlan); + register_capture_dissector("ppi", 105 /* DLT_DLT_IEEE802_11 */, capture_ieee80211, proto_wlan); /* Register handoff to Aruba GRE */ dissector_add_uint("gre.proto", GRE_ARUBA_8200, ieee80211_handle); diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index 77debead48..31e8b0a410 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -572,36 +572,7 @@ capture_ip(const guchar *pd, int offset, int len, packet_counts *ld, const union if (!BYTES_ARE_IN_FRAME(offset, len, IPH_MIN_LEN)) return FALSE; - switch (pd[offset + 9]) { - case IP_PROTO_TCP: - ld->tcp++; - break; - case IP_PROTO_UDP: - case IP_PROTO_UDPLITE: - ld->udp++; - break; - case IP_PROTO_ICMP: - case IP_PROTO_ICMPV6: /* XXX - separate counters? */ - ld->icmp++; - break; - case IP_PROTO_SCTP: - ld->sctp++; - break; - case IP_PROTO_OSPF: - ld->ospf++; - break; - case IP_PROTO_GRE: - ld->gre++; - break; - case IP_PROTO_VINES: - ld->vines++; - break; - default: - ld->other++; - } - - /* We're incrementing "other", so consider this our packet */ - return TRUE; + return try_capture_dissector("ip.proto", pd[offset + 9], pd, offset+IPH_MIN_LEN, len, ld, pseudo_header); } #ifdef HAVE_GEOIP @@ -3135,6 +3106,7 @@ proto_register_ip(void) ip_dissector_table = register_dissector_table("ip.proto", "IP protocol", FT_UINT8, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE); heur_subdissector_list = register_heur_dissector_list("ip"); + register_capture_dissector_table("ip.proto", "IP protocol"); /* Register configuration options */ ip_module = prefs_register_protocol(proto_ip, NULL); @@ -3216,9 +3188,13 @@ proto_reg_handoff_ip(void) dissector_add_for_decode_as("udp.port", ip_handle); dissector_add_for_decode_as("pcli.payload", ip_handle); dissector_add_uint("wtap_encap", WTAP_ENCAP_RAW_IP4, ip_handle); + dissector_add_uint("enc", BSD_AF_INET, ip_handle); heur_dissector_add("tipc", dissect_ip_heur, "IP over TIPC", "ip_tipc", proto_ip, HEURISTIC_ENABLE); register_capture_dissector("ethertype", ETHERTYPE_IP, capture_ip, proto_ip); + register_capture_dissector("ax25.pid", AX25_P_IP, capture_ip, proto_ip); + register_capture_dissector("enc", BSD_AF_INET, capture_ip, proto_ip); + register_capture_dissector("ppp_hdlc", PPP_IP, capture_ip, proto_ip); } /* diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c index 3a0048fdcb..f98afc51c0 100644 --- a/epan/dissectors/packet-ipv6.c +++ b/epan/dissectors/packet-ipv6.c @@ -587,34 +587,7 @@ again: goto again; } - switch(nxt) { - case IP_PROTO_SCTP: - ld->sctp++; - break; - case IP_PROTO_TCP: - ld->tcp++; - break; - case IP_PROTO_UDP: - case IP_PROTO_UDPLITE: - ld->udp++; - break; - case IP_PROTO_ICMP: - case IP_PROTO_ICMPV6: /* XXX - separate counters? */ - ld->icmp++; - break; - case IP_PROTO_OSPF: - ld->ospf++; - break; - case IP_PROTO_GRE: - ld->gre++; - break; - case IP_PROTO_VINES: - ld->vines++; - break; - default: - return FALSE; - } - return TRUE; + return try_capture_dissector("ipv6.nxt", nxt, pd, offset, len, ld, pseudo_header); } /** @@ -3473,6 +3446,7 @@ proto_register_ipv6(void) proto_register_field_array(proto_ipv6_dstopts, hf_ipv6_dstopts, array_length(hf_ipv6_dstopts)); ipv6_next_header_dissector_table = register_dissector_table("ipv6.nxt", "IPv6 Next Header", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE); + register_capture_dissector_table("ipv6.nxt", "IPv6 Next Header"); /* Register configuration options */ ipv6_module = prefs_register_protocol(proto_ipv6, NULL); @@ -3547,6 +3521,7 @@ proto_reg_handoff_ipv6(void) dissector_add_uint("pwach.channel_type", 0x57, ipv6_handle); /* IPv6, RFC4385 clause 6. */ dissector_add_uint("sflow_245.header_protocol", SFLOW_245_HEADER_IPv6, ipv6_handle); dissector_add_uint("wtap_encap", WTAP_ENCAP_RAW_IP6, ipv6_handle); + dissector_add_uint("enc", BSD_AF_INET6_BSD, ipv6_handle); dissector_add_for_decode_as("udp.port", ipv6_handle); @@ -3561,6 +3536,7 @@ proto_reg_handoff_ipv6(void) ip_dissector_table = find_dissector_table("ip.proto"); register_capture_dissector("ethertype", ETHERTYPE_IPv6, capture_ipv6, proto_ipv6); + register_capture_dissector("enc", BSD_AF_INET6_BSD, capture_ipv6, proto_ipv6); } /* diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c index 3e6940cf40..a5df01db1d 100644 --- a/epan/dissectors/packet-ipx.c +++ b/epan/dissectors/packet-ipx.c @@ -1625,6 +1625,8 @@ proto_reg_handoff_ipx(void) dissector_add_uint("ipx.socket", IPX_SOCKET_IPX_MESSAGE1, ipxmsg_handle); register_capture_dissector("ethertype", ETHERTYPE_IPX, capture_ipx, proto_ipx); + register_capture_dissector("ppp_hdlc", PPP_IPX, capture_ipx, proto_ipx); + register_capture_dissector("sll.ltype", LINUX_SLL_P_802_3, capture_ipx, proto_ipx); data_handle = find_dissector("data"); } diff --git a/epan/dissectors/packet-llc.c b/epan/dissectors/packet-llc.c index 0c226894bc..9f4d0e47ec 100644 --- a/epan/dissectors/packet-llc.c +++ b/epan/dissectors/packet-llc.c @@ -928,6 +928,8 @@ proto_reg_handoff_llc(void) dissector_add_uint("juniper.proto", JUNIPER_PROTO_LLC_SNAP, llc_handle); register_capture_dissector("ethertype", ETHERTYPE_JUMBO_LLC, capture_llc, proto_llc); + register_capture_dissector("atm.aal5.type", TRAF_LLCMX, capture_llc, proto_llc); + register_capture_dissector("sll.ltype", LINUX_SLL_P_802_2, capture_llc, proto_llc); /* * Register all the fields for PIDs for various OUIs. diff --git a/epan/dissectors/packet-netrom.c b/epan/dissectors/packet-netrom.c index 6c34abac05..d15d27ee99 100644 --- a/epan/dissectors/packet-netrom.c +++ b/epan/dissectors/packet-netrom.c @@ -45,10 +45,9 @@ #include <epan/packet.h> #include <epan/to_str.h> +#include <epan/capture_dissectors.h> #include <epan/ax25_pids.h> -#include "packet-netrom.h" - void proto_register_netrom(void); void proto_reg_handoff_netrom(void); @@ -488,7 +487,7 @@ dissect_netrom(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _ return tvb_captured_length(tvb); } -gboolean +static gboolean capture_netrom( const guchar *pd _U_, int offset, int len, packet_counts *ld _U_, const union wtap_pseudo_header *pseudo_header _U_) { if ( ! BYTES_ARE_IN_FRAME( offset, len, NETROM_MIN_SIZE ) ) @@ -625,6 +624,7 @@ void proto_reg_handoff_netrom(void) { dissector_add_uint( "ax25.pid", AX25_P_NETROM, create_dissector_handle( dissect_netrom, proto_netrom ) ); + register_capture_dissector("ax25.pid", AX25_P_NETROM, capture_netrom, proto_netrom); ip_handle = find_dissector( "ip" ); data_handle = find_dissector( "data" ); diff --git a/epan/dissectors/packet-netrom.h b/epan/dissectors/packet-netrom.h deleted file mode 100644 index c6e8828914..0000000000 --- a/epan/dissectors/packet-netrom.h +++ /dev/null @@ -1,30 +0,0 @@ -/* packet-netrom.h - * - * Routines for Amateur Packet Radio protocol dissection - * Copyright 2005,2006,2007,2008,2009,2010,2012 R.W. Stearn <richard@rns-stearn.demon.co.uk> - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * 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_NETROM_H__ -#define __PACKET_NETROM_H__ - -gboolean capture_netrom(const guchar *, int, int, packet_counts *, const union wtap_pseudo_header *pseudo_header); - -#endif diff --git a/epan/dissectors/packet-ospf.c b/epan/dissectors/packet-ospf.c index 3c4b6d0eac..0e4f359214 100644 --- a/epan/dissectors/packet-ospf.c +++ b/epan/dissectors/packet-ospf.c @@ -64,6 +64,7 @@ #include "config.h" #include <epan/packet.h> +#include <epan/capture_dissectors.h> #include <epan/ipproto.h> #include <epan/in_cksum.h> #include <epan/expert.h> @@ -1038,6 +1039,14 @@ ospf_has_at_block(tvbuff_t *tvb, int offset, guint8 packet_type, guint8 version) return 0; } + +static gboolean +capture_ospf(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) +{ + ld->ospf++; + return TRUE; +} + static int dissect_ospf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { @@ -3794,6 +3803,8 @@ proto_reg_handoff_ospf(void) ospf_handle = create_dissector_handle(dissect_ospf, proto_ospf); dissector_add_uint("ip.proto", IP_PROTO_OSPF, ospf_handle); + register_capture_dissector("ip.proto", IP_PROTO_OSPF, capture_ospf, proto_ospf); + register_capture_dissector("ipv6.nxt", IP_PROTO_OSPF, capture_ospf, proto_ospf); data_handle = find_dissector("data"); } diff --git a/epan/dissectors/packet-ppi.c b/epan/dissectors/packet-ppi.c index 78ca36c363..9275ccbcb0 100644 --- a/epan/dissectors/packet-ppi.c +++ b/epan/dissectors/packet-ppi.c @@ -60,8 +60,6 @@ #include <wiretap/pcap-encap.h> #include "packet-frame.h" -#include "packet-eth.h" -#include "packet-ieee80211.h" /* * Per-Packet Information (PPI) header. @@ -398,15 +396,7 @@ capture_ppi(const guchar *pd, int offset _U_, int len, packet_counts *ld, const dlt = pletoh32(pd+4); - /* XXX - We should probably combine this with capture_info.c:capture_info_packet() */ - switch(dlt) { - case 1: /* DLT_EN10MB */ - return capture_eth(pd, ppi_len, len, ld, pseudo_header); - case 105: /* DLT_DLT_IEEE802_11 */ - return capture_ieee80211(pd, ppi_len, len, ld, pseudo_header); - } - - return FALSE; + return try_capture_dissector("ppi", dlt, pd, ppi_len, len, ld, pseudo_header); } static void @@ -1489,6 +1479,7 @@ proto_register_ppi(void) expert_register_field_array(expert_ppi, ei, array_length(ei)); ppi_handle = register_dissector("ppi", dissect_ppi, proto_ppi); + register_capture_dissector_table("ppi", "PPI"); register_init_routine(ampdu_reassemble_init); register_cleanup_routine(ampdu_reassemble_cleanup); diff --git a/epan/dissectors/packet-ppp.c b/epan/dissectors/packet-ppp.c index 08028e9562..351898c952 100644 --- a/epan/dissectors/packet-ppp.c +++ b/epan/dissectors/packet-ppp.c @@ -1968,16 +1968,7 @@ capture_ppp_hdlc(const guchar *pd, int offset, int len, packet_counts *ld, const if (!BYTES_ARE_IN_FRAME(offset, len, 4)) return FALSE; - switch (pntoh16(&pd[offset + 2])) { - case PPP_IP: - return capture_ip(pd, offset + 4, len, ld, pseudo_header); - case PPP_IPX: - return capture_ipx(pd, offset + 4, len, ld, pseudo_header); - case PPP_VINES: - return capture_vines(pd, offset + 4, len, ld, pseudo_header); - } - - return FALSE; + return try_capture_dissector("ppp_hdlc", pntoh16(&pd[offset + 2]), pd, offset + 4, len, ld, pseudo_header); } static void @@ -5625,6 +5616,8 @@ proto_register_ppp_raw_hdlc(void) "PPP-HDLC", "ppp_hdlc"); proto_register_subtree_array(ett, array_length(ett)); proto_register_field_array(proto_ppp_hdlc, hf, array_length(hf)); + + register_capture_dissector_table("ppp_hdlc", "PPP-HDLC"); } void @@ -5639,6 +5632,7 @@ proto_reg_handoff_ppp_raw_hdlc(void) heur_dissector_add("usb.bulk", dissect_ppp_usb, "PPP USB bulk endpoint", "ppp_usb_bulk", proto_ppp, HEURISTIC_ENABLE); register_capture_dissector("wtap_encap", WTAP_ENCAP_PPP, capture_ppp_hdlc, proto_ppp_hdlc); + register_capture_dissector("sll.ltype", LINUX_SLL_P_PPPHDLC, capture_ppp_hdlc, proto_ppp_hdlc); } /* diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c index 94cc64a8eb..293760c100 100644 --- a/epan/dissectors/packet-sctp.c +++ b/epan/dissectors/packet-sctp.c @@ -53,6 +53,7 @@ #include <epan/packet.h> +#include <epan/capture_dissectors.h> #include <epan/prefs.h> #include <epan/exceptions.h> #include <epan/exported_pdu.h> @@ -4686,6 +4687,13 @@ dissect_sctp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea proto_tree_move_item(sctp_tree, vt, pi); } +static gboolean +capture_sctp(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) +{ + ld->sctp++; + return TRUE; +} + static int dissect_sctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { @@ -5075,6 +5083,8 @@ proto_reg_handoff_sctp(void) dissector_add_uint("wtap_encap", WTAP_ENCAP_SCTP, sctp_handle); dissector_add_uint("ip.proto", IP_PROTO_SCTP, sctp_handle); dissector_add_uint("udp.port", UDP_TUNNELING_PORT, sctp_handle); + register_capture_dissector("ip.proto", IP_PROTO_SCTP, capture_sctp, proto_sctp); + register_capture_dissector("ipv6.nxt", IP_PROTO_SCTP, capture_sctp, proto_sctp); } /* diff --git a/epan/dissectors/packet-sll.c b/epan/dissectors/packet-sll.c index dc1253dcf9..d339064f28 100644 --- a/epan/dissectors/packet-sll.c +++ b/epan/dissectors/packet-sll.c @@ -151,33 +151,7 @@ capture_sll(const guchar *pd, int offset _U_, int len, packet_counts *ld, const * "proto" is *not* a length field, it's a Linux internal * protocol type. */ - switch (protocol) { - - case LINUX_SLL_P_802_2: - /* - * 802.2 LLC. - */ - return capture_llc(pd, len, SLL_HEADER_SIZE, ld, pseudo_header); - - case LINUX_SLL_P_ETHERNET: - /* - * Ethernet. - */ - return capture_eth(pd, SLL_HEADER_SIZE, len, ld, pseudo_header); - - case LINUX_SLL_P_802_3: - /* - * Novell IPX inside 802.3 with no 802.2 LLC - * header. - */ - return capture_ipx(pd, SLL_HEADER_SIZE, len, ld, pseudo_header); - - case LINUX_SLL_P_PPPHDLC: - /* - * PPP HDLC. - */ - return capture_ppp_hdlc(pd, len, SLL_HEADER_SIZE, ld, pseudo_header); - } + return try_capture_dissector("sll.ltype", protocol, pd, SLL_HEADER_SIZE, len, ld, pseudo_header); } else { return try_capture_dissector("ethertype", protocol, pd, SLL_HEADER_SIZE, len, ld, pseudo_header); } @@ -337,6 +311,7 @@ proto_register_sll(void) FT_UINT16, BASE_HEX, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE ); + register_capture_dissector_table("sll.ltype", "Linux SLL protocol"); } void diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 62f5c8c065..89b462e82f 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -24,6 +24,7 @@ #include <stdio.h> #include <epan/packet.h> +#include <epan/capture_dissectors.h> #include <epan/exceptions.h> #include <epan/addr_resolv.h> #include <epan/ipproto.h> @@ -41,6 +42,7 @@ #include <wsutil/utf8_entities.h> #include <wsutil/str_util.h> #include <wsutil/sha1.h> +#include <wsutil/pint.h> #include "packet-tcp.h" #include "packet-ip.h" @@ -4797,6 +4799,39 @@ tcp_flags_to_str_first_letter(const struct tcpheader *tcph) return buf; } +static gboolean +capture_tcp(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) +{ + guint16 src_port, dst_port, low_port, high_port; + + if (!BYTES_ARE_IN_FRAME(offset, len, 4)) + return FALSE; + + ld->tcp++; + + src_port = pntoh16(&pd[offset]); + dst_port = pntoh16(&pd[offset+2]); + + if (src_port > dst_port) { + low_port = dst_port; + high_port = src_port; + } else { + low_port = src_port; + high_port = dst_port; + } + + if (low_port != 0 && + try_capture_dissector("tcp.port", low_port, pd, offset+20, len, ld, pseudo_header)) + return TRUE; + + if (high_port != 0 && + try_capture_dissector("tcp.port", high_port, pd, offset+20, len, ld, pseudo_header)) + return TRUE; + + /* We've at least identified one type of packet, so this shouldn't be "other" */ + return TRUE; +} + static int dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { @@ -6526,6 +6561,8 @@ proto_register_tcp(void) "TCP port", FT_UINT16, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE); heur_subdissector_list = register_heur_dissector_list("tcp"); + register_capture_dissector_table("tcp.port", "TCP"); + /* Register configuration preferences */ tcp_module = prefs_register_protocol(proto_tcp, NULL); prefs_register_bool_preference(tcp_module, "summary_in_tree", @@ -6632,6 +6669,9 @@ proto_reg_handoff_tcp(void) sport_handle = find_dissector("sport"); tcp_tap = register_tap("tcp"); + register_capture_dissector("ip.proto", IP_PROTO_TCP, capture_tcp, proto_tcp); + register_capture_dissector("ipv6.nxt", IP_PROTO_TCP, capture_tcp, proto_tcp); + mptcp_tap = register_tap("mptcp"); } diff --git a/epan/dissectors/packet-tr.c b/epan/dissectors/packet-tr.c index 2227d6ff8e..da93e10c8b 100644 --- a/epan/dissectors/packet-tr.c +++ b/epan/dissectors/packet-tr.c @@ -814,6 +814,8 @@ proto_reg_handoff_tr(void) dissector_add_uint("sflow_245.header_protocol", SFLOW_245_HEADER_TOKENRING, tr_handle); register_capture_dissector("wtap_encap", WTAP_ENCAP_TOKEN_RING, capture_tr, proto_tr); + register_capture_dissector("atm_lane", TRAF_ST_LANE_802_5, capture_tr, proto_tr); + register_capture_dissector("atm_lane", TRAF_ST_LANE_802_5_MC, capture_tr, proto_tr); } /* diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index f85bc460f1..c9adb6195f 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -29,6 +29,7 @@ #include <epan/packet.h> +#include <epan/capture_dissectors.h> #include <epan/addr_resolv.h> #include <epan/ipproto.h> #include <epan/in_cksum.h> @@ -37,6 +38,7 @@ #include <epan/exceptions.h> #include <epan/show_exception.h> #include <wsutil/utf8_entities.h> +#include <wsutil/pint.h> #include "packet-udp.h" @@ -689,6 +691,39 @@ udp_dissect_pdus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, return offset; } +static gboolean +capture_udp(const guchar *pd _U_, int offset _U_, int len _U_, packet_counts *ld, const union wtap_pseudo_header *pseudo_header _U_) +{ + guint16 src_port, dst_port, low_port, high_port; + + if (!BYTES_ARE_IN_FRAME(offset, len, 4)) + return FALSE; + + ld->udp++; + + src_port = pntoh16(&pd[offset]); + dst_port = pntoh16(&pd[offset+2]); + + if (src_port > dst_port) { + low_port = dst_port; + high_port = src_port; + } else { + low_port = src_port; + high_port = dst_port; + } + + if (low_port != 0 && + try_capture_dissector("udp.port", low_port, pd, offset+20, len, ld, pseudo_header)) + return TRUE; + + if (high_port != 0 && + try_capture_dissector("udp.port", high_port, pd, offset+20, len, ld, pseudo_header)) + return TRUE; + + /* We've at least identified one type of packet, so this shouldn't be "other" */ + return TRUE; +} + static void dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto) { @@ -1095,6 +1130,8 @@ proto_register_udp(void) "UDP port", FT_UINT16, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE); heur_subdissector_list = register_heur_dissector_list("udp"); + register_capture_dissector_table("udp.port", "UDP"); + /* Register configuration preferences */ udp_module = prefs_register_protocol(proto_udp, NULL); prefs_register_bool_preference(udp_module, "summary_in_tree", @@ -1138,6 +1175,12 @@ proto_reg_handoff_udp(void) { dissector_add_uint("ip.proto", IP_PROTO_UDP, udp_handle); dissector_add_uint("ip.proto", IP_PROTO_UDPLITE, udplite_handle); + + register_capture_dissector("ip.proto", IP_PROTO_UDP, capture_udp, hfi_udp->id); + register_capture_dissector("ip.proto", IP_PROTO_UDPLITE, capture_udp, hfi_udplite->id); + register_capture_dissector("ipv6.nxt", IP_PROTO_UDP, capture_udp, hfi_udp->id); + register_capture_dissector("ipv6.nxt", IP_PROTO_UDPLITE, capture_udp, hfi_udplite->id); + data_handle = find_dissector("data"); udp_tap = register_tap("udp"); udp_follow_tap = register_tap("udp_follow"); diff --git a/epan/dissectors/packet-vines.c b/epan/dissectors/packet-vines.c index 58cf57d01b..3c7609f607 100644 --- a/epan/dissectors/packet-vines.c +++ b/epan/dissectors/packet-vines.c @@ -2019,6 +2019,9 @@ proto_reg_handoff_vines_icp(void) dissector_add_uint("vines_ip.protocol", VIP_PROTO_ICP, vines_icp_handle); register_capture_dissector("ethertype", ETHERTYPE_VINES_IP, capture_vines, proto_vines_ip); register_capture_dissector("ethertype", ETHERTYPE_VINES_ECHO, capture_vines, proto_vines_echo); + register_capture_dissector("ppp_hdlc", PPP_VINES, capture_vines, proto_vines_echo); + register_capture_dissector("ip.proto", PPP_VINES, capture_vines, proto_vines_echo); + register_capture_dissector("ipv6.nxt", PPP_VINES, capture_vines, proto_vines_echo); } /* |