1 /* packet-rtitcp.c
2  * Dissector for the RTI TCP Transport Protocol.
3  * Layer on top of TCP used to send Control messages
4  * to establish and maintain the connections as well as
5  * send RTPS data.
6  *
7  * (c) 2005-2015 Copyright, Real-Time Innovations, Inc.
8  * Real-Time Innovations, Inc.
9  * 232 East Java Drive
10  * Sunnyvale, CA 94089
11  *
12  * Wireshark - Network traffic analyzer
13  * By Gerald Combs <gerald@wireshark.org>
14  * Copyright 1998 Gerald Combs
15  *
16  * SPDX-License-Identifier: GPL-2.0-or-later
17  */
18 
19 #include "config.h"
20 
21 #include <epan/packet.h>
22 #include <epan/expert.h>
23 #include <epan/prefs.h>
24 #include <epan/addr_resolv.h>
25 #include <epan/wmem_scopes.h>
26 #include <epan/conversation.h>
27 #include <epan/dissectors/packet-tcp.h>
28 
29 #define RTITCP_MAGIC_NUMBER             0xdd54dd55
30 #define RTPS_MAGIC_NUMBER               0x52545053
31 #define RTITCP_CONTROL_MAGIC_COOKIE     0x2112A442
32 #define RTITCP_CRC_MAGIC_NUMBER         0x43524332
33 
34 /* A sample #define of the minimum length (in bytes) of the protocol data.
35  * If data is received with fewer than this many bytes it is rejected by
36  * the current dissector. */
37 #define RTITCP_MIN_LENGTH 8
38 #define NUMBER_2E30 1073741824
39 
40 #define IDENTITY_BIND_REQUEST                           (0x0C01)
41 #define IDENTITY_BIND_INDICATION                        (0x0C11)
42 #define IDENTITY_BIND_RESPONSE                          (0x0D01)
43 #define IDENTITY_BIND_ERROR                             (0x0D11)
44 
45 #define SERVER_LOGICAL_PORT_REQUEST                     (0x0C02)
46 #define SERVER_LOGICAL_PORT_INDICATION                  (0x0C12)
47 #define SERVER_LOGICAL_PORT_RESPONSE                    (0x0D02)
48 #define SERVER_LOGICAL_PORT_ERROR                       (0x0D12)
49 
50 #define CLIENT_LOGICAL_PORT_REQUEST                     (0x0C03)
51 #define CLIENT_LOGICAL_PORT_INDICATION                  (0x0C13)
52 #define CLIENT_LOGICAL_PORT_RESPONSE                    (0x0D03)
53 #define CLIENT_LOGICAL_PORT_ERROR                       (0x0D13)
54 
55 #define CONNECTION_BIND_REQUEST                         (0x0C04)
56 #define CONNECTION_BIND_INDICATION                      (0x0C14)
57 #define CONNECTION_BIND_RESPONSE                        (0x0D04)
58 #define CONNECTION_BIND_ERROR                           (0x0D14)
59 
60 #define SESSION_ID_REQUEST                              (0x0C05)
61 #define SESSION_ID_INDICATION                           (0x0C15)
62 #define SESSION_ID_RESPONSE                             (0x0D05)
63 #define SESSION_ID_ERROR                                (0x0D15)
64 
65 #define LIVELINESS_REQUEST                              (0x0C06)
66 #define LIVELINESS_RESPONSE                             (0x0D06)
67 
68 #define FINALIZE_SESSION_REQUEST                        (0x0C0F)
69 #define FINALIZE_SESSION_INDICATION                     (0x0C1F)
70 #define FINALIZE_SESSION_RESPONSE                       (0x0D0F)
71 #define FINALIZE_SESSION_ERRROR                         (0x0D1F)
72 
73 #define LOCATOR_KIND_IPV4                               (1)
74 #define LOCATOR_KIND_IPV6                               (2)
75 
76 #define RTPS_LOCATOR_ADDRESS_ATTRIBUTE_TYPE             (0x3D01)
77 #define RTPS_LOCATOR_PORT_ATTRIBUTE_TYPE                (0x3D02)
78 #define CONNECTION_TYPE_ATTRIBUTE_TYPE                  (0x3D03)
79 #define CONNECTION_COOKIE_ATTRIBUTE_TYPE                (0x3D04)
80 #define PORT_OPTIONS_ATTRIBUTE_TYPE                     (0x3D05)
81 #define TRANSPORT_PRIORITY_ATTRIBUTE_TYPE               (0x3D06)
82 #define SESSION_ID_ATTRIBUTE_TYPE                       (0x3D07)
83 
84 #define MAPPED_ADDRESS_ATTRIBUTE_TYPE                   (0x0001)
85 #define XOR_MAPPED_ADDRESS_ATTRIBUTE_TYPE               (0x0020)
86 #define ERROR_CODE_ATTRIBUTE_TYPE                       (0x0009)
87 #define UNKNOWN_ATTRIBUTES_ATTRIBUTE_TYPE               (0x000A)
88 
89 #define SOFTWARE_ATTRIBUTE_TYPE                         (0x8022)
90 #define ALTERNATE_SERVER_ATTRIBUTE_TYPE                 (0x8023)
91 
92 #define CLASS_ID_TCPV4_LAN                              (0x00)
93 #define CLASS_ID_TCPV4_WAN                              (0x40)
94 #define CLASS_ID_TLSV4_LAN                              (0x80)
95 #define CLASS_ID_TLSV4_WAN                              (0xC0)
96 
97 
98 #define NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_OK                                              0
99 /* client requested a transport class not supported by the server */
100 #define NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_TRANSPORT_CLASS_MISMATCH                  1
101 /* required attribute is missing */
102 #define NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_ATTRIBUTE_MISSING                         2
103 /* no matching receive resource for requested port */
104 #define NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_NO_MATCHING_RECVRESOURCE                  3
105 /* no matching cookie found on server */
106 #define NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_NO_MATCH_COOKIE                           4
107 /* fatal internal processing error (caller is not responsible) */
108 #define NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_INTERNAL                                  5
109 /* the operation should be retried at the first occurrence */
110 #define NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_RETRY                                     6
111 #define NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_BAD_REQUEST_ID                        400
112 #define NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_UNKNOWN_ATTRIBUTE_ID                  420
113 #define NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_ALLOCATION_MISMATCH_ID                437
114 #define NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_UNSUPPORTED_TRANSPORT_PROTOCOL_ID     442
115 #define NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_CONNECTION_ALREADY_EXISTS_ID          446
116 #define NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_SERVER_ERROR_ID                       500
117 
118 /* Forward declaration that is needed below if using the
119  * proto_reg_handoff_rtitcp function as a callback for when protocol
120  * preferences get changed. For now we don't have preferences but we
121  * may have them in the future.*/
122 
123 void proto_reg_handoff_rtitcp(void);
124 void proto_register_rtitcp(void);
125 
126 /* Initialize the protocol and registered fields */
127 static gint proto_rtitcp                                         = -1;
128 static gint hf_rtitcp_header_control_byte                        = -1;
129 static gint hf_rtitcp_header_magic_number                        = -1;
130 static gint hf_rtitcp_header_message_length                      = -1;
131 static gint hf_rtitcp_control_transaction_id                     = -1;
132 static gint hf_rtitcp_control_kind                               = -1;
133 static gint hf_rtitcp_control_attribute_type                     = -1;
134 static gint hf_rtitcp_control_attribute_length                   = -1;
135 static gint hf_rtitcp_control_attribute_port                     = -1;
136 static gint hf_rtitcp_attributes_list_length                     = -1;
137 static gint hf_rtitcp_control_magic_cookie                       = -1;
138 static gint hf_rtitcp_control_attribute_connection_cookie        = -1;
139 static gint hf_rtitcp_control_attribute_connection_type          = -1;
140 static gint hf_rtitcp_control_attribute_session_id               = -1;
141 static gint hf_rtitcp_control_attribute_error_code_value         = -1;
142 static gint hf_rtitcp_control_attribute_error_code_description   = -1;
143 static gint hf_rtitcp_locator_ipv4                               = -1;
144 static gint hf_rtitcp_locator_port                               = -1;
145 static gint hf_rtitcp_locator_ipv6                               = -1;
146 static gint hf_rtitcp_locator_kind                               = -1;
147 static gint hf_rtitcp_crc_magic_cookie                           = -1;
148 static gint hf_rtitcp_control_crc_value                          = -1;
149 
150 static gint hf_rtitcp_response_in                                = -1;
151 static gint hf_rtitcp_response_to                                = -1;
152 static gint hf_rtitcp_response_time                              = -1;
153 
154 #define RTITCP_FLAG_NOT_REQUEST 0x0100
155 
156 typedef struct _rtitcp_transaction_t {
157     guint32 req_frame;
158     guint32 rep_frame;
159     nstime_t req_time;
160 } rtitcp_transaction_t;
161 
162 typedef struct _rtitcp_conv_info_t {
163     wmem_map_t *pdus;
164 } rtitcp_conv_info_t;
165 
166 /* Subtree pointers */
167 static gint ett_rtitcp                              = -1;
168 static gint ett_rtitcp_signalling_protocol          = -1;
169 static gint ett_rtitcp_message                      = -1;
170 static gint ett_rtitcp_attributes_list              = -1;
171 static gint ett_rtitcp_attribute                    = -1;
172 
173 static header_field_info *hfi_rtitcp                = NULL;
174 static heur_dissector_list_t heur_subdissector_list;
175 
176 static const value_string ctrl_message_types_vals[] = {
177     { IDENTITY_BIND_REQUEST,                    "Identity Bind Request" },
178     { IDENTITY_BIND_INDICATION,                 "Identity Bind Indication" },
179     { IDENTITY_BIND_RESPONSE,                   "Identity Bind Response" },
180     { IDENTITY_BIND_ERROR,                      "Identity Bind Error" },
181     { SERVER_LOGICAL_PORT_REQUEST,              "Server Logical Port Request" },
182     { SERVER_LOGICAL_PORT_RESPONSE,             "Server Logical Port Response" },
183     { SERVER_LOGICAL_PORT_ERROR,                "Server Logical Port Error" },
184     { CLIENT_LOGICAL_PORT_REQUEST,              "Client Logical Port Request" },
185     { CLIENT_LOGICAL_PORT_RESPONSE,             "Client Logical Port Response" },
186     { CLIENT_LOGICAL_PORT_ERROR,                "Client Logical Port Error" },
187     { CONNECTION_BIND_REQUEST,                  "Connection Bind Request" },
188     { CONNECTION_BIND_RESPONSE,                 "Connection Bind Response" },
189     { CONNECTION_BIND_ERROR,                    "Connection Bind Error" },
190     { SESSION_ID_REQUEST,                       "Session ID Request" },
191     { SESSION_ID_INDICATION,                    "Session ID Indication" },
192     { SESSION_ID_RESPONSE,                      "Session ID Response" },
193     { SESSION_ID_ERROR,                         "Session ID Error" },
194     { LIVELINESS_REQUEST,                       "Liveliness Request" },
195     { LIVELINESS_RESPONSE,                      "Liveliness Response" },
196     { FINALIZE_SESSION_INDICATION,              "Finalize Session Indication" },
197     { 0, NULL }
198 };
199 
200 static const value_string attribute_types_vals[] = {
201     { RTPS_LOCATOR_ADDRESS_ATTRIBUTE_TYPE,    "Locator Address" },
202     { RTPS_LOCATOR_PORT_ATTRIBUTE_TYPE,       "Locator Port" },
203     { CONNECTION_TYPE_ATTRIBUTE_TYPE,         "Connection Type" },
204     { CONNECTION_COOKIE_ATTRIBUTE_TYPE,       "Connection Cookie" },
205     { PORT_OPTIONS_ATTRIBUTE_TYPE,            "Port options" },
206     { TRANSPORT_PRIORITY_ATTRIBUTE_TYPE,      "Transport priority" },
207     { SESSION_ID_ATTRIBUTE_TYPE,              "Session ID" },
208     { MAPPED_ADDRESS_ATTRIBUTE_TYPE,          "Mapped Address" },
209     { XOR_MAPPED_ADDRESS_ATTRIBUTE_TYPE,      "XOR Mapped Address" },
210     { ERROR_CODE_ATTRIBUTE_TYPE,              "Error Code" },
211     { UNKNOWN_ATTRIBUTES_ATTRIBUTE_TYPE,      "Unknown attribute" },
212     { SOFTWARE_ATTRIBUTE_TYPE,                "Software" },
213     { ALTERNATE_SERVER_ATTRIBUTE_TYPE,        "Alternate Server" },
214     { 0, NULL }
215 };
216 
217 static const value_string error_code_kind_vals[] = {
218     { NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_OK,
219       "PROTOCOL_OK" },
220     { NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_TRANSPORT_CLASS_MISMATCH,
221       "PROTOCOL_ERROR_TRANSPORT_CLASS_MISMATCH" },
222     { NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_ATTRIBUTE_MISSING,
223       "PROTOCOL_ERROR_ATTRIBUTE_MISSING" },
224     { NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_NO_MATCHING_RECVRESOURCE,
225       "PROTOCOL_ERROR_NO_MATCHING_RECVRESOURCE" },
226     { NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_NO_MATCH_COOKIE,
227       "PROTOCOL_ERROR_NO_MATCH_COOKIE" },
228     { NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_INTERNAL,
229       "PROTOCOL_ERROR_INTERNAL" },
230     { NDDS_TRANSPORT_TCPV4_CONTROL_PROTOCOL_ERROR_RETRY,
231       "PROTOCOL_ERROR_RETRY" },
232     { NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_BAD_REQUEST_ID,
233       "ERROR_CODE_ATTRIBUTE_BAD_REQUEST_ID" },
234     { NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_UNKNOWN_ATTRIBUTE_ID,
235       "ERROR_CODE_ATTRIBUTE_UNKNOWN_ATTRIBUTE_ID" },
236     { NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_ALLOCATION_MISMATCH_ID,
237       "ERROR_CODE_ATTRIBUTE_ALLOCATION_MISMATCH_ID" },
238     { NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_UNSUPPORTED_TRANSPORT_PROTOCOL_ID,
239       "ERROR_CODE_ATTRIBUTE_UNSUPPORTED_TRANSPORT_PROTOCOL_ID" },
240     { NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_CONNECTION_ALREADY_EXISTS_ID,
241       "ERROR_CODE_ATTRIBUTE_CONNECTION_ALREADY_EXISTS_ID" },
242     { NDDS_TRANSPORT_TCP_CONTROL_ERROR_CODE_ATTRIBUTE_SERVER_ERROR_ID,
243       "ERROR_CODE_ATTRIBUTE_SERVER_ERROR_ID" },
244     { 0, NULL }
245 };
246 
247 static const value_string rtitcp_locator_kind_vals[] = {
248     { LOCATOR_KIND_IPV4,        "IPV4" },
249     { LOCATOR_KIND_IPV6,        "Unreachable peer" },
250     { 0, NULL }
251 };
252 
253 static const value_string rtitcp_attribute_connection_type_vals[] = {
254     { CLASS_ID_TCPV4_LAN,        "TCPV4_LAN" },
255     { CLASS_ID_TCPV4_WAN,        "TCPV4_WAN" },
256     { CLASS_ID_TLSV4_LAN,        "TLSV4_LAN" },
257     { CLASS_ID_TLSV4_WAN,        "TLSV4_WAN" },
258     { 0, NULL }
259 };
260 
rtitcp_util_add_error_attribute(proto_tree * attribute,tvbuff_t * tvb,gint offset,guint size)261 static void rtitcp_util_add_error_attribute(proto_tree *attribute, tvbuff_t* tvb,
262                              gint offset, guint size) {
263     proto_tree_add_item(attribute, hf_rtitcp_control_attribute_error_code_value, tvb, offset, 4, ENC_BIG_ENDIAN);
264     proto_tree_add_item(attribute, hf_rtitcp_control_attribute_error_code_description, tvb, offset + 4,
265             size - 4, ENC_ASCII|ENC_NA);
266 }
267 
rtitcp_util_add_locator_t(proto_tree * tree,packet_info * pinfo _U_,tvbuff_t * tvb,gint offset,gboolean little_endian,proto_item * rtitcp_message,gboolean * first_attribute)268 static void rtitcp_util_add_locator_t(proto_tree *tree, packet_info *pinfo _U_, tvbuff_t * tvb,
269                              gint offset, gboolean little_endian,
270                              proto_item * rtitcp_message, gboolean * first_attribute) {
271     gint32  kind;
272     guint16 port;
273     kind = tvb_get_guint16(tvb, offset+8, little_endian ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN);
274 
275     if (kind == 0xFFFF) {
276         kind = LOCATOR_KIND_IPV4;
277     } else {
278         kind = LOCATOR_KIND_IPV6;
279     }
280     proto_tree_add_uint(tree, hf_rtitcp_locator_kind, tvb, offset+8, 2, kind);
281 
282     if (kind == LOCATOR_KIND_IPV4) {
283         proto_tree_add_item(tree, hf_rtitcp_locator_port, tvb, offset+10, 2, ENC_BIG_ENDIAN);
284         proto_tree_add_item(tree, hf_rtitcp_locator_ipv4, tvb, offset+12, 4, ENC_BIG_ENDIAN);
285 
286         port = tvb_get_guint16(tvb, offset+10, little_endian ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN);
287         if (*first_attribute) {
288             proto_item_append_text(rtitcp_message," (");
289             col_append_str(pinfo->cinfo, COL_INFO, " (");
290         }
291         proto_item_append_text(rtitcp_message, "%s%s:%u",
292             *first_attribute ? "" : ", ", tvb_ip_to_str(pinfo->pool, tvb, offset + 12), port);
293         col_append_fstr(pinfo->cinfo, COL_INFO, "%s%s:%u",
294                 *first_attribute ? "" : ", ", tvb_ip_to_str(pinfo->pool, tvb, offset + 12), port);
295     } else {
296         proto_tree_add_item(tree, hf_rtitcp_locator_ipv6, tvb, offset, 16, ENC_NA);
297         if (*first_attribute) {
298             proto_item_append_text(rtitcp_message," (");
299             col_append_str(pinfo->cinfo, COL_INFO, " (");
300         }
301         proto_item_append_text(rtitcp_message, "%s%s",
302             *first_attribute ? "" : ", ", tvb_ip6_to_str(pinfo->pool, tvb, offset));
303         col_append_fstr(pinfo->cinfo, COL_INFO, "%s%s",
304                 *first_attribute ? "" : ", ", tvb_ip6_to_str(pinfo->pool, tvb, offset));
305     }
306 }
307 
dissect_attribute(tvbuff_t * tvb,packet_info * pinfo,proto_tree * attributes_list,guint offset,guint attributes_list_offset,proto_item * rtitcp_message,gboolean * first_attribute)308 static guint dissect_attribute(tvbuff_t *tvb, packet_info *pinfo,
309         proto_tree *attributes_list, guint offset, guint attributes_list_offset,
310         proto_item * rtitcp_message, gboolean * first_attribute) {
311 
312     guint16 attribute_length, attribute_type;
313     guint padding;
314     proto_item *attribute;
315 
316     attribute_type = tvb_get_guint16(tvb, attributes_list_offset+offset, ENC_BIG_ENDIAN);
317     attribute_length = tvb_get_guint16(tvb, attributes_list_offset+offset+2, ENC_BIG_ENDIAN);
318 
319     attribute = proto_tree_add_subtree_format(attributes_list, tvb,
320             attributes_list_offset+offset, attribute_length+4,
321             ett_rtitcp_attribute, NULL, "Unknown Attribute");
322 
323     proto_tree_add_item(attribute, hf_rtitcp_control_attribute_type, tvb,
324             attributes_list_offset+offset, 2, ENC_BIG_ENDIAN);
325     proto_tree_add_item(attribute, hf_rtitcp_control_attribute_length, tvb,
326             attributes_list_offset+offset+2, 2, ENC_BIG_ENDIAN);
327     proto_item_set_text(attribute,"%s", val_to_str(attribute_type, attribute_types_vals, "Unknown attribute"));
328 
329     switch (attribute_type) {
330         case RTPS_LOCATOR_PORT_ATTRIBUTE_TYPE: {
331             guint32 port;
332             port = tvb_get_guint32(tvb, attributes_list_offset+offset+4, ENC_BIG_ENDIAN);
333             if (*first_attribute) {
334                 proto_item_append_text(rtitcp_message," (");
335                 col_append_str(pinfo->cinfo, COL_INFO, " (");
336             }
337             proto_item_append_text(rtitcp_message, "%s%u",
338                     *first_attribute ? "" : ", ", port);
339             col_append_fstr(pinfo->cinfo, COL_INFO, "%s%u",
340                     *first_attribute ? "" : ", ", port);
341             (*first_attribute) = FALSE;
342             proto_item_append_text(attribute, " (Port = %u)", port);
343             proto_tree_add_item(attribute, hf_rtitcp_control_attribute_port, tvb,
344                     attributes_list_offset+offset+4, attribute_length, ENC_BIG_ENDIAN);
345             break;
346         }
347         case RTPS_LOCATOR_ADDRESS_ATTRIBUTE_TYPE: {
348             rtitcp_util_add_locator_t(attribute, pinfo, tvb, attributes_list_offset+offset+4,
349                                 ENC_BIG_ENDIAN, rtitcp_message, first_attribute);
350             (*first_attribute) = FALSE;
351             break;
352         }
353 
354         case CONNECTION_COOKIE_ATTRIBUTE_TYPE: {
355             proto_tree_add_item(attribute, hf_rtitcp_control_attribute_connection_cookie,
356                     tvb, attributes_list_offset+offset+4, attribute_length, ENC_NA);
357             if (*first_attribute) {
358                 proto_item_append_text(rtitcp_message," (");
359                 col_append_str(pinfo->cinfo, COL_INFO, " (");
360             }
361             proto_item_append_text(rtitcp_message, "%s%s",
362                 (*first_attribute) ? "" : ", ",
363                 tvb_bytes_to_str(pinfo->pool, tvb, attributes_list_offset+offset+4, 16));
364             col_append_fstr(pinfo->cinfo, COL_INFO, "%s%s",
365                 (*first_attribute) ? "" : ", ",
366                 tvb_bytes_to_str(pinfo->pool, tvb, attributes_list_offset+offset+4, 16));
367             (*first_attribute) = FALSE;
368             break;
369         }
370         case CONNECTION_TYPE_ATTRIBUTE_TYPE: {
371             guint8 attribute_connection_type = tvb_get_guint8(tvb, attributes_list_offset+offset+4);
372             proto_tree_add_item(attribute, hf_rtitcp_control_attribute_connection_type, tvb,
373                     attributes_list_offset+offset+4, attribute_length, ENC_BIG_ENDIAN);
374             if (*first_attribute) {
375                 proto_item_append_text(rtitcp_message," (");
376                 col_append_str(pinfo->cinfo, COL_INFO, " (");
377             }
378             proto_item_append_text(rtitcp_message, "%s%s",
379                 (*first_attribute) ? "" : ", ",
380                 val_to_str(attribute_connection_type, rtitcp_attribute_connection_type_vals, "Unknown attribute"));
381             col_append_fstr(pinfo->cinfo, COL_INFO, "%s%s",
382                 (*first_attribute) ? "" : ", ",
383                 val_to_str(attribute_connection_type, rtitcp_attribute_connection_type_vals, "Unknown attribute"));
384             (*first_attribute) = FALSE;
385             break;
386         }
387         case SESSION_ID_ATTRIBUTE_TYPE: {
388             proto_tree_add_item(attribute, hf_rtitcp_control_attribute_session_id, tvb,
389                     attributes_list_offset+offset+4, attribute_length, ENC_NA);
390             break;
391         }
392         case ERROR_CODE_ATTRIBUTE_TYPE: {
393             rtitcp_util_add_error_attribute(attribute, tvb, attributes_list_offset+offset+4, attribute_length);
394             break;
395         }
396         default:
397             break;
398     }
399 
400     padding = (4 - attribute_length%4)%4;
401     return (attribute_length+padding+4);
402 }
print_header(proto_tree * tree,proto_tree * rtitcp_message,tvbuff_t * tvb,guint offset,guint16 msg_length,gboolean printCRC,gboolean is_data)403 static proto_tree* print_header(proto_tree *tree, proto_tree *rtitcp_message, tvbuff_t *tvb, guint offset,
404                                     guint16 msg_length, gboolean printCRC, gboolean is_data) {
405     proto_item *ti;
406 
407     if (is_data) {
408         rtitcp_message = proto_tree_add_subtree_format(tree, tvb, offset, msg_length,
409             ett_rtitcp_message, NULL, "RTI TCP Data Message");
410     } else {
411         rtitcp_message = proto_tree_add_subtree_format(tree, tvb, offset, msg_length,
412             ett_rtitcp_message, NULL, "RTI TCP Control Message");
413     }
414     if (is_data) {
415         guint32 msg_length32;
416         proto_tree_add_item(rtitcp_message, hf_rtitcp_header_control_byte, tvb, offset, 1, ENC_BIG_ENDIAN);
417         ti = proto_tree_add_item(rtitcp_message, hf_rtitcp_header_message_length,
418                 tvb, offset+1, 3, ENC_BIG_ENDIAN);
419         msg_length32 = tvb_get_guint32(tvb, offset, ENC_BIG_ENDIAN);
420         msg_length32 = msg_length32 % NUMBER_2E30;
421         proto_item_set_text(ti,"RTI TCP Message Length: %d", msg_length32);
422     } else {
423         proto_tree_add_item(rtitcp_message, hf_rtitcp_header_control_byte, tvb, offset, 2, ENC_BIG_ENDIAN);
424         proto_tree_add_item(rtitcp_message, hf_rtitcp_header_message_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
425     }
426     proto_tree_add_item(rtitcp_message, hf_rtitcp_header_magic_number, tvb, offset+4, 4, ENC_BIG_ENDIAN);
427     if (printCRC) {
428         proto_tree_add_item(rtitcp_message, hf_rtitcp_crc_magic_cookie, tvb, offset+8, 4, ENC_BIG_ENDIAN);
429         proto_tree_add_item(rtitcp_message, hf_rtitcp_control_crc_value, tvb, offset+12, 4, ENC_BIG_ENDIAN);
430     }
431 
432     return rtitcp_message;
433 }
dissect_control_message(proto_tree * rtitcp_tree,tvbuff_t * tvb,packet_info * pinfo,guint offset)434 static guint16 dissect_control_message(proto_tree *rtitcp_tree, tvbuff_t *tvb, packet_info *pinfo,
435                                   guint offset) {
436 
437    /* 0...2...........7...............15.............23...............31
438    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
439    * |            Not Used           |           msg_length          |
440    * +---------------+---------------+---------------+---------------+
441    * |                      RTITCP_MAGIC_NUMBER                      |
442    * +---------------+---------------+---------------+---------------+
443    * |      control_message_kind     |    attributes_list_length     |
444    * +---------------+---------------+---------------+---------------+
445    * |                   RTITCP_CONTROL_MAGIC_COOKIE                 |
446    * +---------------+---------------+---------------+---------------+
447    * |                                                               |
448    * |-                                                             -|
449    * |                         TRANSACTION_ID                        |
450    * |-                                                             -|
451    * |                                                               |
452    * +---------------+---------------+---------------+---------------+   ---------------------------------
453    * |       attribute_type          |       attribute_length ..         Repeat                          |
454    * +---------------+---------------+---------------+---------------+   until                           |
455    * |                       ATTRIBUTE (length)                      |   attributes_list_length expires  |
456    * +---------------+---------------+---------------+---------------+   --------------------------------*/
457 
458     proto_tree  *attributes_list, *rtitcp_message = NULL;
459     guint16 msg_length, control_message_kind, attributes_list_length, header_length;
460     guint attributes_list_offset, attribute_offset, offset_header = offset;
461     guint attributes_count;
462     gboolean is_data = FALSE, printCRC = FALSE, first_attribute;
463     gchar * transaction_id_str;
464     guint64 seq_num;
465     conversation_t *conversation;
466     rtitcp_conv_info_t *rtitcp_info;
467     rtitcp_transaction_t *rtitcp_trans;
468     guint64 * conversation_info_key = NULL;
469 
470     /* The header length is 8 if it doesn't contain optional fields */
471     header_length = 8;
472 
473     msg_length = tvb_get_guint16(tvb, offset+2, ENC_BIG_ENDIAN);
474     offset += 8;
475 
476     /* Check if CRC is present */
477     if (tvb_get_ntohl(tvb, offset) == RTITCP_CRC_MAGIC_NUMBER) {
478         printCRC = TRUE;
479         header_length += 8;
480         offset += 8; /* Because of 0xCRC32 + actual CRC (4 bytes) */
481     }
482 
483     /* Time to print the header */
484     rtitcp_message = print_header(rtitcp_tree, rtitcp_message, tvb, offset_header, msg_length + header_length, printCRC, is_data);
485 
486     /* Check the control message kind */
487     control_message_kind = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
488     col_append_sep_str(pinfo->cinfo, COL_INFO, ", ",
489                 val_to_str(control_message_kind,ctrl_message_types_vals, "Unknown control message"));
490     proto_tree_add_uint(rtitcp_message, hf_rtitcp_control_kind, tvb, offset, 2, control_message_kind);
491     proto_item_set_text(rtitcp_message,"RTI TCP Control Message , Kind: %s",
492             val_to_str(control_message_kind,ctrl_message_types_vals, "Unknown control message"));
493     offset += 2;
494 
495     /* Take the length in bytes of the attributes list */
496     attributes_list_length = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
497     proto_tree_add_item(rtitcp_message, hf_rtitcp_attributes_list_length, tvb, offset, 2, ENC_BIG_ENDIAN);
498     offset += 2;
499 
500     /* We expect now the RTI TCP Control Magic Cookie */
501     if (tvb_get_ntohl(tvb, offset) != RTITCP_CONTROL_MAGIC_COOKIE) {
502         return msg_length + header_length;
503     }
504     proto_tree_add_item(rtitcp_message, hf_rtitcp_control_magic_cookie, tvb, offset, 4, ENC_BIG_ENDIAN);
505     offset += 4;
506 
507     /* Now we dissect the transaction id */
508     proto_tree_add_item(rtitcp_message, hf_rtitcp_control_transaction_id, tvb, offset, 12, ENC_NA);
509     transaction_id_str = tvb_bytes_to_str(pinfo->pool, tvb, offset, 12);
510 
511     /* Get the transaction identifier. Not the whole transaction but the middle part, which
512      * shouldn't coincide */
513     seq_num = tvb_get_ntoh64(tvb, offset);
514 
515     /*
516      * We need to track some state for this protocol on a per conversation
517      * basis so we can do neat things like request/response tracking
518      */
519     conversation = find_or_create_conversation(pinfo);
520 
521     rtitcp_info = (rtitcp_conv_info_t *)conversation_get_proto_data(conversation, proto_rtitcp);
522     if (!rtitcp_info) {
523         /*
524          * No.  Attach that information to the conversation, and add
525          * it to the list of information structures.
526          */
527         rtitcp_info = wmem_new(wmem_file_scope(), rtitcp_conv_info_t);
528         rtitcp_info->pdus=wmem_map_new(wmem_file_scope(), g_int64_hash, g_int64_equal);
529 
530         conversation_add_proto_data(conversation, proto_rtitcp, rtitcp_info);
531     }
532     if (!pinfo->fd->visited) {
533         if (!(control_message_kind & RTITCP_FLAG_NOT_REQUEST)) {
534             /* This is a request */
535             rtitcp_trans=wmem_new(wmem_file_scope(), rtitcp_transaction_t);
536             rtitcp_trans->req_frame = pinfo->num;
537             rtitcp_trans->rep_frame = 0;
538             rtitcp_trans->req_time = pinfo->abs_ts;
539             conversation_info_key = wmem_new0(wmem_file_scope(), guint64);
540             *conversation_info_key = seq_num;
541             wmem_map_insert(rtitcp_info->pdus, conversation_info_key, (void *)rtitcp_trans);
542         } else {
543             conversation_info_key = &seq_num;
544             rtitcp_trans=(rtitcp_transaction_t *)wmem_map_lookup(rtitcp_info->pdus, conversation_info_key);
545             if (rtitcp_trans) {
546                 rtitcp_trans->rep_frame = pinfo->num;
547             }
548         }
549     } else {
550         conversation_info_key = &seq_num;
551         rtitcp_trans=(rtitcp_transaction_t *)wmem_map_lookup(rtitcp_info->pdus, conversation_info_key);
552     }
553     if (!rtitcp_trans) {
554             /* create a "fake" rtitcp_trans structure */
555             rtitcp_trans=wmem_new(pinfo->pool, rtitcp_transaction_t);
556             rtitcp_trans->req_frame = 0;
557             rtitcp_trans->rep_frame = 0;
558             rtitcp_trans->req_time = pinfo->abs_ts;
559     }
560 
561     /* print state tracking in the tree */
562     if (!(control_message_kind & RTITCP_FLAG_NOT_REQUEST)) {
563         /* This is a request */
564         if (rtitcp_trans->rep_frame) {
565             proto_item *it;
566             it = proto_tree_add_uint(rtitcp_message, hf_rtitcp_response_in,
567                             tvb, 0, 0, rtitcp_trans->rep_frame);
568             proto_item_set_generated(it);
569         }
570     } else {
571         /* This is a reply */
572         if (rtitcp_trans->req_frame) {
573             proto_item *it;
574             nstime_t ns;
575             it = proto_tree_add_uint(rtitcp_message, hf_rtitcp_response_to,
576                             tvb, 0, 0, rtitcp_trans->req_frame);
577             proto_item_set_generated(it);
578 
579             nstime_delta(&ns, &pinfo->abs_ts, &rtitcp_trans->req_time);
580             it = proto_tree_add_time(rtitcp_message, hf_rtitcp_response_time, tvb, 0, 0, &ns);
581             proto_item_set_generated(it);
582         }
583     }
584 
585     /* End of feature */
586     offset += 12;
587 
588     /* Finally, dissect the list of attributes */
589     attributes_list_offset = 0;
590     attributes_list = proto_tree_add_subtree_format(rtitcp_message, tvb,
591             attributes_list_offset+offset, attributes_list_length,
592             ett_rtitcp_attributes_list, NULL, "Attributes List");
593 
594     attributes_count = 0;
595     first_attribute = TRUE;
596     while (attributes_list_offset < attributes_list_length) {
597         ++attributes_count;
598         attribute_offset = dissect_attribute(tvb, pinfo, attributes_list,
599           offset, attributes_list_offset, rtitcp_message, &first_attribute);
600         attributes_list_offset += attribute_offset;
601     }
602     if (!first_attribute) {
603         proto_item_append_text(rtitcp_message,")");
604         col_append_str(pinfo->cinfo, COL_INFO, ")");
605     }
606     /* Now that we have the number of attributes, update the text to show it */
607     proto_item_set_text(attributes_list, "Attributes list [%d attribute%s",
608         attributes_count, attributes_count > 1 ? "s]" : "]");
609 
610     proto_item_append_text(rtitcp_message,", Transaction ID: %s, Len: %d",
611             transaction_id_str, msg_length);
612 
613     return msg_length + header_length;
614 }
615 
616 /* This function dissects all the control messages found */
dissect_rtitcp_control_protocol(proto_tree * rtitcp_tree,tvbuff_t * tvb,packet_info * pinfo)617 static guint dissect_rtitcp_control_protocol(proto_tree *rtitcp_tree, tvbuff_t *tvb, packet_info *pinfo) {
618     guint messages_count, offset;
619     guint16 msg_length;
620     guint32 tvb_len;
621 
622     offset = 0;
623     tvb_len = tvb_reported_length(tvb);
624 
625     messages_count = 0;
626 
627     while (offset < tvb_len) {
628         msg_length = dissect_control_message(rtitcp_tree, tvb, pinfo, offset);
629         offset += msg_length;
630         ++messages_count;
631     }
632 
633     return offset;
634 }
635 
dissect_rtitcp_common(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)636 static gint dissect_rtitcp_common(tvbuff_t *tvb, packet_info *pinfo,
637                             proto_tree *tree, void *data _U_) {
638 
639    /*                   FORMAT OF THE CONTROL MESSAGE
640 
641      0...2...........7...............15.............23...............31
642    * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
643    * |         control bytes         |    RTI TCP message length     |
644    * +---------------+---------------+---------------+---------------+
645    * |                     RTITCP_MAGIC_NUMBER                       |
646    * +---------------+---------------+---------------+---------------+
647    * |      control_message_kind     |    attributes_list_length     |
648    * +---------------+---------------+---------------+---------------+
649    * |                    RTITCP_CONTROL_MAGIC_COOKIE                |
650    * +---------------+---------------+---------------+---------------+
651    * |                                                               |
652    * |-                                                             -|
653    * |                         TRANSACTION_ID                        |
654    * |-                                                             -|
655    * |                                                               |
656    * +---------------+---------------+---------------+---------------+   ---------------------------------
657    * |       attribute_type          |       attribute_length ..         Repeat                          |
658    * +---------------+---------------+---------------+---------------+   until                           |
659    * |                       ATTRIBUTE (length)                      |   attributes_list_length expires  |
660    * +---------------+---------------+---------------+---------------+   --------------------------------*/
661 
662     proto_item   *ti;
663     proto_tree   *rtitcp_tree, *rtitcp_message = NULL;
664     guint offset, offset_header;
665     guint16 rtitcp_msg_length, header_length;
666     guint32 tvb_len, rtitcp_rtps_msg_length;
667     gboolean printCRC = FALSE, is_data = FALSE;
668     tvbuff_t *next_tvb;
669     heur_dtbl_entry_t *hdtbl_entry;
670 
671     offset = 0;
672     tvb_len = tvb_reported_length(tvb);
673 
674     /* From this point, we can consider that this is a RTI TCP message */
675     col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTI-TCP");
676 
677     rtitcp_msg_length = tvb_get_guint16(tvb, offset+2, ENC_BIG_ENDIAN);
678 
679     ti = proto_tree_add_item(tree, proto_rtitcp, tvb, offset, -1, ENC_NA);
680     rtitcp_tree = proto_item_add_subtree(ti, ett_rtitcp);
681 
682     offset_header = 0; /* Remember the offset that delimits the header */
683     header_length = 8; /* the header is 8 bytes length + 8 optional (CRC) */
684     offset += 2; /* First two bytes are CTRL bytes */
685     offset += 2; /* rtitcp_msg_length */
686     offset += 4; /* RTITCP_MAGIC_NUMBER has already been checked */
687 
688     /* if bytes 8 to 12 are RTITCP_CRC_MAGIC_NUMBER, we got a CRC */
689     if (tvb_get_ntohl(tvb, offset) == RTITCP_CRC_MAGIC_NUMBER) {
690         printCRC = TRUE; /* To specify later that CRC must be printed */
691         header_length += 8; /* header increases in 8 bytes */
692         offset += 8; /* Because of 0xCRC32 + actual CRC (4 bytes) */
693     }
694     proto_item_set_len(ti, rtitcp_msg_length + header_length);
695 
696     /* At this point, offset is 8 or 16 bytes and we have now data.
697        This data can be RTPS or RTI TCP Signaling messages */
698     if (tvb_get_ntohl(tvb, offset) == RTPS_MAGIC_NUMBER) {
699 
700         /* IMPORTANT NOTE: We assume always one RTPS message per RTITCP message */
701         /* If the TCP layer has provided us with garbage at the end of the buffer,
702            process only the length specified by rtitcp_msg_length */
703         if (tvb_len > (guint32)(rtitcp_msg_length + header_length)) {
704             tvb_set_reported_length(tvb, (rtitcp_msg_length + header_length));
705         }
706 
707         /* When we encapsulate RTPS, packet length is given by the 30 less
708            significant bits of the first four bytes */
709         rtitcp_rtps_msg_length = tvb_get_guint32(tvb, 0, ENC_BIG_ENDIAN);
710         rtitcp_rtps_msg_length = rtitcp_rtps_msg_length % NUMBER_2E30;
711         /* Add RTI TCP Data Message subtree and print header */
712         is_data = TRUE;
713         rtitcp_message = print_header(rtitcp_tree, rtitcp_message, tvb, offset_header,
714                                         rtitcp_rtps_msg_length + header_length, printCRC, is_data);
715 
716         proto_item_set_text(rtitcp_message,"RTI TCP Data Message, Len: %d",
717                                 rtitcp_rtps_msg_length);
718 
719         /* Take the payload and call the registered sub-dissectors. So far, RTPS */
720         next_tvb = tvb_new_subset_remaining(tvb, offset);
721         dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, NULL);
722         return tvb_captured_length(tvb);
723 
724     } else {
725         return dissect_rtitcp_control_protocol(rtitcp_tree, tvb, pinfo);
726     }
727 }
728 
get_rtitcp_pdu_len(packet_info * pinfo _U_,tvbuff_t * tvb,gint offset,void * data _U_)729 static guint get_rtitcp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb,
730         gint offset, void * data _U_) {
731     guint16 plen;
732     guint16 header_length = 8;
733     /*
734     * Get the length of the RTITCP packet.
735     */
736     plen = tvb_get_guint16(tvb, offset+2, ENC_BIG_ENDIAN);
737     /*
738     * That length doesn't include the header field itself; add that in.
739     */
740     if (tvb_get_ntohl(tvb, offset+8) == RTITCP_CRC_MAGIC_NUMBER)
741         header_length += 8;
742     /* We don't expect plen to be greater than 0xfff8 since adding the header
743      * exceeds the size */
744     if (plen >= 0xfff8)
745         return 1;
746 
747     return plen + header_length;
748 }
dissect_rtitcp(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)749 static gint dissect_rtitcp(tvbuff_t *tvb, packet_info *pinfo,
750                             proto_tree *tree, void *data _U_) {
751 
752     gboolean desegmentation = TRUE;
753 
754     if (tvb_captured_length(tvb) < 8)
755         return 0;
756 
757     /* Check if the RTITCP_MAGIC_NUMBER is here */
758     if (tvb_get_ntohl(tvb, 4) != RTITCP_MAGIC_NUMBER)
759         return 0;
760 
761     col_clear(pinfo->cinfo, COL_INFO);
762 
763     tcp_dissect_pdus(tvb, pinfo, tree, desegmentation, RTITCP_MIN_LENGTH,
764             get_rtitcp_pdu_len, dissect_rtitcp_common, data);
765 
766     return tvb_captured_length(tvb);
767 
768 }
769 
770 
771 /* Register the protocol with Wireshark.
772  *
773  * This format is required because a script is used to build the C function that
774  * calls all the protocol registration.
775  */
776 void
proto_register_rtitcp(void)777 proto_register_rtitcp(void)
778 {
779     /* module_t *rtitcp_module; */
780     /* expert_module_t* expert_rtitcp; */
781 
782     static hf_register_info hf[] = {
783 
784         { &hf_rtitcp_header_control_byte, {
785             "Control Byte", "rtitcp.header.control_byte",
786             FT_UINT8, BASE_HEX, NULL, 0,
787             0, HFILL }
788         },
789 
790         { &hf_rtitcp_header_message_length, {
791             "Message Length", "rtitcp.header.message_length",
792             FT_UINT16, BASE_DEC, NULL, 0,
793             0, HFILL }
794         },
795 
796         { &hf_rtitcp_header_magic_number, {
797             "Magic Cookie", "rtitcp.header.magic_cookie",
798             FT_UINT32, BASE_HEX, NULL, 0,
799             0, HFILL }
800         },
801 
802         { &hf_rtitcp_crc_magic_cookie, {
803             "CRC Magic Cookie", "rtitcp.header.crc_magic_cookie",
804             FT_UINT32, BASE_HEX, NULL, 0,
805             0, HFILL }
806         },
807 
808         { &hf_rtitcp_control_kind,
809           { "Kind", "rtitcp.control.kind",
810             FT_UINT16, BASE_HEX, VALS(ctrl_message_types_vals), 0,
811             NULL, HFILL }
812         },
813 
814         { &hf_rtitcp_control_magic_cookie, {
815             "Control Magic Cookie", "rtitcp.control.magic_cookie",
816             FT_UINT32, BASE_HEX, NULL, 0,
817             0, HFILL }
818         },
819 
820         { &hf_rtitcp_control_transaction_id, {
821             "Transaction ID", "rtitcp.control.transaction_id",
822             FT_BYTES, BASE_NONE, NULL, 0,
823             0, HFILL }
824         },
825 
826         { &hf_rtitcp_control_attribute_session_id, {
827             "Session ID", "rtitcp.control.attribute.session_id",
828             FT_BYTES, BASE_NONE, NULL, 0,
829             0, HFILL }
830         },
831 
832         { &hf_rtitcp_control_attribute_type,
833           { "Attribute Type", "rtitcp.control.attribute_type",
834             FT_UINT16, BASE_HEX, VALS(attribute_types_vals), 0,
835             NULL, HFILL }
836         },
837 
838         { &hf_rtitcp_control_attribute_error_code_value,
839           { "Kind", "rtitcp.control.attribute.error_code",
840             FT_UINT32, BASE_HEX, VALS(error_code_kind_vals), 0,
841             NULL, HFILL }
842         },
843 
844         { &hf_rtitcp_control_attribute_error_code_description, {
845             "Description", "rtitcp.control.attribute.error_code.description",
846             FT_STRING, BASE_NONE, NULL, 0,
847             0, HFILL }
848         },
849 
850         { &hf_rtitcp_control_attribute_connection_cookie, {
851             "Connection Cookie", "rtitcp.control.attribute.connection_cookie",
852             FT_BYTES, BASE_NONE, NULL, 0,
853             0, HFILL }
854         },
855 
856         { &hf_rtitcp_control_attribute_connection_type, {
857             "Class ID", "rtitcp.control_attribute.connection_type",
858             FT_UINT8, BASE_HEX, VALS(rtitcp_attribute_connection_type_vals), 0,
859             0, HFILL }
860         },
861 
862         { &hf_rtitcp_attributes_list_length, {
863             "Attributes list length", "rtitcp.attributes_list_length",
864             FT_UINT16, BASE_DEC, NULL, 0,
865             0,
866             HFILL }
867         },
868 
869         { &hf_rtitcp_control_attribute_length, {
870             "Attribute Length", "rtitcp.control.attribute.length",
871             FT_UINT16, BASE_DEC, NULL, 0,
872             0, HFILL }
873         },
874 
875         { &hf_rtitcp_control_attribute_port, {
876             "Port", "rtitcp.control.attribute_port",
877             FT_UINT32, BASE_DEC, NULL, 0,
878             0, HFILL }
879         },
880 
881         { &hf_rtitcp_locator_kind,
882           { "Kind", "rtitcp.locator.kind",
883             FT_UINT16, BASE_DEC, VALS(rtitcp_locator_kind_vals), 0,
884             NULL, HFILL }
885         },
886 
887         { &hf_rtitcp_locator_ipv4,
888           { "Address", "rtitcp.locator.ipv4",
889             FT_IPv4, BASE_NONE, NULL, 0,
890             NULL, HFILL }
891         },
892 
893         { &hf_rtitcp_locator_port,
894           { "Port", "rtitcp.locator.port",
895             FT_UINT16, BASE_DEC, NULL, 0,
896             NULL, HFILL }
897         },
898 
899         { &hf_rtitcp_locator_ipv6,
900           { "Address", "rtitcp.locator.ipv6",
901             FT_IPv6, BASE_NONE, NULL, 0,
902             NULL, HFILL }
903         },
904 
905         { &hf_rtitcp_control_crc_value, {
906          "CRC", "rtitcp.control.crc",
907          FT_UINT32, BASE_HEX, NULL, 0,
908          0, HFILL }
909         },
910 
911         { &hf_rtitcp_response_in, {
912          "Response In", "rtitcp.response_in",
913          FT_FRAMENUM, BASE_NONE, NULL, 0x0,
914          "The response to this RTITCP request is in this frame", HFILL }
915         },
916 
917         { &hf_rtitcp_response_to, {
918          "Request In", "rtitcp.response_to",
919          FT_FRAMENUM, BASE_NONE, NULL, 0x0,
920          "This is a response to the RTITCP request in this frame", HFILL }
921         },
922 
923         { &hf_rtitcp_response_time, {
924          "Response Time", "rtitcp.response_time",
925          FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
926          "The time between the Request and the Reply", HFILL }
927         },
928 
929     };
930 
931     static gint *ett[] = {
932         &ett_rtitcp,
933         &ett_rtitcp_signalling_protocol,
934         &ett_rtitcp_message,
935         &ett_rtitcp_attributes_list,
936         &ett_rtitcp_attribute
937     };
938 
939     /* Setup protocol expert items */
940     /* static ei_register_info ei[] = {}; */
941 
942     /* Register the protocol name and description */
943     proto_rtitcp = proto_register_protocol("RTI TCP Transport Protocol",
944             "RTITCP", "rtitcp");
945 
946     hfi_rtitcp = proto_registrar_get_nth(proto_rtitcp);
947     /* Required function calls to register the header fields and subtrees */
948     proto_register_field_array(proto_rtitcp, hf, array_length(hf));
949     proto_register_subtree_array(ett, array_length(ett));
950 
951     /* Required function calls to register expert items */
952     /* expert_rtitcp = expert_register_protocol(proto_rtitcp);
953      expert_register_field_array(expert_rtitcp, ei, array_length(ei)); */
954 
955     register_dissector("rtitcp", dissect_rtitcp, proto_rtitcp);
956     heur_subdissector_list = register_heur_dissector_list("rtitcp", proto_rtitcp);
957 
958 }
959 
960 /* Simpler form of proto_reg_handoff_rtitcp which can be used if there are
961  * no prefs-dependent registration function calls. */
962 void
proto_reg_handoff_rtitcp(void)963 proto_reg_handoff_rtitcp(void)
964 {
965     heur_dissector_add("tcp", dissect_rtitcp, "RTI TCP Layer" , "rtitcp", proto_rtitcp, HEURISTIC_ENABLE);
966 }
967 
968 /*
969  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
970  *
971  * Local variables:
972  * c-basic-offset: 4
973  * tab-width: 8
974  * indent-tabs-mode: nil
975  * End:
976  *
977  * vi: set shiftwidth=4 tabstop=8 expandtab:
978  * :indentSize=4:tabSize=8:noTabs=true:
979  */
980