MSWSP: add two more Property Sets
[wireshark-wip.git] / epan / dissectors / packet-tipc.c
blob7287f3f4c27efca2e987e1a6f7277dfcddd5c022
1 /* packet-tipc.c
2 * Routines for Transparent Inter Process Communication packet dissection
4 * $Id$
6 * Copyright 2005-2006, Anders Broman <anders.broman@ericsson.com>
8 * TIPCv2 protocol updates
9 * Copyright 2006-2008, Martin Peylo <wireshark@izac.de>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 * Protocol ref:
29 * http://tipc.sourceforge.net/
33 #include "config.h"
35 #include <epan/prefs.h>
37 #include <glib.h>
38 #include <epan/packet.h>
39 #include <epan/etypes.h>
40 #include <epan/wmem/wmem.h>
41 #include <epan/reassemble.h>
43 #include "packet-tcp.h"
45 static int proto_tipc = -1;
47 /* dissector handles */
48 static dissector_handle_t data_handle;
49 static dissector_handle_t ip_handle;
51 static int hf_tipc_msg_fragments = -1;
52 static int hf_tipc_msg_fragment = -1;
53 static int hf_tipc_msg_fragment_overlap = -1;
54 static int hf_tipc_msg_fragment_overlap_conflicts = -1;
55 static int hf_tipc_msg_fragment_multiple_tails = -1;
56 static int hf_tipc_msg_fragment_too_long_fragment = -1;
57 static int hf_tipc_msg_fragment_error = -1;
58 static int hf_tipc_msg_fragment_count = -1;
59 static int hf_tipc_msg_reassembled_in = -1;
60 static int hf_tipc_msg_reassembled_length = -1;
62 static int hf_tipc_ver = -1;
63 static int hf_tipc_usr = -1;
64 static int hf_tipcv2_usr = -1;
65 static int hf_tipc_hdr_size = -1;
66 static int hf_tipc_nonsequenced = -1;
67 static int hf_tipc_destdrop = -1;
68 static int hf_tipc_unused = -1;
69 static int hf_tipc_msg_size = -1;
70 static int hf_tipc_ack_link_lev_seq = -1;
71 static int hf_tipc_link_lev_seq = -1;
72 static int hf_tipc_prev_proc = -1;
73 static int hf_tipc_org_port = -1;
74 static int hf_tipc_dst_port = -1;
75 static int hf_tipc_data_msg_type = -1;
76 static int hf_tipc_err_code = -1;
77 static int hf_tipc_reroute_cnt = -1;
78 static int hf_tipc_act_id = -1;
79 static int hf_tipc_org_proc = -1;
80 static int hf_tipc_dst_proc = -1;
81 static int hf_tipc_unused2 = -1;
82 static int hf_tipc_importance = -1;
83 static int hf_tipc_link_selector = -1;
84 static int hf_tipc_msg_cnt = -1;
85 static int hf_tipc_probe = -1;
86 static int hf_tipc_bearer_id = -1;
87 static int hf_tipc_link_selector2 = -1;
88 static int hf_tipc_remote_addr = -1;
89 static int hf_tipc_rm_msg_type = -1;
90 static int hf_tipc_nd_msg_type = -1;
91 static int hf_tipc_cm_msg_type = -1;
92 static int hf_tipc_lp_msg_type = -1;
93 static int hf_tipc_cng_prot_msg_type = -1;
94 static int hf_tipc_sm_msg_type = -1;
95 static int hf_tipc_unknown_msg_type = -1;
96 static int hf_tipc_seq_gap = -1;
97 static int hf_tipc_nxt_snt_pkg = -1;
98 static int hf_tipc_unused3 = -1;
99 static int hf_tipc_bearer_name = -1;
101 static int hf_tipc_name_dist_type = -1;
102 static int hf_tipc_name_dist_lower = -1;
103 static int hf_tipc_name_dist_upper = -1;
104 static int hf_tipc_name_dist_port = -1;
105 static int hf_tipc_name_dist_key = -1;
107 static int hf_tipcv2_srcdrop = -1;
108 static int hf_tipcv2_data_msg_type = -1;
109 static int hf_tipcv2_bcast_mtype = -1;
110 static int hf_tipcv2_bundler_mtype = -1;
111 static int hf_tipcv2_link_mtype = -1;
112 static int hf_tipcv2_connmgr_mtype = -1;
113 static int hf_tipcv2_route_mtype_1_6 = -1;
114 static int hf_tipcv2_route_mtype_1_7 = -1;
115 static int hf_tipcv2_changeover_mtype = -1;
116 static int hf_tipcv2_naming_mtype = -1;
117 static int hf_tipcv2_fragmenter_mtype = -1;
118 static int hf_tipcv2_neighbour_mtype = -1;
119 static int hf_tipcv2_errorcode = -1;
120 static int hf_tipcv2_rer_cnt = -1;
121 static int hf_tipcv2_lookup_scope = -1;
122 static int hf_tipcv2_opt_p = -1;
123 static int hf_tipcv2_broadcast_ack_no = -1;
124 static int hf_tipcv2_link_level_ack_no = -1;
125 static int hf_tipcv2_link_level_seq_no = -1;
126 /* static int hf_tipcv2_bcast_seq_no = -1; */
127 static int hf_tipcv2_prev_node = -1;
128 static int hf_tipcv2_orig_node = -1;
129 static int hf_tipcv2_dest_node = -1;
130 static int hf_tipcv2_port_name_type = -1;
131 static int hf_tipcv2_port_name_instance = -1;
132 static int hf_tipcv2_multicast_lower = -1;
133 static int hf_tipcv2_multicast_upper = -1;
135 static int hf_tipcv2_sequence_gap = -1;
136 static int hf_tipcv2_next_sent_broadcast = -1;
137 static int hf_tipcv2_fragment_number = -1;
138 static int hf_tipcv2_fragment_msg_number = -1;
139 static int hf_tipcv2_next_sent_packet = -1;
140 static int hf_tipcv2_session_no = -1;
141 static int hf_tipcv2_link_prio = -1;
142 static int hf_tipcv2_network_plane = -1;
143 static int hf_tipcv2_probe = -1;
144 static int hf_tipcv2_link_tolerance = -1;
145 static int hf_tipcv2_bearer_instance = -1;
146 static int hf_tipcv2_bearer_level_orig_addr = -1;
147 static int hf_tipcv2_cluster_address = -1;
148 static int hf_tipcv2_bitmap = -1;
149 static int hf_tipcv2_node_address = -1;
150 static int hf_tipcv2_destination_domain = -1;
151 static int hf_tipcv2_network_id = -1;
153 static int hf_tipcv2_bcast_tag = -1;
154 static int hf_tipcv2_msg_count = -1;
155 static int hf_tipcv2_max_packet = -1;
156 static int hf_tipcv2_transport_seq_no = -1;
157 static int hf_tipcv2_redundant_link = -1;
158 static int hf_tipcv2_bearer_id = -1;
159 static int hf_tipcv2_conn_mgr_msg_ack = -1;
160 static int hf_tipcv2_minor_pv = -1;
161 static int hf_tipcv2_node_sig = -1;
163 /* added for TIPC v1.7 */
164 static int hf_tipcv2_timestamp = -1;
165 static int hf_tipcv2_item_size = -1;
166 static int hf_tipcv2_network_region = -1;
167 static int hf_tipcv2_local_router = -1;
168 static int hf_tipcv2_remote_router = -1;
169 static int hf_tipcv2_dist_dist = -1;
170 static int hf_tipcv2_dist_scope = -1;
171 static int hf_tipcv2_name_dist_port_id_node = -1;
172 static int hf_tipcv2_media_id = -1;
174 /* added in minor PV 1 */
175 static int hf_tipcv2_syn = -1;
178 static gint ett_tipc_msg_fragment = -1;
179 static gint ett_tipc_msg_fragments = -1;
182 /* Initialize the subtree pointer */
183 static gint ett_tipc = -1;
184 static gint ett_tipc_data = -1;
186 /* protocol preferences */
187 static gboolean tipc_defragment = TRUE;
188 static gboolean dissect_tipc_data = TRUE;
189 static gboolean try_heuristic_first = FALSE;
190 #define V2_AS_ALL 0x1
191 #define V2_AS_1_6 0x2
192 #define V2_AS_1_7 0x4
193 static gint handle_v2_as = V2_AS_ALL;
194 static guint tipc_alternate_tcp_port = 0;
195 static gboolean tipc_tcp_desegment = TRUE;
197 static dissector_handle_t tipc_handle;
199 /* IANA have assigned port 6118 port for TIPC UDP transport. */
200 #define DEFAULT_TIPC_PORT_RANGE "0"
202 static range_t *global_tipc_udp_port_range;
204 /* this is used to find encapsulated protocols */
205 static dissector_table_t tipc_user_dissector;
206 static dissector_table_t tipc_type_dissector;
208 static heur_dissector_list_t tipc_heur_subdissector_list;
210 static proto_tree *top_tree;
212 static const fragment_items tipc_msg_frag_items = {
213 /* Fragment subtrees */
214 &ett_tipc_msg_fragment,
215 &ett_tipc_msg_fragments,
216 /* Fragment fields */
217 &hf_tipc_msg_fragments,
218 &hf_tipc_msg_fragment,
219 &hf_tipc_msg_fragment_overlap,
220 &hf_tipc_msg_fragment_overlap_conflicts,
221 &hf_tipc_msg_fragment_multiple_tails,
222 &hf_tipc_msg_fragment_too_long_fragment,
223 &hf_tipc_msg_fragment_error,
224 &hf_tipc_msg_fragment_count,
225 /* Reassembled in field */
226 &hf_tipc_msg_reassembled_in,
227 /* Reassembled length field */
228 &hf_tipc_msg_reassembled_length,
229 /* Reassembled data field */
230 NULL,
231 /* Tag */
232 "TIPC Message fragments"
236 #define MAX_TIPC_ADDRESS_STR_LEN 15
237 #define TIPCv1 1
238 #define TIPCv2 2
239 /* Users */
240 #define TIPC_DATA_PRIO_0 0
241 #define TIPC_DATA_PRIO_1 1
242 #define TIPC_DATA_PRIO_2 2
243 #define TIPC_DATA_NON_REJECTABLE 3
245 #define TIPC_ROUTING_MANAGER 8
246 #define TIPC_NAME_DISTRIBUTOR 9
247 #define TIPC_CONNECTION_MANAGER 10
248 #define TIPC_LINK_PROTOCOL 11
249 #define TIPC_CHANGEOVER_PROTOCOL 13
250 #define TIPC_SEGMENTATION_MANAGER 14
251 #define TIPC_MSG_BUNDLER 15
253 #define TIPC_LINK_PROTOCO_STATE_MSG 0
255 const value_string tipc_user_values[] = {
256 { TIPC_DATA_PRIO_0, "DATA_PRIO_0"},
257 { TIPC_DATA_PRIO_1, "DATA_PRIO_1"},
258 { TIPC_DATA_PRIO_2, "DATA_PRIO_2"},
259 { TIPC_DATA_NON_REJECTABLE, "DATA_NON_REJECTABLE"},
260 { TIPC_ROUTING_MANAGER, "ROUTING_MANAGER"},
261 { TIPC_NAME_DISTRIBUTOR, "NAME_DISTRIBUTOR"},
262 { TIPC_CONNECTION_MANAGER, "CONNECTION_MANAGER"},
263 { TIPC_LINK_PROTOCOL, "LINK_PROTOCOL"},
264 { TIPC_CHANGEOVER_PROTOCOL, "CHANGEOVER_PROTOCOL"},
265 { TIPC_SEGMENTATION_MANAGER, "SEGMENTATION_MANAGER"},
266 { TIPC_MSG_BUNDLER, "MSG_BUNDLER"},
267 { 0, NULL}
270 #define TIPCv2_DATA_LOW 0
271 #define TIPCv2_DATA_NORMAL 1
272 #define TIPCv2_DATA_HIGH 2
273 #define TIPCv2_DATA_NON_REJECTABLE 3
275 #define TIPCv2_BCAST_PROTOCOL 5
276 #define TIPCv2_MSG_BUNDLER 6
277 #define TIPCv2_LINK_PROTOCOL 7
278 #define TIPCv2_CONN_MANAGER 8
279 #define TIPCv2_ROUTE_DISTRIBUTOR 9
280 #define TIPCv2_CHANGEOVER_PROTOCOL 10
281 #define TIPCv2_NAME_DISTRIBUTOR 11
282 #define TIPCv2_MSG_FRAGMENTER 12
283 #define TIPCv2_NEIGHBOUR_DISCOVERY 13
285 #define TIPCv2_USER_FIRST_FRAGMENT 0
286 #define TIPCv2_USER_FRAGMENT 1
287 #define TIPCv2_USER_LAST_FRAGMENT 2
289 const value_string tipcv2_user_values[] = {
290 { TIPCv2_DATA_LOW, "Low Priority Payload Data"},
291 { TIPCv2_DATA_NORMAL, "Normal Priority Payload Data"},
292 { TIPCv2_DATA_HIGH, "High Priority Payload Data"},
293 { TIPCv2_DATA_NON_REJECTABLE, "Non-Rejectable Payload Data"},
294 { TIPCv2_BCAST_PROTOCOL, "Broadcast Maintenance Protocol"},
295 { TIPCv2_MSG_BUNDLER, "Message Bundler Protocol"},
296 { TIPCv2_LINK_PROTOCOL, "Link State Maintenance Protocol"},
297 { TIPCv2_CONN_MANAGER, "Connection Manager"},
298 { TIPCv2_ROUTE_DISTRIBUTOR, "Routing Table Update Protocol"},
299 { TIPCv2_CHANGEOVER_PROTOCOL, "Link Changeover Protocol"},
300 { TIPCv2_NAME_DISTRIBUTOR, "Name Table Update Protocol"},
301 { TIPCv2_MSG_FRAGMENTER, "Message Fragmentation Protocol"},
302 { TIPCv2_NEIGHBOUR_DISCOVERY, "Neighbour Discovery Protocol"},
303 { 0, NULL}
306 const value_string tipcv2_user_short_str_vals[] = {
307 { TIPCv2_DATA_LOW, "Payld:Low"},
308 { TIPCv2_DATA_NORMAL, "Payld:Normal"},
309 { TIPCv2_DATA_HIGH, "Payld:High"},
310 { TIPCv2_DATA_NON_REJECTABLE, "Payld:NoRej"},
311 { TIPCv2_BCAST_PROTOCOL, "Broadcast"},
312 { TIPCv2_MSG_BUNDLER, "Bundler"},
313 { TIPCv2_LINK_PROTOCOL, "Link State"},
314 { TIPCv2_CONN_MANAGER, "Conn Mgr"},
315 { TIPCv2_ROUTE_DISTRIBUTOR, "Route Dist"},
316 { TIPCv2_CHANGEOVER_PROTOCOL, "Changeover"},
317 { TIPCv2_NAME_DISTRIBUTOR, "Name Dist"},
318 { TIPCv2_MSG_FRAGMENTER, "Fragmenter"},
319 { TIPCv2_NEIGHBOUR_DISCOVERY, "Ngbr Disc"},
320 { 0, NULL}
323 #define TIPC_CONNECTED_MSG 0
324 #define TIPC_NAMED_MSG 2
325 #define TIPC_DIRECT_MSG 3
326 #define TIPC_OVERLOAD_W_MSG 4
328 static const value_string tipc_data_msg_type_values[] = {
329 { 0, "CONN_MSG"},
330 { 2, "NAMED_MSG"},
331 { 3, "DIRECT_MSG"},
332 { 4, "OVERLOAD_W_MSG"},
333 { 0, NULL}
336 static const value_string tipcv2_data_msg_type_defines[] = {
337 { 0, "ConnMsg"},
338 { 1, "McastMsg"},
339 { 2, "NamedMsg"},
340 { 3, "DirectMsg"},
341 { 0, NULL}
344 static const value_string tipcv2_data_msg_type_values[] _U_ = {
345 { 0, "Sent on connection (CONN_MSG)"},
346 { 1, "Logical multicast (MCAST_MSG)"},
347 { 2, "Port name destination address (NAMED_MSG)"},
348 { 3, "Port identity destination address (DIRECT_MSG)"},
349 { 0, NULL}
352 static const value_string tipc_error_code_values[] = {
353 { 0, "MSG_OK"},
354 { 1, "NO_PORT_NAME"},
355 { 2, "NO_REMOTE_PORT"},
356 { 3, "NO_REMOTE_PROCESSOR"},
357 { 4, "DEST_OVERLOADED"},
358 { 6, "NO_CONNECTION"},
359 { 7, "COMMUNICATION_ERROR"},
360 { 0, NULL}
363 static const value_string tipcv2_error_code_strings[] = {
364 { 0, "No error (TIPC_OK)"},
365 { 1, "Destination port name unknown (TIPC_ERR_NO_NAME)"},
366 { 2, "Destination port does not exist (TIPC_ERR_NO_PORT)"},
367 { 3, "Destination node unavailable (TIPC_ERR_NO_NODE)"},
368 { 4, "Destination node overloaded (TIPC_ERR_OVERLOAD)"},
369 { 5, "Connection Shutdown (No error) (TIPC_CONN_SHUTDOWN)"},
370 { 6, "Communication Error (TIPC_CONN_ERROR)"},
371 { 0, NULL}
374 static const value_string tipcv2_error_code_short_strings[] = {
375 { 0, "OK"},
376 { 1, "ErrNoName"},
377 { 2, "ErrNoPort"},
378 { 3, "ErrNoNode"},
379 { 4, "ErrOverload"},
380 { 5, "ConnShutdown"},
381 { 6, "ConnError"},
382 { 0, NULL}
385 static const value_string tipcv2_lookup_scope_strings[] = {
386 { 0, "Zone Scope"},
387 { 1, "Cluster Scope"},
388 { 2, "Node Scope"},
389 { 0, NULL}
392 static const value_string tipc_routing_mgr_msg_type_values[] = {
393 { 0, "EXT_ROUTING_TABLE"},
394 { 1, "LOCAL_ROUTING_TABLE"},
395 { 2, "DP_ROUTING_TABLE"},
396 { 3, "ROUTE_ADDITION"},
397 { 4, "ROUTE_REMOVAL"},
398 { 0, NULL}
401 static const value_string tipc_name_dist_msg_type_values[] = {
402 { 0, "PUBLICATION"},
403 { 1, "WITHDRAWAL"},
404 { 0, NULL}
407 /* CONNECTION_MANAGER */
408 static const value_string tipc_cm_msg_type_values[] = {
409 { 0, "CONNECTION_PROBE"},
410 { 1, "CONNECTION_PROBE_REPLY"},
411 { 0, NULL}
414 static const value_string tipc_link_prot_msg_type_values[] = {
415 { 10, "RESET_MSG"},
416 { 11, "ACTIVATE_MSG"},
417 { 12, "STATE_MSG"},
418 { 0, NULL}
421 /* CHANGEOVER_PROTOCOL */
422 static const value_string tipc_cng_prot_msg_type_values[] = {
423 { 0, "DUPLICATE_MSG"},
424 { 1, "ORIGINAL_MSG"},
425 { 2, "INFO_MSG"},
426 { 0, NULL}
429 /* SEGMENTATION_MANAGER */
430 #define TIPC_FIRST_SEGMENT 1
431 #define TIPC_SEGMENT 2
432 const value_string tipc_sm_msg_type_values[] = {
433 { 1, "FIRST_SEGMENT"},
434 { 2, "SEGMENT"},
435 { 0, NULL}
438 /* TIPCv2_BCAST_PROTOCOL - Broadcast Maintenance Protocol */
439 static const value_string tipcv2_bcast_mtype_strings[] = {
440 { 0, "Bcast"},
441 { 0, NULL}
444 /* TIPCv2_MSG_BUNDLER - Message Bundler Protocol */
445 static const value_string tipcv2_bundler_mtype_strings[] = {
446 { 1, "Bundler"},
447 { 0, NULL}
450 /* TIPCv2_LINK_PROTOCOL - Link State Maintenance Protocol */
451 #define TIPCv2_STATE_MSG 0
452 #define TIPCv2_RESET_MSG 1
453 #define TIPCv2_ACTIV_MSG 2
455 static const value_string tipcv2_link_mtype_strings[] = {
456 { TIPCv2_STATE_MSG, "State"},
457 { TIPCv2_RESET_MSG, "Reset"},
458 { TIPCv2_ACTIV_MSG, "Activate"},
459 { 0, NULL}
462 /* TIPCv2_CONN_MANAGER - Connection Manager */
463 #define TIPCv2_CONMGR_CONN_PROBE 0
464 #define TIPCv2_CONMGR_CONN_PROBE_REPLY 1
465 #define TIPCv2_CONMGR_MSG_ACK 2
466 static const value_string tipcv2_connmgr_mtype_strings[] = {
467 { TIPCv2_CONMGR_CONN_PROBE , "Probe"},
468 { TIPCv2_CONMGR_CONN_PROBE_REPLY , "ProbeReply"},
469 { TIPCv2_CONMGR_MSG_ACK , "Ack"},
470 { 0, NULL}
473 /* TIPCv2_ROUTE_DISTRIBUTOR - Routing Table Update Protocol */
474 /* for TIPC 1.6 */
475 #define TIPCv2_EXT_ROUTING_TABLE 0
476 #define TIPCv2_LOCAL_ROUTING_TABLE 1
477 #define TIPCv2_SEC_ROUTING_TABLE 2
478 #define TIPCv2_ROUTE_ADDITION 3
479 #define TIPCv2_ROUTE_REMOVAL 4
480 /* for TIPC 1.7 */
481 #define TIPCv2_DIST_PUBLISH 0
482 #define TIPCv2_DIST_WITHDRAW 1
483 #define TIPCv2_DIST_PURGE 2
485 static const value_string tipcv2_route_mtype_strings_1_6[] = {
486 { 0, "ExtRoutingTab"},
487 { 1, "LocalRoutingTab"},
488 { 2, "SecRoutingTab"},
489 { 3, "RouteAddition"},
490 { 4, "RouteRemoval"},
491 { 0, NULL}
494 static const value_string tipcv2_route_mtype_strings_1_7[] = {
495 { 0, "Dist Publish"},
496 { 1, "Dist Withdraw"},
497 { 2, "Dist Purge"},
498 { 0, NULL}
501 static const value_string tipcv2_dist_dist_strings[] = {
502 { 0, "Nowhere"},
503 { 1, "To Cluster"},
504 { 2, "To Zone"},
505 { 3, "To Cluster and Zone"},
506 { 4, "To Network"},
507 { 5, "To Cluster and Network"},
508 { 6, "To Zone and Network"},
509 { 7, "To Cluster, Zone and Network"},
510 { 0, NULL}
513 static const value_string tipcv2_dist_scope_strings[] = {
514 { 0, "Zone Scope"},
515 { 1, "Cluster Scope"},
516 { 2, "Node Scope"},
517 { 0, NULL}
520 /* TIPCv2_CHANGEOVER_PROTOCOL - Link Changeover Protocol */
521 static const value_string tipcv2_changeover_mtype_strings[] = {
522 { 0, "Duplicate"},
523 { 1, "Original"},
524 { 0, NULL}
527 /* TIPCv2_NAME_DISTRIBUTOR - Name Table Update Protocol */
528 static const value_string tipcv2_naming_mtype_strings[] = {
529 { 0, "Publication"},
530 { 1, "Withdrawal"},
531 { 0, NULL}
534 /* TIPCv2_MSG_FRAGMENTER - Message Fragmentation Protocol" */
535 static const value_string tipcv2_fragmenter_mtype_strings[] = {
536 { 0, "First"},
537 { 1, "Fragment"},
538 { 2, "Last"},
539 { 0, NULL}
542 /* TIPCv2_NEIGHBOUR_DISCOVERY
543 * 4.3.9 Neighbour Detection Protocol
546 static const value_string tipcv2_neighbour_mtype_strings[] = {
547 { 0, "Request"},
548 { 1, "Response"},
549 { 0, NULL}
552 static const value_string tipcv2_networkplane_strings[] = {
553 { 0, "A"},
554 { 1, "B"},
555 { 2, "C"},
556 { 3, "D"},
557 { 4, "E"},
558 { 5, "F"},
559 { 0, NULL}
562 /* functions forward declarations */
563 static int dissect_tipc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_);
564 void proto_reg_handoff_tipc(void);
566 static reassembly_table tipc_msg_reassembly_table;
569 static void
570 tipc_defragment_init(void)
572 reassembly_table_init(&tipc_msg_reassembly_table,
573 &addresses_reassembly_table_functions);
577 static gchar*
578 tipc_addr_to_str(guint tipc_address)
580 guint8 zone;
581 guint16 subnetwork;
582 guint16 processor;
583 gchar *buff;
585 buff = (gchar *)wmem_alloc(wmem_packet_scope(), MAX_TIPC_ADDRESS_STR_LEN);
587 processor = tipc_address & 0x0fff;
589 tipc_address = tipc_address >> 12;
590 subnetwork = tipc_address & 0x0fff;
592 tipc_address = tipc_address >> 12;
593 zone = tipc_address & 0xff;
595 g_snprintf(buff, MAX_TIPC_ADDRESS_STR_LEN, "%u.%u.%u", zone, subnetwork, processor);
597 return buff;
601 All name distributor messages have a data part containing one or more table elements with
602 the following five-word structure:
603 struct DistributionItem {
604 unsigned int type; / Published port name type /
605 unsigned int lower; / Lower bound of published sequence /
606 unsigned int upper; / Upper bound of published sequence /
607 unsigned int port; / Random number part of port identity /
608 unsigned int key; / Use for verification at withdrawal /
611 static void
612 dissect_tipc_name_dist_data(tvbuff_t *tvb, proto_tree *tree, guint8 item_size)
614 int offset = 0;
615 guint32 dword;
616 gchar *addr_str_ptr;
618 if ((handle_v2_as & V2_AS_1_6) || ((handle_v2_as & (V2_AS_ALL) && item_size == 0))) {
619 /* TIPC 1.6 */
620 while (tvb_reported_length_remaining(tvb, offset) > 0) {
621 proto_tree_add_item(tree, hf_tipc_name_dist_type, tvb, offset, 4, ENC_BIG_ENDIAN);
622 offset = offset+4;
623 proto_tree_add_item(tree, hf_tipc_name_dist_lower, tvb, offset, 4, ENC_BIG_ENDIAN);
624 offset = offset+4;
625 proto_tree_add_item(tree, hf_tipc_name_dist_upper, tvb, offset, 4, ENC_BIG_ENDIAN);
626 offset = offset+4;
627 proto_tree_add_item(tree, hf_tipc_name_dist_port, tvb, offset, 4, ENC_BIG_ENDIAN);
628 offset = offset+4;
629 proto_tree_add_item(tree, hf_tipc_name_dist_key, tvb, offset, 4, ENC_BIG_ENDIAN);
630 offset = offset+4;
632 } else {
633 /* TIPC 1.7 */
634 while (tvb_reported_length_remaining(tvb, offset) > 0) {
635 proto_tree_add_item(tree, hf_tipc_name_dist_type, tvb, offset, 4, ENC_BIG_ENDIAN);
636 offset = offset+4;
637 proto_tree_add_item(tree, hf_tipc_name_dist_lower, tvb, offset, 4, ENC_BIG_ENDIAN);
638 offset = offset+4;
639 proto_tree_add_item(tree, hf_tipc_name_dist_upper, tvb, offset, 4, ENC_BIG_ENDIAN);
640 offset = offset+4;
641 proto_tree_add_item(tree, hf_tipc_name_dist_port, tvb, offset, 4, ENC_BIG_ENDIAN);
642 offset = offset+4;
643 proto_tree_add_item(tree, hf_tipc_name_dist_key, tvb, offset, 4, ENC_BIG_ENDIAN);
644 offset = offset+4;
645 dword = tvb_get_ntohl(tvb, offset);
646 addr_str_ptr = tipc_addr_to_str(dword);
647 proto_tree_add_string(tree, hf_tipcv2_name_dist_port_id_node, tvb, offset, 4, addr_str_ptr);
648 offset = offset+4;
649 proto_tree_add_item(tree, hf_tipcv2_dist_dist, tvb, offset, 4, ENC_BIG_ENDIAN);
650 proto_tree_add_item(tree, hf_tipcv2_dist_scope, tvb, offset, 4, ENC_BIG_ENDIAN);
651 offset = offset + 4;
652 if (item_size == 7) continue;
653 /* if item_size is >7, the following fields are ignored
654 * so far */
655 proto_tree_add_text(tree, tvb, offset, ((item_size-7)*4), "This field is not specified in TIPC v7");
656 offset += (item_size-7)*4;
661 /* Set message type in COL INFO and return type of message (data or Internal message type */
662 static void
663 tipc_v2_set_info_col(tvbuff_t *tvb, packet_info *pinfo, guint8 user, guint8 msg_type, guint8 hdr_size)
665 guint32 portNameInst, dword;
666 guint32 portNameType, portNameInstLow, portNameInstHigh;
667 guint8 error;
668 /*guint8 item_size = 0;*/
670 switch (user) {
671 case TIPCv2_DATA_LOW:
672 case TIPCv2_DATA_NORMAL:
673 case TIPCv2_DATA_HIGH:
674 case TIPCv2_DATA_NON_REJECTABLE:
675 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(msg_type, tipcv2_data_msg_type_defines, "unknown"));
677 /* Display Error != 0 in Info Column */
678 dword = tvb_get_ntohl(tvb, 4);
679 error = (dword>>25) & 0xf;
680 if (error > 0)
681 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(error, tipcv2_error_code_short_strings, "unknown"));
682 if (hdr_size > 8) {
683 /* Port Name Type: 32 bits */
684 portNameType = tvb_get_ntohl(tvb, 32);
685 col_append_fstr(pinfo->cinfo, COL_INFO, " type:%d", portNameType);
686 if (hdr_size > 9) {
687 /* W9 name instance/multicast lower bound */
688 portNameInst = tvb_get_ntohl(tvb, 36);
689 col_append_fstr(pinfo->cinfo, COL_INFO, " inst:%d", portNameInst);
690 /* Port Name Sequence Lower: 32 bits */
691 if (hdr_size > 10) {
692 portNameInst = tvb_get_ntohl(tvb, 40);
693 col_append_fstr(pinfo->cinfo, COL_INFO, "-%d", portNameInst);
697 break;
698 case TIPCv2_BCAST_PROTOCOL:
699 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(msg_type, tipcv2_bcast_mtype_strings, "unknown"));
700 break;
701 case TIPCv2_MSG_BUNDLER:
702 /* No message types */
703 break;
704 case TIPCv2_LINK_PROTOCOL:
705 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(msg_type, tipcv2_link_mtype_strings, "unknown"));
706 break;
707 case TIPCv2_CONN_MANAGER:
708 dword = tvb_get_ntohl(tvb, 4);
709 /* Display Error != 0 in Info Column */
710 error = (dword>>25) & 0xf;
711 if (error > 0)
712 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(error, tipcv2_error_code_short_strings, "unknown"));
713 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(msg_type, tipcv2_connmgr_mtype_strings, "unknown"));
714 break;
715 case TIPCv2_ROUTE_DISTRIBUTOR:
716 /* determine if it is TIPC v1.6 or v1.7 */
717 /*dword = tvb_get_ntohl(tvb, 36); */
718 /*item_size = (dword >> 24) & 0xff;*/
719 if ((handle_v2_as & V2_AS_1_6) || ((handle_v2_as & V2_AS_ALL) == 0)) {
720 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(msg_type, tipcv2_route_mtype_strings_1_6, "unknown"));
721 } else {
722 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(msg_type, tipcv2_route_mtype_strings_1_7, "unknown"));
724 break;
725 case TIPCv2_CHANGEOVER_PROTOCOL:
726 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(msg_type, tipcv2_changeover_mtype_strings, "unknown"));
727 break;
728 case TIPCv2_NAME_DISTRIBUTOR:
729 portNameType = tvb_get_ntohl(tvb, 40);
730 portNameInstLow = tvb_get_ntohl(tvb, 44);
731 portNameInstHigh = tvb_get_ntohl(tvb, 48);
733 if (portNameInstLow == portNameInstHigh) {
734 col_append_fstr(pinfo->cinfo, COL_INFO, " %s type:%d inst:%d",
735 val_to_str_const(msg_type, tipcv2_naming_mtype_strings, "unknown"), portNameType, portNameInstLow);
736 } else {
737 /* sequence */
738 col_append_fstr(pinfo->cinfo, COL_INFO, " %s type:%d seq:%d-%d",
739 val_to_str_const(msg_type, tipcv2_naming_mtype_strings, "unknown"), portNameType, portNameInstLow, portNameInstHigh);
741 break;
742 case TIPCv2_MSG_FRAGMENTER:
743 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(msg_type, tipcv2_fragmenter_mtype_strings, "unknown"));
744 break;
745 case TIPCv2_NEIGHBOUR_DISCOVERY:
746 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", val_to_str_const(msg_type, tipcv2_neighbour_mtype_strings, "unknown"));
747 break;
748 default:
749 break;
753 /* Set message type in COL INFO and return type of message (data or Internal message type */
754 static gboolean
755 tipc_v1_set_col_msgtype(packet_info *pinfo, guint8 user, guint8 msg_type)
757 gboolean datatype_hdr = FALSE;
759 switch (user) {
760 case TIPC_DATA_PRIO_0:
761 case TIPC_DATA_PRIO_1:
762 case TIPC_DATA_PRIO_2:
763 case TIPC_DATA_NON_REJECTABLE:
765 * src and dest address will be found at different location depending on User ad hdr_size
767 datatype_hdr = TRUE;
768 col_append_fstr(pinfo->cinfo, COL_INFO, "%s(%u) ", val_to_str_const(msg_type, tipc_data_msg_type_values, "unknown"), msg_type);
769 break;
770 case TIPC_NAME_DISTRIBUTOR:
771 col_append_fstr(pinfo->cinfo, COL_INFO, "%s(%u) ", val_to_str_const(msg_type, tipc_name_dist_msg_type_values, "unknown"), msg_type);
772 break;
773 case TIPC_CONNECTION_MANAGER:
774 col_append_fstr(pinfo->cinfo, COL_INFO, "%s(%u) ", val_to_str_const(msg_type, tipc_cm_msg_type_values, "unknown"), msg_type);
775 break;
776 case TIPC_ROUTING_MANAGER:
777 col_append_fstr(pinfo->cinfo, COL_INFO, "%s(%u) ", val_to_str_const(msg_type, tipc_routing_mgr_msg_type_values, "unknown"), msg_type);
778 break;
779 case TIPC_LINK_PROTOCOL:
780 col_append_fstr(pinfo->cinfo, COL_INFO, "%s(%u) ", val_to_str_const(msg_type, tipc_link_prot_msg_type_values, "unknown"), msg_type);
781 break;
782 case TIPC_CHANGEOVER_PROTOCOL:
783 col_append_fstr(pinfo->cinfo, COL_INFO, "%s(%u) ", val_to_str_const(msg_type, tipc_cng_prot_msg_type_values, "unknown"), msg_type);
784 break;
785 case TIPC_SEGMENTATION_MANAGER:
786 col_append_fstr(pinfo->cinfo, COL_INFO, "%s(%u) ", val_to_str_const(msg_type, tipc_sm_msg_type_values, "unknown"), msg_type);
787 break;
788 case TIPC_MSG_BUNDLER:
789 break;
790 default:
791 break;
793 return datatype_hdr;
797 Version 2(draft-maloy-tipc-01.txt):
798 4.2.1 Internal Message Header Format
800 0 1 2 3
801 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
802 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
803 w0:|vers |msg usr|hdr sz |n|resrv| packet size |
804 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
805 w1:|m typ| sequence gap | broadcast ack no |
806 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
807 w2:| link level ack no | broadcast/link level seq no |
808 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
809 w3:| previous node |
810 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
811 w4:| next sent broadcast/fragm no | next sent pkt/ fragm msg no |
812 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
813 w5:| session no | res |r|berid|link prio|netpl|p|
814 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
815 w6:| originating node |
816 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
817 w7:| destination node |
818 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
819 w8:| transport sequence number |
820 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
821 w9:| msg count | link tolerance |
822 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
824 / User Specific Data /
826 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
829 static int
830 dissect_tipc_v2_internal_msg(tvbuff_t *tipc_tvb, proto_tree *tipc_tree, packet_info *pinfo, int offset, guint8 user, guint32 msg_size, guint8 orig_hdr_size)
832 guint32 dword;
833 gchar *addr_str_ptr;
834 tvbuff_t *data_tvb;
835 guint8 message_type;
836 guint8 item_size = 0;
837 guint16 message_count;
838 guint msg_no = 0;
839 guint32 msg_in_bundle_size;
840 guint8 msg_in_bundle_user;
841 gint b_inst_strlen, padlen;
843 /* for fragmented messages */
844 gint len, reported_len;
845 gboolean save_fragmented;
846 guint32 frag_no, frag_msg_no;
847 tvbuff_t* new_tvb = NULL;
848 fragment_head *frag_msg = NULL;
850 message_type = (tvb_get_guint8(tipc_tvb, offset) >>5) & 0x7;
852 switch (user) {
853 case TIPCv2_BCAST_PROTOCOL:
854 /* W1 */
855 proto_tree_add_item(tipc_tree, hf_tipcv2_bcast_mtype, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
856 /* NO sequence gap */
857 proto_tree_add_item(tipc_tree, hf_tipcv2_broadcast_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
858 offset = offset + 4;
859 /* W2 */
860 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
861 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_seq_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
862 offset = offset + 4;
863 /* W3 */
864 dword = tvb_get_ntohl(tipc_tvb, offset);
865 addr_str_ptr = tipc_addr_to_str(dword);
866 proto_tree_add_string(tipc_tree, hf_tipcv2_prev_node, tipc_tvb, offset, 4, addr_str_ptr);
867 offset = offset + 4;
868 if (handle_v2_as & (V2_AS_1_6)) {
869 /* W4-8 */
870 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 20, "words 4-8 unused for this user");
871 offset = offset + 20;
872 } else {
873 /* W4 */
874 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 4 unused for this user");
875 offset = offset + 4;
876 /* W5 */
877 proto_tree_add_item(tipc_tree, hf_tipcv2_network_id, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
878 offset = offset + 4;
879 /* W6 */
880 dword = tvb_get_ntohl(tipc_tvb, offset);
881 addr_str_ptr = tipc_addr_to_str(dword);
882 proto_tree_add_string(tipc_tree, hf_tipcv2_orig_node, tipc_tvb, offset, 4, addr_str_ptr);
883 offset = offset + 4;
884 /* W7 */
885 dword = tvb_get_ntohl(tipc_tvb, offset);
886 addr_str_ptr = tipc_addr_to_str(dword);
887 proto_tree_add_string(tipc_tree, hf_tipcv2_dest_node, tipc_tvb, offset, 4, addr_str_ptr);
888 offset = offset + 4;
889 /* W8 */
890 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 8 unused for this user");
891 offset = offset + 4;
893 /* W9 */
894 proto_tree_add_item(tipc_tree, hf_tipcv2_bcast_tag, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
895 /* NO link tolerance */
896 offset = offset + 4;
897 break;
898 case TIPCv2_MSG_BUNDLER:
899 if (handle_v2_as & (V2_AS_1_6)) {
900 /* W1+W2 */
901 /* No message types */
902 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 8, "words 1+2 unused for this user");
903 offset = offset + 8;
904 } else {
905 /* W1 */
906 proto_tree_add_item(tipc_tree, hf_tipcv2_bundler_mtype, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
907 proto_tree_add_item(tipc_tree, hf_tipcv2_broadcast_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
908 offset = offset + 4;
909 /* W2 */
910 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
911 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_seq_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
912 offset = offset + 4;
914 /* W3 */
915 dword = tvb_get_ntohl(tipc_tvb, offset);
916 addr_str_ptr = tipc_addr_to_str(dword);
917 proto_tree_add_string(tipc_tree, hf_tipcv2_prev_node, tipc_tvb, offset, 4, addr_str_ptr);
918 offset = offset + 4;
919 if (handle_v2_as & (V2_AS_1_6)) {
920 /* W4-8 */
921 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 20, "words 4-8 unused for this user");
922 offset = offset + 20;
923 } else {
924 /* W4+5 */
925 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 8, "words 4+5 unused for this user");
926 offset = offset + 8;
927 /* W6 */
928 dword = tvb_get_ntohl(tipc_tvb, offset);
929 addr_str_ptr = tipc_addr_to_str(dword);
930 proto_tree_add_string(tipc_tree, hf_tipcv2_orig_node, tipc_tvb, offset, 4, addr_str_ptr);
931 offset = offset + 4;
932 /* W7 */
933 dword = tvb_get_ntohl(tipc_tvb, offset);
934 addr_str_ptr = tipc_addr_to_str(dword);
935 proto_tree_add_string(tipc_tree, hf_tipcv2_dest_node, tipc_tvb, offset, 4, addr_str_ptr);
936 offset = offset + 4;
937 /* W8 */
938 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 8 unused for this user");
939 offset = offset + 4;
941 /* W9 */
942 /* Message Count: 16 bits. */
943 proto_tree_add_item(tipc_tree, hf_tipcv2_msg_count, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
944 message_count = tvb_get_ntohs(tipc_tvb, offset);
945 /* According to the spec this should not be set here,
946 * while there is data != 0 in this field when capturing
948 proto_tree_add_item(tipc_tree, hf_tipcv2_link_tolerance, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
950 offset = offset + 4;
951 /* This should give equal results like
952 * while (message_count-- > 0) */
953 while ((guint32)offset < msg_size) {
954 msg_no++;
956 dword = tvb_get_ntohl(tipc_tvb, offset);
957 msg_in_bundle_size = dword & 0x1ffff;
958 msg_in_bundle_user = (dword >> 25) & 0xf;
960 proto_tree_add_text(top_tree, tipc_tvb, offset, msg_in_bundle_size, "Message %u of %u in Bundle (%s)",
961 msg_no, message_count, val_to_str_const(msg_in_bundle_user, tipcv2_user_short_str_vals, "unknown"));
962 data_tvb = tvb_new_subset(tipc_tvb, offset, msg_in_bundle_size, msg_in_bundle_size);
964 /* the info column shall not be deleted by the
965 * encapsulated messages */
966 col_append_str(pinfo->cinfo, COL_INFO, " | ");
967 col_set_fence(pinfo->cinfo, COL_INFO);
969 dissect_tipc(data_tvb, pinfo, top_tree, NULL);
971 /* the modulo is used to align the messages to 4 Bytes */
972 offset += msg_in_bundle_size + ((msg_in_bundle_size%4)?(4-(msg_in_bundle_size%4)):0);
974 break;
975 case TIPCv2_LINK_PROTOCOL:
976 /* W1 */
977 proto_tree_add_item(tipc_tree, hf_tipcv2_link_mtype, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
978 /* Sequence Gap: 13 bits. */
979 proto_tree_add_item(tipc_tree, hf_tipcv2_sequence_gap, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
980 proto_tree_add_item(tipc_tree, hf_tipcv2_broadcast_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
981 offset = offset + 4;
982 /* W2 */
983 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
984 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_seq_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
985 offset = offset + 4;
986 /* W3 */
987 dword = tvb_get_ntohl(tipc_tvb, offset);
988 addr_str_ptr = tipc_addr_to_str(dword);
989 proto_tree_add_string(tipc_tree, hf_tipcv2_prev_node, tipc_tvb, offset, 4, addr_str_ptr);
990 offset = offset + 4;
991 /* W4 */
992 /* Next Sent Broadcast: 16 bits */
993 proto_tree_add_item(tipc_tree, hf_tipcv2_next_sent_broadcast, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
994 /* Next Sent Packet: 16 bits. */
995 proto_tree_add_item(tipc_tree, hf_tipcv2_next_sent_packet, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
996 offset = offset + 4;
997 /* W5 */
998 /* Session Number: 16 bits. */
999 proto_tree_add_item(tipc_tree, hf_tipcv2_session_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1000 /* Reserved: 3 bits Must be set to zero. */
1001 /* the following two fields appear in this user according to */
1002 /* Jon Maloy on the tipc-discussion mailing list */
1003 /* Redundant Link: 1 bit */
1004 proto_tree_add_item(tipc_tree, hf_tipcv2_redundant_link, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1005 /* Bearer Identity: 3 bits */
1006 proto_tree_add_item(tipc_tree, hf_tipcv2_bearer_id, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1007 /* Link Priority: 5 bits. */
1008 proto_tree_add_item(tipc_tree, hf_tipcv2_link_prio, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1009 /* Network Plane: 3 bits. */
1010 proto_tree_add_item(tipc_tree, hf_tipcv2_network_plane, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1011 /* Probe: 1 bit. */
1012 proto_tree_add_item(tipc_tree, hf_tipcv2_probe, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1013 offset = offset + 4;
1014 if (handle_v2_as & (V2_AS_1_6)) {
1015 /* W6-8 */
1016 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 12, "words 6-8 unused for this user");
1017 offset = offset + 12;
1018 } else {
1019 /* W6 */
1020 dword = tvb_get_ntohl(tipc_tvb, offset);
1021 addr_str_ptr = tipc_addr_to_str(dword);
1022 proto_tree_add_string(tipc_tree, hf_tipcv2_orig_node, tipc_tvb, offset, 4, addr_str_ptr);
1023 offset = offset + 4;
1024 /* W7 */
1025 dword = tvb_get_ntohl(tipc_tvb, offset);
1026 addr_str_ptr = tipc_addr_to_str(dword);
1027 proto_tree_add_string(tipc_tree, hf_tipcv2_dest_node, tipc_tvb, offset, 4, addr_str_ptr);
1028 offset = offset + 4;
1029 /* W8 */
1030 proto_tree_add_item(tipc_tree, hf_tipcv2_timestamp, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1031 offset = offset + 4;
1033 /* W9 */
1034 proto_tree_add_item(tipc_tree, hf_tipcv2_max_packet, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1035 /* Link Tolerance: 16 bits */
1036 proto_tree_add_item(tipc_tree, hf_tipcv2_link_tolerance, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1037 offset = offset + 4;
1039 if ((message_type == TIPCv2_RESET_MSG)
1040 || ((message_type == TIPCv2_STATE_MSG) && ((msg_size-(orig_hdr_size*4)) != 0))) /* is allowed */
1041 proto_tree_add_item(tipc_tree, hf_tipcv2_bearer_instance, tipc_tvb, offset, -1, ENC_ASCII|ENC_NA);
1042 /* the bearer instance string is padded with \0 to the next word boundry */
1043 b_inst_strlen = tvb_strsize(tipc_tvb, offset);
1044 offset += b_inst_strlen;
1045 if ((padlen = (4-b_inst_strlen%4)) > 0) {
1046 proto_tree_add_text(tipc_tree, tipc_tvb, offset, padlen, "Padding: %d byte%c", padlen, (padlen!=1?'s':0));
1047 offset += padlen;
1049 if ((offset-msg_size) > 0) {
1050 proto_tree_add_text(tipc_tree, tipc_tvb, offset, -1, "Filler for MTU discovery: %d byte%c", tvb_length_remaining(tipc_tvb, offset), (padlen!=1?'s':0));
1052 break;
1053 case TIPCv2_CONN_MANAGER:
1054 /* CONN_MANAGER uses the 36-byte header format of CONN_MSG payload messages */
1055 /* W1 */
1056 proto_tree_add_item(tipc_tree, hf_tipcv2_connmgr_mtype, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1057 proto_tree_add_item(tipc_tree, hf_tipcv2_errorcode, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1058 proto_tree_add_item(tipc_tree, hf_tipcv2_rer_cnt, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1059 proto_tree_add_item(tipc_tree, hf_tipcv2_lookup_scope, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1061 /* Options Position: 3 bits */
1062 /* this is not used by this user according to Jon Maloy in tipc-discussion mailing list
1063 opt_p = tvb_get_guint8(tipc_tvb, offset+1) & 0x7;
1064 proto_tree_add_item(tipc_tree, hf_tipcv2_opt_p , tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1065 if (opt_p != 0) {
1066 hdr_size = hdr_size - (opt_p << 2);
1069 proto_tree_add_item(tipc_tree, hf_tipcv2_broadcast_ack_no , tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1070 offset = offset + 4;
1072 /* W2 */
1073 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_ack_no , tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1074 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_seq_no , tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1075 offset = offset + 4;
1077 /* W3 */
1078 dword = tvb_get_ntohl(tipc_tvb, offset);
1079 addr_str_ptr = tipc_addr_to_str(dword);
1080 proto_tree_add_string(tipc_tree, hf_tipcv2_prev_node, tipc_tvb, offset, 4, addr_str_ptr);
1081 offset = offset + 4;
1083 /* W4 */
1084 proto_tree_add_item(tipc_tree, hf_tipc_org_port , tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1085 offset = offset + 4;
1087 /* W5 */
1088 proto_tree_add_item(tipc_tree, hf_tipc_dst_port , tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1089 offset = offset + 4;
1091 /* W6 */
1092 dword = tvb_get_ntohl(tipc_tvb, offset);
1093 addr_str_ptr = tipc_addr_to_str(dword);
1094 proto_tree_add_string(tipc_tree, hf_tipcv2_orig_node, tipc_tvb, offset, 4, addr_str_ptr);
1095 offset = offset + 4;
1097 /* W7 */
1098 dword = tvb_get_ntohl(tipc_tvb, offset);
1099 addr_str_ptr = tipc_addr_to_str(dword);
1100 proto_tree_add_string(tipc_tree, hf_tipcv2_dest_node, tipc_tvb, offset, 4, addr_str_ptr);
1101 offset = offset + 4;
1103 /* W8 */
1104 /* according to Allan Stephens this was never verfied by the receiver
1105 proto_tree_add_item(tipc_tree, hf_tipcv2_transport_seq_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1107 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 8 unused for this user (might be set prior to 1.7.3 but was never verified)");
1108 offset = offset + 4;
1111 /* this is not used here according to Jon Maloy in tipc-discussion mailing list
1112 * Options
1114 if (opt_p != 0) {
1115 proto_tree_add_text(tipc_tree, tipc_tvb, offset, (opt_p >> 2), "Options");
1116 offset = offset + (opt_p << 2);
1120 if (message_type == TIPCv2_CONMGR_MSG_ACK || (handle_v2_as & (V2_AS_ALL + V2_AS_1_7)))
1122 /* W9 */
1123 proto_tree_add_item(tipc_tree, hf_tipcv2_conn_mgr_msg_ack, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1124 offset += 4;
1126 break;
1127 case TIPCv2_ROUTE_DISTRIBUTOR:
1128 /* W1 */
1129 /* determine if it is TIPC v1.6 or v1.7 */
1130 dword = tvb_get_ntohl(tipc_tvb, offset+28);
1131 item_size = (dword >> 24) & 0xff;
1132 if ((handle_v2_as & V2_AS_1_6) || ((handle_v2_as & V2_AS_ALL) == 0)) {
1133 proto_tree_add_item(tipc_tree, hf_tipcv2_route_mtype_1_6, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1134 } else {
1135 proto_tree_add_item(tipc_tree, hf_tipcv2_route_mtype_1_7, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1137 proto_tree_add_item(tipc_tree, hf_tipcv2_broadcast_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1138 offset = offset + 4;
1139 /* W2 */
1140 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1141 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_seq_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1142 offset = offset + 4;
1143 /* W3 */
1144 dword = tvb_get_ntohl(tipc_tvb, offset);
1145 addr_str_ptr = tipc_addr_to_str(dword);
1146 proto_tree_add_string(tipc_tree, hf_tipcv2_prev_node, tipc_tvb, offset, 4, addr_str_ptr);
1147 offset = offset + 4;
1148 /* W4 */
1150 if (handle_v2_as & V2_AS_1_6) {
1151 /* W4-9 */
1152 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 24, "words 4-9 unused for this user");
1153 offset = offset + 24;
1154 } else {
1155 /* W4 */
1156 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 4 unused for this user");
1157 offset = offset + 4;
1158 /* W5 */
1159 proto_tree_add_item(tipc_tree, hf_tipc_dst_port, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1160 offset = offset + 4;
1161 /* W6 */
1162 dword = tvb_get_ntohl(tipc_tvb, offset);
1163 addr_str_ptr = tipc_addr_to_str(dword);
1164 proto_tree_add_string(tipc_tree, hf_tipcv2_orig_node, tipc_tvb, offset, 4, addr_str_ptr);
1165 offset = offset + 4;
1166 /* W7 */
1167 dword = tvb_get_ntohl(tipc_tvb, offset);
1168 addr_str_ptr = tipc_addr_to_str(dword);
1169 proto_tree_add_string(tipc_tree, hf_tipcv2_dest_node, tipc_tvb, offset, 4, addr_str_ptr);
1170 offset = offset + 4;
1171 /* W8 */
1172 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 8 unused for this user");
1173 offset = offset + 4;
1174 /* W9 */
1175 dword = tvb_get_ntohl(tipc_tvb, offset);
1176 item_size = (dword >> 24) & 0xff;
1177 proto_tree_add_item(tipc_tree, hf_tipcv2_item_size, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1178 offset = offset + 4;
1181 /* item_size == 0 indicates that it's TIPC v1.6 style */
1182 if ((handle_v2_as & V2_AS_1_6) || ((handle_v2_as & V2_AS_ALL) && (item_size == 0))) {
1183 /* W10 */
1184 switch (message_type) {
1185 case TIPCv2_EXT_ROUTING_TABLE: /* 0 */
1186 case TIPCv2_LOCAL_ROUTING_TABLE: /* 1 */
1187 case TIPCv2_SEC_ROUTING_TABLE: /* 2 */
1188 /* Cluster Address */
1189 dword = tvb_get_ntohl(tipc_tvb, offset);
1190 addr_str_ptr = tipc_addr_to_str(dword);
1191 proto_tree_add_string(tipc_tree, hf_tipcv2_cluster_address, tipc_tvb, offset, 4, addr_str_ptr);
1192 offset = offset + 4;
1193 /* bitmap */
1194 proto_tree_add_item(tipc_tree, hf_tipcv2_bitmap, tipc_tvb, offset, -1, ENC_NA);
1195 break;
1196 case TIPCv2_ROUTE_ADDITION: /* 3 */
1197 case TIPCv2_ROUTE_REMOVAL: /* 4 */
1198 /* Node Address */
1199 dword = tvb_get_ntohl(tipc_tvb, offset);
1200 addr_str_ptr = tipc_addr_to_str(dword);
1201 proto_tree_add_string(tipc_tree, hf_tipcv2_node_address, tipc_tvb, offset, 4, addr_str_ptr);
1202 offset = offset + 4;
1203 default:
1204 break;
1206 } else {
1207 /* what if item_size is set to a value fitting to TIPC v1.6 ? */
1208 dword = tvb_get_ntohl(tipc_tvb, offset);
1209 addr_str_ptr = tipc_addr_to_str(dword);
1210 proto_tree_add_string(tipc_tree, hf_tipcv2_network_region, tipc_tvb, offset, 4, addr_str_ptr);
1211 offset += 4;
1212 dword = tvb_get_ntohl(tipc_tvb, offset);
1213 addr_str_ptr = tipc_addr_to_str(dword);
1214 proto_tree_add_string(tipc_tree, hf_tipcv2_local_router, tipc_tvb, offset, 4, addr_str_ptr);
1215 offset += 4;
1216 dword = tvb_get_ntohl(tipc_tvb, offset);
1217 addr_str_ptr = tipc_addr_to_str(dword);
1218 proto_tree_add_string(tipc_tree, hf_tipcv2_remote_router, tipc_tvb, offset, 4, addr_str_ptr);
1219 offset += 4;
1220 proto_tree_add_item(tipc_tree, hf_tipcv2_dist_dist, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1221 proto_tree_add_item(tipc_tree, hf_tipcv2_dist_scope, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1222 offset = offset + 4;
1224 break;
1226 case TIPCv2_CHANGEOVER_PROTOCOL:
1227 /* W1 */
1228 proto_tree_add_item(tipc_tree, hf_tipcv2_changeover_mtype, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1229 proto_tree_add_item(tipc_tree, hf_tipcv2_broadcast_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1230 offset = offset + 4;
1231 /* W2 */
1232 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1233 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_seq_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1234 offset = offset + 4;
1235 /* W3 */
1236 dword = tvb_get_ntohl(tipc_tvb, offset);
1237 addr_str_ptr = tipc_addr_to_str(dword);
1238 proto_tree_add_string(tipc_tree, hf_tipcv2_prev_node, tipc_tvb, offset, 4, addr_str_ptr);
1239 offset = offset + 4;
1240 /* W4 */
1241 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 4 unused for this user");
1242 offset = offset + 4;
1243 /* W5 */
1244 /* the following two fields appear in this user according to */
1245 /* Jon Maloy on the tipc-discussion mailing list */
1246 /* Redundant Link: 1 bit */
1247 if (handle_v2_as & (V2_AS_1_6)) {
1248 proto_tree_add_item(tipc_tree, hf_tipcv2_redundant_link, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1250 /* Bearer Identity: 3 bits */
1251 proto_tree_add_item(tipc_tree, hf_tipcv2_bearer_id, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1252 offset = offset + 4;
1253 /* W6-W8 */
1254 if (handle_v2_as & (V2_AS_1_6)) {
1255 /* W6-8 */
1256 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 12, "words 6-8 unused for this user");
1257 offset = offset + 12;
1258 } else {
1259 /* W6 */
1260 dword = tvb_get_ntohl(tipc_tvb, offset);
1261 addr_str_ptr = tipc_addr_to_str(dword);
1262 proto_tree_add_string(tipc_tree, hf_tipcv2_orig_node, tipc_tvb, offset, 4, addr_str_ptr);
1263 offset = offset + 4;
1264 /* W7 */
1265 dword = tvb_get_ntohl(tipc_tvb, offset);
1266 addr_str_ptr = tipc_addr_to_str(dword);
1267 proto_tree_add_string(tipc_tree, hf_tipcv2_dest_node, tipc_tvb, offset, 4, addr_str_ptr);
1268 offset = offset + 4;
1269 /* W8 */
1270 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 8 unused for this user");
1271 offset = offset + 4;
1273 /* W9 */
1274 switch (message_type)
1276 case 0:
1277 /* DUPLICATE_MSG */
1278 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 9 unused for this message type");
1279 break;
1280 case 1:
1281 /* ORIGINAL_MSG */
1282 /* Message Count: 16 bits. */
1283 proto_tree_add_item(tipc_tree, hf_tipcv2_msg_count, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1284 break;
1285 default:
1286 break;
1288 offset = offset + 4;
1289 break;
1290 case TIPCv2_NAME_DISTRIBUTOR:
1291 /* W1 */
1292 proto_tree_add_item(tipc_tree, hf_tipcv2_naming_mtype, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1293 proto_tree_add_item(tipc_tree, hf_tipcv2_broadcast_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1294 offset = offset + 4;
1295 /* W2 */
1296 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1297 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_seq_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1298 offset = offset + 4;
1299 /* W3 */
1300 dword = tvb_get_ntohl(tipc_tvb, offset);
1301 addr_str_ptr = tipc_addr_to_str(dword);
1302 proto_tree_add_string(tipc_tree, hf_tipcv2_prev_node, tipc_tvb, offset, 4, addr_str_ptr);
1303 offset = offset + 4;
1304 /* W4+W5 */
1305 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 8, "words 4+5 unused for this user");
1306 offset = offset + 8;
1307 /* W6 */
1308 /* Originating Node: 32 bits. */
1309 dword = tvb_get_ntohl(tipc_tvb, offset);
1310 addr_str_ptr = tipc_addr_to_str(dword);
1311 proto_tree_add_string(tipc_tree, hf_tipcv2_orig_node, tipc_tvb, offset, 4, addr_str_ptr);
1312 offset = offset + 4;
1313 /* W7 */
1314 /* Destination Node: 32 bits. */
1315 dword = tvb_get_ntohl(tipc_tvb, offset);
1316 addr_str_ptr = tipc_addr_to_str(dword);
1317 proto_tree_add_string(tipc_tree, hf_tipcv2_dest_node, tipc_tvb, offset, 4, addr_str_ptr);
1318 offset = offset + 4;
1319 if (handle_v2_as & (V2_AS_1_6 + V2_AS_ALL)) {
1320 /* W8 */
1321 /* Transport Level Sequence Number: 32 bits */
1322 proto_tree_add_item(tipc_tree, hf_tipcv2_transport_seq_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1323 offset = offset + 4;
1324 } else {
1325 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 8 unused for this user");
1326 offset = offset + 4;
1328 /* W9 */
1329 if (handle_v2_as & V2_AS_1_6) {
1330 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 9 unused for this user");
1331 offset = offset + 4;
1332 } else {
1333 dword = tvb_get_ntohl(tipc_tvb, offset);
1334 item_size = (dword >> 24) & 0xff;
1335 proto_tree_add_item(tipc_tree, hf_tipcv2_item_size, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1336 offset = offset + 4;
1338 /* W10 */
1339 /* dissect the (one or more) Publications */
1340 data_tvb = tvb_new_subset_remaining(tipc_tvb, offset);
1341 dissect_tipc_name_dist_data(data_tvb, tipc_tree, item_size);
1342 break;
1343 case TIPCv2_MSG_FRAGMENTER:
1344 /* W1 */
1345 proto_tree_add_item(tipc_tree, hf_tipcv2_fragmenter_mtype, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1346 proto_tree_add_item(tipc_tree, hf_tipcv2_broadcast_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1347 offset = offset + 4;
1348 /* W2 */
1349 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1350 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_seq_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1351 offset = offset + 4;
1352 /* W3 */
1353 dword = tvb_get_ntohl(tipc_tvb, offset);
1354 addr_str_ptr = tipc_addr_to_str(dword);
1355 proto_tree_add_string(tipc_tree, hf_tipcv2_prev_node, tipc_tvb, offset, 4, addr_str_ptr);
1356 offset = offset + 4;
1357 /* W4 */
1358 dword = tvb_get_ntohl(tipc_tvb, offset);
1359 /* Fragment Number: 16 Bits. */
1360 proto_tree_add_item(tipc_tree, hf_tipcv2_fragment_number, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1361 frag_no = (dword >> 16) & 0x0000ffff;
1362 /* Fragment msg Number: 16 bits */
1363 proto_tree_add_item(tipc_tree, hf_tipcv2_fragment_msg_number, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1364 frag_msg_no = dword & 0x0000ffff;
1365 offset = offset + 4;
1366 if (handle_v2_as & (V2_AS_1_6)) {
1367 /* W5-W9 */
1368 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 20, "words 5-9 unused for this user");
1369 offset = offset + 20;
1370 } else {
1371 /* W5 */
1372 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "word 5 unused for this user");
1373 offset = offset + 4;
1374 /* W6 */
1375 dword = tvb_get_ntohl(tipc_tvb, offset);
1376 addr_str_ptr = tipc_addr_to_str(dword);
1377 proto_tree_add_string(tipc_tree, hf_tipcv2_orig_node, tipc_tvb, offset, 4, addr_str_ptr);
1378 offset = offset + 4;
1379 /* W7 */
1380 dword = tvb_get_ntohl(tipc_tvb, offset);
1381 addr_str_ptr = tipc_addr_to_str(dword);
1382 proto_tree_add_string(tipc_tree, hf_tipcv2_dest_node, tipc_tvb, offset, 4, addr_str_ptr);
1383 offset = offset + 4;
1384 /* W8+9 */
1385 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 8, "words 8+9 unused for this user");
1386 offset = offset + 8;
1389 len = (msg_size - (orig_hdr_size<<2));
1390 reported_len = tvb_reported_length_remaining(tipc_tvb, offset);
1392 if (tipc_defragment) {
1393 /* reassemble fragmented packages */
1394 save_fragmented = pinfo->fragmented;
1395 pinfo->fragmented = TRUE;
1397 frag_msg = fragment_add_seq_check(&tipc_msg_reassembly_table,
1398 tipc_tvb, offset,
1399 pinfo,
1400 frag_msg_no, /* ID for fragments belonging together */
1401 NULL,
1402 /* TODO: make sure that fragments are on the same LINK */
1403 /* TIPC starts with "1" but we * need "0" */
1404 (frag_no-1), /* number of the fragment */
1405 len, /* fragment length - to the end of the data */
1406 (message_type != TIPCv2_USER_LAST_FRAGMENT)); /* More fragments? */
1408 new_tvb = process_reassembled_data(tipc_tvb, offset, pinfo,
1409 "Reassembled TIPC", frag_msg, &tipc_msg_frag_items,
1410 NULL, tipc_tree);
1412 if (frag_msg) { /* Reassembled */
1413 col_append_str(pinfo->cinfo, COL_INFO,
1414 " (Message Reassembled)");
1415 } else { /* Not last packet of reassembled Short Message */
1416 col_append_fstr(pinfo->cinfo, COL_INFO,
1417 " (Message fragment %u)", frag_no);
1419 if (new_tvb) { /* take it all */
1421 /* the info column shall not be deleted by the
1422 * encapsulated messages */
1423 col_append_str(pinfo->cinfo, COL_INFO, " | ");
1424 col_set_fence(pinfo->cinfo, COL_INFO);
1425 dissect_tipc(new_tvb, pinfo, top_tree, NULL);
1426 } else { /* make a new subset */
1427 data_tvb = tvb_new_subset(tipc_tvb, offset, len, reported_len);
1428 call_dissector(data_handle, data_tvb, pinfo, top_tree);
1431 pinfo->fragmented = save_fragmented;
1432 } else {
1433 /* don't reassemble is set in the "preferences" */
1434 data_tvb = tvb_new_subset(tipc_tvb, offset, len, reported_len);
1435 call_dissector(data_handle, data_tvb, pinfo, top_tree);
1438 break;
1439 case TIPCv2_NEIGHBOUR_DISCOVERY:
1441 The protocol for neighbour detection
1442 uses a special message format, with the following generic structure:
1444 0 1 2 3
1445 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1446 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1447 w0:|vers |msg usr|hdr sz |n|resrv| packet size |
1448 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1449 w1:|m typ|00000| minor_pv | node signature |
1450 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1451 w2:| destination domain |
1452 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1453 w3:| previous node |
1454 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1455 w4:| network identity |
1456 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1457 w5:| |
1458 +-+-+-+-+-+-+- +-+-+-+-+-+-+-+
1459 w6:| |
1460 +-+-+-+-+-+-+- bearer level originating address +-+-+-+-+-+-+-+
1461 w7:| |
1462 +-+-+-+-+-+-+- +-+-+-+-+-+-+-+
1463 w8:| |
1464 +-+-+-+-+-+-+- +-+-+-+-+-+-+-+
1465 w9:| |
1466 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1468 / vendor specific data (optional) /
1470 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1472 /* W1 */
1473 proto_tree_add_item(tipc_tree, hf_tipcv2_neighbour_mtype, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1474 /* Reserved 5 bits */
1475 /* Minor pv 8 bits */
1476 proto_tree_add_item(tipc_tree, hf_tipcv2_minor_pv, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1477 proto_tree_add_item(tipc_tree, hf_tipcv2_node_sig, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1478 offset = offset + 4;
1479 /* W2 */
1480 /* Destination Domain */
1481 dword = tvb_get_ntohl(tipc_tvb, offset);
1482 addr_str_ptr = tipc_addr_to_str(dword);
1483 proto_tree_add_string(tipc_tree, hf_tipcv2_destination_domain, tipc_tvb, offset, 4, addr_str_ptr);
1484 offset = offset + 4;
1485 /* W3 */
1486 dword = tvb_get_ntohl(tipc_tvb, offset);
1487 addr_str_ptr = tipc_addr_to_str(dword);
1488 proto_tree_add_string(tipc_tree, hf_tipcv2_prev_node, tipc_tvb, offset, 4, addr_str_ptr);
1489 offset = offset + 4;
1490 /* W4 */
1491 /* Network Identity: */
1492 proto_tree_add_item(tipc_tree, hf_tipcv2_network_id, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1493 offset = offset + 4;
1494 if (handle_v2_as & (V2_AS_1_6)) {
1495 /* W5 - W9 Bearer Level Originating Address: */
1496 proto_tree_add_item(tipc_tree, hf_tipcv2_bearer_level_orig_addr, tipc_tvb, offset, 20, ENC_NA);
1497 offset = offset + 20;
1498 } else {
1499 /* W5 */
1500 proto_tree_add_item(tipc_tree, hf_tipcv2_media_id, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1501 offset = offset + 4;
1502 /* W6 - W9 Bearer Level Originating Address: */
1503 proto_tree_add_item(tipc_tree, hf_tipcv2_bearer_level_orig_addr, tipc_tvb, offset, 16, ENC_NA);
1504 offset = offset + 16;
1506 if (msg_size-(orig_hdr_size*4) != 0) {
1507 proto_tree_add_text(tipc_tree, tipc_tvb, offset, -1, "Vendor specific data");
1509 break;
1510 default:
1511 break;
1514 return offset;
1518 /* Version 2 Header
1519 http://tipc.sourceforge.net/doc/draft-spec-tipc-02.html#sec:TIPC_Pkt_Format
1520 3.1.1. Payload Message Header Format
1522 0 1 2 3
1523 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1524 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1525 w0:|vers | user |hdr sz |n|d|s|r| message size |
1526 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1527 w1:|mstyp| error |rer cnt|lsc|opt p| broadcast ack no |
1528 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1529 w2:| link level ack no | broadcast/link level seq no |
1530 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1531 w3:| previous node |
1532 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1533 w4:| originating port |
1534 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1535 w5:| destination port |
1536 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1537 w6:| originating node |
1538 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1539 w7:| destination node |
1540 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1541 w8:| name type / transport sequence number |
1542 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1543 w9:| name instance/multicast lower bound |
1544 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1545 wA:| multicast upper bound |
1546 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1548 \ options \
1550 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1553 /* this function tries to call subdissectors for encapsulated data
1554 * @name_type pointer to the used port name type, NULL if not available
1555 * @user guint8 holding the used TIPC user, is allways available
1557 static void
1558 call_tipc_v2_data_subdissectors(tvbuff_t *data_tvb, packet_info *pinfo, guint32 *name_type_p, guint8 user)
1560 if (dissect_tipc_data) {
1561 /* dissection of TIPC data is set in preferences */
1563 /* check for heuristic dissectors if specified in the
1564 * preferences to try them first */
1565 if (try_heuristic_first) {
1566 if (dissector_try_heuristic(tipc_heur_subdissector_list, data_tvb, pinfo, top_tree, NULL))
1567 return;
1569 /* This triggers if a dissectors if
1570 * tipc.user is just set to a TIPC user holding data */
1571 if (dissector_try_uint(tipc_user_dissector, user, data_tvb, pinfo, top_tree))
1572 return;
1573 /* The Name Type is not always explicitly set in a TIPC Data
1574 * Message.
1576 * On the tipc-discussion mailing list, Allan Stephens described
1577 * where the Port Name is not set with the following words:
1579 * <cite>
1580 * The "named" and "mcast" message types have info in the TIPC header to
1581 * specify the message's destination (a port name and port name sequence,
1582 * respectively); these message types typically occur when an application
1583 * sends connectionless traffic. The "conn" type is used to carry
1584 * connection-oriented traffic over an already established connection;
1585 * since the sending socket/port already knows the port ID of the other end
1586 * of the connection, there is no need for any port name information to be
1587 * present in the TIPC header.
1589 * The "direct" type is used to carry connectionless traffic to a
1590 * destination that was specified using a port ID, rather than a port name;
1591 * again, no port name info is present in the TIPC header because it is not
1592 * required. Situations where this sort of message might be generated
1593 * include: a) an application obtains a port ID as part of a subscription
1594 * event generated by TIPC's topology server and then sends a message to
1595 * that port ID (using sendto() or sendmsg()), and b) a server obtains a
1596 * client's port ID when it receives a message from the client (using
1597 * recvfrom() or recvmsg()) and then sends a reply back to that client port
1598 * ID (using sendto() or sendmsg()).
1599 * </cite>
1601 * TODO: it should be determined by
1602 * some kind of static function which port name type a message
1603 * is going to, if it is not specified explicitly in a message */
1604 if (name_type_p)
1605 if (dissector_try_uint(tipc_type_dissector, *name_type_p, data_tvb, pinfo, top_tree))
1606 return;
1607 /* check for heuristic dissectors if specified in the
1608 * preferences not to try them first */
1609 if (!try_heuristic_first) {
1610 if (dissector_try_heuristic(tipc_heur_subdissector_list, data_tvb, pinfo, top_tree, NULL))
1611 return;
1615 /* dissection of TIPC data is not set in preferences or no subdissector found */
1617 call_dissector(data_handle, data_tvb, pinfo, top_tree);
1621 static void
1622 dissect_tipc_v2(tvbuff_t *tipc_tvb, proto_tree *tipc_tree, packet_info *pinfo, int offset, guint8 user, guint32 msg_size, guint8 hdr_size, gboolean datatype_hdr)
1624 guint32 dword;
1625 gchar *addr_str_ptr;
1626 guint8 opt_p = 0;
1627 proto_item *item;
1628 /* The unit used is 32 bit words */
1629 guint8 orig_hdr_size;
1631 guint32 name_type = 0;
1632 guint32 *name_type_p = NULL;
1633 tvbuff_t *data_tvb;
1634 gint len, reported_len;
1636 orig_hdr_size = hdr_size;
1638 /* Word 0 */
1639 /* Version: 3 bits */
1640 proto_tree_add_item(tipc_tree, hf_tipc_ver, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1641 /* User: 4 bits */
1642 proto_tree_add_item(tipc_tree, hf_tipcv2_usr, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1643 /* Header Size: 4 bits */
1644 item = proto_tree_add_item(tipc_tree, hf_tipc_hdr_size, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1645 proto_item_append_text(item, " = %u bytes", (hdr_size * 4));
1646 /* Non-sequenced: 1 bit */
1647 proto_tree_add_item(tipc_tree, hf_tipc_nonsequenced, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1648 if (datatype_hdr) {
1649 /* Destination Droppable: 1 bit */
1650 proto_tree_add_item(tipc_tree, hf_tipc_destdrop, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1651 /* Source Droppable: 1 bit */
1652 proto_tree_add_item(tipc_tree, hf_tipcv2_srcdrop, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1653 /* SYN: 1 bit */
1654 proto_tree_add_item(tipc_tree, hf_tipcv2_syn, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1656 /* Reserved: 1 bits */
1658 /* Message Size: 17 bits */
1659 proto_tree_add_item(tipc_tree, hf_tipc_msg_size, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1660 offset = offset + 4;
1662 if (!datatype_hdr) {
1663 dissect_tipc_v2_internal_msg(tipc_tvb, tipc_tree, pinfo, offset, user, msg_size, orig_hdr_size);
1664 return;
1667 /* Word 1 */
1668 /* Message Type: 3 bits */
1669 proto_tree_add_item(tipc_tree, hf_tipcv2_data_msg_type, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1670 /* Error Code: 4 bits */
1671 proto_tree_add_item(tipc_tree, hf_tipcv2_errorcode, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1673 /* Reroute Counter: 4 bits */
1674 proto_tree_add_item(tipc_tree, hf_tipcv2_rer_cnt, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1675 /* Lookup Scope: 2 bits */
1676 proto_tree_add_item(tipc_tree, hf_tipcv2_lookup_scope, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1678 /* Options Position: 3 bits */
1679 if (handle_v2_as & (V2_AS_ALL + V2_AS_1_6)) {
1680 opt_p = tvb_get_guint8(tipc_tvb, offset+1) & 0x7;
1681 proto_tree_add_item(tipc_tree, hf_tipcv2_opt_p, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1682 if (opt_p != 0) {
1683 hdr_size = hdr_size - (opt_p << 2);
1686 /* Broadcast Acknowledge Number: 16 bits */
1687 proto_tree_add_item(tipc_tree, hf_tipcv2_broadcast_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1688 offset = offset + 4;
1690 /* W2 */
1691 /* Link Level Acknowledge Number: 16 bits */
1692 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_ack_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1693 /* broadcast/link level seq no */
1694 proto_tree_add_item(tipc_tree, hf_tipcv2_link_level_seq_no, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1695 offset = offset + 4;
1696 /* W3 previous node */
1697 dword = tvb_get_ntohl(tipc_tvb, offset);
1698 addr_str_ptr = tipc_addr_to_str(dword);
1699 proto_tree_add_string(tipc_tree, hf_tipcv2_prev_node, tipc_tvb, offset, 4, addr_str_ptr);
1700 offset = offset + 4;
1702 /* W4 Originating Port: 32 bits */
1703 proto_tree_add_item(tipc_tree, hf_tipc_org_port, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1704 offset = offset + 4;
1706 /* W5 Destination Port: 32 bits */
1707 proto_tree_add_item(tipc_tree, hf_tipc_dst_port, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1708 offset = offset + 4;
1709 if (hdr_size > 6) {
1711 /* W6 Originating Node: 32 bits */
1712 dword = tvb_get_ntohl(tipc_tvb, offset);
1713 addr_str_ptr = tipc_addr_to_str(dword);
1714 proto_tree_add_string(tipc_tree, hf_tipcv2_orig_node, tipc_tvb, offset, 4, addr_str_ptr);
1715 offset = offset + 4;
1716 /* W7 Destination Node: 32 bits */
1717 dword = tvb_get_ntohl(tipc_tvb, offset);
1718 addr_str_ptr = tipc_addr_to_str(dword);
1719 proto_tree_add_string(tipc_tree, hf_tipcv2_dest_node, tipc_tvb, offset, 4, addr_str_ptr);
1720 offset = offset + 4;
1721 if (hdr_size > 8) {
1722 /* W8 name type / transport sequence number */
1723 /* Transport Level Sequence Number: 32 bits */
1724 /* Port Name Type: 32 bits */
1725 proto_tree_add_item(tipc_tree, hf_tipcv2_port_name_type, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1726 name_type = tvb_get_ntohl(tipc_tvb, offset);
1727 name_type_p = &name_type;
1728 offset = offset + 4;
1730 if (hdr_size > 9) {
1731 /* W9 name instance/multicast lower bound */
1732 if (hdr_size < 11)
1733 /* no multicast */
1734 /* Port Name Instance: 32 bits */
1735 proto_tree_add_item(tipc_tree, hf_tipcv2_port_name_instance, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1736 else
1737 /* multicast */
1738 /* Port Name Sequence Lower: 32 bits */
1739 proto_tree_add_item(tipc_tree, hf_tipcv2_multicast_lower, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1740 offset = offset + 4;
1741 if (hdr_size > 10) {
1743 /* W10 multicast upper bound */
1744 /* Port Name Sequence Upper: 32 bits */
1745 proto_tree_add_item(tipc_tree, hf_tipcv2_multicast_upper, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
1746 offset = offset + 4;
1751 /* Options */
1752 if (handle_v2_as & (V2_AS_ALL + V2_AS_1_6)) {
1753 if (opt_p != 0) {
1754 proto_tree_add_text(tipc_tree, tipc_tvb, offset, (opt_p >> 2), "Options");
1755 offset = offset + (opt_p << 2);
1758 /* TIPCv2 data */
1759 len = (msg_size - (orig_hdr_size<<2));
1760 reported_len = tvb_reported_length_remaining(tipc_tvb, offset);
1761 data_tvb = tvb_new_subset(tipc_tvb, offset, len, reported_len);
1763 call_tipc_v2_data_subdissectors(data_tvb, pinfo, name_type_p, user);
1766 /* From message.h (http://cvs.sourceforge.net/viewcvs.py/tipc/source/stable_ericsson/TIPC_SCC/src/Message.h?rev=1.2&view=markup)
1767 ////////////////////////////////////////////////////////////////////
1768 TIPC internal header format, version 1:
1771 | Word 0-2: common to all users |
1773 +-------+-------+-------+-------+-------+-------+-------+-------+
1774 |netw-|imp|link | | |p|bea- |link |
1775 w3:|ork |ort|sel- | message count | |r|rer |sel- |
1776 |id |anc|ector| | |b|id |ector|
1777 +-------+-------+-------+-------+-------+-------+-------+-------+
1779 w4:| remote address |
1781 +-------+-------+-------+-------+-------+-------+-------+-------+
1782 | msg | | |
1783 w5:| type | gap | next sent |
1784 | | | |
1785 +-------+-------+-------+-------+-------+-------+-------+-------+
1786 | | link | |
1787 w6:| reserve | prio- | link tolerance |
1788 | | ity | |
1789 +-------+-------+-------+-------+-------+-------+-------+-------+
1791 w7:| |
1793 +-------+-------+ +-------+-------+
1795 w8:| |
1797 +-------+-------+ bearer name +-------+-------+
1799 w9:| |
1801 +-------+-------+ +-------+-------+
1803 wa:| |
1805 +-------+-------+-------+-------+-------+-------+-------+-------+
1807 NB: Connection Manager and Name Distributor use data message format.
1810 static void
1811 dissect_tipc_int_prot_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tipc_tree, int offset, guint8 user, guint32 msg_size)
1813 guint8 msg_type;
1814 tvbuff_t *data_tvb;
1815 guint32 msg_in_bundle_size;
1816 guint32 dword;
1817 guint msg_no = 0;
1818 guint8 link_sel;
1819 guint16 link_lev_seq_no;
1820 guint32 reassembled_msg_length = 0;
1821 guint32 no_of_segments = 0;
1823 gboolean save_fragmented;
1824 tvbuff_t* new_tvb = NULL;
1825 tvbuff_t* next_tvb = NULL;
1826 fragment_head *frag_msg = NULL;
1827 proto_item *item;
1829 link_lev_seq_no = tvb_get_ntohl(tvb, 4) & 0xffff;
1830 /* Internal Protocol Header */
1831 /* Unused */
1833 msg_type = tvb_get_guint8(tvb, 20)>>4;
1834 /* W3 */
1835 dword = tvb_get_ntohl(tvb, offset);
1836 link_sel = dword & 0x7;
1837 proto_tree_add_item(tipc_tree, hf_tipc_unused2, tvb, offset, 4, ENC_BIG_ENDIAN);
1838 /* Importance */
1839 if (user == TIPC_SEGMENTATION_MANAGER)
1840 proto_tree_add_item(tipc_tree, hf_tipc_importance, tvb, offset, 4, ENC_BIG_ENDIAN);
1841 /* Link selector */
1842 if (user == TIPC_SEGMENTATION_MANAGER || user == TIPC_NAME_DISTRIBUTOR || user == TIPC_CHANGEOVER_PROTOCOL)
1843 proto_tree_add_item(tipc_tree, hf_tipc_link_selector, tvb, offset, 4, ENC_BIG_ENDIAN);
1844 /* Message count */
1845 if (user == TIPC_MSG_BUNDLER || user == TIPC_CHANGEOVER_PROTOCOL) {
1846 proto_tree_add_item(tipc_tree, hf_tipc_msg_cnt, tvb, offset, 4, ENC_BIG_ENDIAN);
1848 /* Unused */
1849 /* Probe */
1850 if (user == TIPC_LINK_PROTOCOL)
1851 proto_tree_add_item(tipc_tree, hf_tipc_probe, tvb, offset, 4, ENC_BIG_ENDIAN);
1852 /* Bearer identity */
1853 if (user == TIPC_LINK_PROTOCOL || user == TIPC_CHANGEOVER_PROTOCOL)
1854 proto_tree_add_item(tipc_tree, hf_tipc_bearer_id, tvb, offset, 4, ENC_BIG_ENDIAN);
1855 /* Link selector */
1856 if (user == TIPC_SEGMENTATION_MANAGER || user == TIPC_NAME_DISTRIBUTOR || user == TIPC_CHANGEOVER_PROTOCOL)
1857 proto_tree_add_item(tipc_tree, hf_tipc_link_selector2, tvb, offset, 4, ENC_BIG_ENDIAN);
1859 offset = offset + 4;
1861 /* W4 */
1862 /* Remote address */
1863 if (user == TIPC_ROUTING_MANAGER)
1864 proto_tree_add_item(tipc_tree, hf_tipc_remote_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
1865 offset = offset + 4;
1867 /* W5 */
1868 /* Message type */
1869 switch (user) {
1870 case TIPC_ROUTING_MANAGER:
1871 proto_tree_add_item(tipc_tree, hf_tipc_rm_msg_type, tvb, offset, 4, ENC_BIG_ENDIAN);
1872 break;
1873 case TIPC_NAME_DISTRIBUTOR:
1874 proto_tree_add_item(tipc_tree, hf_tipc_nd_msg_type, tvb, offset, 4, ENC_BIG_ENDIAN);
1875 break;
1876 case TIPC_CONNECTION_MANAGER:
1877 break;
1878 case TIPC_LINK_PROTOCOL:
1879 proto_tree_add_item(tipc_tree, hf_tipc_lp_msg_type, tvb, offset, 4, ENC_BIG_ENDIAN);
1880 break;
1881 case TIPC_CHANGEOVER_PROTOCOL:
1882 proto_tree_add_item(tipc_tree, hf_tipc_cng_prot_msg_type, tvb, offset, 4, ENC_BIG_ENDIAN);
1883 break;
1884 case TIPC_SEGMENTATION_MANAGER:
1885 proto_tree_add_item(tipc_tree, hf_tipc_sm_msg_type, tvb, offset, 4, ENC_BIG_ENDIAN);
1886 break;
1887 default:
1888 proto_tree_add_item(tipc_tree, hf_tipc_unknown_msg_type, tvb, offset, 4, ENC_BIG_ENDIAN);
1889 break;
1891 /* Sequence gap */
1892 if (user == TIPC_LINK_PROTOCOL && msg_type == TIPC_LINK_PROTOCO_STATE_MSG)
1893 proto_tree_add_item(tipc_tree, hf_tipc_seq_gap, tvb, offset, 4, ENC_BIG_ENDIAN);
1894 /* Next sent packet */
1895 proto_tree_add_item(tipc_tree, hf_tipc_nxt_snt_pkg, tvb, offset, 4, ENC_BIG_ENDIAN);
1897 offset = offset + 4;
1898 /* W6 */
1899 /* Unused */
1900 proto_tree_add_item(tipc_tree, hf_tipc_unused3, tvb, offset, 4, ENC_BIG_ENDIAN);
1901 offset = offset + 4;
1902 /* W7 */
1903 if (msg_size == 28) /* No data */
1904 return;
1906 switch (user) {
1907 case TIPC_LINK_PROTOCOL:
1908 proto_tree_add_item(tipc_tree, hf_tipc_bearer_name, tvb, offset, -1, ENC_ASCII|ENC_NA);
1909 break;
1910 case TIPC_CHANGEOVER_PROTOCOL:
1911 switch (msg_type) {
1912 case 0: /* DUPLICATE_MSG */
1913 case 1: /* ORIGINAL_MSG */
1914 proto_tree_add_text(tipc_tree, tvb, offset, -1, "TIPC_CHANGEOVER_PROTOCOL %s (%u)",
1915 val_to_str_const(msg_type, tipc_cng_prot_msg_type_values, "unknown"), msg_type);
1916 data_tvb = tvb_new_subset_remaining(tvb, offset);
1917 col_set_fence(pinfo->cinfo, COL_INFO);
1918 dissect_tipc(data_tvb, pinfo, tipc_tree, NULL);
1919 break;
1920 default:
1921 /* INFO_MSG: Even when there are no packets in the send queue of a removed link, the other
1922 * endpoint must be informed about this fact, so it can be unblocked when it has terminated its
1923 * part of the changeover procedure. This message type may be regarded as an empty
1924 * ORIGINAL_MSG, where message count is zero, and no packet is wrapped inside.
1926 proto_tree_add_text(tipc_tree, tvb, offset, -1, "TIPC_CHANGEOVER_PROTOCOL Protocol/dissection Error");
1927 break;
1929 break;
1930 case TIPC_SEGMENTATION_MANAGER:
1931 save_fragmented = pinfo->fragmented;
1932 if (tipc_defragment) {
1933 pinfo->fragmented = TRUE;
1935 frag_msg = fragment_add_seq_next(&tipc_msg_reassembly_table,
1936 tvb, offset,
1937 pinfo,
1938 link_sel, /* ID for fragments belonging together - NEEDS IMPROVING? */
1939 NULL,
1940 tvb_length_remaining(tvb, offset), /* fragment length - to the end */
1941 TRUE); /* More fragments? */
1942 if (msg_type == TIPC_FIRST_SEGMENT) {
1943 reassembled_msg_length = tvb_get_ntohl(tvb, offset) & 0x1ffff;
1944 /* The number of segments needed for he complete message (Including header) will be
1945 * The size of the data section of the first message, divided by the complete message size
1946 * + one segment for the remainder (if any).
1948 no_of_segments = reassembled_msg_length/(msg_size - 28);
1949 if (reassembled_msg_length > (no_of_segments * (msg_size - 28)))
1950 no_of_segments++;
1951 fragment_set_tot_len(&tipc_msg_reassembly_table,
1952 pinfo, link_sel, NULL,
1953 no_of_segments-1);
1954 item = proto_tree_add_text(tipc_tree, tvb, offset, -1, "Segmented message size %u bytes -> No segments = %i",
1955 reassembled_msg_length, no_of_segments);
1956 PROTO_ITEM_SET_GENERATED(item);
1959 new_tvb = process_reassembled_data(tvb, offset, pinfo,
1960 "Reassembled TIPC", frag_msg, &tipc_msg_frag_items,
1961 NULL, tipc_tree);
1963 if (frag_msg) { /* Reassembled */
1964 col_append_str(pinfo->cinfo, COL_INFO,
1965 " (Message Reassembled)");
1966 } else { /* Not last packet of reassembled Short Message */
1967 col_append_fstr(pinfo->cinfo, COL_INFO,
1968 " (Message fragment %u)", link_lev_seq_no);
1972 if (new_tvb) { /* take it all */
1973 next_tvb = new_tvb;
1974 } else { /* make a new subset */
1975 next_tvb = tvb_new_subset_remaining(tvb, offset);
1977 pinfo->fragmented = save_fragmented;
1978 if (new_tvb) {
1979 col_set_fence(pinfo->cinfo, COL_INFO);
1980 dissect_tipc(next_tvb, pinfo, tipc_tree, NULL);
1981 return;
1984 proto_tree_add_text(tipc_tree, next_tvb, 0, -1, "%u bytes Data Fragment", (msg_size - 28));
1985 break;
1986 case TIPC_MSG_BUNDLER:
1987 proto_tree_add_text(tipc_tree, tvb, offset, -1, "Message Bundle");
1988 while ((guint32)offset < msg_size) {
1989 msg_no++;
1990 msg_in_bundle_size = tvb_get_ntohl(tvb, offset);
1991 proto_tree_add_text(tipc_tree, tvb, offset, msg_in_bundle_size, "%u Message in Bundle", msg_no);
1992 data_tvb = tvb_new_subset(tvb, offset, msg_in_bundle_size, msg_in_bundle_size);
1993 col_set_fence(pinfo->cinfo, COL_INFO);
1994 dissect_tipc(data_tvb, pinfo, tipc_tree, NULL);
1995 offset = offset + msg_in_bundle_size;
1997 break;
1998 default:
1999 proto_tree_add_text(tipc_tree, tvb, offset, -1, "%u bytes Data", (msg_size - 28));
2000 break;
2005 /* determines the length of a TIPC package */
2006 static guint
2007 get_tipc_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
2009 return tvb_get_ntohl(tvb, offset) & 0x0001FFFF;
2013 /* triggers the dissection of TIPC-over-TCP */
2014 static int
2015 dissect_tipc_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data)
2017 tcp_dissect_pdus(tvb, pinfo, parent_tree, tipc_tcp_desegment, 4, get_tipc_pdu_len,
2018 dissect_tipc, data);
2019 return tvb_length(tvb);
2022 static int
2023 dissect_tipc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
2025 proto_item *ti, *tipc_data_item, *item;
2026 proto_tree *tipc_tree, *tipc_data_tree;
2027 int offset = 0;
2028 guint32 dword;
2029 guint8 version;
2030 guint32 msg_size;
2031 guint8 hdr_size;
2032 guint8 user;
2033 gchar *addr_str_ptr;
2034 const guchar *src_addr, *dst_addr;
2035 tvbuff_t *data_tvb, *tipc_tvb;
2036 gboolean datatype_hdr = FALSE;
2037 guint8 msg_type = 0;
2039 /* Make entry in Protocol column on summary display */
2040 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TIPC");
2042 col_clear(pinfo->cinfo, COL_INFO);
2044 top_tree = tree;
2045 dword = tvb_get_ntohl(tvb, offset);
2046 version = (dword >>29) & 0xf;
2047 hdr_size = (dword >>21) & 0xf;
2048 user = (dword>>25) & 0xf;
2049 msg_size = dword & 0x1ffff;
2051 if ((guint32)tvb_length_remaining(tvb, offset) < msg_size) {
2052 tipc_tvb = tvb;
2053 } else {
2054 tipc_tvb = tvb_new_subset(tvb, offset, msg_size, msg_size);
2056 /* user == 7 only works for v2, this will decode the legacy TIPC configuration protocol */
2057 if (user == TIPCv2_LINK_PROTOCOL) version = TIPCv2;
2058 /* Set User values in COL INFO different in V1 and V2 */
2059 switch (version) {
2060 case 0:
2061 case TIPCv1:
2062 msg_type = tvb_get_guint8(tipc_tvb, offset + 20)>>4;
2063 col_append_fstr(pinfo->cinfo, COL_INFO, " %s(%u) ", val_to_str_const(user, tipc_user_values, "unknown"), user);
2064 /* Set msg type in info col and find out if it's a data hdr or not */
2065 datatype_hdr = tipc_v1_set_col_msgtype(pinfo, user, msg_type);
2066 if (datatype_hdr) {
2067 /* Data type header */
2068 if (hdr_size > 5 && user <4) {
2069 /* W6 Originating Processor */
2070 src_addr = tvb_get_ptr(tipc_tvb, offset + 24, 4);
2071 SET_ADDRESS(&pinfo->src, AT_TIPC, 4, src_addr);
2073 /* W7 Destination Processor */
2074 dst_addr = tvb_get_ptr(tipc_tvb, offset + 28, 4);
2075 SET_ADDRESS(&pinfo->dst, AT_TIPC, 4, dst_addr);
2076 } else {
2077 /* Short data hdr */
2078 /* W2 Previous Processor */
2079 src_addr = tvb_get_ptr(tipc_tvb, offset + 8, 4);
2080 SET_ADDRESS(&pinfo->src, AT_TIPC, 4, src_addr);
2082 } else {
2083 /* W2 Previous Processor */
2084 src_addr = tvb_get_ptr(tipc_tvb, offset + 8, 4);
2085 SET_ADDRESS(&pinfo->src, AT_TIPC, 4, src_addr);
2087 break;
2088 case TIPCv2:
2089 msg_type = tvb_get_guint8(tipc_tvb, offset + 4)>>5;
2090 col_append_fstr(pinfo->cinfo, COL_INFO, "%-12s", val_to_str_const(user, tipcv2_user_short_str_vals, "unknown"));
2091 /* Set msg type in info col */
2092 tipc_v2_set_info_col(tvb, pinfo, user, msg_type, hdr_size);
2094 /* find out if it's a data hdr or not */
2095 switch (user) {
2096 case TIPCv2_DATA_LOW:
2097 case TIPCv2_DATA_NORMAL:
2098 case TIPCv2_DATA_HIGH:
2099 case TIPCv2_DATA_NON_REJECTABLE:
2100 datatype_hdr = TRUE;
2101 break;
2102 default:
2103 datatype_hdr = FALSE;
2104 break;
2107 if (datatype_hdr) {
2108 if (hdr_size > 6) {
2109 /* W6 Originating Processor */
2110 src_addr = tvb_get_ptr(tipc_tvb, offset + 24, 4);
2111 SET_ADDRESS(&pinfo->src, AT_TIPC, 4, src_addr);
2113 /* W7 Destination Processor */
2114 dst_addr = tvb_get_ptr(tipc_tvb, offset + 28, 4);
2115 SET_ADDRESS(&pinfo->dst, AT_TIPC, 4, dst_addr);
2116 } else {
2117 /* W3 Previous Processor */
2118 src_addr = tvb_get_ptr(tipc_tvb, offset + 12, 4);
2119 SET_ADDRESS(&pinfo->src, AT_TIPC, 4, src_addr);
2122 } else {
2123 if (user != TIPCv2_NEIGHBOUR_DISCOVERY) {
2124 /* W6 Originating Processor */
2125 src_addr = tvb_get_ptr(tipc_tvb, offset + 24, 4);
2126 SET_ADDRESS(&pinfo->src, AT_TIPC, 4, src_addr);
2128 /* W7 Destination Processor */
2129 dst_addr = tvb_get_ptr(tipc_tvb, offset + 28, 4);
2130 SET_ADDRESS(&pinfo->dst, AT_TIPC, 4, dst_addr);
2131 } else {
2132 /* W2 Destination Domain */
2133 dst_addr = tvb_get_ptr(tipc_tvb, offset + 8, 4);
2134 SET_ADDRESS(&pinfo->dst, AT_TIPC, 4, dst_addr);
2136 /* W3 Previous Node */
2137 src_addr = tvb_get_ptr(tipc_tvb, offset + 12, 4);
2138 SET_ADDRESS(&pinfo->src, AT_TIPC, 4, src_addr);
2141 break;
2142 default:
2143 break;
2146 ti = proto_tree_add_item(tree, proto_tipc, tipc_tvb, offset, -1, ENC_NA);
2147 tipc_tree = proto_item_add_subtree(ti, ett_tipc);
2148 if (version == TIPCv2) {
2149 dissect_tipc_v2(tipc_tvb, tipc_tree, pinfo, offset, user, msg_size, hdr_size, datatype_hdr);
2150 return tvb_length(tvb);
2153 /* Word 0-2 common for all messages */
2154 /* Word 0 */
2155 proto_tree_add_item(tipc_tree, hf_tipc_ver, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2156 proto_tree_add_item(tipc_tree, hf_tipc_usr, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2157 item = proto_tree_add_item(tipc_tree, hf_tipc_hdr_size, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2158 proto_item_append_text(item, " = %u bytes", (hdr_size * 4));
2159 proto_tree_add_item(tipc_tree, hf_tipc_nonsequenced, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2160 proto_tree_add_item(tipc_tree, hf_tipc_unused, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2161 if (datatype_hdr) {
2162 proto_tree_add_item(tipc_tree, hf_tipc_destdrop, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2163 proto_tree_add_item(tipc_tree, hf_tipcv2_srcdrop, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2166 proto_tree_add_item(tipc_tree, hf_tipc_msg_size, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2167 offset = offset + 4;
2169 /* Word 1 */
2170 proto_tree_add_item(tipc_tree, hf_tipc_ack_link_lev_seq, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2171 proto_tree_add_item(tipc_tree, hf_tipc_link_lev_seq, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2172 offset = offset + 4;
2174 /* Word 2 */
2175 dword = tvb_get_ntohl(tipc_tvb, offset);
2176 addr_str_ptr = tipc_addr_to_str(dword);
2177 proto_tree_add_string(tipc_tree, hf_tipc_prev_proc, tipc_tvb, offset, 4, addr_str_ptr);
2179 offset = offset + 4;
2180 switch (user) {
2181 case TIPC_ROUTING_MANAGER:
2182 case TIPC_LINK_PROTOCOL:
2183 case TIPC_CHANGEOVER_PROTOCOL:
2184 case TIPC_SEGMENTATION_MANAGER:
2185 case TIPC_MSG_BUNDLER:
2186 dissect_tipc_int_prot_msg(tipc_tvb, pinfo, tipc_tree, offset, user, msg_size);
2187 return tvb_length(tvb);
2188 default:
2189 break;
2192 dword = tvb_get_ntohl(tipc_tvb, offset);
2193 pinfo->ptype = PT_TIPC;
2194 pinfo->srcport = dword;
2195 proto_tree_add_item(tipc_tree, hf_tipc_org_port, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2196 offset = offset + 4;
2197 if (user != TIPC_NAME_DISTRIBUTOR) {
2198 dword = tvb_get_ntohl(tipc_tvb, offset);
2199 pinfo->destport = dword;
2200 proto_tree_add_item(tipc_tree, hf_tipc_dst_port, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2202 offset = offset + 4;
2203 /* 20 - 24 Bytes
2204 20 bytes: Used in subnetwork local, connection oriented messages, where error code, reroute
2205 counter and activity identity are zero. A recipient finding that the header size field is 20 does
2206 by default know both user (DATA), message type (CONNECTED_MSG), error code
2207 (MSG_OK), reroute counter (0), and activity identity (undefined). Since no more testing for
2208 this is needed these fields can be left out in the header. Furthermore, since such messages
2209 only will do zero or one inter-processor hop, we know that previous processor is the real
2210 origin of the message. Hence the field originating processor can be omitted. For the same
2211 reason, the recipient processor will know that it is identical to destination processor, so even
2212 this field can be skipped. Finally, because the link layer guarantees delivery and sequence
2213 order for this single hop, even the connection sequence number is redundant. So the message
2214 can just be passed directly on to the destination port. Since this type of message statistically
2215 should be by far the most frequent one this small optimization pays off.
2217 if (hdr_size <= 6) {
2218 proto_tree_add_text(tipc_tree, tipc_tvb, offset, -1, "%u bytes Data", (msg_size - hdr_size*4));
2219 } else {
2220 switch (user) {
2221 case TIPC_NAME_DISTRIBUTOR:
2222 proto_tree_add_item(tipc_tree, hf_tipc_nd_msg_type, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2223 break;
2224 case TIPC_CONNECTION_MANAGER:
2225 proto_tree_add_item(tipc_tree, hf_tipc_cm_msg_type, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2226 break;
2227 default:
2228 proto_tree_add_item(tipc_tree, hf_tipc_data_msg_type, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2229 break;
2231 proto_tree_add_item(tipc_tree, hf_tipc_err_code, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2232 proto_tree_add_item(tipc_tree, hf_tipc_reroute_cnt, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2233 proto_tree_add_item(tipc_tree, hf_tipc_act_id, tipc_tvb, offset, 4, ENC_BIG_ENDIAN);
2234 offset = offset + 4;
2236 dword = tvb_get_ntohl(tipc_tvb, offset);
2237 addr_str_ptr = tipc_addr_to_str(dword);
2239 proto_tree_add_string(tipc_tree, hf_tipc_org_proc, tipc_tvb, offset, 4, addr_str_ptr);
2240 offset = offset + 4;
2242 dword = tvb_get_ntohl(tipc_tvb, offset);
2243 addr_str_ptr = tipc_addr_to_str(dword);
2245 proto_tree_add_string(tipc_tree, hf_tipc_dst_proc, tipc_tvb, offset, 4, addr_str_ptr);
2246 offset = offset + 4;
2247 /* 32 bytes
2248 32 bytes: The size of all data messages containing an explicit port identity as destination
2249 address.
2251 if (hdr_size > 8) {
2252 if (user == TIPC_NAME_DISTRIBUTOR) {
2254 Although an internal service, the name distributor uses the full 40-byte "external" data header
2255 format when updating the naming table instances. This is because its messages may need
2256 routing, - all system processor must contain the publications from all device processors and
2257 vice versa, whether they are directly linked or not. The fields name type, name instance, and
2258 destination port of that header have no meaning for such messages
2260 offset = offset + 8;
2261 tipc_data_item = proto_tree_add_text(tipc_tree, tvb, offset, -1, "TIPC_NAME_DISTRIBUTOR %u bytes User Data", (msg_size - hdr_size*4));
2262 tipc_data_tree = proto_item_add_subtree(tipc_data_item , ett_tipc_data);
2263 data_tvb = tvb_new_subset_remaining(tipc_tvb, offset);
2264 dissect_tipc_name_dist_data(data_tvb, tipc_data_tree, 0);
2265 return tvb_length(tvb);
2266 } else {
2267 /* Port name type / Connection level sequence number */
2268 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "Port name type / Connection level sequence number");
2269 offset = offset + 4;
2270 /* Port name instance */
2271 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 4, "Port name instance");
2272 offset = offset + 4;
2276 if (user < 4 && dissect_tipc_data) { /* DATA type user */
2277 tvbuff_t *next_tvb;
2278 guint32 msg_type32 = msg_type;
2279 guint32 *name_type_p = &msg_type32;
2280 switch (msg_type) {
2281 case TIPC_CONNECTED_MSG:
2282 proto_tree_add_text(tipc_tree, tipc_tvb, offset, -1, "%u bytes Data", (msg_size - hdr_size*4));
2283 break;
2284 case TIPC_NAMED_MSG:
2285 data_tvb = tvb_new_subset_remaining(tipc_tvb, offset+14);
2286 proto_tree_add_text(tipc_tree, tipc_tvb, offset, 14, "TIPC_NAMED_MSG Hdr");
2287 proto_tree_add_text(tipc_tree, data_tvb, 0, -1, "%u bytes Data", (msg_size - hdr_size*4));
2288 break;
2289 case TIPC_DIRECT_MSG:
2290 proto_tree_add_text(tipc_tree, tipc_tvb, offset, -1, "%u bytes Data", (msg_size - hdr_size*4));
2291 break;
2292 default:
2293 proto_tree_add_text(tipc_tree, tipc_tvb, offset, -1, "%u bytes Data", (msg_size - hdr_size*4));
2294 break;
2296 /* tipc data type user doesn't change format, reuse v2 function */
2297 next_tvb = tvb_new_subset_remaining(tvb, offset);
2298 call_tipc_v2_data_subdissectors(next_tvb, pinfo, name_type_p, user);
2300 } /*if (hdr_size <= 5) */
2302 return tvb_length(tvb);
2305 /* Register TIPC with Wireshark */
2306 void
2307 proto_register_tipc(void)
2309 static hf_register_info hf[] = {
2310 { &hf_tipc_msg_fragments,
2311 { "Message fragments", "tipc.msg.fragments",
2312 FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }
2314 { &hf_tipc_msg_fragment,
2315 { "Message fragment", "tipc.msg.fragment",
2316 FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL }
2318 { &hf_tipc_msg_fragment_overlap,
2319 { "Message fragment overlap", "tipc.msg.fragment.overlap",
2320 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }
2322 { &hf_tipc_msg_fragment_overlap_conflicts,
2323 { "Message fragment overlapping with conflicting data", "tipc.msg.fragment.overlap.conflicts",
2324 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }
2326 { &hf_tipc_msg_fragment_multiple_tails,
2327 { "Message has multiple tail fragments", "tipc.msg.fragment.multiple_tails",
2328 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }
2330 { &hf_tipc_msg_fragment_too_long_fragment,
2331 { "Message fragment too long", "tipc.msg.fragment.too_long_fragment",
2332 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL }
2334 { &hf_tipc_msg_fragment_error,
2335 { "Message defragmentation error", "tipc.msg.fragment.error",
2336 FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL }
2338 { &hf_tipc_msg_fragment_count,
2339 { "Message fragment count", "tipc.msg.fragment.count",
2340 FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }
2342 { &hf_tipc_msg_reassembled_in,
2343 { "Reassembled in", "tipc.msg.reassembled.in",
2344 FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL }
2346 { &hf_tipc_msg_reassembled_length,
2347 { "Reassembled TIPC length", "tipc.msg.reassembled.length",
2348 FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }
2350 { &hf_tipc_ver,
2351 { "Version", "tipc.ver",
2352 FT_UINT32, BASE_DEC, NULL, 0xe0000000,
2353 "TIPC protocol version", HFILL }
2355 { &hf_tipc_usr,
2356 { "User", "tipc.usr",
2357 FT_UINT32, BASE_DEC, VALS(tipc_user_values), 0x1e000000,
2358 "TIPC User", HFILL }
2360 { &hf_tipcv2_usr,
2361 { "User", "tipc.usr",
2362 FT_UINT32, BASE_DEC, VALS(tipcv2_user_values), 0x1e000000,
2363 "TIPC User", HFILL }
2365 { &hf_tipc_hdr_size,
2366 { "Header size", "tipc.hdr_size",
2367 FT_UINT32, BASE_DEC, NULL, 0x01e00000,
2368 "TIPC Header size", HFILL }
2370 { &hf_tipc_nonsequenced,
2371 { "Non-sequenced", "tipc.non_sequenced",
2372 FT_UINT32, BASE_DEC, NULL, 0x00100000,
2373 "Non-sequenced Bit", HFILL }
2375 { &hf_tipc_destdrop,
2376 { "Destination Droppable", "tipc.destdrop",
2377 FT_UINT32, BASE_DEC, NULL, 0x00080000,
2378 "Destination Droppable Bit", HFILL }
2380 { &hf_tipc_unused,
2381 { "Unused", "tipc.hdr_unused",
2382 FT_UINT32, BASE_DEC, NULL, 0x000e0000,
2383 "TIPC Unused", HFILL }
2385 { &hf_tipc_msg_size,
2386 { "Message size", "tipc.msg_size",
2387 FT_UINT32, BASE_DEC, NULL, 0x0001ffff,
2388 "TIPC Message size", HFILL }
2390 { &hf_tipc_ack_link_lev_seq,
2391 { "Acknowledged link level sequence number", "tipc.ack_link_lev_seq",
2392 FT_UINT32, BASE_DEC, NULL, 0xffff0000,
2393 "TIPC Acknowledged link level sequence number", HFILL }
2395 { &hf_tipc_link_lev_seq,
2396 { "Link level sequence number", "tipc.link_lev_seq",
2397 FT_UINT32, BASE_DEC, NULL, 0x0000ffff,
2398 "TIPC Link level sequence number", HFILL }
2400 { &hf_tipc_prev_proc,
2401 { "Previous processor", "tipc.prev_proc",
2402 FT_STRING, BASE_NONE, NULL, 0x0,
2403 "TIPC Previous processor", HFILL }
2405 { &hf_tipc_org_port,
2406 { "Originating port", "tipc.org_port",
2407 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2408 "TIPC Originating port", HFILL }
2410 { &hf_tipc_dst_port,
2411 { "Destination port", "tipc.dst_port",
2412 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2413 "TIPC Destination port", HFILL }
2415 { &hf_tipc_data_msg_type,
2416 { "Message type", "tipc.msg_type",
2417 FT_UINT32, BASE_DEC, VALS(tipc_data_msg_type_values), 0xf0000000,
2418 "TIPC Message type", HFILL }
2420 { &hf_tipc_err_code,
2421 { "Error code", "tipc.err_code",
2422 FT_UINT32, BASE_DEC, VALS(tipc_error_code_values), 0x0f000000,
2423 "TIPC Error code", HFILL }
2425 { &hf_tipc_reroute_cnt,
2426 { "Reroute counter", "tipc.route_cnt",
2427 FT_UINT32, BASE_DEC, NULL, 0x00f00000,
2428 "TIPC Reroute counter", HFILL }
2430 { &hf_tipc_act_id,
2431 { "Activity identity", "tipc.act_id",
2432 FT_UINT32, BASE_DEC, NULL, 0x000fffff,
2433 "TIPC Activity identity", HFILL }
2435 { &hf_tipc_org_proc,
2436 { "Originating processor", "tipc.org_proc",
2437 FT_STRING, BASE_NONE, NULL, 0x0,
2438 "TIPC Originating processor", HFILL }
2440 { &hf_tipc_dst_proc,
2441 { "Destination processor", "tipc.dst_proc",
2442 FT_STRING, BASE_NONE, NULL, 0x0,
2443 "TIPC Destination processor", HFILL }
2445 { &hf_tipc_unused2,
2446 { "Unused", "tipc.unused2",
2447 FT_UINT32, BASE_DEC, NULL, 0xe0000000,
2448 "TIPC Unused", HFILL }
2450 { &hf_tipc_importance,
2451 { "Importance", "tipc.importance",
2452 FT_UINT32, BASE_DEC, NULL, 0x18000000,
2453 "TIPC Importance", HFILL }
2455 { &hf_tipc_link_selector,
2456 { "Link selector", "tipc.link_selector",
2457 FT_UINT32, BASE_DEC, NULL, 0x07000000,
2458 "TIPC Link selector", HFILL }
2460 { &hf_tipc_msg_cnt,
2461 { "Message count", "tipc.imsg_cnt",
2462 FT_UINT32, BASE_DEC, NULL, 0x00ffff00,
2463 "TIPC Message count", HFILL }
2465 { &hf_tipc_probe,
2466 { "Probe", "tipc.probe",
2467 FT_UINT32, BASE_DEC, NULL, 0x00000040,
2468 "TIPC Probe", HFILL }
2470 { &hf_tipc_bearer_id,
2471 { "Bearer identity", "tipc.bearer_id",
2472 FT_UINT32, BASE_DEC, NULL, 0x00000038,
2473 "TIPC Bearer identity", HFILL }
2475 { &hf_tipc_link_selector2,
2476 { "Link selector", "tipc.link_selector",
2477 FT_UINT32, BASE_DEC, NULL, 0x00000007,
2478 "TIPC Link selector", HFILL }
2480 { &hf_tipc_remote_addr,
2481 { "Remote address", "tipc.remote_addr",
2482 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2483 "TIPC Remote address", HFILL }
2485 { &hf_tipc_rm_msg_type,
2486 { "Message type", "tipc.rm_msg_type",
2487 FT_UINT32, BASE_DEC, VALS(tipc_routing_mgr_msg_type_values), 0xf0000000,
2488 "TIPC Message type", HFILL }
2490 { &hf_tipc_nd_msg_type,
2491 { "Message type", "tipc.nd_msg_type",
2492 FT_UINT32, BASE_DEC, VALS(tipc_name_dist_msg_type_values), 0xf0000000,
2493 "TIPC Message type", HFILL }
2495 { &hf_tipc_cm_msg_type,
2496 { "Message type", "tipc.nd_msg_type",
2497 FT_UINT32, BASE_DEC, VALS(tipc_cm_msg_type_values), 0xf0000000,
2498 "TIPC Message type", HFILL }
2500 { &hf_tipc_lp_msg_type,
2501 { "Message type", "tipc.lp_msg_type",
2502 FT_UINT32, BASE_DEC, VALS(tipc_link_prot_msg_type_values), 0xf0000000,
2503 "TIPC Message type", HFILL }
2505 { &hf_tipc_cng_prot_msg_type,
2506 { "Message type", "tipc.cng_prot_msg_type",
2507 FT_UINT32, BASE_DEC, VALS(tipc_cng_prot_msg_type_values), 0xf0000000,
2508 "TIPC Message type", HFILL }
2510 { &hf_tipc_sm_msg_type,
2511 { "Message type", "tipc.sm_msg_type",
2512 FT_UINT32, BASE_DEC, VALS(tipc_sm_msg_type_values), 0xf0000000,
2513 "TIPC Message type", HFILL }
2515 { &hf_tipc_unknown_msg_type,
2516 { "Message type", "tipc.unknown_msg_type",
2517 FT_UINT32, BASE_DEC, NULL, 0xf0000000,
2518 "TIPC Message type", HFILL }
2520 { &hf_tipc_seq_gap,
2521 { "Sequence gap", "tipc.seq_gap",
2522 FT_UINT32, BASE_DEC, NULL, 0x1fff0000,
2523 "TIPC Sequence gap", HFILL }
2525 { &hf_tipc_nxt_snt_pkg,
2526 { "Next sent packet", "tipc.nxt_snt_pkg",
2527 FT_UINT32, BASE_DEC, NULL, 0x0000ffff,
2528 "TIPC Next sent packet", HFILL }
2530 { &hf_tipc_unused3,
2531 { "Unused", "tipc.unused3",
2532 FT_UINT32, BASE_DEC, NULL, 0x0,
2533 "TIPC Unused", HFILL }
2535 { &hf_tipc_bearer_name,
2536 { "Bearer name", "tipc.bearer_name",
2537 FT_STRINGZ, BASE_NONE, NULL, 0x0,
2538 "TIPC Bearer name", HFILL }
2540 { &hf_tipc_name_dist_type,
2541 { "Published port name type", "tipc.name_dist_type",
2542 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2543 "TIPC Published port name type", HFILL }
2545 { &hf_tipc_name_dist_lower,
2546 { "Lower bound of published sequence", "tipc.name_dist_lower",
2547 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2548 "TIPC Lower bound of published sequence", HFILL }
2550 { &hf_tipc_name_dist_upper,
2551 { "Upper bound of published sequence", "tipc.name_dist_upper",
2552 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2553 "TIPC Upper bound of published sequence", HFILL }
2555 { &hf_tipc_name_dist_port,
2556 { "Random number part of port identity", "tipc.dist_port",
2557 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2558 "TIPC Random number part of port identity", HFILL }
2560 { &hf_tipc_name_dist_key,
2561 { "Key (Use for verification at withdrawal)", "tipc.dist_key",
2562 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2563 "TIPC key", HFILL }
2565 { &hf_tipcv2_srcdrop,
2566 { "Source Droppable", "tipc.srcdrop",
2567 FT_UINT32, BASE_DEC, NULL, 0x00040000,
2568 "Destination Droppable Bit", HFILL }
2570 { &hf_tipcv2_syn,
2571 { "Connection request (SYN)", "tipc.syn",
2572 FT_UINT32, BASE_DEC, NULL, 0x00020000,
2573 "Destination Droppable Bit", HFILL }
2575 { &hf_tipcv2_data_msg_type,
2576 { "Message type", "tipc.data_type",
2577 FT_UINT32, BASE_DEC, VALS(tipc_data_msg_type_values), 0xe0000000,
2578 "TIPC Message type", HFILL }
2580 { &hf_tipcv2_bcast_mtype,
2581 { "Message type", "tipcv2.bcast_msg_type",
2582 FT_UINT32, BASE_DEC, VALS(tipcv2_bcast_mtype_strings), 0xe0000000,
2583 "TIPC Message type", HFILL }
2585 { &hf_tipcv2_bundler_mtype,
2586 { "Message type", "tipcv2.bundler_msg_type",
2587 FT_UINT32, BASE_DEC, VALS(tipcv2_bundler_mtype_strings), 0xe0000000,
2588 "TIPC Message type", HFILL }
2590 { &hf_tipcv2_link_mtype,
2591 { "Message type", "tipcv2.link_msg_type",
2592 FT_UINT32, BASE_DEC, VALS(tipcv2_link_mtype_strings), 0xe0000000,
2593 "TIPC Message type", HFILL }
2595 { &hf_tipcv2_connmgr_mtype,
2596 { "Message type", "tipcv2.connmgr_msg_type",
2597 FT_UINT32, BASE_DEC, VALS(tipcv2_connmgr_mtype_strings), 0xe0000000,
2598 "TIPC Message type", HFILL }
2600 { &hf_tipcv2_route_mtype_1_6,
2601 { "Message type", "tipcv2.route_msg_type",
2602 FT_UINT32, BASE_DEC, VALS(tipcv2_route_mtype_strings_1_6), 0xe0000000,
2603 "TIPC Message type", HFILL }
2605 { &hf_tipcv2_route_mtype_1_7,
2606 { "Message type", "tipcv2.route_msg_type",
2607 FT_UINT32, BASE_DEC, VALS(tipcv2_route_mtype_strings_1_7), 0xe0000000,
2608 "TIPC Message type", HFILL }
2610 { &hf_tipcv2_changeover_mtype,
2611 { "Message type", "tipcv2.changeover_msg_type",
2612 FT_UINT32, BASE_DEC, VALS(tipcv2_changeover_mtype_strings), 0xe0000000,
2613 "TIPC Message type", HFILL }
2615 { &hf_tipcv2_naming_mtype,
2616 { "Message type", "tipcv2.naming_msg_type",
2617 FT_UINT32, BASE_DEC, VALS(tipcv2_naming_mtype_strings), 0xe0000000,
2618 "TIPC Message type", HFILL }
2620 { &hf_tipcv2_fragmenter_mtype,
2621 { "Message type", "tipcv2.fragmenter_msg_type",
2622 FT_UINT32, BASE_DEC, VALS(tipcv2_fragmenter_mtype_strings), 0xe0000000,
2623 "TIPC Message type", HFILL }
2625 { &hf_tipcv2_neighbour_mtype,
2626 { "Message type", "tipcv2.data_msg_type",
2627 FT_UINT32, BASE_DEC, VALS(tipcv2_neighbour_mtype_strings), 0xe0000000,
2628 "TIPC Message type", HFILL }
2630 { &hf_tipcv2_errorcode,
2631 { "Error code", "tipcv2.errorcode",
2632 FT_UINT32, BASE_DEC, VALS(tipcv2_error_code_strings), 0x1e000000,
2633 NULL, HFILL }
2635 { &hf_tipcv2_rer_cnt,
2636 { "Reroute Counter", "tipcv2.rer_cnt",
2637 FT_UINT32, BASE_DEC, NULL, 0x01e00000,
2638 NULL, HFILL }
2640 { &hf_tipcv2_lookup_scope,
2641 { "Lookup Scope", "tipcv2.lookup_scope",
2642 FT_UINT32, BASE_DEC, VALS(tipcv2_lookup_scope_strings), 0x00180000,
2643 NULL, HFILL }
2645 { &hf_tipcv2_opt_p,
2646 { "Options Position", "tipcv2.opt_p",
2647 FT_UINT32, BASE_DEC, NULL, 0x00070000,
2648 NULL, HFILL }
2650 { &hf_tipcv2_broadcast_ack_no,
2651 { "Broadcast Acknowledge Number", "tipcv2.broadcast_ack_no",
2652 FT_UINT32, BASE_DEC, NULL, 0x0000FFFF,
2653 NULL, HFILL }
2655 { &hf_tipcv2_link_level_ack_no,
2656 { "Link Level Acknowledge Number", "tipcv2.link_level_ack_no",
2657 FT_UINT32, BASE_DEC, NULL, 0xFFFF0000,
2658 NULL, HFILL }
2660 { &hf_tipcv2_link_level_seq_no,
2661 { "Link Level Sequence Number", "tipcv2.link_level_seq_no",
2662 FT_UINT32, BASE_DEC, NULL, 0x0000FFFF,
2663 NULL, HFILL }
2665 #if 0
2666 { &hf_tipcv2_bcast_seq_no,
2667 { "Broadcast Sequence Number", "tipcv2.bcast_seq_no",
2668 FT_UINT32, BASE_DEC, NULL, 0x0000FFFF,
2669 NULL, HFILL }
2671 #endif
2672 { &hf_tipcv2_prev_node,
2673 { "Previous Node", "tipcv2.prev_node",
2674 FT_STRING, BASE_NONE, NULL, 0x0,
2675 "TIPC Previous Node", HFILL }
2677 { &hf_tipcv2_orig_node,
2678 { "Originating Node", "tipcv2.orig_node",
2679 FT_STRING, BASE_NONE, NULL, 0x0,
2680 "TIPC Originating Node", HFILL }
2682 { &hf_tipcv2_dest_node,
2683 { "Destination Node", "tipcv2.dest_node",
2684 FT_STRING, BASE_NONE, NULL, 0x0,
2685 "TIPC Destination Node", HFILL }
2687 { &hf_tipcv2_port_name_type,
2688 { "Port name type", "tipcv2.port_name_type",
2689 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2690 NULL, HFILL }
2692 { &hf_tipcv2_port_name_instance,
2693 { "Port name instance", "tipcv2.port_name_instance",
2694 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2695 NULL, HFILL }
2697 { &hf_tipcv2_multicast_lower,
2698 { "Multicast lower bound", "tipcv2.multicast_lower",
2699 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2700 "Multicast port name instance lower bound", HFILL }
2702 { &hf_tipcv2_multicast_upper,
2703 { "Multicast upper bound", "tipcv2.multicast_upper",
2704 FT_UINT32, BASE_DEC, NULL, 0xffffffff,
2705 "Multicast port name instance upper bound", HFILL }
2707 { &hf_tipcv2_sequence_gap,
2708 { "Sequence Gap", "tipcv2.seq_gap",
2709 FT_UINT32, BASE_DEC, NULL, 0x1FFF0000,
2710 NULL, HFILL }
2712 { &hf_tipcv2_next_sent_broadcast,
2713 { "Next Sent Broadcast", "tipcv2.next_sent_broadcast",
2714 FT_UINT32, BASE_DEC, NULL, 0xFFFF0000,
2715 NULL, HFILL }
2717 { &hf_tipcv2_fragment_number,
2718 { "Fragment Number", "tipcv2.fragment_number",
2719 FT_UINT32, BASE_DEC, NULL, 0xFFFF0000,
2720 NULL, HFILL }
2722 { &hf_tipcv2_fragment_msg_number,
2723 { "Fragment Message Number", "tipcv2.fragment_msg_number",
2724 FT_UINT32, BASE_DEC, NULL, 0x0000FFFF,
2725 NULL, HFILL }
2727 { &hf_tipcv2_next_sent_packet,
2728 { "Next Sent Packet", "tipcv2.next_sent_packet",
2729 FT_UINT32, BASE_DEC, NULL, 0x0000FFFF,
2730 NULL, HFILL }
2732 { &hf_tipcv2_session_no,
2733 { "Session Number", "tipcv2.session_no",
2734 FT_UINT32, BASE_DEC, NULL, 0xFFFF0000,
2735 NULL, HFILL }
2737 { &hf_tipcv2_link_prio,
2738 { "Link Priority", "tipcv2.link_prio",
2739 FT_UINT32, BASE_DEC, NULL, 0x000001F0,
2740 NULL, HFILL }
2742 { &hf_tipcv2_network_plane,
2743 { "Network Plane", "tipcv2.network_plane",
2744 FT_UINT32, BASE_DEC, VALS(tipcv2_networkplane_strings), 0x0000000E,
2745 NULL, HFILL }
2747 { &hf_tipcv2_probe,
2748 { "Probe", "tipcv2.probe",
2749 FT_UINT32, BASE_DEC, NULL, 0x00000001,
2750 NULL, HFILL }
2752 { &hf_tipcv2_link_tolerance,
2753 { "Link Tolerance (ms)", "tipcv2.link_tolerance",
2754 FT_UINT32, BASE_DEC, NULL, 0x0000FFFF,
2755 "Link Tolerance in ms", HFILL }
2757 { &hf_tipcv2_bearer_instance,
2758 { "Bearer Instance", "tipcv2.bearer_instance",
2759 FT_STRINGZ, BASE_NONE, NULL, 0,
2760 "Bearer instance used by the sender node for this link", HFILL }
2762 { &hf_tipcv2_bearer_level_orig_addr,
2763 { "Bearer Level Originating Address", "tipcv2.bearer_level_orig_addr",
2764 FT_BYTES, BASE_NONE, NULL, 0,
2765 NULL, HFILL }
2767 { &hf_tipcv2_cluster_address,
2768 { "Cluster Address", "tipcv2.cluster_address",
2769 FT_STRING, BASE_NONE, NULL, 0x0,
2770 "The remote cluster concerned by the table", HFILL }
2772 { &hf_tipcv2_bitmap,
2773 { "Bitmap", "tipcv2.bitmap",
2774 FT_BYTES, BASE_NONE, NULL, 0,
2775 "Bitmap, indicating to which nodes within that cluster the sending node has direct links", HFILL }
2777 { &hf_tipcv2_node_address,
2778 { "Node Address", "tipcv2.node_address",
2779 FT_STRING, BASE_NONE, NULL, 0x0,
2780 "Which node the route addition/loss concern", HFILL }
2782 { &hf_tipcv2_destination_domain,
2783 { "Destination Domain", "tipcv2.destination_domain",
2784 FT_STRING, BASE_NONE, NULL, 0x0,
2785 "The domain to which the link request is directed", HFILL }
2787 { &hf_tipcv2_network_id,
2788 { "Network Identity", "tipcv2.network_id",
2789 FT_UINT32, BASE_DEC, NULL, 0xFFFFFFFF,
2790 "The sender node's network identity", HFILL }
2792 { &hf_tipcv2_bcast_tag,
2793 { "Broadcast Tag", "tipcv2.bcast_tag",
2794 FT_UINT32, BASE_DEC, NULL, 0xFFFF0000,
2795 NULL, HFILL }
2797 { &hf_tipcv2_msg_count,
2798 { "Message Count", "tipcv2.msg_count",
2799 FT_UINT32, BASE_DEC, NULL, 0xFFFF0000,
2800 NULL, HFILL }
2802 { &hf_tipcv2_max_packet,
2803 { "Max Packet", "tipcv2.max_packet",
2804 FT_UINT32, BASE_DEC, NULL, 0xFFFF0000,
2805 NULL, HFILL }
2807 { &hf_tipcv2_transport_seq_no,
2808 { "Transport Sequence No", "tipcv2.tseq_no",
2809 FT_UINT32, BASE_DEC, NULL, 0xFFFFFFFF,
2810 "Transport Level Sequence Number", HFILL }
2812 { &hf_tipcv2_redundant_link,
2813 { "Redundant Link", "tipcv2.redundant_link",
2814 FT_UINT32, BASE_DEC, NULL, 0x00001000,
2815 NULL, HFILL }
2817 { &hf_tipcv2_bearer_id,
2818 { "Bearer identity", "tipcv2.bearer_id",
2819 FT_UINT32, BASE_DEC, NULL, 0x00000e00,
2820 NULL, HFILL }
2822 { &hf_tipcv2_conn_mgr_msg_ack, /* special CONN_MANAGER payload */
2823 { "Number of Messages Acknowledged", "tipcv2.conn_mgr_msg_ack",
2824 FT_UINT32, BASE_DEC, NULL, 0xffff0000,
2825 NULL, HFILL }
2827 { &hf_tipcv2_minor_pv,
2828 { "Minor protocol version", "tipcv2.minor_pv",
2829 FT_UINT32, BASE_DEC, NULL, 0x00ff0000,
2830 NULL, HFILL }
2832 { &hf_tipcv2_node_sig,
2833 { "Node signature", "tipcv2.node_sig",
2834 FT_UINT32, BASE_DEC, NULL, 0x0000FFFF,
2835 NULL, HFILL }
2837 { &hf_tipcv2_timestamp,
2838 { "Timestamp", "tipcv2.timestamp",
2839 FT_UINT32, BASE_DEC, NULL, 0xFFFFFFFF,
2840 "OS-dependent Timestamp", HFILL }
2842 { &hf_tipcv2_item_size,
2843 { "Item Size", "tipcv2.item_size",
2844 FT_UINT32, BASE_DEC, NULL, 0xFF000000,
2845 NULL, HFILL }
2847 { &hf_tipcv2_network_region,
2848 { "Network Region", "tipcv2.network_region",
2849 FT_STRING, BASE_NONE, NULL, 0x0,
2850 NULL, HFILL }
2852 { &hf_tipcv2_local_router,
2853 { "Local Router", "tipcv2.local_router",
2854 FT_STRING, BASE_NONE, NULL, 0x0,
2855 NULL, HFILL }
2857 { &hf_tipcv2_remote_router,
2858 { "Remote Router", "tipcv2.remote_router",
2859 FT_STRING, BASE_NONE, NULL, 0x0,
2860 NULL, HFILL }
2862 { &hf_tipcv2_dist_dist,
2863 { "Route Distributor Dist", "tipcv2.dist_dist",
2864 FT_UINT32, BASE_DEC, VALS(tipcv2_dist_dist_strings), 0x000000f0,
2865 NULL, HFILL }
2867 { &hf_tipcv2_dist_scope,
2868 { "Route Distributor Scope", "tipcv2.dist_scope",
2869 FT_UINT32, BASE_DEC, VALS(tipcv2_dist_scope_strings), 0x0000000f,
2870 NULL, HFILL }
2872 { &hf_tipcv2_name_dist_port_id_node,
2873 { "Port Id Node", "tipcv2.port_id_node",
2874 FT_STRING, BASE_NONE, NULL, 0x0,
2875 NULL, HFILL }
2877 { &hf_tipcv2_media_id,
2878 { "Media Id", "tipcv2.media_id",
2879 FT_UINT32, BASE_DEC, NULL, 0x000000ff,
2880 NULL, HFILL }
2884 /* Setup protocol subtree array */
2885 static gint *ett[] = {
2886 &ett_tipc,
2887 &ett_tipc_data,
2888 &ett_tipc_msg_fragment,
2889 &ett_tipc_msg_fragments
2892 module_t *tipc_module;
2894 /* options for the enum in the protocol preferences */
2895 static const enum_val_t handle_v2_as_options[] = {
2896 { "all", "ALL", V2_AS_ALL },
2897 { "tipc l.5/1.6", "TIPC 1.5/1.6", V2_AS_1_6 },
2898 { "tipc 1.7", "TIPC 1.7", V2_AS_1_7 },
2899 { NULL, NULL, 0 }
2902 /* Register the protocol name and description */
2903 proto_tipc = proto_register_protocol("Transparent Inter Process Communication(TIPC)",
2904 "TIPC", "tipc");
2906 /* Required function calls to register the header fields and subtrees used */
2907 proto_register_field_array(proto_tipc, hf, array_length(hf));
2908 proto_register_subtree_array(ett, array_length(ett));
2910 /* allow other protocols to be called according to specific values in order to
2911 * dissect the protocols sent by TIPC */
2913 /* this allows e.g. to dissect everything which is TIPC Data */
2914 tipc_user_dissector = register_dissector_table("tipc.usr",
2915 "TIPC user", FT_UINT8, BASE_DEC);
2916 /* this allows to dissect everything which is TIPC Data and uses a specific
2917 * port name type it actually does not really work because the type is not
2918 * necessarily set in every data message */
2919 tipc_type_dissector = register_dissector_table("tipcv2.port_name_type",
2920 "TIPC port name type", FT_UINT32, BASE_DEC);
2922 /* make heuristic dissectors possible */
2923 register_heur_dissector_list("tipc", &tipc_heur_subdissector_list);
2925 /* Register by name */
2926 new_register_dissector("tipc", dissect_tipc, proto_tipc);
2928 register_init_routine(tipc_defragment_init);
2930 /* Register configuration options */
2931 tipc_module = prefs_register_protocol(proto_tipc, proto_reg_handoff_tipc);
2933 /* Set default ports */
2934 range_convert_str(&global_tipc_udp_port_range, DEFAULT_TIPC_PORT_RANGE, MAX_TCP_PORT);
2936 prefs_register_range_preference(tipc_module, "udp.ports", "TIPC UDP ports",
2937 "UDP ports to be decoded as TIPC (default: "
2938 DEFAULT_TIPC_PORT_RANGE ")"
2939 "IANA have assigned port 6118 port for TIPC UDP transport.",
2940 &global_tipc_udp_port_range, MAX_UDP_PORT);
2942 prefs_register_bool_preference(tipc_module, "defragment",
2943 "Reassemble TIPCv1 SEGMENTATION_MANAGER datagrams",
2944 "Whether TIPCv1 SEGMENTATION_MANAGER datagrams should be reassembled",
2945 &tipc_defragment);
2947 prefs_register_bool_preference(tipc_module, "dissect_tipc_data",
2948 "Dissect TIPC data",
2949 "Whether to try to dissect TIPC data or not",
2950 &dissect_tipc_data);
2952 prefs_register_bool_preference(tipc_module, "try_heuristic_first",
2953 "Try heuristic sub-dissectors first",
2954 "Try to decode a TIPCv2 packet using an heuristic sub-dissector before using a registered sub-dissector",
2955 &try_heuristic_first);
2957 prefs_register_enum_preference(tipc_module, "handle_v2_as",
2958 "Handle version 2 as",
2959 "TIPC 1.7 removes/adds fields (not) available in TIPC 1.5/1.6 while keeping the version number 2 in the packages. \"ALL\" shows all fields that were ever used in both versions.",
2960 &handle_v2_as,
2961 handle_v2_as_options,
2962 TRUE);
2964 prefs_register_uint_preference(tipc_module, "alternate_port",
2965 "TIPC-over-TCP port", "Decode this TCP ports traffic as TIPC. Set to \"0\" to disable.", 10,
2966 &tipc_alternate_tcp_port);
2968 prefs_register_bool_preference(tipc_module, "desegment",
2969 "Reassemble TIPC-over-TCP messages spanning multiple TCP segments",
2970 "Whether the TIPC-over-TCP dissector should reassemble messages spanning multiple TCP segments. "
2971 "To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
2972 &tipc_tcp_desegment);
2975 void
2976 proto_reg_handoff_tipc(void)
2978 static gboolean inited = FALSE;
2979 static dissector_handle_t tipc_tcp_handle;
2980 static guint tipc_alternate_tcp_port_prev = 0;
2981 static range_t *tipc_udp_port_range;
2983 if (!inited) {
2984 tipc_handle = new_create_dissector_handle(dissect_tipc, proto_tipc);
2985 tipc_tcp_handle = new_create_dissector_handle(dissect_tipc_tcp, proto_tipc);
2986 ip_handle = find_dissector("ip");
2987 data_handle = find_dissector("data");
2989 dissector_add_uint("ethertype", ETHERTYPE_TIPC, tipc_handle);
2991 inited = TRUE;
2992 } else {
2993 /* change TIPC-over-TCP port if changed in the preferences */
2994 if (tipc_alternate_tcp_port != tipc_alternate_tcp_port_prev) {
2995 if (tipc_alternate_tcp_port_prev != 0)
2996 dissector_delete_uint("tcp.port", tipc_alternate_tcp_port_prev, tipc_tcp_handle);
2997 if (tipc_alternate_tcp_port != 0)
2998 dissector_add_uint("tcp.port", tipc_alternate_tcp_port, tipc_tcp_handle);
2999 tipc_alternate_tcp_port_prev = tipc_alternate_tcp_port;
3001 dissector_add_uint_range("udp.port", tipc_udp_port_range, tipc_handle);
3002 g_free(tipc_udp_port_range);
3005 tipc_udp_port_range = range_copy(global_tipc_udp_port_range);
3006 dissector_add_uint_range("udp.port", tipc_udp_port_range, tipc_handle);