* 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.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*
* Please refer to the following specs for protocol detail:
* - draft-ietf-behave-rfc3489bis-15
* - draft-ietf-behave-nat-behavior-discovery-03
* - draft-ietf-behave-turn-07
* - draft-ietf-behave-turn-ipv6-03
+ *
+ * XXX - these are now:
+ * - RFC 5389
+ * - RFC 5245
+ * - RFC 5780
+ * - RFC 5766
+ * - RFC 6156
+ *
+ * Update as necessary.
*/
#include "config.h"
/* heuristic subdissectors */
static heur_dissector_list_t heur_subdissector_list;
-/* data dissector handle */
-static dissector_handle_t data_handle;
-
/* Initialize the protocol and registered fields */
static int proto_turnchannel = -1;
/* Initialize the subtree pointers */
static gint ett_turnchannel = -1;
+static dissector_handle_t turnchannel_tcp_handle;
+static dissector_handle_t turnchannel_udp_handle;
+
static int
dissect_turnchannel_message(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, void *data _U_)
if (data_len < reported_len) {
reported_len = data_len;
}
- next_tvb = tvb_new_subset(tvb, TURNCHANNEL_HDR_LEN, new_len,
+ next_tvb = tvb_new_subset_length_caplen(tvb, TURNCHANNEL_HDR_LEN, new_len,
reported_len);
if (!dissector_try_heuristic(heur_subdissector_list,
next_tvb, pinfo, tree, &hdtbl_entry, NULL)) {
- call_dissector(data_handle,next_tvb, pinfo, tree);
+ call_data_dissector(next_tvb, pinfo, tree);
}
}
proto_turnchannel = proto_register_protocol("TURN Channel",
"TURNCHANNEL", "turnchannel");
- new_register_dissector("turnchannel", dissect_turnchannel_message,
- proto_turnchannel);
+ turnchannel_tcp_handle = register_dissector("turnchannel-tcp", dissect_turnchannel_tcp, proto_turnchannel);
+ turnchannel_udp_handle = register_dissector("turnchannel", dissect_turnchannel_message, proto_turnchannel);
/* subdissectors */
- heur_subdissector_list = register_heur_dissector_list("turnchannel");
+ heur_subdissector_list = register_heur_dissector_list("turnchannel", proto_turnchannel);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_turnchannel, hf, array_length(hf));
void
proto_reg_handoff_turnchannel(void)
{
- dissector_handle_t turnchannel_tcp_handle;
- dissector_handle_t turnchannel_udp_handle;
-
- turnchannel_tcp_handle = create_dissector_handle(dissect_turnchannel_tcp, proto_turnchannel);
- turnchannel_udp_handle = find_dissector("turnchannel");
-
/* Register for "Decode As" in case STUN negotiation isn't captured */
- dissector_add_for_decode_as("tcp.port", turnchannel_tcp_handle);
- dissector_add_for_decode_as("udp.port", turnchannel_udp_handle);
+ dissector_add_for_decode_as_with_preference("tcp.port", turnchannel_tcp_handle);
+ dissector_add_for_decode_as_with_preference("udp.port", turnchannel_udp_handle);
+
+ /*
+ * SSL/TLS and DTLS Application-Layer Protocol Negotiation (ALPN)
+ * protocol ID.
+ */
+ dissector_add_string("tls.alpn", "stun.turn", turnchannel_tcp_handle);
+ dissector_add_string("dtls.alpn", "stun.turn", turnchannel_udp_handle);
/* TURN negotiation is handled through STUN2 dissector (packet-stun.c),
so only it should be able to determine if a packet is a TURN packet */
heur_dissector_add("stun", dissect_turnchannel_heur, "TURN Channel over STUN", "turnchannel_stun", proto_turnchannel, HEURISTIC_ENABLE);
-
- data_handle = find_dissector("data");
}
/*