1 /* packet-corosync-totemsrp.c
2 * Dissectors for totem single ring protocol implemented in corosync cluster engine
3 * Copyright 2007 2009 2010 2014 Masatake YAMATO <yamato@redhat.com>
4 * Copyright (c) 2010 2014 Red Hat, Inc.
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 /* Fields description are taken from
27 Y.AMIR, L.E.MOSER, P.M.MELLIAR-SMITH, D.A.AGARWAL, P.CIARFELLA.
28 "The Totem Single-Ring Ordering and Membership Protocol"*/
31 * NOTE: the source code at www.corosync.org looks as if it will not
32 * work with multiple OSes in a cluster if it uses IPv6, as it appears
33 * to use the OS's AF_ values in packets, and the value of AF_INET6
34 * is ***NOT*** the same in all OSes.
36 * (It'll work with IPv4, because AF_INET came out of 4.2BSD and
37 * most if not all OSes just picked up BSD's value of 2.)
39 * So we just check for all the AF_INET6 values we know about.
41 * We get the AF_ values from epan/aftypes.h, *not* from the OS
42 * we happen to be built for.
47 #include <epan/packet.h>
48 #include <epan/aftypes.h>
51 * Utilities for subdissectors of corosync_totemsrp.
53 struct corosync_totemsrp_info {
58 /* Forward declaration we need below */
59 void proto_register_corosync_totemsrp(void);
60 void proto_reg_handoff_corosync_totemsrp(void);
62 /* Initialize the protocol and registered fields */
63 static int proto_corosync_totemsrp = -1;
65 static heur_dissector_list_t heur_subdissector_list;
67 /* fields for struct message_header */
68 static int hf_corosync_totemsrp_message_header_type = -1;
69 static int hf_corosync_totemsrp_message_header_encapsulated = -1;
70 static int hf_corosync_totemsrp_message_header_endian_detector = -1;
71 static int hf_corosync_totemsrp_message_header_nodeid = -1;
73 /* fields for struct orf_token */
74 static int hf_corosync_totemsrp_orf_token = -1;
75 static int hf_corosync_totemsrp_orf_token_seq = -1;
76 static int hf_corosync_totemsrp_orf_token_token_seq = -1;
77 static int hf_corosync_totemsrp_orf_token_aru = -1;
78 static int hf_corosync_totemsrp_orf_token_aru_addr = -1;
79 static int hf_corosync_totemsrp_orf_token_backlog = -1;
80 static int hf_corosync_totemsrp_orf_token_fcc = -1;
81 static int hf_corosync_totemsrp_orf_token_retrnas_flg = -1;
82 static int hf_corosync_totemsrp_orf_token_rtr_list_entries = -1;
84 /* field for struct memb_ring_id */
85 static int hf_corosync_totemsrp_memb_ring_id = -1;
86 static int hf_corosync_totemsrp_memb_ring_id_seq = -1;
88 /* field for struct totem_ip_address */
89 static int hf_corosync_totemsrp_ip_address = -1;
90 static int hf_corosync_totemsrp_ip_address_nodeid = -1;
91 static int hf_corosync_totemsrp_ip_address_family = -1;
92 static int hf_corosync_totemsrp_ip_address_addr = -1;
93 static int hf_corosync_totemsrp_ip_address_addr4 = -1;
94 static int hf_corosync_totemsrp_ip_address_addr4_padding = -1;
95 static int hf_corosync_totemsrp_ip_address_addr6 = -1;
97 /* field of struct mcast */
98 static int hf_corosync_totemsrp_mcast = -1;
99 static int hf_corosync_totemsrp_mcast_seq = -1;
100 static int hf_corosync_totemsrp_mcast_this_seqno = -1;
101 static int hf_corosync_totemsrp_mcast_node_id = -1;
102 static int hf_corosync_totemsrp_mcast_system_from = -1;
103 static int hf_corosync_totemsrp_mcast_guarantee = -1;
105 /* field of struct memb_merge_detect */
106 static int hf_corosync_totemsrp_memb_merge_detect = -1;
108 /* field of struct struct srp_addr */
109 static int hf_corosync_totemsrp_srp_addr = -1;
111 /* field of struct rtr_item */
112 static int hf_corosync_totemsrp_rtr_item = -1;
113 static int hf_corosync_totemsrp_rtr_item_seq = -1;
115 /* field of struct memb_join */
116 static int hf_corosync_totemsrp_memb_join = -1;
117 static int hf_corosync_totemsrp_memb_join_proc_list_entries = -1;
118 static int hf_corosync_totemsrp_memb_join_failed_list_entries = -1;
119 static int hf_corosync_totemsrp_memb_join_ring_seq = -1;
121 /* field of struct memb_commit_token */
122 static int hf_corosync_totemsrp_memb_commit_token = -1;
123 static int hf_corosync_totemsrp_memb_commit_token_token_seq = -1;
124 static int hf_corosync_totemsrp_memb_commit_token_retrans_flg = -1;
125 static int hf_corosync_totemsrp_memb_commit_token_memb_index = -1;
126 static int hf_corosync_totemsrp_memb_commit_token_addr_entries = -1;
128 /* field of struct memb_commit_token_memb_entry */
129 static int hf_corosync_totemsrp_memb_commit_token_memb_entry = -1;
130 static int hf_corosync_totemsrp_memb_commit_token_memb_entry_aru = -1;
131 static int hf_corosync_totemsrp_memb_commit_token_memb_entry_high_delivered = -1;
132 static int hf_corosync_totemsrp_memb_commit_token_memb_entry_received_flg = -1;
134 /* field of struct token_hold_cancel */
135 static int hf_corosync_totemsrp_token_hold_cancel = -1;
137 /* Initialize the subtree pointers */
138 static gint ett_corosync_totemsrp = -1;
139 static gint ett_corosync_totemsrp_orf_token = -1;
140 static gint ett_corosync_totemsrp_memb_ring_id = -1;
141 static gint ett_corosync_totemsrp_ip_address = -1;
142 static gint ett_corosync_totemsrp_mcast = -1;
143 static gint ett_corosync_totemsrp_memb_merge_detect = -1;
144 static gint ett_corosync_totemsrp_srp_addr = -1;
145 static gint ett_corosync_totemsrp_rtr_item = -1;
146 static gint ett_corosync_totemsrp_memb_join = -1;
147 static gint ett_corosync_totemsrp_memb_commit_token = -1;
148 static gint ett_corosync_totemsrp_memb_commit_token_memb_entry = -1;
149 static gint ett_corosync_totemsrp_token_hold_cancel = -1;
150 static gint ett_corosync_totemsrp_memb_join_proc_list = -1;
151 static gint ett_corosync_totemsrp_memb_join_failed_list = -1;
157 #define COROSYNC_TOTEMSRP_MESSAGE_TYPE_ORF_TOKEN 0
158 #define COROSYNC_TOTEMSRP_MESSAGE_TYPE_MCAST 1
159 #define COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_MERGE_DETECT 2
160 #define COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_JOIN 3
161 #define COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_COMMIT_TOKEN 4
162 #define COROSYNC_TOTEMSRP_MESSAGE_TYPE_TOKEN_HOLD_CANCEL 5
164 static const value_string corosync_totemsrp_message_header_type[] = {
165 { COROSYNC_TOTEMSRP_MESSAGE_TYPE_ORF_TOKEN, "orf" },
166 { COROSYNC_TOTEMSRP_MESSAGE_TYPE_MCAST, "mcast" },
167 { COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_MERGE_DETECT, "merge rings" },
168 { COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_JOIN, "join message" },
169 { COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_COMMIT_TOKEN, "commit token" },
170 { COROSYNC_TOTEMSRP_MESSAGE_TYPE_TOKEN_HOLD_CANCEL, "cancel" },
174 #define COROSYNC_TOTEMSRP_MESSAGE_ENCAPSULATED 1
175 #define COROSYNC_TOTEMSRP_MESSAGE_NOT_ENCAPSULATED 2
177 static const value_string corosync_totemsrp_message_header_encapsulated[] = {
178 { 0, "not mcast message" },
179 { COROSYNC_TOTEMSRP_MESSAGE_ENCAPSULATED, "encapsulated" },
180 { COROSYNC_TOTEMSRP_MESSAGE_NOT_ENCAPSULATED, "not encapsulated" },
185 static const value_string corosync_totemsrp_ip_address_family[] = {
186 { COMMON_AF_INET, "AF_INET" },
187 { BSD_AF_INET6_BSD, "AF_INET6 (most BSD)" },
188 { BSD_AF_INET6_FREEBSD, "AF_INET6 (FreeBSD)" },
189 { BSD_AF_INET6_DARWIN, "AF_INET6 (macOS and iOS)" },
190 { LINUX_AF_INET6, "AF_INET6 (Linux)" },
191 { SOLARIS_AF_INET6, "AF_INET6 (Solaris)" },
192 { WINSOCK_AF_INET6, "AF_INET6 (Windows)" },
197 corosync_totemsrp_get_guint16(tvbuff_t* tvb, gint offset, const guint encoding)
199 if (encoding == ENC_LITTLE_ENDIAN)
200 return tvb_get_letohs(tvb, offset);
202 return tvb_get_ntohs(tvb, offset);
207 corosync_totemsrp_get_guint32(tvbuff_t* tvb, gint offset, const guint encoding)
209 if (encoding == ENC_LITTLE_ENDIAN)
210 return tvb_get_letohl(tvb, offset);
212 return tvb_get_ntohl(tvb, offset);
216 corosync_totemsrp_get_guint64(tvbuff_t* tvb, gint offset, const guint encoding)
218 if (encoding == ENC_LITTLE_ENDIAN)
219 return tvb_get_letoh64(tvb, offset);
221 return tvb_get_ntoh64(tvb, offset);
225 #define COROSYNC_TOTEMSRP_SRP_ADDR_INTERFACE_MAX 2
227 static int dissect_corosync_totemsrp0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
228 gboolean encapsulated);
232 dissect_corosync_totemsrp_ip_address(tvbuff_t *tvb,
233 packet_info *pinfo _U_,
234 proto_tree *parent_tree,
235 guint length _U_, int offset,
236 const guint encoding,
237 gboolean print_interface,
243 int original_offset = offset;
248 nid = corosync_totemsrp_get_guint32(tvb, offset, encoding);
251 family = corosync_totemsrp_get_guint16(tvb, offset + 4, encoding);
253 item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_ip_address, tvb, offset,
255 tree = proto_item_add_subtree(item, ett_corosync_totemsrp_ip_address);
257 proto_item_append_text(item, " (");
259 proto_item_append_text(item, "interface: %u; ", interface);
261 proto_tree_add_item(tree, hf_corosync_totemsrp_ip_address_nodeid,
262 tvb, offset, 4, encoding);
263 proto_item_append_text(item, "node: %u)", nid);
266 proto_tree_add_item(tree, hf_corosync_totemsrp_ip_address_family,
267 tvb, offset, 2, encoding);
274 proto_tree_add_item(tree, hf_corosync_totemsrp_ip_address_addr4, tvb, offset, len, ENC_BIG_ENDIAN);
276 case BSD_AF_INET6_BSD:
277 case BSD_AF_INET6_FREEBSD:
278 case BSD_AF_INET6_DARWIN:
280 case SOLARIS_AF_INET6:
281 case WINSOCK_AF_INET6:
282 len = sizeof(struct e_in6_addr);
283 proto_tree_add_item(tree, hf_corosync_totemsrp_ip_address_addr6, tvb, offset, len, ENC_NA);
286 len = sizeof(struct e_in6_addr);
287 proto_tree_add_item(tree, hf_corosync_totemsrp_ip_address_addr, tvb, offset, len, ENC_NA);
293 if (len != sizeof(struct e_in6_addr)) {
296 padding_len = (gint)(sizeof(struct e_in6_addr) - len);
297 proto_tree_add_item (tree, hf_corosync_totemsrp_ip_address_addr4_padding,
298 tvb, offset, padding_len, ENC_NA);
299 offset += padding_len;
302 proto_item_set_len(item, offset - original_offset);
303 return offset - original_offset;
307 dissect_corosync_totemsrp_memb_ring_id(tvbuff_t *tvb,
308 packet_info *pinfo, proto_tree *parent_tree,
309 guint length, int offset,
310 const guint encoding,
314 int original_offset = offset;
320 item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_memb_ring_id, tvb, offset,
322 tree = proto_item_add_subtree(item, ett_corosync_totemsrp_memb_ring_id);
324 offset += dissect_corosync_totemsrp_ip_address(tvb, pinfo, tree,
330 proto_tree_add_item(tree, hf_corosync_totemsrp_memb_ring_id_seq,
331 tvb, offset, 8, encoding);
332 rid = corosync_totemsrp_get_guint64(tvb, offset, encoding);
335 proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u)", rid);
342 proto_item_set_len(item, offset - original_offset);
343 return offset - original_offset;
347 dissect_corosync_totemsrp_rtr_list(tvbuff_t *tvb,
348 packet_info *pinfo, proto_tree *parent_tree,
349 guint length, int offset,
350 const guint encoding)
352 int original_offset = offset;
360 item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_rtr_item, tvb, offset,
362 tree = proto_item_add_subtree(item, ett_corosync_totemsrp_rtr_item);
364 offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
370 proto_tree_add_item(tree, hf_corosync_totemsrp_rtr_item_seq,
371 tvb, offset, 4, encoding);
373 seq = corosync_totemsrp_get_guint32(tvb, offset, encoding);
374 proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u node: %u seq: %u)",
375 ring_id, node_id, seq);
378 proto_item_set_len(item, offset - original_offset);
379 return (offset - original_offset);
383 dissect_corosync_totemsrp_orf_token(tvbuff_t *tvb,
384 packet_info *pinfo, proto_tree *parent_tree,
385 guint length, int offset,
386 const guint encoding)
388 int original_offset = offset;
389 guint32 rtr_list_entries = 0, seq, aru, i;
395 item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_orf_token,
396 tvb, offset, -1, ENC_NA);
397 tree = proto_item_add_subtree(item, ett_corosync_totemsrp_orf_token);
399 proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_seq,
400 tvb, offset, 4, encoding);
403 proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_token_seq,
404 tvb, offset, 4, encoding);
405 seq = corosync_totemsrp_get_guint32(tvb, offset, encoding);
408 proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_aru,
409 tvb, offset, 4, encoding);
410 aru = corosync_totemsrp_get_guint32(tvb, offset, encoding);
413 proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_aru_addr,
414 tvb, offset, 4, encoding);
417 offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
423 proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_backlog,
424 tvb, offset, 4, encoding);
427 proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_fcc,
428 tvb, offset, 4, encoding);
431 proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_retrnas_flg,
432 tvb, offset, 4, encoding);
435 proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_rtr_list_entries,
436 tvb, offset, 4, encoding);
437 rtr_list_entries = corosync_totemsrp_get_guint32(tvb, offset, encoding);
440 for (i = 0; i < rtr_list_entries; i++) {
441 offset += dissect_corosync_totemsrp_rtr_list(tvb, pinfo,
447 proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u node: %u nrtr: %d seq: %d au: %u)",
448 ring_id, node_id, rtr_list_entries, seq, aru);
450 proto_item_set_len(item, offset - original_offset);
451 return offset - original_offset;
455 dissect_corosync_totemsrp_srp_addr(tvbuff_t *tvb,
456 packet_info *pinfo, proto_tree *parent_tree,
457 guint length, int offset,
459 const guint encoding)
461 int original_offset = offset;
466 item = proto_tree_add_item(parent_tree, hf? hf: hf_corosync_totemsrp_srp_addr, tvb, offset,
468 tree = proto_item_add_subtree(item, ett_corosync_totemsrp_srp_addr);
470 offset += dissect_corosync_totemsrp_ip_address(tvb, pinfo, tree,
475 proto_item_append_text(item, " (node: %u)", nodeid);
477 offset += dissect_corosync_totemsrp_ip_address(tvb, pinfo, tree,
483 proto_item_set_len(item, offset - original_offset);
484 return (offset - original_offset);
488 dissect_corosync_totemsrp_mcast(tvbuff_t *tvb,
489 packet_info *pinfo, proto_tree *tree,
490 guint length, int offset,
491 guint8 message_header__encapsulated,
492 const guint encoding, proto_tree *parent_tree,
493 struct corosync_totemsrp_info *totemsrp_info)
495 int original_offset = offset;
496 proto_tree *mcast_tree;
503 heur_dtbl_entry_t *hdtbl_entry = NULL;
505 item = proto_tree_add_item(tree, hf_corosync_totemsrp_mcast, tvb, offset,
507 mcast_tree = proto_item_add_subtree(item, ett_corosync_totemsrp_mcast);
509 offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, mcast_tree,
511 hf_corosync_totemsrp_mcast_system_from,
514 proto_tree_add_item(mcast_tree, hf_corosync_totemsrp_mcast_seq,
515 tvb, offset, 4, encoding);
518 proto_tree_add_item(mcast_tree, hf_corosync_totemsrp_mcast_this_seqno,
519 tvb, offset, 4, encoding);
522 offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, mcast_tree,
528 proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u node: %u)",
531 proto_tree_add_item(tree, hf_corosync_totemsrp_mcast_node_id,
532 tvb, offset, 4, encoding);
535 proto_tree_add_item(tree, hf_corosync_totemsrp_mcast_guarantee,
536 tvb, offset, 4, encoding);
539 next_tvb = tvb_new_subset_remaining(tvb, offset);
541 if (message_header__encapsulated == COROSYNC_TOTEMSRP_MESSAGE_ENCAPSULATED)
543 offset += dissect_corosync_totemsrp0(next_tvb, pinfo, tree, TRUE);
547 if (dissector_try_heuristic(heur_subdissector_list,
556 proto_item_set_len(item, offset - original_offset);
557 return (offset - original_offset);
562 dissect_corosync_totemsrp_memb_merge_detect(tvbuff_t *tvb,
563 packet_info *pinfo, proto_tree *parent_tree,
564 guint length, int offset,
565 const guint encoding)
567 int original_offset = offset;
573 item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_memb_merge_detect, tvb, offset,
575 tree = proto_item_add_subtree(item, ett_corosync_totemsrp_memb_merge_detect);
577 offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, tree,
582 offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
588 proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u node: %u)",
591 proto_item_set_len(item, offset - original_offset);
592 return (offset - original_offset);
596 dissect_corosync_totemsrp_memb_join(tvbuff_t *tvb,
597 packet_info *pinfo, proto_tree *parent_tree,
598 guint length, int offset,
599 const guint encoding)
601 int original_offset = offset;
605 guint32 proc_list_entries;
606 proto_tree *proc_tree;
608 guint32 failed_list_entries;
609 proto_tree *failed_tree;
610 proto_item *failed_item;
614 proto_item *proc_item;
616 item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_memb_join, tvb, offset,
618 tree = proto_item_add_subtree(item, ett_corosync_totemsrp_memb_join);
621 offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, tree,
626 proc_item = proto_tree_add_item(tree, hf_corosync_totemsrp_memb_join_proc_list_entries,
627 tvb, offset, 4, encoding);
628 proc_list_entries = corosync_totemsrp_get_guint32(tvb, offset, encoding);
631 failed_item = proto_tree_add_item(tree, hf_corosync_totemsrp_memb_join_failed_list_entries,
632 tvb, offset, 4, encoding);
633 failed_list_entries = corosync_totemsrp_get_guint32(tvb, offset, encoding);
636 proto_tree_add_item(tree, hf_corosync_totemsrp_memb_join_ring_seq,
637 tvb, offset, 8, encoding);
640 proc_tree = proto_item_add_subtree(proc_item, ett_corosync_totemsrp_memb_join_proc_list);
642 proto_item_append_text(item, " (nprocs: %u nfailed: %u)",
643 proc_list_entries, failed_list_entries);
645 for (i = 0; i < proc_list_entries; i++) {
646 offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, proc_tree,
652 failed_tree = proto_item_add_subtree(failed_item,
653 ett_corosync_totemsrp_memb_join_failed_list);
655 for (i = 0; i < failed_list_entries; i++) {
656 offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, failed_tree,
662 proto_item_set_len(item, offset - original_offset);
663 return (offset - original_offset);
667 dissect_corosync_totemsrp_memb_commit_token_memb_entry(tvbuff_t *tvb,
669 proto_tree *parent_tree,
670 guint length, int offset,
671 const guint encoding,
675 int original_offset = offset;
680 item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_memb_commit_token_memb_entry,
681 tvb, offset, -1, encoding);
682 tree = proto_item_add_subtree(item, ett_corosync_totemsrp_memb_commit_token_memb_entry);
685 offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
691 proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_memb_entry_aru,
692 tvb, offset, 4, encoding);
695 proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_memb_entry_high_delivered,
696 tvb, offset, 4, encoding);
699 proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_memb_entry_received_flg,
700 tvb, offset, 4, encoding);
703 proto_item_set_len(item, offset - original_offset);
704 return (offset - original_offset);
708 dissect_corosync_totemsrp_memb_commit_token(tvbuff_t *tvb,
709 packet_info *pinfo, proto_tree *parent_tree,
710 guint length, int offset,
711 const guint encoding)
713 int original_offset = offset;
717 guint32 i, addr_entries;
723 item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_memb_commit_token,
724 tvb, offset, -1, ENC_NA);
725 tree = proto_item_add_subtree(item, ett_corosync_totemsrp_memb_commit_token);
727 proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_token_seq,
728 tvb, offset, 4, encoding);
729 seq = corosync_totemsrp_get_guint32(tvb, offset, encoding);
732 offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
738 proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_retrans_flg,
739 tvb, offset, 4, encoding);
742 proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_memb_index,
743 tvb, offset, 4, encoding);
746 proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_addr_entries,
747 tvb, offset, 4, encoding);
748 addr_entries = corosync_totemsrp_get_guint32(tvb, offset, encoding);
751 for (i = 0; i < addr_entries; i++) {
752 offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, tree,
758 for (i = 0; i < addr_entries; i++) {
759 offset += dissect_corosync_totemsrp_memb_commit_token_memb_entry(tvb, pinfo, tree,
766 proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u node: %u seq: %u entries: %u)",
767 ring_id, node_id, seq, addr_entries);
769 proto_item_set_len(item, offset - original_offset);
770 return (offset - original_offset);
774 dissect_corosync_totemsrp_token_hold_cancel(tvbuff_t *tvb,
775 packet_info *pinfo, proto_tree *parent_tree,
776 guint length, int offset,
777 const guint encoding)
779 int original_offset = offset;
785 item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_token_hold_cancel, tvb, offset,
787 tree = proto_item_add_subtree(item, ett_corosync_totemsrp_token_hold_cancel);
789 offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
795 proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u node: %u)",
798 proto_item_set_len(item, offset - original_offset);
799 return (offset - original_offset);
803 dissect_corosync_totemsrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
805 return dissect_corosync_totemsrp0(tvb, pinfo, parent_tree, FALSE);
808 #define COROSYNC_TOTEMSRP_TEST_LITTLE_ENDIAN 0x22FF
809 #define COROSYNC_TOTEMSRP_TEST_BIG_ENDIAN 0xFF22
812 dissect_corosync_totemsrp0(tvbuff_t *tvb,
813 packet_info *pinfo, proto_tree *tree,
814 gboolean encapsulated)
820 proto_tree *corosync_tree;
822 guint8 message_header__type;
823 guint8 message_header__encapsulated;
826 struct corosync_totemsrp_info info;
828 /* Check that there's enough data */
829 length = tvb_reported_length(tvb);
830 if (length < 1 + 1 + 2 + 4)
834 message_header__type = tvb_get_guint8(tvb, 0);
835 if (message_header__type > 5)
838 message_header__encapsulated = tvb_get_guint8(tvb, 1);
840 /* message_header -- byte order checking */
841 endian_test = tvb_get_ntohs(tvb, 2);
842 if (endian_test == COROSYNC_TOTEMSRP_TEST_LITTLE_ENDIAN)
843 encoding = ENC_LITTLE_ENDIAN;
844 else if (endian_test == COROSYNC_TOTEMSRP_TEST_BIG_ENDIAN)
845 encoding = ENC_BIG_ENDIAN;
849 if (encapsulated == FALSE)
851 col_set_str(pinfo->cinfo, COL_PROTOCOL, "COROSYNC/TOTEMSRP");
852 col_set_str(pinfo->cinfo, COL_INFO,
853 ((message_header__type == COROSYNC_TOTEMSRP_MESSAGE_TYPE_MCAST)
854 && (message_header__encapsulated == COROSYNC_TOTEMSRP_MESSAGE_ENCAPSULATED))?
856 val_to_str_const(message_header__type,
857 corosync_totemsrp_message_header_type,
861 item = proto_tree_add_item(tree, proto_corosync_totemsrp, tvb, offset, -1, ENC_NA);
862 corosync_tree = proto_item_add_subtree(item, ett_corosync_totemsrp);
864 proto_tree_add_item(corosync_tree, hf_corosync_totemsrp_message_header_type,
865 tvb, offset, 1, ENC_NA);
868 proto_tree_add_item(corosync_tree, hf_corosync_totemsrp_message_header_encapsulated,
869 tvb, offset, 1, ENC_NA);
872 proto_tree_add_item(corosync_tree, hf_corosync_totemsrp_message_header_endian_detector,
873 tvb, offset, 2, encoding);
876 proto_tree_add_item(corosync_tree,
877 hf_corosync_totemsrp_message_header_nodeid,
878 tvb, offset, 4, encoding);
879 info.encoding = encoding;
880 info.nodeid = corosync_totemsrp_get_guint32(tvb, offset, encoding);
883 switch (message_header__type) {
884 case COROSYNC_TOTEMSRP_MESSAGE_TYPE_ORF_TOKEN:
885 dissect_corosync_totemsrp_orf_token(tvb, pinfo, corosync_tree, length, offset, encoding);
887 case COROSYNC_TOTEMSRP_MESSAGE_TYPE_MCAST:
888 dissect_corosync_totemsrp_mcast(tvb, pinfo, corosync_tree, length, offset,
889 message_header__encapsulated,
890 encoding, tree, &info);
892 case COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_MERGE_DETECT:
893 dissect_corosync_totemsrp_memb_merge_detect(tvb, pinfo, corosync_tree, length, offset,
896 case COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_JOIN:
897 dissect_corosync_totemsrp_memb_join(tvb, pinfo, corosync_tree, length, offset,
900 case COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_COMMIT_TOKEN:
901 dissect_corosync_totemsrp_memb_commit_token(tvb, pinfo, corosync_tree, length, offset,
904 case COROSYNC_TOTEMSRP_MESSAGE_TYPE_TOKEN_HOLD_CANCEL:
905 dissect_corosync_totemsrp_token_hold_cancel(tvb, pinfo, corosync_tree, length, offset,
916 proto_register_corosync_totemsrp(void)
918 static hf_register_info hf[] = {
920 { &hf_corosync_totemsrp_message_header_type,
921 { "Type", "corosync_totemsrp.message_header.type",
922 FT_INT8, BASE_DEC, VALS(corosync_totemsrp_message_header_type), 0x0,
924 { &hf_corosync_totemsrp_message_header_encapsulated,
925 { "Encapsulated", "corosync_totemsrp.message_header.encapsulated",
926 FT_INT8, BASE_DEC, VALS(corosync_totemsrp_message_header_encapsulated), 0x0,
928 { &hf_corosync_totemsrp_message_header_endian_detector,
929 { "Endian detector", "corosync_totemsrp.message_header.endian_detector",
930 FT_UINT16, BASE_HEX, NULL, 0x0,
932 { &hf_corosync_totemsrp_message_header_nodeid,
933 { "Node ID", "corosync_totemsrp.message_header.nodeid",
934 FT_UINT32, BASE_DEC, NULL, 0x0,
938 { &hf_corosync_totemsrp_orf_token,
939 { "Ordering, Reliability, Flow (ORF) control Token", "corosync_totemsrp.orf_token",
940 FT_NONE, BASE_NONE, NULL, 0x0,
942 { &hf_corosync_totemsrp_orf_token_seq,
943 { "Sequence number allowing recognition of redundant copies of the token", "corosync_totemsrp.orf_token.seq",
944 FT_UINT32, BASE_DEC, NULL, 0x0,
946 { &hf_corosync_totemsrp_orf_token_token_seq,
947 { "The largest sequence number", "corosync_totemsrp.orf_token.seq",
948 FT_UINT32, BASE_DEC, NULL, 0x0,
949 "The largest sequence number of any message "
950 "that has been broadcast on the ring"
953 { &hf_corosync_totemsrp_orf_token_aru,
954 { "Sequence number all received up to", "corosync_totemsrp.orf_token.aru",
955 FT_UINT32, BASE_DEC, NULL, 0x0,
957 { &hf_corosync_totemsrp_orf_token_aru_addr,
958 { "ID of node setting ARU", "corosync_totemsrp.orf_token.aru_addr",
959 FT_UINT32, BASE_DEC, NULL, 0x0,
961 { &hf_corosync_totemsrp_orf_token_backlog,
962 { "Backlog", "corosync_totemsrp.orf_token.backlog",
963 FT_UINT32, BASE_DEC, NULL, 0x0,
964 "The sum of the number of new message waiting to be transmitted by each processor on the ring "
965 "at the time at which that processor forwarded the token during the previous rotation"
968 { &hf_corosync_totemsrp_orf_token_fcc,
970 "corosync_totemsrp.orf_token.fcc",
971 FT_UINT32, BASE_DEC, NULL, 0x0,
972 "A count of the number of messages broadcast by all processors "
973 "during the previous rotation of the token"
976 { &hf_corosync_totemsrp_orf_token_retrnas_flg,
977 { "Retransmission flag", "corosync_totemsrp.orf_token.retrans_flg",
978 FT_INT32, BASE_DEC, NULL, 0x0,
980 { &hf_corosync_totemsrp_orf_token_rtr_list_entries,
981 { "The number of retransmission list entries", "corosync_totemsrp.orf_token.rtr_list_entries",
982 FT_INT32, BASE_DEC, NULL, 0x0,
986 { &hf_corosync_totemsrp_memb_ring_id,
987 { "Member ring id", "corosync_totemsrp.memb_ring_id",
988 FT_NONE, BASE_NONE, NULL, 0x0,
990 { &hf_corosync_totemsrp_memb_ring_id_seq,
991 { "Sequence in member ring id", "corosync_totemsrp.memb_ring_id.seq",
992 FT_UINT64, BASE_DEC, NULL, 0x0,
995 /* totem_ip_address */
996 { &hf_corosync_totemsrp_ip_address,
997 { "Node IP address", "corosync_totemsrp.ip_address",
998 FT_NONE, BASE_NONE, NULL, 0x0,
1000 { &hf_corosync_totemsrp_ip_address_nodeid,
1001 { "Node ID", "corosync_totemsrp.ip_address.nodeid",
1002 FT_UINT32, BASE_DEC, NULL, 0x0,
1004 { &hf_corosync_totemsrp_ip_address_family,
1005 { "Address family", "corosync_totemsrp.ip_address.family",
1006 FT_UINT16, BASE_DEC, VALS(corosync_totemsrp_ip_address_family), 0x0,
1008 { &hf_corosync_totemsrp_ip_address_addr,
1009 { "Address", "corosync_totemsrp.ip_address.addr",
1010 FT_BYTES, BASE_NONE, NULL, 0x0,
1012 { &hf_corosync_totemsrp_ip_address_addr4,
1013 { "Address", "corosync_totemsrp.ip_address.addr4",
1014 FT_IPv4, BASE_NONE, NULL, 0x0,
1016 { &hf_corosync_totemsrp_ip_address_addr4_padding,
1017 { "Address padding", "corosync_totemsrp.ip_address.addr4_padding",
1018 FT_BYTES, BASE_NONE, NULL, 0x0,
1020 { &hf_corosync_totemsrp_ip_address_addr6,
1021 { "Address", "corosync_totemsrp.ip_address.addr6",
1022 FT_IPv6, BASE_NONE, NULL, 0x0,
1026 { &hf_corosync_totemsrp_mcast,
1027 { "ring ordered multicast message", "corosync_totemsrp.mcast",
1028 FT_NONE, BASE_NONE, NULL, 0x0,
1030 { &hf_corosync_totemsrp_mcast_seq,
1031 {"Multicast sequence number", "corosync_totemsrp.mcast.seq",
1032 FT_UINT32, BASE_DEC, NULL, 0x0,
1034 { &hf_corosync_totemsrp_mcast_this_seqno,
1035 {"This Sequence number", "corosync_totemsrp.mcast.this_seqno",
1036 FT_INT32, BASE_DEC, NULL, 0x0,
1038 { &hf_corosync_totemsrp_mcast_node_id,
1039 {"Node id(unused?)", "corosync_totemsrp.mcast.node_id",
1040 FT_UINT32, BASE_DEC, NULL, 0x0,
1042 { &hf_corosync_totemsrp_mcast_system_from,
1043 {"System from address", "corosync_totemsrp.mcast.system_from",
1044 FT_NONE, BASE_NONE, NULL, 0x0,
1047 { &hf_corosync_totemsrp_mcast_guarantee,
1048 {"Guarantee", "corosync_totemsrp.mcast.guarantee",
1049 FT_INT32, BASE_DEC, NULL, 0x0,
1052 /* memb_merge_detect */
1053 { &hf_corosync_totemsrp_memb_merge_detect,
1054 { "Merge rings if there are available rings", "corosync_totemsrp.memb_merge_detect",
1055 FT_NONE, BASE_NONE, NULL, 0x0,
1059 { &hf_corosync_totemsrp_srp_addr,
1060 {"Single Ring Protocol Address", "corosync_totemsrp.srp_addr",
1061 FT_NONE, BASE_NONE, NULL, 0x0,
1065 { &hf_corosync_totemsrp_rtr_item,
1066 {"Retransmission Item", "corosync_totemsrp.rtr_item",
1067 FT_NONE, BASE_NONE, NULL, 0x0,
1069 { &hf_corosync_totemsrp_rtr_item_seq,
1070 {"Sequence of Retransmission Item", "corosync_totemsrp.rtr_item.seq",
1071 FT_UINT32, BASE_DEC, NULL, 0x0,
1075 { &hf_corosync_totemsrp_memb_join,
1076 {"Membership join message", "corosync_totemsrp.memb_join",
1077 FT_NONE, BASE_NONE, NULL, 0x0,
1079 { &hf_corosync_totemsrp_memb_join_proc_list_entries,
1080 {"The number of processor list entries", "corosync_totemsrp.memb_join.proc_list_entries",
1081 FT_UINT32, BASE_DEC, NULL, 0x0,
1083 { &hf_corosync_totemsrp_memb_join_failed_list_entries,
1084 {"The number of failed list entries", "corosync_totemsrp.memb_join.failed_list_entries",
1085 FT_UINT32, BASE_DEC, NULL, 0x0,
1087 { &hf_corosync_totemsrp_memb_join_ring_seq,
1088 {"Ring sequence number", "corosync_totemsrp.memb_join.ring_seq",
1089 FT_UINT64, BASE_DEC, NULL, 0x0,
1092 /* memb_commit_token */
1093 { &hf_corosync_totemsrp_memb_commit_token,
1094 {"Membership commit token", "corosync_totemsrp.memb_commit_token",
1095 FT_NONE, BASE_NONE, NULL, 0x0,
1097 { &hf_corosync_totemsrp_memb_commit_token_token_seq,
1098 {"Token sequence", "corosync_totemsrp.memb_commit_token.token_seq",
1099 FT_UINT32, BASE_DEC, NULL, 0x0,
1101 { &hf_corosync_totemsrp_memb_commit_token_retrans_flg,
1102 {"Retransmission flag", "corosync_totemsrp.memb_commit_token.retrans_flg",
1103 FT_UINT32, BASE_DEC, NULL, 0x0,
1105 { &hf_corosync_totemsrp_memb_commit_token_memb_index,
1106 {"Member index", "corosync_totemsrp.memb_commit_token.memb_index",
1107 FT_INT32, BASE_DEC, NULL, 0x0,
1109 { &hf_corosync_totemsrp_memb_commit_token_addr_entries,
1110 {"The number of address entries", "corosync_totemsrp.memb_commit_token.addr_entries",
1111 FT_INT32, BASE_DEC, NULL, 0x0,
1114 /* memb_commit_token_memb_entry */
1115 { &hf_corosync_totemsrp_memb_commit_token_memb_entry,
1116 { "Membership entry", "corosync_totemsrp.memb_commit_token_memb_entry",
1117 FT_NONE, BASE_NONE, NULL, 0x0,
1119 { &hf_corosync_totemsrp_memb_commit_token_memb_entry_aru,
1120 {"Sequence number all received up to", "corosync_totemsrp.memb_commit_token_memb_entry.aru",
1121 FT_UINT32, BASE_DEC, NULL, 0x0,
1123 { &hf_corosync_totemsrp_memb_commit_token_memb_entry_high_delivered,
1124 {"High delivered", "corosync_totemsrp.memb_commit_token_memb_entry.high_delivered",
1125 FT_UINT32, BASE_DEC, NULL, 0x0,
1127 { &hf_corosync_totemsrp_memb_commit_token_memb_entry_received_flg,
1128 {"Received flag", "corosync_totemsrp.memb_commit_token_memb_entry.received_flg",
1129 FT_UINT32, BASE_DEC, NULL, 0x0,
1132 /* token_hold_cancel */
1133 { &hf_corosync_totemsrp_token_hold_cancel,
1134 {"Hold cancel token", "corosync_totemsrp.token_hold_cancel",
1135 FT_NONE, BASE_NONE, NULL, 0x0,
1139 static gint *ett[] = {
1140 &ett_corosync_totemsrp,
1141 &ett_corosync_totemsrp_orf_token,
1142 &ett_corosync_totemsrp_memb_ring_id,
1143 &ett_corosync_totemsrp_ip_address,
1144 &ett_corosync_totemsrp_mcast,
1145 &ett_corosync_totemsrp_memb_merge_detect,
1146 &ett_corosync_totemsrp_srp_addr,
1147 &ett_corosync_totemsrp_rtr_item,
1148 &ett_corosync_totemsrp_memb_join,
1149 &ett_corosync_totemsrp_memb_commit_token,
1150 &ett_corosync_totemsrp_memb_commit_token_memb_entry,
1151 &ett_corosync_totemsrp_token_hold_cancel,
1152 &ett_corosync_totemsrp_memb_join_proc_list,
1153 &ett_corosync_totemsrp_memb_join_failed_list
1157 proto_corosync_totemsrp = proto_register_protocol("Totem Single Ring Protocol implemented in Corosync Cluster Engine",
1158 "COROSYNC/TOTEMSRP", "corosync_totemsrp");
1159 proto_register_field_array(proto_corosync_totemsrp, hf, array_length(hf));
1160 proto_register_subtree_array(ett, array_length(ett));
1162 heur_subdissector_list = register_heur_dissector_list("corosync_totemsrp.mcast", proto_corosync_totemsrp);
1164 register_dissector( "corosync_totemsrp", dissect_corosync_totemsrp, proto_corosync_totemsrp);
1168 proto_reg_handoff_corosync_totemsrp(void)
1170 /* Nothing to be done.
1171 dissect_corosync_totemsrp is directly called from corosync_totemnet dissector. */
1176 * Editor modelines - http://www.wireshark.org/tools/modelines.html
1181 * indent-tabs-mode: nil
1184 * vi: set shiftwidth=2 tabstop=8 expandtab:
1185 * :indentSize=2:tabSize=8:noTabs=true: