aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-11-15 20:35:51 -0500
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2014-11-16 13:45:18 +0000
commitf92ed4df2d4720720080d8013da124a0eb956de7 (patch)
tree2b3bf92972a849fe668f121e53e45bfe1b7c6451 /epan/dissectors
parent3b8ed366ddd149f2cc1428a713235c18afc192e7 (diff)
Remove ipproto member of packet_info.
All situations can be handled with "shimmed" dissector functions. Change-Id: Ic85483b32d99d3270b193c9f6b29574d8fad46a8 Reviewed-on: https://code.wireshark.org/review/5327 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/packet-catapult-dct2000.c12
-rw-r--r--epan/dissectors/packet-gsm_ipa.c40
-rw-r--r--epan/dissectors/packet-ip.c7
-rw-r--r--epan/dissectors/packet-ipv6.c8
-rw-r--r--epan/dissectors/packet-opensafety.c19
-rw-r--r--epan/dissectors/packet-rtp.c2
-rw-r--r--epan/dissectors/packet-stun.c22
-rw-r--r--epan/dissectors/packet-t38.c19
8 files changed, 62 insertions, 67 deletions
diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c
index e947d589b4..28307ecce5 100644
--- a/epan/dissectors/packet-catapult-dct2000.c
+++ b/epan/dissectors/packet-catapult-dct2000.c
@@ -2598,16 +2598,6 @@ dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Try to add right stuff to pinfo so conversation stuff works... */
pinfo->ptype = type_of_port;
- switch (type_of_port) {
- case PT_UDP:
- pinfo->ipproto = IP_PROTO_UDP;
- break;
- case PT_TCP:
- pinfo->ipproto = IP_PROTO_TCP;
- break;
- default:
- pinfo->ipproto = IP_PROTO_NONE;
- }
/* Add addresses & ports into ipprim tree.
Also set address info in pinfo for conversations... */
@@ -2764,8 +2754,6 @@ dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Add these SCTPPRIM fields inside an SCTPPRIM subtree */
sctpprim_tree = proto_item_add_subtree(ti_local, ett_catapult_dct2000_sctpprim);
- pinfo->ipproto = IP_PROTO_SCTP;
-
/* Destination address */
if (dest_addr_offset != 0) {
proto_item *addr_ti;
diff --git a/epan/dissectors/packet-gsm_ipa.c b/epan/dissectors/packet-gsm_ipa.c
index 2a1c4681d4..508c78d89b 100644
--- a/epan/dissectors/packet-gsm_ipa.c
+++ b/epan/dissectors/packet-gsm_ipa.c
@@ -78,7 +78,8 @@ void proto_reg_handoff_gsm_ipa(void);
#define IPA_UDP_PORTS "3006"
#define IPA_UDP_PORTS_DEFAULT "0"
-static dissector_handle_t ipa_handle;
+static dissector_handle_t ipa_tcp_handle;
+static dissector_handle_t ipa_udp_handle;
static range_t *global_ipa_tcp_ports = NULL;
static range_t *global_ipa_udp_ports = NULL;
static gboolean global_ipa_in_root = FALSE;
@@ -281,7 +282,7 @@ dissect_osmo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ipatree, proto_tree
/* Code to actually dissect the packets */
static void
-dissect_ipa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+dissect_ipa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_udp)
{
gint remaining;
gint header_length = 3;
@@ -309,7 +310,7 @@ dissect_ipa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* We attempt to detect this by checking if the length from the
* header + four bytes of the IPA header equals the remaining size.
*/
- if ((pinfo->ipproto == IP_PROTO_UDP) && (len + 4 == remaining)) {
+ if (is_udp && (len + 4 == remaining)) {
header_length++;
}
@@ -372,6 +373,18 @@ dissect_ipa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
}
+static void
+dissect_ipa_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ dissect_ipa(tvb, pinfo, tree, FALSE);
+}
+
+static void
+dissect_ipa_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ dissect_ipa(tvb, pinfo, tree, TRUE);
+}
+
void proto_register_ipa(void)
{
module_t *ipa_module;
@@ -433,19 +446,13 @@ void proto_register_ipa(void)
&ett_ipaccess,
};
- proto_ipa =
- proto_register_protocol("GSM over IP protocol as used by ip.access",
- "GSM over IP", "gsm_ipa");
- proto_ipaccess =
- proto_register_protocol("GSM over IP ip.access CCM sub-protocol",
- "IPA", "ipaccess");
+ proto_ipa = proto_register_protocol("GSM over IP protocol as used by ip.access", "GSM over IP", "gsm_ipa");
+ proto_ipaccess = proto_register_protocol("GSM over IP ip.access CCM sub-protocol", "IPA", "ipaccess");
proto_register_field_array(proto_ipa, hf, array_length(hf));
proto_register_field_array(proto_ipaccess, hf_ipa, array_length(hf_ipa));
proto_register_subtree_array(ett, array_length(ett));
- register_dissector("gsm_ipa", dissect_ipa, proto_ipa);
-
/* Register table for subdissectors */
osmo_dissector_table = register_dissector_table("ipa.osmo.protocol",
"GSM over IP ip.access Protocol",
@@ -488,20 +495,21 @@ void proto_reg_handoff_gsm_ipa(void)
sub_handles[SUB_MGCP] = find_dissector("mgcp");
sub_handles[SUB_DATA] = find_dissector("data");
- ipa_handle = create_dissector_handle(dissect_ipa, proto_ipa);
+ ipa_tcp_handle = create_dissector_handle(dissect_ipa_tcp, proto_ipa);
+ ipa_udp_handle = create_dissector_handle(dissect_ipa_udp, proto_ipa);
ipa_initialized = TRUE;
} else {
- dissector_delete_uint_range("tcp.port", ipa_tcp_ports, ipa_handle);
+ dissector_delete_uint_range("tcp.port", ipa_tcp_ports, ipa_tcp_handle);
g_free(ipa_tcp_ports);
- dissector_delete_uint_range("udp.port", ipa_udp_ports, ipa_handle);
+ dissector_delete_uint_range("udp.port", ipa_udp_ports, ipa_udp_handle);
g_free(ipa_udp_ports);
}
ipa_tcp_ports = range_copy(global_ipa_tcp_ports);
ipa_udp_ports = range_copy(global_ipa_udp_ports);
- dissector_add_uint_range("udp.port", ipa_udp_ports, ipa_handle);
- dissector_add_uint_range("tcp.port", ipa_tcp_ports, ipa_handle);
+ dissector_add_uint_range("udp.port", ipa_udp_ports, ipa_udp_handle);
+ dissector_add_uint_range("tcp.port", ipa_tcp_ports, ipa_tcp_handle);
}
/*
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c
index ec081f382c..c34eddb7cd 100644
--- a/epan/dissectors/packet-ip.c
+++ b/epan/dissectors/packet-ip.c
@@ -482,12 +482,13 @@ static dissector_handle_t data_handle;
static void ip_prompt(packet_info *pinfo, gchar* result)
{
- g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "IP protocol %u as", pinfo->ipproto);
+ g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "IP protocol %u as",
+ GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_ip, 0)));
}
static gpointer ip_value(packet_info *pinfo)
{
- return GUINT_TO_POINTER(pinfo->ipproto);
+ return p_get_proto_data(pinfo->pool, pinfo, proto_ip, 0);
}
static const char* ip_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter)
@@ -2336,7 +2337,7 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
IPOPT_EOOL, &IP_OPT_TYPES, &ei_ip_opt_len_invalid, pinfo, field_tree, tf, iph);
}
- pinfo->ipproto = iph->ip_p;
+ p_add_proto_data(pinfo->pool, pinfo, proto_ip, 0, GUINT_TO_POINTER((guint)iph->ip_p));
tap_queue_packet(ip_tap, pinfo, iph);
/* Skip over header + options */
diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c
index 4806040739..9dad84d6d0 100644
--- a/epan/dissectors/packet-ipv6.c
+++ b/epan/dissectors/packet-ipv6.c
@@ -123,6 +123,7 @@ void proto_reg_handoff_ipv6(void);
/* Protocol specific data indices */
#define IPV6_PROTO_NXT_HDR 0
+#define IPV6_PROTO_VALUE 1
static int ipv6_tap = -1;
@@ -342,12 +343,13 @@ static expert_field ei_ipv6_routing_hdr_rpl_segments_ge0 = EI_INIT;
static void ipv6_prompt(packet_info *pinfo, gchar* result)
{
- g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "IP protocol %u as", pinfo->ipproto);
+ g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "IP protocol %u as",
+ GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_ipv6, IPV6_PROTO_VALUE)));
}
static gpointer ipv6_value(packet_info *pinfo)
{
- return GUINT_TO_POINTER(pinfo->ipproto);
+ return p_get_proto_data(pinfo->pool, pinfo, proto_ipv6, IPV6_PROTO_VALUE);
}
static void ipv6_next_header_prompt(packet_info *pinfo, gchar* result)
@@ -2162,7 +2164,7 @@ again:
proto_item_set_len (ipv6_item, offset);
/* collect packet info */
- pinfo->ipproto = nxt;
+ p_add_proto_data(pinfo->pool, pinfo, proto_ipv6, IPV6_PROTO_VALUE, GUINT_TO_POINTER((guint)nxt));
tap_queue_packet(ipv6_tap, pinfo, &ipv6);
if (offlg & IP6F_OFF_MASK || (ipv6_reassemble && offlg & IP6F_MORE_FRAG)) {
diff --git a/epan/dissectors/packet-opensafety.c b/epan/dissectors/packet-opensafety.c
index b26424bc46..47fdeb124e 100644
--- a/epan/dissectors/packet-opensafety.c
+++ b/epan/dissectors/packet-opensafety.c
@@ -2301,6 +2301,15 @@ dissect_opensafety_epl(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tr
return result;
}
+static gboolean
+dissect_opensafety_siii_udp(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ )
+{
+ if ( ! global_enable_siii )
+ return FALSE;
+
+ return opensafety_package_dissector("openSAFETY/SercosIII UDP", "", FALSE, FALSE, 0,
+ message_tvb, pinfo, tree, OPENSAFETY_ACYCLIC_DATA );
+}
static gboolean
dissect_opensafety_siii(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ )
@@ -2311,12 +2320,6 @@ dissect_opensafety_siii(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *t
if ( ! global_enable_siii )
return result;
- if ( pinfo->ipproto == IP_PROTO_UDP )
- {
- return opensafety_package_dissector("openSAFETY/SercosIII UDP", "", FALSE, FALSE, 0,
- message_tvb, pinfo, tree, OPENSAFETY_ACYCLIC_DATA );
- }
-
/* We can assume to have a SercosIII package, as the SercosIII dissector won't detect
* SercosIII-UDP packages, this is most likely SercosIII-over-ethernet */
@@ -2441,7 +2444,7 @@ apply_prefs ( void )
/* Sercos III dissector does not handle UDP transport, has to be handled
* separately, everything else should be caught by the heuristic dissector
*/
- dissector_add_uint("udp.port", opensafety_udp_siii_port_number, find_dissector("opensafety_siii"));
+ dissector_add_uint("udp.port", opensafety_udp_siii_port_number, find_dissector("opensafety_siii_udp"));
}
@@ -2849,7 +2852,7 @@ proto_register_opensafety(void)
/* Registering default and ModBus/TCP dissector */
new_register_dissector("opensafety_udpdata", dissect_opensafety_udpdata, proto_opensafety );
new_register_dissector("opensafety_mbtcp", dissect_opensafety_mbtcp, proto_opensafety );
- new_register_dissector("opensafety_siii", dissect_opensafety_siii, proto_opensafety );
+ new_register_dissector("opensafety_siii_udp", dissect_opensafety_siii_udp, proto_opensafety );
new_register_dissector("opensafety_pnio", dissect_opensafety_pn_io, proto_opensafety);
}
diff --git a/epan/dissectors/packet-rtp.c b/epan/dissectors/packet-rtp.c
index 439190eb4c..c832c0067b 100644
--- a/epan/dissectors/packet-rtp.c
+++ b/epan/dissectors/packet-rtp.c
@@ -3692,7 +3692,7 @@ proto_reg_handoff_rtp(void)
classicstun_handle = find_dissector("classicstun");
classicstun_heur_handle = find_dissector("classicstun-heur");
stun_heur_handle = find_dissector("stun-heur");
- t38_handle = find_dissector("t38");
+ t38_handle = find_dissector("t38_udp");
zrtp_handle = find_dissector("zrtp");
sprt_handle = find_dissector("sprt");
diff --git a/epan/dissectors/packet-stun.c b/epan/dissectors/packet-stun.c
index 2f080b2900..255137f8c1 100644
--- a/epan/dissectors/packet-stun.c
+++ b/epan/dissectors/packet-stun.c
@@ -498,7 +498,7 @@ dissect_stun_message_channel_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree
static int
-dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean heur_check)
+dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean heur_check, gboolean is_udp)
{
guint captured_length;
guint16 msg_type;
@@ -546,7 +546,7 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
/* note that padding is only mandatory over streaming
protocols */
- if (pinfo->ipproto == IP_PROTO_UDP) {
+ if (is_udp) {
if (reported_length != (msg_length + CHANNEL_DATA_HDR_LEN))
return 0;
} else { /* TCP */
@@ -1261,23 +1261,29 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole
}
static int
-dissect_stun(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+dissect_stun_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
- return dissect_stun_message(tvb, pinfo, tree, FALSE);
+ return dissect_stun_message(tvb, pinfo, tree, FALSE, TRUE);
+}
+
+static int
+dissect_stun_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+{
+ return dissect_stun_message(tvb, pinfo, tree, FALSE, FALSE);
}
static int
dissect_stun_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, MIN_HDR_LEN,
- get_stun_message_len, dissect_stun, data);
+ get_stun_message_len, dissect_stun_tcp_pdu, data);
return tvb_reported_length(tvb);
}
static gboolean
dissect_stun_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
- if (dissect_stun_message(tvb, pinfo, tree, TRUE) == 0) {
+ if (dissect_stun_message(tvb, pinfo, tree, TRUE, TRUE) == 0) {
/*
* It wasn't a valid STUN message, and wasn't
* dissected as such.
@@ -1621,7 +1627,7 @@ proto_register_stun(void)
/* heuristic subdissectors (used for the DATA field) */
register_heur_dissector_list("stun", &heur_subdissector_list);
- new_register_dissector("stun-udp", dissect_stun, proto_stun);
+ new_register_dissector("stun-udp", dissect_stun_udp, proto_stun);
new_register_dissector("stun-heur", dissect_stun_heur, proto_stun);
}
@@ -1632,7 +1638,7 @@ proto_reg_handoff_stun(void)
dissector_handle_t stun_udp_handle;
stun_tcp_handle = new_create_dissector_handle(dissect_stun_tcp, proto_stun);
- stun_udp_handle = new_create_dissector_handle(dissect_stun, proto_stun);
+ stun_udp_handle = new_create_dissector_handle(dissect_stun_udp, proto_stun);
dissector_add_uint("tcp.port", TCP_PORT_STUN, stun_tcp_handle);
dissector_add_uint("udp.port", UDP_PORT_STUN, stun_udp_handle);
diff --git a/epan/dissectors/packet-t38.c b/epan/dissectors/packet-t38.c
index baf2a6163b..6bc4495279 100644
--- a/epan/dissectors/packet-t38.c
+++ b/epan/dissectors/packet-t38.c
@@ -1202,19 +1202,6 @@ dissect_t38_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
}
-static void
-dissect_t38(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
-{
- if(pinfo->ipproto == IP_PROTO_TCP)
- {
- dissect_t38_tcp(tvb, pinfo, tree);
- }
- else if(pinfo->ipproto == IP_PROTO_UDP)
- {
- dissect_t38_udp(tvb, pinfo, tree);
- }
-}
-
/* Look for conversation info and display any setup info found */
void
show_setup_info(tvbuff_t *tvb, proto_tree *tree, t38_conv *p_t38_conversation)
@@ -1331,7 +1318,7 @@ proto_register_t38(void)
"OCTET_STRING", HFILL }},
/*--- End of included file: packet-t38-hfarr.c ---*/
-#line 671 "../../asn1/t38/packet-t38-template.c"
+#line 658 "../../asn1/t38/packet-t38-template.c"
{ &hf_t38_setup,
{ "Stream setup", "t38.setup", FT_STRING, BASE_NONE,
NULL, 0x0, "Stream setup, method and frame number", HFILL }},
@@ -1392,7 +1379,7 @@ proto_register_t38(void)
&ett_t38_T_fec_data,
/*--- End of included file: packet-t38-ettarr.c ---*/
-#line 718 "../../asn1/t38/packet-t38-template.c"
+#line 705 "../../asn1/t38/packet-t38-template.c"
&ett_t38_setup,
&ett_data_fragment,
&ett_data_fragments
@@ -1410,7 +1397,7 @@ proto_register_t38(void)
proto_register_subtree_array(ett, array_length(ett));
expert_t38 = expert_register_protocol(proto_t38);
expert_register_field_array(expert_t38, ei, array_length(ei));
- register_dissector("t38", dissect_t38, proto_t38);
+ register_dissector("t38_udp", dissect_t38_udp, proto_t38);
/* Init reassemble tables for HDLC */
register_init_routine(t38_defragment_init);