A bunch of "{Mac} OS X" -> "macOS" changes.
[metze/wireshark/wip.git] / epan / dissectors / packet-corosync-totemsrp.c
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.
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 /* Fields description are taken from
26
27    Y.AMIR, L.E.MOSER, P.M.MELLIAR-SMITH, D.A.AGARWAL, P.CIARFELLA.
28    "The Totem Single-Ring Ordering and Membership Protocol"*/
29
30 /*
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.
35  *
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.)
38  *
39  * So we just check for all the AF_INET6 values we know about.
40  *
41  * We get the AF_ values from epan/aftypes.h, *not* from the OS
42  * we happen to be built for.
43  */
44
45 # include "config.h"
46
47 #include <epan/packet.h>
48 #include <epan/aftypes.h>
49
50 /*
51  * Utilities for subdissectors of corosync_totemsrp.
52  */
53 struct corosync_totemsrp_info {
54   guint encoding;
55   guint nodeid;
56 };
57
58 /* Forward declaration we need below */
59 void proto_register_corosync_totemsrp(void);
60 void proto_reg_handoff_corosync_totemsrp(void);
61
62 /* Initialize the protocol and registered fields */
63 static int proto_corosync_totemsrp = -1;
64
65 static heur_dissector_list_t heur_subdissector_list;
66
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;
72
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;
83
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;
87
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;
96
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;
104
105 /* field of struct memb_merge_detect */
106 static int hf_corosync_totemsrp_memb_merge_detect              = -1;
107
108 /* field of struct struct srp_addr */
109 static int hf_corosync_totemsrp_srp_addr                       = -1;
110
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;
114
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;
120
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;
127
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;
133
134 /* field of struct token_hold_cancel */
135 static int hf_corosync_totemsrp_token_hold_cancel              = -1;
136
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;
152
153
154 /*
155  * Value strings
156  */
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
163
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"            },
171   { 0, NULL                                                               }
172 };
173
174 #define COROSYNC_TOTEMSRP_MESSAGE_ENCAPSULATED     1
175 #define COROSYNC_TOTEMSRP_MESSAGE_NOT_ENCAPSULATED 2
176
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"  },
181   { 0, NULL                                                             }
182 };
183
184
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)" },
193   { 0, NULL              }
194 };
195
196 static guint16
197 corosync_totemsrp_get_guint16(tvbuff_t* tvb, gint offset, const guint encoding)
198 {
199   if (encoding == ENC_LITTLE_ENDIAN)
200     return tvb_get_letohs(tvb, offset);
201
202   return tvb_get_ntohs(tvb, offset);
203 }
204
205
206 static guint32
207 corosync_totemsrp_get_guint32(tvbuff_t* tvb, gint offset, const guint encoding)
208 {
209   if (encoding == ENC_LITTLE_ENDIAN)
210     return tvb_get_letohl(tvb, offset);
211
212   return tvb_get_ntohl(tvb, offset);
213 }
214
215 static guint64
216 corosync_totemsrp_get_guint64(tvbuff_t* tvb, gint offset, const guint encoding)
217 {
218   if (encoding == ENC_LITTLE_ENDIAN)
219     return tvb_get_letoh64(tvb, offset);
220
221   return tvb_get_ntoh64(tvb, offset);
222 }
223
224
225 #define COROSYNC_TOTEMSRP_SRP_ADDR_INTERFACE_MAX 2
226
227 static int dissect_corosync_totemsrp0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
228                                       gboolean encapsulated);
229
230
231 static int
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,
238                                      guint    interface,
239                                      guint   *nodeid)
240 {
241   guint16 family;
242   guint nid;
243   int original_offset = offset;
244   proto_tree *tree;
245   proto_item *item;
246   gint len;
247
248   nid = corosync_totemsrp_get_guint32(tvb, offset, encoding);
249   if (nodeid)
250     *nodeid = nid;
251   family = corosync_totemsrp_get_guint16(tvb, offset + 4, encoding);
252
253   item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_ip_address, tvb, offset,
254                              -1, ENC_NA);
255   tree = proto_item_add_subtree(item, ett_corosync_totemsrp_ip_address);
256
257   proto_item_append_text(item, " (");
258   if (print_interface)
259     proto_item_append_text(item, "interface: %u; ", interface);
260
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);
264   offset += 4;
265
266   proto_tree_add_item(tree, hf_corosync_totemsrp_ip_address_family,
267                         tvb, offset, 2, encoding);
268   offset += 2;
269
270   switch (family)
271   {
272   case COMMON_AF_INET:
273     len = 4;
274     proto_tree_add_item(tree, hf_corosync_totemsrp_ip_address_addr4, tvb, offset, len, ENC_BIG_ENDIAN);
275     break;
276   case BSD_AF_INET6_BSD:
277   case BSD_AF_INET6_FREEBSD:
278   case BSD_AF_INET6_DARWIN:
279   case LINUX_AF_INET6:
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);
284     break;
285   default:
286     len = sizeof(struct e_in6_addr);
287     proto_tree_add_item(tree, hf_corosync_totemsrp_ip_address_addr, tvb, offset, len, ENC_NA);
288     break;
289   }
290
291   offset += len;
292
293   if (len != sizeof(struct e_in6_addr)) {
294     gint padding_len;
295
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;
300   }
301
302   proto_item_set_len(item, offset - original_offset);
303   return offset - original_offset;
304 }
305
306 static int
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,
311                                        guint *node_id,
312                                        guint64 *ring_id)
313 {
314   int original_offset = offset;
315   proto_tree *tree;
316   proto_item *item;
317   guint64 rid;
318   guint nid;
319
320   item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_memb_ring_id, tvb, offset,
321                                -1, encoding);
322   tree = proto_item_add_subtree(item, ett_corosync_totemsrp_memb_ring_id);
323
324   offset += dissect_corosync_totemsrp_ip_address(tvb, pinfo, tree,
325                                                     length, offset,
326                                                     encoding,
327                                                     FALSE, -1,
328                                                     &nid);
329
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);
333   offset += 8;
334
335   proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u)", rid);
336
337   if (node_id)
338     *node_id = nid;
339   if (ring_id)
340     *ring_id = rid;
341
342   proto_item_set_len(item, offset - original_offset);
343   return offset - original_offset;
344 }
345
346 static int
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)
351 {
352   int original_offset = offset;
353   proto_tree *tree;
354   proto_item *item;
355
356   guint node_id;
357   guint64 ring_id;
358   guint32 seq;
359
360   item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_rtr_item, tvb, offset,
361                                -1, ENC_NA);
362   tree = proto_item_add_subtree(item, ett_corosync_totemsrp_rtr_item);
363
364   offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
365                                                         length, offset,
366                                                         encoding,
367                                                         &node_id,
368                                                         &ring_id);
369
370   proto_tree_add_item(tree, hf_corosync_totemsrp_rtr_item_seq,
371                         tvb, offset, 4, encoding);
372
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);
376   offset += 4;
377
378   proto_item_set_len(item, offset - original_offset);
379   return (offset - original_offset);
380 }
381
382 static int
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)
387 {
388   int original_offset = offset;
389   guint32 rtr_list_entries = 0, seq, aru, i;
390   proto_tree *tree;
391   proto_item *item;
392   guint   node_id;
393   guint64 ring_id;
394
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);
398
399   proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_seq,
400                         tvb, offset, 4, encoding);
401   offset += 4;
402
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);
406   offset += 4;
407
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);
411   offset += 4;
412
413   proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_aru_addr,
414                         tvb, offset, 4, encoding);
415   offset += 4;
416
417   offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
418                                                         length, offset,
419                                                         encoding,
420                                                         &node_id,
421                                                         &ring_id);
422
423   proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_backlog,
424                         tvb, offset, 4, encoding);
425   offset += 4;
426
427   proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_fcc,
428                         tvb, offset, 4, encoding);
429   offset += 4;
430
431   proto_tree_add_item(tree, hf_corosync_totemsrp_orf_token_retrnas_flg,
432                         tvb, offset, 4, encoding);
433   offset += 4;
434
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);
438   offset += 4;
439
440   for (i = 0; i < rtr_list_entries; i++) {
441     offset += dissect_corosync_totemsrp_rtr_list(tvb, pinfo,
442                                                     tree,
443                                                     length, offset,
444                                                     encoding);
445   }
446
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);
449
450   proto_item_set_len(item, offset - original_offset);
451   return offset - original_offset;
452 }
453
454 static int
455 dissect_corosync_totemsrp_srp_addr(tvbuff_t *tvb,
456                                    packet_info *pinfo, proto_tree *parent_tree,
457                                    guint length, int offset,
458                                    int   hf,
459                                    const guint encoding)
460 {
461   int original_offset = offset;
462   proto_tree *tree;
463   proto_item *item;
464   guint nodeid;
465
466   item = proto_tree_add_item(parent_tree, hf? hf: hf_corosync_totemsrp_srp_addr, tvb, offset,
467                                -1, encoding);
468   tree = proto_item_add_subtree(item, ett_corosync_totemsrp_srp_addr);
469
470   offset += dissect_corosync_totemsrp_ip_address(tvb, pinfo, tree,
471                                                       length, offset,
472                                                       encoding,
473                                                       TRUE, 0,
474                                                       &nodeid);
475   proto_item_append_text(item, " (node: %u)", nodeid);
476
477   offset += dissect_corosync_totemsrp_ip_address(tvb, pinfo, tree,
478                                                       length, offset,
479                                                       encoding,
480                                                       TRUE, 1,
481                                                       NULL);
482
483   proto_item_set_len(item, offset - original_offset);
484   return (offset - original_offset);
485 }
486
487 static int
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)
494 {
495   int original_offset = offset;
496   proto_tree *mcast_tree;
497
498   proto_item *item;
499   guint node_id;
500   guint64 ring_id;
501   tvbuff_t *next_tvb;
502
503   heur_dtbl_entry_t *hdtbl_entry = NULL;
504
505   item = proto_tree_add_item(tree, hf_corosync_totemsrp_mcast, tvb, offset,
506                                -1, encoding);
507   mcast_tree = proto_item_add_subtree(item, ett_corosync_totemsrp_mcast);
508
509   offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, mcast_tree,
510                                                     length, offset,
511                                                     hf_corosync_totemsrp_mcast_system_from,
512                                                     encoding);
513
514   proto_tree_add_item(mcast_tree, hf_corosync_totemsrp_mcast_seq,
515                         tvb, offset, 4, encoding);
516   offset += 4;
517
518   proto_tree_add_item(mcast_tree, hf_corosync_totemsrp_mcast_this_seqno,
519                         tvb, offset, 4, encoding);
520   offset += 4;
521
522   offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, mcast_tree,
523                                                         length, offset,
524                                                         encoding,
525                                                         &node_id,
526                                                         &ring_id);
527
528   proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u node: %u)",
529                            ring_id, node_id);
530
531   proto_tree_add_item(tree, hf_corosync_totemsrp_mcast_node_id,
532                         tvb, offset, 4, encoding);
533   offset += 4;
534
535   proto_tree_add_item(tree, hf_corosync_totemsrp_mcast_guarantee,
536                         tvb, offset, 4, encoding);
537   offset += 4;
538
539   next_tvb = tvb_new_subset_remaining(tvb, offset);
540
541   if (message_header__encapsulated == COROSYNC_TOTEMSRP_MESSAGE_ENCAPSULATED)
542   {
543     offset += dissect_corosync_totemsrp0(next_tvb, pinfo, tree, TRUE);
544   }
545   else
546   {
547     if (dissector_try_heuristic(heur_subdissector_list,
548                                 next_tvb,
549                                 pinfo,
550                                 parent_tree,
551                                 &hdtbl_entry,
552                                 totemsrp_info))
553        offset = length;
554   }
555
556   proto_item_set_len(item, offset - original_offset);
557   return (offset - original_offset);
558 }
559
560
561 static int
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)
566 {
567   int original_offset = offset;
568   proto_tree *tree;
569   proto_item *item;
570   guint node_id;
571   guint64 ring_id;
572
573   item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_memb_merge_detect, tvb, offset,
574                                -1, ENC_NA);
575   tree = proto_item_add_subtree(item, ett_corosync_totemsrp_memb_merge_detect);
576
577   offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, tree,
578                                                     length, offset,
579                                                     0,
580                                                     encoding);
581
582   offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
583                                                         length, offset,
584                                                         encoding,
585                                                         &node_id,
586                                                         &ring_id);
587
588   proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u node: %u)",
589                            ring_id, node_id);
590
591   proto_item_set_len(item, offset - original_offset);
592   return (offset - original_offset);
593 }
594
595 static int
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)
600 {
601   int original_offset = offset;
602   proto_tree *tree;
603   proto_item *item;
604
605   guint32 proc_list_entries;
606   proto_tree *proc_tree;
607
608   guint32 failed_list_entries;
609   proto_tree *failed_tree;
610   proto_item *failed_item;
611
612   guint i;
613
614   proto_item *proc_item;
615
616   item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_memb_join, tvb, offset,
617                                -1, encoding);
618   tree = proto_item_add_subtree(item, ett_corosync_totemsrp_memb_join);
619
620
621   offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, tree,
622                                                     length, offset,
623                                                     0,
624                                                     encoding);
625
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);
629   offset += 4;
630
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);
634   offset += 4;
635
636   proto_tree_add_item(tree, hf_corosync_totemsrp_memb_join_ring_seq,
637                         tvb, offset, 8, encoding);
638   offset += 8;
639
640   proc_tree = proto_item_add_subtree(proc_item, ett_corosync_totemsrp_memb_join_proc_list);
641
642   proto_item_append_text(item, " (nprocs: %u nfailed: %u)",
643                            proc_list_entries, failed_list_entries);
644
645   for (i = 0; i < proc_list_entries; i++) {
646     offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, proc_tree,
647                                                     length, offset,
648                                                     0,
649                                                     encoding);
650   }
651
652   failed_tree = proto_item_add_subtree(failed_item,
653                                          ett_corosync_totemsrp_memb_join_failed_list);
654
655   for (i = 0; i < failed_list_entries; i++) {
656     offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, failed_tree,
657                                                     length, offset,
658                                                     0,
659                                                     encoding);
660   }
661
662   proto_item_set_len(item, offset - original_offset);
663   return (offset - original_offset);
664 }
665
666 static int
667 dissect_corosync_totemsrp_memb_commit_token_memb_entry(tvbuff_t *tvb,
668                                                        packet_info *pinfo,
669                                                        proto_tree *parent_tree,
670                                                        guint length, int offset,
671                                                        const guint encoding,
672                                                        guint *node_id,
673                                                        guint64 *ring_id)
674 {
675   int original_offset = offset;
676
677   proto_tree *tree;
678   proto_item *item;
679
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);
683
684
685   offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
686                                                         length, offset,
687                                                         encoding,
688                                                         node_id,
689                                                         ring_id);
690
691   proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_memb_entry_aru,
692                         tvb, offset, 4, encoding);
693   offset += 4;
694
695   proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_memb_entry_high_delivered,
696                         tvb, offset, 4, encoding);
697   offset += 4;
698
699   proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_memb_entry_received_flg,
700                         tvb, offset, 4, encoding);
701   offset += 4;
702
703   proto_item_set_len(item, offset - original_offset);
704   return (offset - original_offset);
705 }
706
707 static int
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)
712 {
713   int original_offset = offset;
714   proto_tree *tree;
715   proto_item *item;
716
717   guint32 i, addr_entries;
718
719   guint32 seq;
720   guint node_id;
721   guint64 ring_id;
722
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);
726
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);
730   offset += 4;
731
732   offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
733                                                         length, offset,
734                                                         encoding,
735                                                         &node_id,
736                                                         &ring_id);
737
738   proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_retrans_flg,
739                         tvb, offset, 4, encoding);
740   offset += 4;
741
742   proto_tree_add_item(tree, hf_corosync_totemsrp_memb_commit_token_memb_index,
743                         tvb, offset, 4, encoding);
744   offset += 4;
745
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);
749   offset += 4;
750
751   for (i = 0; i < addr_entries; i++) {
752     offset += dissect_corosync_totemsrp_srp_addr(tvb, pinfo, tree,
753                                                     length, offset,
754                                                     0,
755                                                     encoding);
756   }
757
758   for (i = 0; i < addr_entries; i++) {
759     offset += dissect_corosync_totemsrp_memb_commit_token_memb_entry(tvb, pinfo, tree,
760                                                                         length, offset,
761                                                                         encoding,
762                                                                         NULL,
763                                                                         NULL);
764   }
765
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);
768
769   proto_item_set_len(item, offset - original_offset);
770   return (offset - original_offset);
771 }
772
773 static int
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)
778 {
779   int original_offset = offset;
780   proto_tree *tree;
781   proto_item *item;
782   guint node_id;
783   guint64 ring_id;
784
785   item = proto_tree_add_item(parent_tree, hf_corosync_totemsrp_token_hold_cancel, tvb, offset,
786                                -1, ENC_NA);
787   tree = proto_item_add_subtree(item, ett_corosync_totemsrp_token_hold_cancel);
788
789   offset += dissect_corosync_totemsrp_memb_ring_id(tvb, pinfo, tree,
790                                                         length, offset,
791                                                         encoding,
792                                                         &node_id,
793                                                         &ring_id);
794
795   proto_item_append_text(item, " (ring: %" G_GINT64_MODIFIER "u node: %u)",
796                              ring_id, node_id);
797
798   proto_item_set_len(item, offset - original_offset);
799   return (offset - original_offset);
800 }
801
802 static int
803 dissect_corosync_totemsrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
804 {
805   return dissect_corosync_totemsrp0(tvb, pinfo, parent_tree, FALSE);
806 }
807
808 #define COROSYNC_TOTEMSRP_TEST_LITTLE_ENDIAN    0x22FF
809 #define COROSYNC_TOTEMSRP_TEST_BIG_ENDIAN       0xFF22
810
811 static int
812 dissect_corosync_totemsrp0(tvbuff_t *tvb,
813                            packet_info *pinfo, proto_tree *tree,
814                            gboolean encapsulated)
815 {
816   proto_item *item;
817   guint       length;
818   int         offset = 0;
819   guint16     endian_test;
820   proto_tree *corosync_tree;
821
822   guint8      message_header__type;
823   guint8      message_header__encapsulated;
824
825   guint encoding;
826   struct corosync_totemsrp_info info;
827
828   /* Check that there's enough data */
829   length = tvb_reported_length(tvb);
830   if (length < 1 + 1 + 2 + 4)
831     return 0;
832
833   /* message header */
834   message_header__type = tvb_get_guint8(tvb, 0);
835   if (message_header__type > 5)
836     return 0;
837
838   message_header__encapsulated = tvb_get_guint8(tvb, 1);
839
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;
846   else
847     return 0;
848
849   if (encapsulated == FALSE)
850   {
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))?
855               "ENCAPSULATED":
856               val_to_str_const(message_header__type,
857                                corosync_totemsrp_message_header_type,
858                                "Unknown"));
859   }
860
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);
863
864   proto_tree_add_item(corosync_tree, hf_corosync_totemsrp_message_header_type,
865                         tvb, offset, 1, ENC_NA);
866   offset += 1;
867
868   proto_tree_add_item(corosync_tree, hf_corosync_totemsrp_message_header_encapsulated,
869                         tvb, offset, 1, ENC_NA);
870   offset += 1;
871
872   proto_tree_add_item(corosync_tree, hf_corosync_totemsrp_message_header_endian_detector,
873                         tvb, offset, 2, encoding);
874   offset += 2;
875
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);
881   offset += 4;
882
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);
886     break;
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);
891     break;
892   case COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_MERGE_DETECT:
893     dissect_corosync_totemsrp_memb_merge_detect(tvb, pinfo, corosync_tree, length, offset,
894                                                 encoding);
895     break;
896   case COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_JOIN:
897     dissect_corosync_totemsrp_memb_join(tvb, pinfo, corosync_tree, length, offset,
898                                         encoding);
899     break;
900   case COROSYNC_TOTEMSRP_MESSAGE_TYPE_MEMB_COMMIT_TOKEN:
901     dissect_corosync_totemsrp_memb_commit_token(tvb, pinfo, corosync_tree, length, offset,
902                                                 encoding);
903     break;
904   case COROSYNC_TOTEMSRP_MESSAGE_TYPE_TOKEN_HOLD_CANCEL:
905     dissect_corosync_totemsrp_token_hold_cancel(tvb, pinfo, corosync_tree, length, offset,
906                                                 encoding);
907     break;
908   default:
909     break;
910   }
911
912   return length;
913 }
914
915 void
916 proto_register_corosync_totemsrp(void)
917 {
918   static hf_register_info hf[] = {
919     /* message_header */
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,
923         NULL, HFILL }},
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,
927         NULL, HFILL }},
928     { &hf_corosync_totemsrp_message_header_endian_detector,
929       { "Endian detector", "corosync_totemsrp.message_header.endian_detector",
930         FT_UINT16, BASE_HEX, NULL, 0x0,
931         NULL, HFILL }},
932     { &hf_corosync_totemsrp_message_header_nodeid,
933       { "Node ID", "corosync_totemsrp.message_header.nodeid",
934         FT_UINT32, BASE_DEC, NULL, 0x0,
935         NULL, HFILL }},
936
937     /* orf_token */
938     { &hf_corosync_totemsrp_orf_token,
939       { "Ordering, Reliability, Flow (ORF) control Token", "corosync_totemsrp.orf_token",
940         FT_NONE, BASE_NONE, NULL, 0x0,
941         NULL, HFILL }},
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,
945         NULL, HFILL }},
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"
951         "[1]" ,
952         HFILL }},
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,
956         NULL, HFILL }},
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,
960         NULL, HFILL }},
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"
966         "[1]",
967         HFILL }},
968     { &hf_corosync_totemsrp_orf_token_fcc,
969       { "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"
974         "[1]",
975         HFILL }},
976     { &hf_corosync_totemsrp_orf_token_retrnas_flg,
977       { "Retransmission flag", "corosync_totemsrp.orf_token.retrans_flg",
978         FT_INT32, BASE_DEC, NULL, 0x0,
979         NULL, HFILL }},
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,
983         NULL, HFILL }},
984
985     /* memb_ring_id */
986     { &hf_corosync_totemsrp_memb_ring_id,
987       { "Member ring id", "corosync_totemsrp.memb_ring_id",
988         FT_NONE, BASE_NONE, NULL, 0x0,
989         NULL, HFILL }},
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,
993         NULL, HFILL }},
994
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,
999         NULL, HFILL }},
1000     { &hf_corosync_totemsrp_ip_address_nodeid,
1001       { "Node ID", "corosync_totemsrp.ip_address.nodeid",
1002         FT_UINT32, BASE_DEC, NULL, 0x0,
1003         NULL, HFILL }},
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,
1007         NULL, HFILL }},
1008     { &hf_corosync_totemsrp_ip_address_addr,
1009       { "Address", "corosync_totemsrp.ip_address.addr",
1010         FT_BYTES, BASE_NONE, NULL, 0x0,
1011         NULL, HFILL }},
1012     { &hf_corosync_totemsrp_ip_address_addr4,
1013       { "Address", "corosync_totemsrp.ip_address.addr4",
1014         FT_IPv4, BASE_NONE, NULL, 0x0,
1015         NULL, HFILL }},
1016     { &hf_corosync_totemsrp_ip_address_addr4_padding,
1017       { "Address padding", "corosync_totemsrp.ip_address.addr4_padding",
1018         FT_BYTES, BASE_NONE, NULL, 0x0,
1019         NULL, HFILL }},
1020     { &hf_corosync_totemsrp_ip_address_addr6,
1021       { "Address", "corosync_totemsrp.ip_address.addr6",
1022         FT_IPv6, BASE_NONE, NULL, 0x0,
1023         NULL, HFILL }},
1024
1025     /* mcast */
1026     { &hf_corosync_totemsrp_mcast,
1027       { "ring ordered multicast message", "corosync_totemsrp.mcast",
1028         FT_NONE, BASE_NONE, NULL, 0x0,
1029         NULL, HFILL }},
1030     { &hf_corosync_totemsrp_mcast_seq,
1031       {"Multicast sequence number", "corosync_totemsrp.mcast.seq",
1032        FT_UINT32, BASE_DEC, NULL, 0x0,
1033        NULL, HFILL }},
1034     { &hf_corosync_totemsrp_mcast_this_seqno,
1035       {"This Sequence number", "corosync_totemsrp.mcast.this_seqno",
1036        FT_INT32, BASE_DEC, NULL, 0x0,
1037        NULL, HFILL }},
1038     { &hf_corosync_totemsrp_mcast_node_id,
1039       {"Node id(unused?)", "corosync_totemsrp.mcast.node_id",
1040        FT_UINT32, BASE_DEC, NULL, 0x0,
1041        NULL, HFILL }},
1042     { &hf_corosync_totemsrp_mcast_system_from,
1043       {"System from address", "corosync_totemsrp.mcast.system_from",
1044        FT_NONE, BASE_NONE, NULL, 0x0,
1045        NULL, HFILL }},
1046
1047     { &hf_corosync_totemsrp_mcast_guarantee,
1048       {"Guarantee", "corosync_totemsrp.mcast.guarantee",
1049        FT_INT32, BASE_DEC, NULL, 0x0,
1050        NULL, HFILL }},
1051
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,
1056         NULL, HFILL }},
1057
1058     /* srp_addr */
1059     { &hf_corosync_totemsrp_srp_addr,
1060       {"Single Ring Protocol Address", "corosync_totemsrp.srp_addr",
1061        FT_NONE, BASE_NONE, NULL, 0x0,
1062        NULL, HFILL }},
1063
1064     /* rtr_item */
1065     { &hf_corosync_totemsrp_rtr_item,
1066       {"Retransmission Item", "corosync_totemsrp.rtr_item",
1067        FT_NONE, BASE_NONE, NULL, 0x0,
1068        NULL, HFILL }},
1069     { &hf_corosync_totemsrp_rtr_item_seq,
1070       {"Sequence of Retransmission Item", "corosync_totemsrp.rtr_item.seq",
1071        FT_UINT32, BASE_DEC, NULL, 0x0,
1072        NULL, HFILL }},
1073
1074     /* memb_join */
1075     { &hf_corosync_totemsrp_memb_join,
1076       {"Membership join message", "corosync_totemsrp.memb_join",
1077        FT_NONE, BASE_NONE, NULL, 0x0,
1078        NULL, HFILL}},
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,
1082        NULL, HFILL}},
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,
1086        NULL, HFILL}},
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,
1090        NULL, HFILL}},
1091
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,
1096        NULL, HFILL}},
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,
1100        NULL, HFILL}},
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,
1104        NULL, HFILL}},
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,
1108        NULL, HFILL}},
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,
1112        NULL, HFILL}},
1113
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,
1118         NULL, HFILL}},
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,
1122        NULL, HFILL}},
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,
1126        NULL, HFILL}},
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,
1130        NULL, HFILL}},
1131
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,
1136        NULL, HFILL}},
1137   };
1138
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
1154
1155   };
1156
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));
1161
1162   heur_subdissector_list = register_heur_dissector_list("corosync_totemsrp.mcast", proto_corosync_totemsrp);
1163
1164   register_dissector( "corosync_totemsrp", dissect_corosync_totemsrp, proto_corosync_totemsrp);
1165 }
1166
1167 void
1168 proto_reg_handoff_corosync_totemsrp(void)
1169 {
1170   /* Nothing to be done.
1171      dissect_corosync_totemsrp is directly called from corosync_totemnet dissector. */
1172 }
1173
1174
1175 /*
1176  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
1177  *
1178  * Local variables:
1179  * c-basic-offset: 2
1180  * tab-width: 8
1181  * indent-tabs-mode: nil
1182  * End:
1183  *
1184  * vi: set shiftwidth=2 tabstop=8 expandtab:
1185  * :indentSize=2:tabSize=8:noTabs=true:
1186  */