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>
}
}
-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)
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);
/* 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... */
/* 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;
#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;
/* 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;
* 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++;
}
}
}
+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;
&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",
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);
}
/*
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)
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 */
/* Protocol specific data indices */
#define IPV6_PROTO_NXT_HDR 0
+#define IPV6_PROTO_VALUE 1
static int ipv6_tap = -1;
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)
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)) {
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_ )
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 */
/* 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"));
}
/* 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);
}
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");
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;
/* 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 */
}
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.
/* 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);
}
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);
}
}
-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)
"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 }},
&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
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);
address net_dst; /**< network-layer destination address */
address src; /**< source address (net if present, DL otherwise )*/
address dst; /**< destination address (net if present, DL otherwise )*/
- guint32 ipproto; /**< IP protocol, if this is an IP packet */
circuit_type ctype; /**< type of circuit, for protocols with a VC identifier */
guint32 circuit_id; /**< circuit ID, for protocols with a VC identifier */
const char *noreassembly_reason; /**< reason why reassembly wasn't done, if any */
/* WSLUA_ATTRIBUTE Pinfo_delta_dis_ts RO Number of seconds passed since the last displayed packet. */
WSLUA_ATTRIBUTE_BLOCK_NUMBER_GETTER(Pinfo,delta_dis_ts,lua_delta_nstime_to_sec(obj, obj->ws_pinfo->fd, obj->ws_pinfo->fd->prev_dis_num));
-/* WSLUA_ATTRIBUTE Pinfo_ipproto RO IP Protocol id. */
-PINFO_NUMBER_GETTER(ipproto);
-
/* WSLUA_ATTRIBUTE Pinfo_circuit_id RW For circuit based protocols. */
PINFO_NUMBER_GETTER(circuit_id);
PINFO_NUMBER_SETTER(circuit_id,guint32);
WSLUA_ATTRIBUTE_ROREG(Pinfo,port_type),
WSLUA_ATTRIBUTE_RWREG(Pinfo,src_port),
WSLUA_ATTRIBUTE_RWREG(Pinfo,dst_port),
- WSLUA_ATTRIBUTE_ROREG(Pinfo,ipproto),
WSLUA_ATTRIBUTE_RWREG(Pinfo,circuit_id),
WSLUA_ATTRIBUTE_ROREG(Pinfo,match),
WSLUA_ATTRIBUTE_ROREG(Pinfo,curr_proto),
void PacketList::contextMenuEvent(QContextMenuEvent *event)
{
QAction *action;
- gboolean is_tcp = FALSE, is_udp = FALSE;
+ gboolean is_tcp = FALSE, is_udp = FALSE, is_sctp = FALSE;
/* walk the list of a available protocols in the packet to see what we have */
if (cap_file_ != NULL && cap_file_->edt != NULL)
- proto_get_frame_protocols(cap_file_->edt->pi.layers, NULL, &is_tcp, &is_udp, NULL, NULL);
+ proto_get_frame_protocols(cap_file_->edt->pi.layers, NULL, &is_tcp, &is_udp, &is_sctp, NULL);
action = window()->findChild<QAction *>("actionSCTP");
- if (cap_file_ != NULL && cap_file_->edt != NULL &&
- cap_file_->edt->pi.ipproto == IP_PROTO_SCTP)
+ if (cap_file_ != NULL && cap_file_->edt != NULL && is_sctp)
action->setEnabled(TRUE);
else
action->setEnabled(FALSE);