2011-10-13 06:06:53 +00:00
|
|
|
/* packet-fmtp.c
|
|
|
|
*
|
|
|
|
* Routines for FMTP version 2 packet dissection.
|
|
|
|
*
|
|
|
|
* The specifications of this public protocol can be found on Eurocontrol web site:
|
2016-03-26 02:50:53 +00:00
|
|
|
* http://www.eurocontrol.int/sites/default/files/publication/files/20070614-fmtp-spec-v2.0.pdf
|
2011-10-13 06:06:53 +00:00
|
|
|
*
|
|
|
|
* Copyright 2011, Christophe Paletou <c.paletou@free.fr>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2011-10-13 06:06:53 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2011-10-13 06:06:53 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include "packet-tcp.h"
|
|
|
|
|
2013-12-15 23:44:12 +00:00
|
|
|
void proto_register_fmtp(void);
|
|
|
|
void proto_reg_handoff_fmtp(void);
|
|
|
|
|
2011-10-13 06:06:53 +00:00
|
|
|
static int proto_fmtp = -1;
|
|
|
|
static int hf_fmtp_pdu_version = -1;
|
|
|
|
static int hf_fmtp_pdu_reserved = -1;
|
|
|
|
static int hf_fmtp_pdu_type = -1;
|
|
|
|
static int hf_fmtp_pdu_length = -1;
|
|
|
|
static gint ett_fmtp = -1;
|
|
|
|
|
2011-10-15 15:21:35 +00:00
|
|
|
/* #define TCP_PORT_FMTP 8500 */
|
|
|
|
#define FMTP_HEADER_LEN 5
|
|
|
|
#define FMTP_MAX_DATA_LEN 10240
|
|
|
|
#define FMTP_MAX_LEN FMTP_HEADER_LEN + FMTP_MAX_DATA_LEN
|
2011-10-13 06:06:53 +00:00
|
|
|
|
2011-10-15 15:21:35 +00:00
|
|
|
#define FMTP_TYP_OPERATIONAL 1
|
|
|
|
#define FMTP_TYP_OPERATOR 2
|
|
|
|
#define FMTP_TYP_IDENTIFICATION 3
|
|
|
|
#define FMTP_TYP_SYSTEM 4
|
2011-10-13 06:06:53 +00:00
|
|
|
|
2011-10-15 15:21:35 +00:00
|
|
|
#define INFO_STR_SIZE 1024
|
2011-10-13 06:06:53 +00:00
|
|
|
|
|
|
|
static const value_string packet_type_names[] = {
|
2011-10-15 15:21:35 +00:00
|
|
|
{ FMTP_TYP_OPERATIONAL, "Operational message" },
|
|
|
|
{ FMTP_TYP_OPERATOR, "Operator message" },
|
|
|
|
{ FMTP_TYP_IDENTIFICATION, "Identification message" },
|
|
|
|
{ FMTP_TYP_SYSTEM , "System message" },
|
|
|
|
{ 0, NULL }
|
2011-10-13 06:06:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string system_message_names[] = {
|
2011-10-15 15:21:35 +00:00
|
|
|
{ 12337, "Startup" }, /* 0x3031 */
|
|
|
|
{ 12336, "Shutdown" }, /* 0x3030 */
|
|
|
|
{ 12339, "Heartbeat" }, /* 0x3033 */
|
|
|
|
{ 0, NULL }
|
2011-10-13 06:06:53 +00:00
|
|
|
};
|
|
|
|
|
2013-11-09 17:46:28 +00:00
|
|
|
static int
|
2013-11-09 18:17:00 +00:00
|
|
|
dissect_fmtp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2011-10-13 06:06:53 +00:00
|
|
|
{
|
2011-10-15 15:21:35 +00:00
|
|
|
guint8 packet_type;
|
|
|
|
guint16 packet_len;
|
|
|
|
tvbuff_t *next_tvb;
|
2011-10-13 06:06:53 +00:00
|
|
|
proto_item *ti = NULL;
|
|
|
|
proto_tree *fmtp_tree = NULL;
|
|
|
|
|
|
|
|
packet_type = tvb_get_guint8(tvb, 4);
|
|
|
|
packet_len = tvb_get_ntohs(tvb, 2);
|
|
|
|
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "FMTP");
|
|
|
|
|
|
|
|
/* Clear out stuff in the info column */
|
2011-10-15 15:21:35 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2011-10-13 06:06:53 +00:00
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_fmtp, tvb, 0, -1, ENC_NA);
|
2011-10-13 06:06:53 +00:00
|
|
|
proto_item_append_text(ti, ", %s",
|
|
|
|
val_to_str(packet_type, packet_type_names, "Unknown (0x%02x)"));
|
|
|
|
|
|
|
|
switch (packet_type) {
|
|
|
|
|
|
|
|
case FMTP_TYP_IDENTIFICATION:
|
|
|
|
proto_item_append_text(ti, " (%s)",
|
2014-06-17 15:30:58 +00:00
|
|
|
tvb_get_string_enc(wmem_packet_scope(), tvb, FMTP_HEADER_LEN, packet_len-FMTP_HEADER_LEN, ENC_ASCII));
|
2011-10-15 15:21:35 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "%s (%s)",
|
|
|
|
val_to_str(packet_type, packet_type_names, "Unknown (0x%02x)"),
|
2014-06-17 15:30:58 +00:00
|
|
|
tvb_get_string_enc(wmem_packet_scope(), tvb, FMTP_HEADER_LEN, packet_len-FMTP_HEADER_LEN, ENC_ASCII));
|
2011-10-13 15:49:45 +00:00
|
|
|
break;
|
2011-10-13 06:06:53 +00:00
|
|
|
|
|
|
|
case FMTP_TYP_SYSTEM:
|
|
|
|
proto_item_append_text(ti, " (%s)",
|
2014-06-17 15:30:58 +00:00
|
|
|
tvb_get_string_enc(wmem_packet_scope(), tvb, FMTP_HEADER_LEN, packet_len-FMTP_HEADER_LEN, ENC_ASCII));
|
2011-10-15 15:21:35 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "%s (%s)",
|
|
|
|
val_to_str(packet_type, packet_type_names, "Unknown (0x%02x)"),
|
|
|
|
val_to_str(tvb_get_ntohs(tvb, FMTP_HEADER_LEN), system_message_names, "Unknown (0x%02x)"));
|
|
|
|
break;
|
2011-10-13 06:06:53 +00:00
|
|
|
|
|
|
|
default:
|
2011-10-15 15:21:35 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
|
2011-10-13 06:06:53 +00:00
|
|
|
val_to_str(packet_type, packet_type_names, "Unknown (0x%02x)"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (tree) { /* we are being asked for details */
|
|
|
|
fmtp_tree = proto_item_add_subtree(ti, ett_fmtp);
|
2014-12-13 17:52:20 +00:00
|
|
|
proto_tree_add_item(fmtp_tree, hf_fmtp_pdu_version, tvb, 0, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(fmtp_tree, hf_fmtp_pdu_reserved, tvb, 1, 1, ENC_BIG_ENDIAN);
|
2013-02-27 16:08:48 +00:00
|
|
|
proto_tree_add_item(fmtp_tree, hf_fmtp_pdu_length, tvb, 2, 2, ENC_BIG_ENDIAN);
|
2014-12-13 17:52:20 +00:00
|
|
|
proto_tree_add_item(fmtp_tree, hf_fmtp_pdu_type, tvb, 4, 1, ENC_BIG_ENDIAN);
|
2011-10-13 06:06:53 +00:00
|
|
|
|
2011-10-15 15:21:35 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, FMTP_HEADER_LEN);
|
2016-03-20 00:33:14 +00:00
|
|
|
call_data_dissector(next_tvb, pinfo, fmtp_tree);
|
2011-10-13 06:06:53 +00:00
|
|
|
}
|
2013-11-09 17:46:28 +00:00
|
|
|
|
2015-06-23 18:13:21 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2011-10-13 06:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
2015-01-25 19:30:13 +00:00
|
|
|
get_fmtp_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
|
2011-10-13 06:06:53 +00:00
|
|
|
{
|
|
|
|
return (guint)tvb_get_ntohs(tvb, offset+2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-11-09 17:46:28 +00:00
|
|
|
dissect_fmtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
2011-10-13 06:06:53 +00:00
|
|
|
{
|
2016-03-26 02:50:53 +00:00
|
|
|
guint16 length;
|
|
|
|
|
|
|
|
if (tvb_captured_length(tvb) < 5)
|
|
|
|
return FALSE;
|
2011-10-13 06:06:53 +00:00
|
|
|
/*
|
|
|
|
* Check that packet looks like FMTP before going further
|
|
|
|
*/
|
|
|
|
/* VERSION must currently be 0x02 */
|
|
|
|
if (tvb_get_guint8(tvb, 0) != 0x02) return (FALSE);
|
|
|
|
/* RESERVED must currently be 0x00 */
|
|
|
|
if (tvb_get_guint8(tvb, 1) != 0x00) return (FALSE);
|
2016-03-26 02:50:53 +00:00
|
|
|
length = tvb_get_ntohs(tvb, 2);
|
2011-10-13 06:06:53 +00:00
|
|
|
/* LENGTH must currently not exceed 5 (header) + 10240 (data) */
|
2016-03-26 02:50:53 +00:00
|
|
|
if ((length > FMTP_MAX_LEN) || (length < FMTP_HEADER_LEN)) return (FALSE);
|
2011-10-13 06:06:53 +00:00
|
|
|
/* TYP must currently be in range 0x01-0x04 */
|
|
|
|
if ((tvb_get_guint8(tvb, 4) < 0x01) || (tvb_get_guint8(tvb, 4) > 0x04))
|
|
|
|
return (FALSE);
|
|
|
|
|
|
|
|
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, FMTP_HEADER_LEN,
|
2013-11-09 17:46:28 +00:00
|
|
|
get_fmtp_message_len, dissect_fmtp_message, data);
|
2011-10-13 06:06:53 +00:00
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_fmtp(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_fmtp_pdu_version,
|
|
|
|
{ "Version", "fmtp.version",
|
|
|
|
FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_fmtp_pdu_reserved,
|
|
|
|
{ "Reserved", "fmtp.reserved",
|
|
|
|
FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_fmtp_pdu_length,
|
|
|
|
{ "Length", "fmtp.length",
|
|
|
|
FT_UINT16, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_fmtp_pdu_type,
|
|
|
|
{ "Type", "fmtp.type",
|
|
|
|
FT_UINT8, BASE_DEC,
|
|
|
|
VALS(packet_type_names), 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_fmtp
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_fmtp = proto_register_protocol(
|
|
|
|
"Flight Message Transfer Protocol (FMTP)",
|
|
|
|
"FMTP",
|
2011-10-15 15:21:35 +00:00
|
|
|
"fmtp");
|
2011-10-13 06:06:53 +00:00
|
|
|
|
2011-10-15 15:21:35 +00:00
|
|
|
proto_register_field_array(proto_fmtp, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2011-10-13 06:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_fmtp(void)
|
|
|
|
{
|
2011-10-15 15:21:35 +00:00
|
|
|
/* Register as heuristic dissector for TCP */
|
2015-07-13 00:40:31 +00:00
|
|
|
heur_dissector_add("tcp", dissect_fmtp, "FMTP over TCP", "fmtp_tcp", proto_fmtp, HEURISTIC_ENABLE);
|
2011-10-13 06:06:53 +00:00
|
|
|
}
|
|
|
|
|
2013-02-27 16:18:16 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
2013-12-13 00:44:32 +00:00
|
|
|
* tab-width: 8
|
2013-02-27 16:18:16 +00:00
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
2013-12-13 00:44:32 +00:00
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
2013-02-27 16:18:16 +00:00
|
|
|
*/
|
|
|
|
|