3 * Routines for FMTP version 2 packet dissection.
5 * The specifications of this public protocol can be found on Eurocontrol web site:
6 * http://www.eurocontrol.int/ses/public/standard_page/fmtp_spec.html
8 * Copyright 2011, Christophe Paletou <c.paletou@free.fr>
12 * Wireshark - Network traffic analyzer
13 * By Gerald Combs <gerald@wireshark.org>
14 * Copyright 1998 Gerald Combs
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #include <epan/packet.h>
34 #include "packet-tcp.h"
36 static int proto_fmtp
= -1;
37 static int hf_fmtp_pdu_version
= -1;
38 static int hf_fmtp_pdu_reserved
= -1;
39 static int hf_fmtp_pdu_type
= -1;
40 static int hf_fmtp_pdu_length
= -1;
41 static gint ett_fmtp
= -1;
43 /* #define TCP_PORT_FMTP 8500 */
44 #define FMTP_HEADER_LEN 5
45 #define FMTP_MAX_DATA_LEN 10240
46 #define FMTP_MAX_LEN FMTP_HEADER_LEN + FMTP_MAX_DATA_LEN
48 #define FMTP_TYP_OPERATIONAL 1
49 #define FMTP_TYP_OPERATOR 2
50 #define FMTP_TYP_IDENTIFICATION 3
51 #define FMTP_TYP_SYSTEM 4
53 #define INFO_STR_SIZE 1024
55 static dissector_handle_t data_handle
;
57 static const value_string packet_type_names
[] = {
58 { FMTP_TYP_OPERATIONAL
, "Operational message" },
59 { FMTP_TYP_OPERATOR
, "Operator message" },
60 { FMTP_TYP_IDENTIFICATION
, "Identification message" },
61 { FMTP_TYP_SYSTEM
, "System message" },
65 static const value_string system_message_names
[] = {
66 { 12337, "Startup" }, /* 0x3031 */
67 { 12336, "Shutdown" }, /* 0x3030 */
68 { 12339, "Heartbeat" }, /* 0x3033 */
73 dissect_fmtp_message(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
78 proto_item
*ti
= NULL
;
79 proto_tree
*fmtp_tree
= NULL
;
81 packet_type
= tvb_get_guint8(tvb
, 4);
82 packet_len
= tvb_get_ntohs(tvb
, 2);
84 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "FMTP");
86 /* Clear out stuff in the info column */
87 col_clear(pinfo
->cinfo
, COL_INFO
);
89 ti
= proto_tree_add_item(tree
, proto_fmtp
, tvb
, 0, -1, ENC_NA
);
90 proto_item_append_text(ti
, ", %s",
91 val_to_str(packet_type
, packet_type_names
, "Unknown (0x%02x)"));
93 switch (packet_type
) {
95 case FMTP_TYP_IDENTIFICATION
:
96 proto_item_append_text(ti
, " (%s)",
97 tvb_get_string(wmem_packet_scope(), tvb
, FMTP_HEADER_LEN
, packet_len
-FMTP_HEADER_LEN
));
98 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s (%s)",
99 val_to_str(packet_type
, packet_type_names
, "Unknown (0x%02x)"),
100 tvb_get_string(wmem_packet_scope(), tvb
, FMTP_HEADER_LEN
, packet_len
-FMTP_HEADER_LEN
));
103 case FMTP_TYP_SYSTEM
:
104 proto_item_append_text(ti
, " (%s)",
105 tvb_get_string(wmem_packet_scope(), tvb
, FMTP_HEADER_LEN
, packet_len
-FMTP_HEADER_LEN
));
106 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s (%s)",
107 val_to_str(packet_type
, packet_type_names
, "Unknown (0x%02x)"),
108 val_to_str(tvb_get_ntohs(tvb
, FMTP_HEADER_LEN
), system_message_names
, "Unknown (0x%02x)"));
112 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s",
113 val_to_str(packet_type
, packet_type_names
, "Unknown (0x%02x)"));
116 if (tree
) { /* we are being asked for details */
117 fmtp_tree
= proto_item_add_subtree(ti
, ett_fmtp
);
118 proto_tree_add_item(fmtp_tree
, hf_fmtp_pdu_version
, tvb
, 0, 1, ENC_NA
);
119 proto_tree_add_item(fmtp_tree
, hf_fmtp_pdu_reserved
, tvb
, 1, 1, ENC_NA
);
120 proto_tree_add_item(fmtp_tree
, hf_fmtp_pdu_length
, tvb
, 2, 2, ENC_BIG_ENDIAN
);
121 proto_tree_add_item(fmtp_tree
, hf_fmtp_pdu_type
, tvb
, 4, 1, ENC_NA
);
123 next_tvb
= tvb_new_subset_remaining(tvb
, FMTP_HEADER_LEN
);
124 call_dissector(data_handle
, next_tvb
, pinfo
, fmtp_tree
);
127 return tvb_length(tvb
);
131 get_fmtp_message_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
, int offset
)
133 return (guint
)tvb_get_ntohs(tvb
, offset
+2);
137 dissect_fmtp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
140 * Check that packet looks like FMTP before going further
142 /* VERSION must currently be 0x02 */
143 if (tvb_get_guint8(tvb
, 0) != 0x02) return (FALSE
);
144 /* RESERVED must currently be 0x00 */
145 if (tvb_get_guint8(tvb
, 1) != 0x00) return (FALSE
);
146 /* LENGTH must currently not exceed 5 (header) + 10240 (data) */
147 if (tvb_get_ntohs(tvb
, 2) > FMTP_MAX_LEN
) return (FALSE
);
148 /* TYP must currently be in range 0x01-0x04 */
149 if ((tvb_get_guint8(tvb
, 4) < 0x01) || (tvb_get_guint8(tvb
, 4) > 0x04))
152 tcp_dissect_pdus(tvb
, pinfo
, tree
, TRUE
, FMTP_HEADER_LEN
,
153 get_fmtp_message_len
, dissect_fmtp_message
, data
);
158 proto_register_fmtp(void)
160 static hf_register_info hf
[] = {
161 { &hf_fmtp_pdu_version
,
162 { "Version", "fmtp.version",
167 { &hf_fmtp_pdu_reserved
,
168 { "Reserved", "fmtp.reserved",
173 { &hf_fmtp_pdu_length
,
174 { "Length", "fmtp.length",
180 { "Type", "fmtp.type",
182 VALS(packet_type_names
), 0x0,
187 /* Setup protocol subtree array */
188 static gint
*ett
[] = {
192 proto_fmtp
= proto_register_protocol(
193 "Flight Message Transfer Protocol (FMTP)",
197 proto_register_field_array(proto_fmtp
, hf
, array_length(hf
));
198 proto_register_subtree_array(ett
, array_length(ett
));
202 proto_reg_handoff_fmtp(void)
204 /* Register as heuristic dissector for TCP */
205 heur_dissector_add("tcp", dissect_fmtp
, proto_fmtp
);
206 data_handle
= find_dissector("data");
210 * Editor modelines - http://www.wireshark.org/tools/modelines.html
215 * indent-tabs-mode: nil
218 * vi: set shiftwidth=4 tabstop=4 expandtab:
219 * :indentSize=4:tabSize=4:noTabs=true: