Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-ocfs2.c
blobd2389fa0a23701dabddd3ad1740a7f3e2cb48fd2
1 /*
2 * packet-ocfs2.c
4 * Routines for OCFS2's networking protocol disassembly (o2net and o2dlm)
5 * The OCFS2 cluster file system is available in the mainline Linux kernel.
7 * Copyright (C) 2006, 2011 Oracle. All rights reserved.
9 * Authors:
10 * Kurt Hackel <kurt.hackel@oracle.com>
11 * Zach Brown <zach.brown@oracle.com>
12 * Sunil Mushran <sunil.mushran@oracle.com>
13 * Jeff Liu <jeff.liu@oracle.com>
15 * SPDX-License-Identifier: GPL-2.0-or-later
18 #include "config.h"
21 #include <epan/packet.h>
22 #include "packet-tcp.h"
24 void proto_register_ocfs2(void);
25 void proto_reg_handoff_ocfs2(void);
27 static dissector_handle_t ocfs2_handle;
29 static int ett_ocfs2;
30 static int ett_dtm_lock_flags;
31 static int ett_mres_flags;
32 static int ett_migrate_lockres_locks;
33 static int ett_query_nodeinfo;
35 static int proto_ocfs2;
36 static int hf_msg_magic;
37 static int hf_msg_data_len;
38 static int hf_msg_msg_type;
39 static int hf_msg_sys_status;
40 static int hf_msg_status;
41 static int hf_msg_key;
42 static int hf_msg_msg_num;
43 static int hf_msg_pad;
45 static int hf_dlm_node_idx;
46 static int hf_dlm_lock_flags;
47 static int hf_dlm_lock_flag_unused1;
48 static int hf_dlm_lock_flag_orphan;
49 static int hf_dlm_lock_flag_parentable;
50 static int hf_dlm_lock_flag_block;
51 static int hf_dlm_lock_flag_local;
52 static int hf_dlm_lock_flag_valblk;
53 static int hf_dlm_lock_flag_noqueue;
54 static int hf_dlm_lock_flag_convert;
55 static int hf_dlm_lock_flag_nodlckwt;
56 static int hf_dlm_lock_flag_unlock;
57 static int hf_dlm_lock_flag_cancel;
58 static int hf_dlm_lock_flag_deqall;
59 static int hf_dlm_lock_flag_invvalblk;
60 static int hf_dlm_lock_flag_syncsts;
61 static int hf_dlm_lock_flag_timeout;
62 static int hf_dlm_lock_flag_sngldlck;
63 static int hf_dlm_lock_flag_findlocal;
64 static int hf_dlm_lock_flag_proc_owned;
65 static int hf_dlm_lock_flag_xid;
66 static int hf_dlm_lock_flag_xid_conflict;
67 static int hf_dlm_lock_flag_force;
68 static int hf_dlm_lock_flag_revvalblk;
69 static int hf_dlm_lock_flag_unused2;
70 static int hf_dlm_lock_flag_migration;
71 static int hf_dlm_lock_flag_put_lvb;
72 static int hf_dlm_lock_flag_get_lvb;
73 static int hf_dlm_lock_flag_recovery;
74 static int hf_dlm_am_flags;
75 static int hf_dlm_fr_flags;
76 static int hf_dlm_namelen;
77 static int hf_dlm_name;
78 static int hf_dlm_cookie;
79 static int hf_dlm_requested_type;
80 static int hf_dlm_lvb1;
81 static int hf_dlm_lvb2;
82 static int hf_dlm_lvb3;
83 static int hf_dlm_ast_type;
84 static int hf_dlm_blocked_type;
85 static int hf_dlm_dead_node;
86 static int hf_dlm_domain_name_len;
87 static int hf_dlm_domain_name;
88 static int hf_dlm_proto_ver;
89 static int hf_dlm_fs_proto_ver;
90 static int hf_dlm_node_map;
91 static int hf_dlm_master;
92 static int hf_dlm_new_master;
93 static int hf_dlm_mres_num_locks;
94 static int hf_dlm_mres_flags;
95 static int hf_dlm_mres_flag_recovery;
96 static int hf_dlm_mres_flag_migration;
97 static int hf_dlm_mres_flag_all_done;
98 static int hf_dlm_mres_total_locks;
99 static int hf_dlm_mres_mig_cookie;
100 static int hf_dlm_mres_list;
101 static int hf_dlm_mres_ml_flags;
102 static int hf_dlm_mres_type;
103 static int hf_dlm_mres_convert_type;
104 static int hf_dlm_mres_highest_blocked;
105 static int hf_dlm_mres_node;
106 static int hf_dlm_qr_node;
107 static int hf_dlm_qr_numregions;
108 static int hf_dlm_qr_namelen;
109 static int hf_dlm_qr_domain;
110 static int hf_dlm_qr_region;
111 static int hf_dlm_qn_nodenum;
112 static int hf_dlm_qn_numnodes;
113 static int hf_dlm_qn_namelen;
114 static int hf_dlm_qn_domain;
115 static int hf_dlm_qn_node;
116 static int hf_dlm_qn_port;
117 static int hf_dlm_qn_ip;
118 static int hf_dlm_reco_lvb;
119 static int hf_dlm_pad8;
120 static int hf_dlm_pad16;
121 static int hf_dlm_pad32;
122 static int hf_dlm_flags;
123 static int hf_dlm_payload;
125 #define O2NM_MAX_NAME_LEN 64
126 #define O2NM_NODE_MAP_IN_BYTES 32
128 #define OCFS2_DENTRY_LOCK_INO_START 18
131 * generic o2net constants
134 #define O2NET_MSG_MAGIC 0xfa55
135 #define O2NET_MSG_STATUS_MAGIC 0xfa56
136 #define O2NET_MSG_KEEP_REQ_MAGIC 0xfa57
137 #define O2NET_MSG_KEEP_RESP_MAGIC 0xfa58
138 static const value_string o2net_magic[] = {
139 { O2NET_MSG_MAGIC, "Request" },
140 { O2NET_MSG_STATUS_MAGIC, "Response" },
141 { O2NET_MSG_KEEP_REQ_MAGIC, "Keepalive Request" },
142 { O2NET_MSG_KEEP_RESP_MAGIC, "Keepalive Response" },
143 { 0x0000, NULL }
146 /* DLM constants */
147 #define DLM_LVB_LEN 64
148 #define DLM_MOD_KEY (0x666c6172)
150 #if 0
151 enum dlm_query_join_response {
152 JOIN_DISALLOW = 0,
153 JOIN_OK,
154 JOIN_OK_NO_MAP,
155 JOIN_PROTOCOL_MISMATCH
157 #endif
159 /* DLM lock modes */
160 enum {
161 LKM_IVMODE = -1,
162 LKM_NLMODE = 0,
163 LKM_CRMODE,
164 LKM_CWMODE,
165 LKM_PRMODE,
166 LKM_PWMODE,
167 LKM_EXMODE,
168 LKM_MAXMODE
171 static const value_string dlm_lock_modes[] = {
172 { LKM_IVMODE, "IV" },
173 { LKM_NLMODE, "NL" },
174 { LKM_CRMODE, "CR" },
175 { LKM_CWMODE, "CW" },
176 { LKM_PRMODE, "PR" },
177 { LKM_PWMODE, "PW" },
178 { LKM_EXMODE, "EX" },
179 { 0x0000, NULL }
182 /* DLM message types */
183 enum {
184 DLM_MASTER_REQUEST_MSG = 500,
185 DLM_UNUSED_MSG1 = 501,
186 DLM_ASSERT_MASTER_MSG = 502,
187 DLM_CREATE_LOCK_MSG = 503,
188 DLM_CONVERT_LOCK_MSG = 504,
189 DLM_PROXY_AST_MSG = 505,
190 DLM_UNLOCK_LOCK_MSG = 506,
191 DLM_DEREF_LOCKRES_MSG = 507,
192 DLM_MIGRATE_REQUEST_MSG = 508,
193 DLM_MIG_LOCKRES_MSG = 509,
194 DLM_QUERY_JOIN_MSG = 510,
195 DLM_ASSERT_JOINED_MSG = 511,
196 DLM_CANCEL_JOIN_MSG = 512,
197 DLM_EXIT_DOMAIN_MSG = 513,
198 DLM_MASTER_REQUERY_MSG = 514,
199 DLM_LOCK_REQUEST_MSG = 515,
200 DLM_RECO_DATA_DONE_MSG = 516,
201 DLM_BEGIN_RECO_MSG = 517,
202 DLM_FINALIZE_RECO_MSG = 518,
203 DLM_QUERY_REGION_MSG = 519,
204 DLM_QUERY_NODEINFO_MSG = 520
207 static const value_string dlm_magic[] = {
208 { DLM_MASTER_REQUEST_MSG, "Master Request" },
209 { DLM_UNUSED_MSG1, "Unused 1" },
210 { DLM_ASSERT_MASTER_MSG, "Assert Master" },
211 { DLM_CREATE_LOCK_MSG, "Create Lock" },
212 { DLM_CONVERT_LOCK_MSG, "Convert Lock" },
213 { DLM_PROXY_AST_MSG, "Proxy AST" },
214 { DLM_UNLOCK_LOCK_MSG, "Unlock Lock" },
215 { DLM_DEREF_LOCKRES_MSG, "Deref Lockres" },
216 { DLM_MIGRATE_REQUEST_MSG, "Migrate Request" },
217 { DLM_MIG_LOCKRES_MSG, "Migrate Lockres" },
218 { DLM_QUERY_JOIN_MSG, "Query Join" },
219 { DLM_ASSERT_JOINED_MSG, "Assert Join" },
220 { DLM_CANCEL_JOIN_MSG, "Cancel Join" },
221 { DLM_EXIT_DOMAIN_MSG, "Exit Domain" },
222 { DLM_MASTER_REQUERY_MSG, "Master Requery" },
223 { DLM_LOCK_REQUEST_MSG, "Lock Request" },
224 { DLM_RECO_DATA_DONE_MSG, "Recovery Data Done" },
225 { DLM_BEGIN_RECO_MSG, "Begin Recovery" },
226 { DLM_FINALIZE_RECO_MSG, "Finalize Recovery" },
227 { DLM_QUERY_REGION_MSG, "Query Region" },
228 { DLM_QUERY_NODEINFO_MSG, "Query Node Info" },
229 { 0x0000, NULL }
232 static value_string_ext ext_dlm_magic = VALUE_STRING_EXT_INIT(dlm_magic);
235 enum {
236 DLM_GRANTED_LIST = 0,
237 DLM_CONVERTING_LIST,
238 DLM_BLOCKED_LIST,
239 DLM_MAX_LIST
242 static const value_string dlm_lockres_list[] = {
243 { DLM_GRANTED_LIST, "Granted" },
244 { DLM_CONVERTING_LIST, "Converting" },
245 { DLM_BLOCKED_LIST, "Blocked" },
246 { 0x0000, NULL }
250 #if 0
251 enum dlm_status {
252 DLM_NORMAL = 0,
253 DLM_GRANTED,
254 DLM_DENIED,
255 DLM_DENIED_NOLOCKS,
256 DLM_WORKING,
257 DLM_BLOCKED,
258 DLM_BLOCKED_ORPHAN,
259 DLM_DENIED_GRACE_PERIOD,
260 DLM_SYSERR,
261 DLM_NOSUPPORT,
262 DLM_CANCELGRANT,
263 DLM_IVLOCKID,
264 DLM_SYNC,
265 DLM_BADTYPE,
266 DLM_BADRESOURCE,
267 DLM_MAXHANDLES,
268 DLM_NOCLINFO,
269 DLM_NOLOCKMGR,
270 DLM_NOPURGED,
271 DLM_BADARGS,
272 DLM_VOID,
273 DLM_NOTQUEUED,
274 DLM_IVBUFLEN,
275 DLM_CVTUNGRANT,
276 DLM_BADPARAM,
277 DLM_VALNOTVALID,
278 DLM_REJECTED,
279 DLM_ABORT,
280 DLM_CANCEL,
281 DLM_IVRESHANDLE,
282 DLM_DEADLOCK,
283 DLM_DENIED_NOASTS,
284 DLM_FORWARD,
285 DLM_TIMEOUT,
286 DLM_IVGROUPID,
287 DLM_VERS_CONFLICT,
288 DLM_BAD_DEVICE_PATH,
289 DLM_NO_DEVICE_PERMISSION,
290 DLM_NO_CONTROL_DEVICE,
291 DLM_RECOVERING,
292 DLM_MIGRATING,
293 DLM_MAXSTATS
296 static const value_string dlm_errnames[] = {
297 { DLM_NORMAL, "DLM_NORMAL" },
298 { DLM_GRANTED, "DLM_GRANTED" },
299 { DLM_DENIED, "DLM_DENIED" },
300 { DLM_DENIED_NOLOCKS, "DLM_DENIED_NOLOCKS" },
301 { DLM_WORKING, "DLM_WORKING" },
302 { DLM_BLOCKED, "DLM_BLOCKED" },
303 { DLM_BLOCKED_ORPHAN, "DLM_BLOCKED_ORPHAN" },
304 { DLM_DENIED_GRACE_PERIOD, "DLM_DENIED_GRACE_PERIOD" },
305 { DLM_SYSERR, "DLM_SYSERR" },
306 { DLM_NOSUPPORT, "DLM_NOSUPPORT" },
307 { DLM_CANCELGRANT, "DLM_CANCELGRANT" },
308 { DLM_IVLOCKID, "DLM_IVLOCKID" },
309 { DLM_SYNC, "DLM_SYNC" },
310 { DLM_BADTYPE, "DLM_BADTYPE" },
311 { DLM_BADRESOURCE, "DLM_BADRESOURCE" },
312 { DLM_MAXHANDLES, "DLM_MAXHANDLES" },
313 { DLM_NOCLINFO, "DLM_NOCLINFO" },
314 { DLM_NOLOCKMGR, "DLM_NOLOCKMGR" },
315 { DLM_NOPURGED, "DLM_NOPURGED" },
316 { DLM_BADARGS, "DLM_BADARGS" },
317 { DLM_VOID, "DLM_VOID" },
318 { DLM_NOTQUEUED, "DLM_NOTQUEUED" },
319 { DLM_IVBUFLEN, "DLM_IVBUFLEN" },
320 { DLM_CVTUNGRANT, "DLM_CVTUNGRANT" },
321 { DLM_BADPARAM, "DLM_BADPARAM" },
322 { DLM_VALNOTVALID, "DLM_VALNOTVALID" },
323 { DLM_REJECTED, "DLM_REJECTED" },
324 { DLM_ABORT, "DLM_ABORT" },
325 { DLM_CANCEL, "DLM_CANCEL" },
326 { DLM_IVRESHANDLE, "DLM_IVRESHANDLE" },
327 { DLM_DEADLOCK, "DLM_DEADLOCK" },
328 { DLM_DENIED_NOASTS, "DLM_DENIED_NOASTS" },
329 { DLM_FORWARD, "DLM_FORWARD" },
330 { DLM_TIMEOUT, "DLM_TIMEOUT" },
331 { DLM_IVGROUPID, "DLM_IVGROUPID" },
332 { DLM_VERS_CONFLICT, "DLM_VERS_CONFLICT" },
333 { DLM_BAD_DEVICE_PATH, "DLM_BAD_DEVICE_PATH" },
334 { DLM_NO_DEVICE_PERMISSION, "DLM_NO_DEVICE_PERMISSION" },
335 { DLM_NO_CONTROL_DEVICE , "DLM_NO_CONTROL_DEVICE " },
336 { DLM_RECOVERING, "DLM_RECOVERING" },
337 { DLM_MIGRATING, "DLM_MIGRATING" },
338 { DLM_MAXSTATS, "DLM_MAXSTATS" },
339 { 0x0000, NULL }
342 value_string_ext ext_dlm_errnames = VALUE_STRING_EXT_INIT(dlm_errnames);
344 static const value_string dlm_errmsgs[] = {
345 { DLM_NORMAL, "request in progress" },
346 { DLM_GRANTED, "request granted" },
347 { DLM_DENIED, "request denied" },
348 { DLM_DENIED_NOLOCKS, "request denied, out of system resources" },
349 { DLM_WORKING, "async request in progress" },
350 { DLM_BLOCKED, "lock request blocked" },
351 { DLM_BLOCKED_ORPHAN, "lock request blocked by a orphan lock" },
352 { DLM_DENIED_GRACE_PERIOD, "topological change in progress" },
353 { DLM_SYSERR, "system error" },
354 { DLM_NOSUPPORT, "unsupported" },
355 { DLM_CANCELGRANT, "can't cancel convert: already granted" },
356 { DLM_IVLOCKID, "bad lockid" },
357 { DLM_SYNC, "synchronous request granted" },
358 { DLM_BADTYPE, "bad resource type" },
359 { DLM_BADRESOURCE, "bad resource handle" },
360 { DLM_MAXHANDLES, "no more resource handles" },
361 { DLM_NOCLINFO, "can't contact cluster manager" },
362 { DLM_NOLOCKMGR, "can't contact lock manager" },
363 { DLM_NOPURGED, "can't contact purge daemon" },
364 { DLM_BADARGS, "bad api args" },
365 { DLM_VOID, "no status" },
366 { DLM_NOTQUEUED, "NOQUEUE was specified and request failed" },
367 { DLM_IVBUFLEN, "invalid resource name length" },
368 { DLM_CVTUNGRANT, "attempted to convert ungranted lock" },
369 { DLM_BADPARAM, "invalid lock mode specified" },
370 { DLM_VALNOTVALID, "value block has been invalidated" },
371 { DLM_REJECTED, "request rejected, unrecognized client" },
372 { DLM_ABORT, "blocked lock request cancelled" },
373 { DLM_CANCEL, "conversion request cancelled" },
374 { DLM_IVRESHANDLE, "invalid resource handle" },
375 { DLM_DEADLOCK, "deadlock recovery refused this request" },
376 { DLM_DENIED_NOASTS, "failed to allocate AST" },
377 { DLM_FORWARD, "request must wait for primary's response" },
378 { DLM_TIMEOUT, "timeout value for lock has expired" },
379 { DLM_IVGROUPID, "invalid group specification" },
380 { DLM_VERS_CONFLICT, "version conflicts prevent request handling" },
381 { DLM_BAD_DEVICE_PATH, "Locks device does not exist or path wrong" },
382 { DLM_NO_DEVICE_PERMISSION, "Client has insufficient perms for device" },
383 { DLM_NO_CONTROL_DEVICE, "Cannot set options on opened device " },
384 { DLM_RECOVERING, "lock resource being recovered" },
385 { DLM_MIGRATING, "lock resource being migrated" },
386 { DLM_MAXSTATS, "invalid error number" },
387 { 0x0000, NULL }
390 value_string_ext ext_dlm_errmsgs = VALUE_STRING_EXT_INIT(dlm_errmsgs);
391 #endif
394 #define DLM_ASSERT_MASTER_MLE_CLEANUP 0x00000001
395 #define DLM_ASSERT_MASTER_REQUERY 0x00000002
396 #define DLM_ASSERT_MASTER_FINISH_MIGRATION 0x00000004
397 static const value_string dlm_assert_master_flags[] = {
398 { DLM_ASSERT_MASTER_MLE_CLEANUP, "cleanup" },
399 { DLM_ASSERT_MASTER_REQUERY, "requery" },
400 { DLM_ASSERT_MASTER_FINISH_MIGRATION, "finish" },
401 { 0x0000, NULL }
404 #define DLM_FINALIZE_STAGE2 0x01
405 static const value_string dlm_finalize_reco_flags[] = {
406 { DLM_FINALIZE_STAGE2, "stage2" },
407 { 0x0000, NULL }
410 enum dlm_ast_type {
411 DLM_AST = 0,
412 DLM_BAST,
413 DLM_ASTUNLOCK
416 static const value_string dlm_proxy_ast_types[] = {
417 { DLM_AST, "AST" },
418 { DLM_BAST, "BAST" },
419 { DLM_ASTUNLOCK, "Unlock AST (unused)" },
420 { 0x0000, NULL }
423 /* DLM lock flag types */
424 enum {
425 DLM_LOCK_FLAGS_PUT_LVB = 0x20000000,
426 DLM_LOCK_FLAGS_GET_LVB = 0x40000000
430 static int dlm_cookie_handler(proto_tree *tree, tvbuff_t *tvb, unsigned offset, int hf_cookie)
432 proto_item *item;
433 uint64_t cookie;
434 uint64_t seq;
435 uint8_t node_idx;
437 item = proto_tree_add_item(tree, hf_cookie, tvb, offset, 8, ENC_BIG_ENDIAN);
438 cookie = tvb_get_ntoh64(tvb, offset);
440 cookie >>= 56;
441 node_idx = (uint8_t)((cookie >> 56) & INT64_C(0xff));
442 seq = cookie & INT64_C(0x00ffffffffffffff);
444 proto_item_append_text(item, " (%u:%" PRIu64 ")", node_idx, seq);
446 return offset + 8;
449 static int dlm_lkm_flags_handler(proto_tree *tree, tvbuff_t *tvb, unsigned offset,
450 uint32_t *dlm_lock_flags_ptr)
452 static int * const flags[] = {
453 &hf_dlm_lock_flag_unused1,
454 &hf_dlm_lock_flag_orphan,
455 &hf_dlm_lock_flag_parentable,
456 &hf_dlm_lock_flag_block,
457 &hf_dlm_lock_flag_local,
458 &hf_dlm_lock_flag_valblk,
459 &hf_dlm_lock_flag_noqueue,
460 &hf_dlm_lock_flag_convert,
461 &hf_dlm_lock_flag_nodlckwt,
462 &hf_dlm_lock_flag_unlock,
463 &hf_dlm_lock_flag_cancel,
464 &hf_dlm_lock_flag_deqall,
465 &hf_dlm_lock_flag_invvalblk,
466 &hf_dlm_lock_flag_syncsts,
467 &hf_dlm_lock_flag_timeout,
468 &hf_dlm_lock_flag_sngldlck,
469 &hf_dlm_lock_flag_findlocal,
470 &hf_dlm_lock_flag_proc_owned,
471 &hf_dlm_lock_flag_xid,
472 &hf_dlm_lock_flag_xid_conflict,
473 &hf_dlm_lock_flag_force,
474 &hf_dlm_lock_flag_revvalblk,
475 &hf_dlm_lock_flag_unused2,
476 &hf_dlm_lock_flag_migration,
477 &hf_dlm_lock_flag_put_lvb,
478 &hf_dlm_lock_flag_get_lvb,
479 &hf_dlm_lock_flag_recovery,
480 NULL
483 if(dlm_lock_flags_ptr != NULL){
484 *dlm_lock_flags_ptr = tvb_get_ntohl(tvb, offset);
486 proto_tree_add_bitmask_with_flags(tree, tvb, offset, hf_dlm_lock_flags,
487 ett_dtm_lock_flags, flags, ENC_BIG_ENDIAN, BMT_NO_INT | BMT_NO_FALSE | BMT_NO_TFS);
488 return offset + 4;
491 static int dlm_name_handler(proto_tree *tree, tvbuff_t *tvb, unsigned offset, int namelen)
493 uint8_t lock_type;
494 uint64_t blkno;
495 proto_item *ti;
497 ti = proto_tree_add_item(tree, hf_dlm_name, tvb, offset, namelen, ENC_ASCII);
498 lock_type = tvb_get_uint8(tvb, offset);
499 if (lock_type == 'N') {
500 blkno = tvb_get_ntoh64(tvb, offset + OCFS2_DENTRY_LOCK_INO_START);
501 proto_item_append_text(ti, "%08x", (unsigned int)blkno);
504 return offset + namelen;
508 * We would like to get one whole lockres into a single network
509 * message whenever possible. Generally speaking, there will be
510 * at most one dlm_lock on a lockres for each node in the cluster,
511 * plus (infrequently) any additional locks coming in from userdlm.
513 * struct _dlm_lockres_page
515 * dlm_migratable_lockres mres;
516 * dlm_migratable_lock ml[DLM_MAX_MIGRATABLE_LOCKS];
517 * uint8_t pad[DLM_MIG_LOCKRES_RESERVED];
518 * };
520 * from ../cluster/tcp.h
521 * NET_MAX_PAYLOAD_BYTES (4096 - sizeof(net_msg))
522 * (roughly 4080 bytes)
523 * and sizeof(dlm_migratable_lockres) = 112 bytes
524 * and sizeof(dlm_migratable_lock) = 16 bytes
526 * Choosing DLM_MAX_MIGRATABLE_LOCKS=240 and
527 * DLM_MIG_LOCKRES_RESERVED=128 means we have this:
529 * (DLM_MAX_MIGRATABLE_LOCKS * sizeof(dlm_migratable_lock)) +
530 * sizeof(dlm_migratable_lockres) + DLM_MIG_LOCKRES_RESERVED =
531 * NET_MAX_PAYLOAD_BYTES
532 * (240 * 16) + 112 + 128 = 4080
534 * So a lockres would need more than 240 locks before it would
535 * use more than one network packet to recover. Not too bad.
538 static void dissect_dlm_migrate_lockres(proto_tree *tree, tvbuff_t *tvb, int offset)
540 unsigned int i;
541 uint32_t num_locks;
543 static int * const mres_flags[] = {
544 &hf_dlm_mres_flag_recovery,
545 &hf_dlm_mres_flag_migration,
546 &hf_dlm_mres_flag_all_done,
547 NULL
550 /* master */
551 proto_tree_add_item(tree, hf_dlm_master, tvb, offset, 1, ENC_BIG_ENDIAN);
552 offset += 1;
554 /* lockname_len */
555 proto_tree_add_item(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN);
556 offset += 1;
558 /* num_locks */
559 proto_tree_add_item_ret_uint(tree, hf_dlm_mres_num_locks, tvb, offset, 1, ENC_BIG_ENDIAN, &num_locks);
560 offset += 1;
562 /* no locks were found on this lockres! done! */
563 if (num_locks == 0)
564 return;
566 /* flags */
567 proto_tree_add_bitmask_with_flags(tree, tvb, offset, hf_dlm_mres_flags,
568 ett_mres_flags, mres_flags, ENC_BIG_ENDIAN, BMT_NO_INT | BMT_NO_FALSE | BMT_NO_TFS);
569 offset += 1;
571 /* total_locks */
572 proto_tree_add_item(tree, hf_dlm_mres_total_locks, tvb, offset, 4, ENC_BIG_ENDIAN);
573 offset += 4;
575 /* mig_cookie */
576 offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_mres_mig_cookie);
578 /* lockname */
579 proto_tree_add_item(tree, hf_dlm_name, tvb, offset, 32, ENC_ASCII);
580 offset += 32;
582 /* lvb */
583 proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
584 offset += 24;
586 proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
587 offset += 24;
589 proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
590 offset += 16;
592 /* dlm_migratable_lock */
593 for (i = 0; i < num_locks; i++) {
594 proto_tree *subtree;
596 subtree = proto_tree_add_subtree_format(tree, tvb, offset, 16,
597 ett_migrate_lockres_locks, NULL, "Locks%d: ", i + 1);
599 /* cookie */
600 offset = dlm_cookie_handler(subtree, tvb, offset, hf_dlm_mres_mig_cookie);
602 proto_tree_add_item(subtree, hf_dlm_pad8, tvb, offset, 1, ENC_BIG_ENDIAN);
603 offset += 1;
605 /* list */
606 proto_tree_add_item(subtree, hf_dlm_mres_list, tvb, offset, 1, ENC_BIG_ENDIAN);
607 offset += 1;
609 /* flags */
610 proto_tree_add_item(subtree, hf_dlm_mres_ml_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
611 offset += 1;
613 /* type */
614 proto_tree_add_item(subtree, hf_dlm_mres_type, tvb, offset, 1, ENC_BIG_ENDIAN);
615 offset += 1;
617 /* convert_type */
618 proto_tree_add_item(subtree, hf_dlm_mres_convert_type, tvb, offset, 1, ENC_BIG_ENDIAN);
619 offset += 1;
621 /* highest_blocked */
622 proto_tree_add_item(subtree, hf_dlm_mres_highest_blocked, tvb, offset, 1, ENC_BIG_ENDIAN);
623 offset += 1;
625 proto_tree_add_item(subtree, hf_dlm_mres_node, tvb, offset, 1, ENC_BIG_ENDIAN);
626 offset += 1;
630 static void
631 dlm_fmt_revision( char *result, uint32_t revision )
633 snprintf( result, ITEM_LABEL_LENGTH, "%d.%02d", (uint8_t)(( revision & 0xFF00 ) >> 8), (uint8_t)(revision & 0xFF) );
636 #define DLM_QUERY_JOIN_REQUEST_OFF_DLMPROTO 4
637 #define DLM_QUERY_JOIN_REQUEST_OFF_FSPROTO 6
638 #define DLM_QUERY_JOIN_REQUEST_OFF_DOMAIN 8
639 #define DLM_QUERY_JOIN_REQUEST_OFF_NODEMAP 72
640 #define DLM_QUERY_JOIN_REQUEST_LEN_DLMPROTO 2
641 #define DLM_QUERY_JOIN_REQUEST_LEN_FSPROTO 2
642 #define DLM_QUERY_JOIN_REQUEST_LEN_DOMAIN 64
643 #define DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP 32
645 #define DLM_QUERY_JOIN_REQUEST_OLD_LEN 100
646 static void dissect_dlm_query_join_request(proto_tree *tree, tvbuff_t *tvb, int offset)
648 uint8_t cc, *node_bits_array;
649 uint8_t *node_map;
650 int len;
651 unsigned int i, j;
652 bool oldver = false;
654 node_bits_array = (uint8_t *)wmem_alloc0(wmem_packet_scope(), (DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP*8)+1);
656 len = tvb_reported_length_remaining(tvb, offset);
657 if (len == DLM_QUERY_JOIN_REQUEST_OLD_LEN)
658 oldver = true;
660 /* node_idx */
661 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_BIG_ENDIAN);
662 offset += 1;
664 proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
665 offset += 2;
667 /* name_len */
668 proto_tree_add_item(tree, hf_dlm_domain_name_len, tvb, offset, 1, ENC_BIG_ENDIAN);
669 offset += 1;
671 if (!oldver)
673 /* dlm_proto */
674 proto_tree_add_item(tree, hf_dlm_proto_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
675 offset += 2;
677 /* fs_proto */
678 proto_tree_add_item(tree, hf_dlm_fs_proto_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
679 offset += 2;
682 /* domain */
683 proto_tree_add_item(tree, hf_dlm_domain_name, tvb, offset, 64, ENC_ASCII);
684 offset += 64;
686 /* node_map */
687 node_map = (uint8_t *)tvb_memdup(wmem_packet_scope(), tvb, offset, DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP);
689 for (i = 0; i < DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP; i++) {
690 cc = node_map[i];
691 for (j = 0; j < 8; j++)
692 node_bits_array[i * 8 + j] =
693 (((cc >> j) & 1) ? '1' : '0');
696 /* NULL terminate string */
697 node_bits_array[(DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP*8)] = 0;
698 proto_tree_add_bytes_format_value(tree, hf_dlm_node_map, tvb, offset, DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP, NULL, "%s", node_bits_array);
701 #define O2HB_MAX_REGION_NAME_LEN 32
703 static void dissect_dlm_query_region(proto_tree *tree, tvbuff_t *tvb,
704 unsigned offset)
706 uint32_t i, num_regions;
707 unsigned char *region;
709 /* qr_node */
710 proto_tree_add_item(tree, hf_dlm_qr_node, tvb, offset, 1, ENC_BIG_ENDIAN);
711 offset += 1;
713 /* qr_numregions */
714 proto_tree_add_item_ret_uint(tree, hf_dlm_qr_numregions, tvb, offset, 1, ENC_BIG_ENDIAN, &num_regions);
715 offset += 1;
717 /* qr_namelen */
718 proto_tree_add_item(tree, hf_dlm_qr_namelen, tvb, offset, 1, ENC_BIG_ENDIAN);
719 offset += 1;
721 proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_BIG_ENDIAN);
722 offset += 1;
724 /* qr_domain */
725 proto_tree_add_item(tree, hf_dlm_qr_domain, tvb, offset, 64, ENC_ASCII);
726 offset += 64;
728 /* qr_regions */
729 for (i = 0; i < num_regions; i++, offset += O2HB_MAX_REGION_NAME_LEN) {
730 region = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, O2HB_MAX_REGION_NAME_LEN, ENC_ASCII);
731 proto_tree_add_string_format(tree, hf_dlm_qr_region, tvb, offset, 1,
732 region, "Region%d: %s", i + 1, region);
736 static void dissect_dlm_query_nodeinfo(proto_tree *tree, tvbuff_t *tvb, unsigned offset)
738 uint32_t i, num_nodes;
740 /* qn_nodenum */
741 proto_tree_add_item(tree, hf_dlm_qn_nodenum, tvb, offset, 1, ENC_BIG_ENDIAN);
742 offset += 1;
744 /* qn_numnodes */
745 proto_tree_add_item_ret_uint(tree, hf_dlm_qn_numnodes, tvb, offset, 1, ENC_BIG_ENDIAN, &num_nodes);
746 offset += 1;
748 /* qn_namelen */
749 proto_tree_add_item(tree, hf_dlm_qn_namelen, tvb, offset, 1, ENC_BIG_ENDIAN);
750 offset += 1;
752 /* qn_domain */
753 proto_tree_add_item(tree, hf_dlm_qn_domain, tvb, offset, 64, ENC_ASCII);
754 offset += 64;
756 /* qn_nodes */
757 for (i = 0; i < num_nodes; i++) {
758 proto_tree *subtree;
760 /* ni_nodenum */
761 subtree = proto_tree_add_subtree_format(tree, tvb, offset, 8,
762 ett_query_nodeinfo, NULL, "Node%d: ", i+1);
764 proto_tree_add_item(subtree, hf_dlm_qn_node, tvb, offset, 1, ENC_BIG_ENDIAN);
765 offset += 1;
767 proto_tree_add_item(subtree, hf_dlm_pad8, tvb, offset, 1, ENC_BIG_ENDIAN);
768 offset += 1;
770 proto_tree_add_item(subtree, hf_dlm_qn_port, tvb, offset, 2, ENC_BIG_ENDIAN);
771 offset += 2;
773 proto_tree_add_item(subtree, hf_dlm_qn_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
774 offset += 4;
778 static int dissect_master_msg(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_flag)
780 uint32_t namelen;
782 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
783 offset += 1;
785 proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
786 offset += 1;
788 proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
789 offset += 2;
791 if (hf_flag <= 0)
792 proto_tree_add_item(tree, hf_dlm_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
793 else
794 proto_tree_add_item(tree, hf_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
795 offset += 4;
797 return dlm_name_handler(tree, tvb, offset, namelen);
800 static int dissect_create_lock_msg(proto_tree *tree, tvbuff_t *tvb, int offset,
801 uint32_t *dlm_lock_flags_ptr)
803 uint32_t namelen;
805 offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_cookie);
806 offset = dlm_lkm_flags_handler(tree, tvb, offset, dlm_lock_flags_ptr);
808 proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_NA);
809 offset += 1;
811 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
812 offset += 1;
814 proto_tree_add_item(tree, hf_dlm_requested_type, tvb, offset, 1, ENC_BIG_ENDIAN);
815 offset += 1;
817 proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
818 offset += 1;
820 dlm_name_handler(tree, tvb, offset, namelen);
821 return offset + O2NM_MAX_NAME_LEN;
824 static int dissect_convert_lock_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
826 uint32_t dlm_lock_flags;
827 offset = dissect_create_lock_msg(tree, tvb, offset, &dlm_lock_flags);
829 if(dlm_lock_flags & DLM_LOCK_FLAGS_PUT_LVB){
830 proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
831 offset += 24;
833 proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
834 offset += 24;
836 proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
837 offset += 16;
840 return offset;
843 static int dissect_unlock_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
845 uint32_t namelen;
846 uint32_t dlm_lock_flags;
848 offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_cookie);
849 offset = dlm_lkm_flags_handler(tree, tvb, offset, &dlm_lock_flags);
851 proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
852 offset += 2;
854 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
855 offset += 1;
857 proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
858 offset += 1;
860 dlm_name_handler(tree, tvb, offset, namelen);
861 offset += O2NM_MAX_NAME_LEN;
863 if(dlm_lock_flags & DLM_LOCK_FLAGS_PUT_LVB){
864 proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
865 offset += 24;
867 proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
868 offset += 24;
870 proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
871 offset += 16;
874 return offset;
877 static int dissect_proxy_ast_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
879 uint32_t namelen;
880 uint32_t dlm_lock_flags;
882 offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_cookie);
883 offset = dlm_lkm_flags_handler(tree, tvb, offset, &dlm_lock_flags);
885 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
886 offset += 1;
888 proto_tree_add_item(tree, hf_dlm_ast_type, tvb, offset, 1, ENC_BIG_ENDIAN);
889 offset += 1;
891 proto_tree_add_item(tree, hf_dlm_blocked_type, tvb, offset, 1, ENC_BIG_ENDIAN);
892 offset += 1;
894 proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
895 offset += 1;
897 dlm_name_handler(tree, tvb, offset, namelen);
898 offset += O2NM_MAX_NAME_LEN;
900 if(dlm_lock_flags & DLM_LOCK_FLAGS_GET_LVB){
901 proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
902 offset += 24;
904 proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
905 offset += 24;
907 proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
908 offset += 16;
910 return offset;
913 static int dissect_deref_lockres_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
915 uint32_t namelen;
917 proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
918 offset += 4;
920 proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
921 offset += 2;
923 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
924 offset += 1;
926 proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
927 offset += 1;
929 return dlm_name_handler(tree, tvb, offset, namelen);
932 static int dissect_migrate_request_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
934 uint32_t namelen;
936 proto_tree_add_item(tree, hf_dlm_master, tvb, offset, 1, ENC_NA);
937 offset += 1;
939 proto_tree_add_item(tree, hf_dlm_new_master, tvb, offset, 1, ENC_NA);
940 offset += 1;
942 proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
943 offset += 1;
945 proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_NA);
946 offset += 1;
948 proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
949 offset += 4;
951 return dlm_name_handler(tree, tvb, offset, namelen);
954 static int dissect_dlm_joined_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
956 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
957 offset += 1;
959 proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
960 offset += 2;
962 proto_tree_add_item(tree, hf_dlm_domain_name_len, tvb, offset, 1, ENC_BIG_ENDIAN);
963 offset += 1;
965 proto_tree_add_item(tree, hf_dlm_domain_name, tvb, offset, 64, ENC_ASCII);
966 offset += 64;
968 return offset;
971 static int dissect_master_requery_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
973 uint32_t namelen;
975 proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
976 offset += 2;
978 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
979 offset += 1;
981 proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
982 offset += 1;
984 proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
985 offset += 4;
987 return dlm_name_handler(tree, tvb, offset, namelen);
990 static int dissect_lock_request_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
992 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
993 offset += 1;
995 proto_tree_add_item(tree, hf_dlm_dead_node, tvb, offset, 1, ENC_NA);
996 offset += 1;
998 proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
999 offset += 2;
1001 proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
1002 offset += 4;
1004 return offset;
1007 static int dissect_reco_data_done_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
1009 offset = dissect_lock_request_msg(tree, tvb, offset);
1011 proto_tree_add_item(tree, hf_dlm_reco_lvb, tvb, offset, 64, ENC_NA);
1012 offset += 64;
1014 return offset;
1017 static int dissect_finalize_reco_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
1019 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
1020 offset += 1;
1022 proto_tree_add_item(tree, hf_dlm_dead_node, tvb, offset, 1, ENC_NA);
1023 offset += 1;
1025 proto_tree_add_item(tree, hf_dlm_fr_flags, tvb, offset, 1, ENC_NA);
1026 offset += 1;
1028 proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_NA);
1029 offset += 1;
1031 proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
1032 offset += 4;
1034 return offset;
1037 static int dissect_ocfs2_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1039 proto_tree *subtree;
1040 proto_item *ti;
1041 uint32_t len, msg_type;
1042 uint32_t magic;
1043 tvbuff_t *next_tvb;
1044 int offset = 0;
1046 magic = tvb_get_ntohs(tvb, offset);
1047 if (try_val_to_str(magic, o2net_magic) == NULL)
1048 return 0;
1050 col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCFS2");
1051 col_clear(pinfo->cinfo, COL_INFO);
1053 ti = proto_tree_add_item(tree, proto_ocfs2, tvb, offset, -1, ENC_NA);
1054 subtree = proto_item_add_subtree(ti, ett_ocfs2);
1056 proto_tree_add_item(subtree, hf_msg_magic, tvb, offset, 2, ENC_BIG_ENDIAN);
1057 offset += 2;
1059 proto_tree_add_item_ret_uint(subtree, hf_msg_data_len, tvb, 2, 2, ENC_BIG_ENDIAN, &len);
1060 offset += 2;
1062 proto_tree_add_item_ret_uint(subtree, hf_msg_msg_type, tvb, 4, 2, ENC_BIG_ENDIAN, &msg_type);
1063 offset += 2;
1065 switch(magic){
1066 case O2NET_MSG_KEEP_REQ_MAGIC:
1067 col_append_sep_str(pinfo->cinfo, COL_INFO, " | ", "Keepalive Request");
1068 break;
1069 case O2NET_MSG_KEEP_RESP_MAGIC:
1070 col_append_sep_str(pinfo->cinfo, COL_INFO, " | ", "Keepalive Response");
1071 break;
1072 default:
1073 col_append_sep_str(pinfo->cinfo, COL_INFO, " | ",
1074 val_to_str_ext(msg_type, &ext_dlm_magic, "Unknown Type (0x%02x)") );
1075 break;
1078 col_set_fence(pinfo->cinfo, COL_INFO);
1080 proto_tree_add_item(subtree, hf_msg_pad, tvb, 4, 2, ENC_BIG_ENDIAN);
1081 offset += 2;
1083 proto_tree_add_item(subtree, hf_msg_sys_status, tvb, 8, 4, ENC_BIG_ENDIAN);
1084 offset += 4;
1086 proto_tree_add_item(subtree, hf_msg_status, tvb, 12, 4, ENC_BIG_ENDIAN);
1087 offset += 4;
1089 proto_tree_add_item(subtree, hf_msg_key, tvb, 16, 4, ENC_BIG_ENDIAN);
1090 offset += 4;
1092 proto_tree_add_item(subtree, hf_msg_msg_num, tvb, 20, 4, ENC_BIG_ENDIAN);
1093 offset += 4;
1095 if (magic == O2NET_MSG_MAGIC) {
1096 switch (msg_type) {
1097 case DLM_MASTER_REQUEST_MSG:
1098 dissect_master_msg(subtree, tvb, offset, -1);
1099 break;
1100 case DLM_ASSERT_MASTER_MSG:
1101 dissect_master_msg(subtree, tvb, offset, hf_dlm_am_flags);
1102 break;
1103 case DLM_CREATE_LOCK_MSG:
1104 dissect_create_lock_msg(subtree, tvb, offset, NULL);
1105 break;
1106 case DLM_CONVERT_LOCK_MSG:
1107 dissect_convert_lock_msg(subtree, tvb, offset);
1108 break;
1109 case DLM_PROXY_AST_MSG:
1110 dissect_proxy_ast_msg(subtree, tvb, offset);
1111 break;
1112 case DLM_UNLOCK_LOCK_MSG:
1113 dissect_unlock_msg(subtree, tvb, offset);
1114 break;
1115 case DLM_DEREF_LOCKRES_MSG:
1116 dissect_deref_lockres_msg(subtree, tvb, offset);
1117 break;
1118 case DLM_MIGRATE_REQUEST_MSG:
1119 dissect_migrate_request_msg(subtree, tvb, offset);
1120 break;
1121 case DLM_MIG_LOCKRES_MSG:
1122 dissect_dlm_migrate_lockres(subtree, tvb, offset);
1123 break;
1124 case DLM_QUERY_JOIN_MSG:
1125 dissect_dlm_query_join_request(subtree, tvb, offset);
1126 break;
1127 case DLM_ASSERT_JOINED_MSG:
1128 case DLM_CANCEL_JOIN_MSG:
1129 dissect_dlm_joined_msg(subtree, tvb, offset);
1130 break;
1131 case DLM_EXIT_DOMAIN_MSG:
1132 proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
1133 break;
1134 case DLM_MASTER_REQUERY_MSG:
1135 dissect_master_requery_msg(subtree, tvb, offset);
1136 break;
1137 case DLM_LOCK_REQUEST_MSG:
1138 case DLM_BEGIN_RECO_MSG:
1139 dissect_lock_request_msg(subtree, tvb, offset);
1140 break;
1141 case DLM_RECO_DATA_DONE_MSG:
1142 dissect_reco_data_done_msg(subtree, tvb, offset);
1143 break;
1144 case DLM_FINALIZE_RECO_MSG:
1145 dissect_finalize_reco_msg(subtree, tvb, offset);
1146 break;
1147 case DLM_QUERY_REGION_MSG:
1148 dissect_dlm_query_region(subtree, tvb, offset);
1149 break;
1150 case DLM_QUERY_NODEINFO_MSG:
1151 dissect_dlm_query_nodeinfo(subtree, tvb, offset);
1152 break;
1153 default:
1154 proto_tree_add_item(tree, hf_dlm_payload, tvb, offset, len, ENC_NA);
1155 break;
1157 } else {
1158 next_tvb = tvb_new_subset_length(tvb, offset, len);
1159 call_data_dissector(next_tvb, pinfo, tree);
1162 return tvb_reported_length(tvb);
1165 static unsigned
1166 get_ocfs2_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
1168 uint16_t plen;
1170 /* Get the length of the data from header. */
1171 plen = tvb_get_ntohs(tvb, offset + 2);
1173 /* That length doesn't include the header itself, add that in. */
1174 return plen + 24;
1177 static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
1179 uint32_t magic;
1180 int offset = 0;
1182 if (!tvb_bytes_exist(tvb, offset, 2))
1183 return 0;
1185 magic = tvb_get_ntohs(tvb, offset);
1186 if (try_val_to_str(magic, o2net_magic) == NULL)
1187 return 0;
1189 tcp_dissect_pdus(tvb, pinfo, tree, true, 4, get_ocfs2_pdu_len, dissect_ocfs2_pdu, data);
1190 return tvb_captured_length(tvb);
1193 void proto_register_ocfs2(void)
1195 static hf_register_info hf[] = {
1196 /* ocfs2_msg */
1197 { &hf_msg_magic,
1198 { "Magic", "ocfs2.msg.magic", FT_UINT16, BASE_HEX,
1199 VALS(o2net_magic), 0x0,
1200 "Magic number identifier of O2NET-over-TCPmessage",
1201 HFILL
1204 { &hf_msg_data_len,
1205 { "Len", "ocfs2.msg.data_len", FT_UINT16, BASE_DEC,
1206 NULL, 0x0, "Data length", HFILL
1209 { &hf_msg_msg_type,
1210 { "Type", "ocfs2.msg.msg_type", FT_UINT16, BASE_DEC|BASE_EXT_STRING,
1211 &ext_dlm_magic, 0x0, "Message type", HFILL
1214 { &hf_msg_pad,
1215 { "Pad", "ocfs2.msg.pad", FT_UINT16, BASE_HEX,
1216 NULL, 0x0, NULL, HFILL
1219 { &hf_msg_sys_status,
1220 { "Sys Status", "ocfs2.msg.sys_status", FT_UINT32,
1221 BASE_DEC, NULL, 0x0,
1222 "System level status return code", HFILL
1225 { &hf_msg_status,
1226 { "Status", "ocfs2.msg.status", FT_UINT32, BASE_DEC,
1227 NULL, 0x0, "Return code", HFILL
1230 { &hf_msg_key,
1231 { "Key", "ocfs2.msg.key", FT_UINT32, BASE_HEX, NULL,
1232 0x0, NULL, HFILL
1235 { &hf_msg_msg_num,
1236 { "Num", "ocfs2.msg.msg_num", FT_UINT32, BASE_DEC, NULL,
1237 0x0, "Message identification number", HFILL
1240 { &hf_dlm_node_idx,
1241 { "Node", "ocfs2.dlm.node_idx", FT_UINT8, BASE_DEC,
1242 NULL, 0x0, "Node index", HFILL
1245 { &hf_dlm_lock_flags,
1246 { "Flags", "ocfs2.dlm.lock.flags", FT_UINT32, BASE_HEX,
1247 NULL, 0x0, NULL, HFILL
1250 { &hf_dlm_lock_flag_unused1,
1251 { "unused", "ocfs2.dlm.lock.flags.unused", FT_UINT32, BASE_HEX,
1252 NULL, 0x0000000F, NULL, HFILL
1255 { &hf_dlm_lock_flag_orphan,
1256 { "orphan", "ocfs2.dlm.lock.flags.orphan", FT_BOOLEAN, 32,
1257 NULL, 0x00000010, NULL, HFILL
1260 { &hf_dlm_lock_flag_parentable,
1261 { "parentable", "ocfs2.dlm.lock.flags.parentable", FT_BOOLEAN, 32,
1262 NULL, 0x00000020, NULL, HFILL
1265 { &hf_dlm_lock_flag_block,
1266 { "block", "ocfs2.dlm.lock.flags.block", FT_BOOLEAN, 32,
1267 NULL, 0x00000040, NULL, HFILL
1270 { &hf_dlm_lock_flag_local,
1271 { "local", "ocfs2.dlm.lock.flags.local", FT_BOOLEAN, 32,
1272 NULL, 0x00000080, NULL, HFILL
1275 { &hf_dlm_lock_flag_valblk,
1276 { "valblk", "ocfs2.dlm.lock.flags.valblk", FT_BOOLEAN, 32,
1277 NULL, 0x00000100, NULL, HFILL
1280 { &hf_dlm_lock_flag_noqueue,
1281 { "noqueue", "ocfs2.dlm.lock.flags.noqueue", FT_BOOLEAN, 32,
1282 NULL, 0x00000200, NULL, HFILL
1285 { &hf_dlm_lock_flag_convert,
1286 { "convert", "ocfs2.dlm.lock.flags.convert", FT_BOOLEAN, 32,
1287 NULL, 0x00000400, NULL, HFILL
1290 { &hf_dlm_lock_flag_nodlckwt,
1291 { "nodlckwt", "ocfs2.dlm.lock.flags.nodlckwt", FT_BOOLEAN, 32,
1292 NULL, 0x00000800, NULL, HFILL
1295 { &hf_dlm_lock_flag_unlock,
1296 { "unlock", "ocfs2.dlm.lock.flags.unlock", FT_BOOLEAN, 32,
1297 NULL, 0x00001000, NULL, HFILL
1300 { &hf_dlm_lock_flag_cancel,
1301 { "cancel", "ocfs2.dlm.lock.flags.cancel", FT_BOOLEAN, 32,
1302 NULL, 0x00002000, NULL, HFILL
1305 { &hf_dlm_lock_flag_deqall,
1306 { "deqall", "ocfs2.dlm.lock.flags.deqall", FT_BOOLEAN, 32,
1307 NULL, 0x00004000, NULL, HFILL
1310 { &hf_dlm_lock_flag_invvalblk,
1311 { "invvalblk", "ocfs2.dlm.lock.flags.invvalblk", FT_BOOLEAN, 32,
1312 NULL, 0x00008000, NULL, HFILL
1315 { &hf_dlm_lock_flag_syncsts,
1316 { "syncsts", "ocfs2.dlm.lock.flags.syncsts", FT_BOOLEAN, 32,
1317 NULL, 0x00010000, NULL, HFILL
1320 { &hf_dlm_lock_flag_timeout,
1321 { "timeout", "ocfs2.dlm.lock.flags.timeout", FT_BOOLEAN, 32,
1322 NULL, 0x00020000, NULL, HFILL
1325 { &hf_dlm_lock_flag_sngldlck,
1326 { "sngldlck", "ocfs2.dlm.lock.flags.sngldlck", FT_BOOLEAN, 32,
1327 NULL, 0x00040000, NULL, HFILL
1330 { &hf_dlm_lock_flag_findlocal,
1331 { "findlocal", "ocfs2.dlm.lock.flags.findlocal", FT_BOOLEAN, 32,
1332 NULL, 0x00080000, NULL, HFILL
1335 { &hf_dlm_lock_flag_proc_owned,
1336 { "proc_owned", "ocfs2.dlm.lock.flags.proc_owned", FT_BOOLEAN, 32,
1337 NULL, 0x00100000, NULL, HFILL
1340 { &hf_dlm_lock_flag_xid,
1341 { "xid", "ocfs2.dlm.lock.flags.xid", FT_BOOLEAN, 32,
1342 NULL, 0x00200000, NULL, HFILL
1345 { &hf_dlm_lock_flag_xid_conflict,
1346 { "xid_conflict", "ocfs2.dlm.lock.flags.xid_conflict", FT_BOOLEAN, 32,
1347 NULL, 0x00400000, NULL, HFILL
1350 { &hf_dlm_lock_flag_force,
1351 { "force", "ocfs2.dlm.lock.flags.force", FT_BOOLEAN, 32,
1352 NULL, 0x00800000, NULL, HFILL
1355 { &hf_dlm_lock_flag_revvalblk,
1356 { "revvalblk", "ocfs2.dlm.lock.flags.revvalblk", FT_BOOLEAN, 32,
1357 NULL, 0x01000000, NULL, HFILL
1360 { &hf_dlm_lock_flag_unused2,
1361 { "unused", "ocfs2.dlm.lock.flags.unused", FT_UINT32, BASE_HEX,
1362 NULL, 0x0E000000, NULL, HFILL
1365 { &hf_dlm_lock_flag_migration,
1366 { "migration", "ocfs2.dlm.lock.flags.migration", FT_BOOLEAN, 32,
1367 NULL, 0x10000000, NULL, HFILL
1370 { &hf_dlm_lock_flag_put_lvb,
1371 { "put_lvb", "ocfs2.dlm.lock.flags.put_lvb", FT_BOOLEAN, 32,
1372 NULL, 0x20000000, NULL, HFILL
1375 { &hf_dlm_lock_flag_get_lvb,
1376 { "get_lvb", "ocfs2.dlm.lock.flags.get_lvb", FT_BOOLEAN, 32,
1377 NULL, 0x40000000, NULL, HFILL
1380 { &hf_dlm_lock_flag_recovery,
1381 { "recovery", "ocfs2.dlm.lock.flags.recovery", FT_BOOLEAN, 32,
1382 NULL, 0x80000000, NULL, HFILL
1385 { &hf_dlm_am_flags,
1386 { "Flags", "ocfs2.dlm.am_flags", FT_UINT32, BASE_HEX,
1387 VALS(dlm_assert_master_flags), 0x0,
1388 "Assert Master Flags", HFILL
1391 { &hf_dlm_fr_flags,
1392 { "Flags", "ocfs2.dlm.fr_flags", FT_UINT32, BASE_HEX,
1393 VALS(dlm_finalize_reco_flags), 0x0,
1394 "Finalize Recovery Flags", HFILL
1397 { &hf_dlm_namelen,
1398 { "Namelen", "ocfs2.dlm.namelen", FT_UINT8, BASE_DEC,
1399 NULL, 0x0, NULL, HFILL
1402 { &hf_dlm_name,
1403 { "Name", "ocfs2.dlm.name", FT_STRING, BASE_NONE, NULL,
1404 0x0, NULL, HFILL
1407 { &hf_dlm_cookie,
1408 { "Cookie", "ocfs2.dlm.cookie", FT_UINT64, BASE_HEX,
1409 NULL, 0x0,
1410 "Unique ID for a single lock on a resource", HFILL
1413 { &hf_dlm_requested_type,
1414 { "Requested", "ocfs2.dlm.requested_type", FT_UINT8,
1415 BASE_DEC, VALS(dlm_lock_modes), 0x0,
1416 "Requested lock level", HFILL
1419 { &hf_dlm_blocked_type,
1420 { "Blocked", "ocfs2.dlm.blocked_type", FT_UINT8,
1421 BASE_DEC, VALS(dlm_lock_modes), 0x0,
1422 "Blocked lock type", HFILL
1425 { &hf_dlm_ast_type,
1426 { "AST Type", "ocfs2.dlm.ast_type", FT_UINT8, BASE_DEC,
1427 VALS(dlm_proxy_ast_types), 0x0, NULL, HFILL
1430 { &hf_dlm_dead_node,
1431 { "Dead Node", "ocfs2.dlm.dead_node", FT_UINT8,
1432 BASE_DEC, NULL, 0x0, "Dead node index", HFILL
1435 { &hf_dlm_lvb1,
1436 { "LVB1", "ocfs2.dlm.lvb", FT_BYTES, BASE_NONE, NULL,
1437 0x0, "Lock value block", HFILL
1440 { &hf_dlm_lvb2,
1441 { "LVB2", "ocfs2.dlm.lvb", FT_BYTES, BASE_NONE, NULL,
1442 0x0, "Lock value block", HFILL
1445 { &hf_dlm_lvb3,
1446 { "LVB3", "ocfs2.dlm.lvb", FT_BYTES, BASE_NONE, NULL,
1447 0x0, "Lock value block", HFILL
1450 { &hf_dlm_domain_name_len,
1451 { "Domain Namelen", "ocfs2.dlm.domain_namelen",
1452 FT_UINT8, BASE_DEC, NULL, 0x0, NULL,
1453 HFILL
1456 { &hf_dlm_proto_ver,
1457 { "DLM Protocol", "ocfs2.dlm.proto_ver",
1458 FT_UINT16, BASE_CUSTOM, CF_FUNC(dlm_fmt_revision), 0x0, NULL,
1459 HFILL
1462 { &hf_dlm_fs_proto_ver,
1463 { "FS Protocol", "ocfs2.dlm.fs_proto_ver",
1464 FT_UINT16, BASE_CUSTOM, CF_FUNC(dlm_fmt_revision), 0x0, NULL,
1465 HFILL
1468 { &hf_dlm_node_map,
1469 { "Node Map", "ocfs2.dlm.node_map", FT_BYTES,
1470 BASE_NONE, NULL, 0x0, NULL, HFILL
1473 { &hf_dlm_domain_name,
1474 { "Domain Name", "ocfs2.dlm.domain_name", FT_STRING,
1475 BASE_NONE, NULL, 0x0, NULL, HFILL
1478 { &hf_dlm_master,
1479 { "Master", "ocfs2.dlm.master", FT_UINT8, BASE_DEC,
1480 NULL, 0x0, NULL, HFILL
1483 { &hf_dlm_new_master,
1484 { "New Master", "ocfs2.dlm.new_master", FT_UINT8,
1485 BASE_DEC, NULL, 0x0, NULL, HFILL
1488 { &hf_dlm_mres_num_locks,
1489 { "Num Locks", "ocfs2.dlm.num_locks", FT_UINT8,
1490 BASE_DEC, NULL, 0x0, "Migres Num Locks", HFILL
1493 { &hf_dlm_mres_flags,
1494 { "Flags", "ocfs2.dlm.mres_flags", FT_UINT8, BASE_HEX,
1495 NULL, 0x06, "Migres Flags", HFILL
1498 { &hf_dlm_mres_flag_recovery,
1499 { "recovery", "ocfs2.dlm.mres_flags.recovery", FT_BOOLEAN, 8,
1500 NULL, 0x02, NULL, HFILL
1503 { &hf_dlm_mres_flag_migration,
1504 { "migration", "ocfs2.dlm.mres_flags.migration", FT_BOOLEAN, 8,
1505 NULL, 0x04, NULL, HFILL
1508 /* TODO: what should this flag be? Should also be added to hf_dlm_mres_flags above */
1509 { &hf_dlm_mres_flag_all_done,
1510 { "all_done", "ocfs2.dlm.mres_flags.all_done", FT_BOOLEAN, 8,
1511 NULL, 0xf8, NULL, HFILL
1514 { &hf_dlm_mres_total_locks,
1515 { "Total Locks", "ocfs2.dlm.total_locks", FT_UINT32,
1516 BASE_DEC, NULL, 0x0, "Migres Total Locks", HFILL
1519 { &hf_dlm_mres_mig_cookie,
1520 { "Cookie", "ocfs2.dlm.migratable_lock.mig_cookie",
1521 FT_UINT64, BASE_DEC, NULL, 0x0, "Migres Cookie", HFILL
1524 { &hf_dlm_mres_list,
1525 { "List", "ocfs2.dlm.migratable_lock.list", FT_UINT8,
1526 BASE_DEC, VALS(dlm_lockres_list), 0x0, NULL, HFILL
1529 { &hf_dlm_mres_ml_flags,
1530 { "List", "ocfs2.dlm.migratable_lock.flags", FT_UINT8,
1531 BASE_HEX, NULL, 0x0, NULL, HFILL
1534 { &hf_dlm_mres_type,
1535 { "Type", "ocfs2.dlm.migratable_lock.type", FT_UINT8,
1536 BASE_DEC, VALS(dlm_lock_modes), 0x0, NULL, HFILL
1539 { &hf_dlm_mres_convert_type,
1540 { "Convert type", "ocfs2.dlm.migratable_lock.convert_type", FT_UINT8,
1541 BASE_DEC, NULL, 0x0, NULL, HFILL
1544 { &hf_dlm_mres_highest_blocked,
1545 { "Highest blocked", "ocfs2.dlm.migratable_lock.highest_blocked", FT_UINT8,
1546 BASE_DEC, NULL, 0x0, NULL, HFILL
1549 { &hf_dlm_mres_node,
1550 { "Node", "ocfs2.dlm.migratable_lock.node", FT_UINT8,
1551 BASE_DEC, NULL, 0x0, NULL, HFILL
1554 { &hf_dlm_qr_node,
1555 { "Node", "ocfs2.dlm.query_region.qr_node", FT_UINT8,
1556 BASE_DEC, NULL, 0x0, "Query Region Node", HFILL
1559 { &hf_dlm_qr_numregions,
1560 { "Num Regions", "ocfs2.dlm.query_region.qr_numregions",
1561 FT_UINT8, BASE_DEC, NULL, 0x0,
1562 "The number of regions to compare with", HFILL
1565 { &hf_dlm_qr_namelen,
1566 { "Domain Namelen", "ocfs2.dlm.query_region.qr_namelen",
1567 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
1570 { &hf_dlm_qr_domain,
1571 { "Domain Name", "ocfs2.dlm.query_region.qr_domain",
1572 FT_STRING, BASE_NONE, NULL, 0x0, NULL,
1573 HFILL
1576 { &hf_dlm_qr_region,
1577 { "Region", "ocfs2.dlm.query_region.region",
1578 FT_STRING, BASE_NONE, NULL, 0x0, NULL,
1579 HFILL
1582 { &hf_dlm_qn_nodenum,
1583 { "Node", "ocfs2.dlm_query_nodeinfo.qn_nodenum",
1584 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
1587 { &hf_dlm_qn_numnodes,
1588 { "Num Nodes", "ocfs2.dlm_query_nodeinfo.qn_numnodes",
1589 FT_UINT8, BASE_DEC, NULL, 0x0,
1590 "The number of nodes to query", HFILL
1593 { &hf_dlm_qn_namelen,
1594 { "Domain Namelen",
1595 "ocfs2.dlm_query_nodeinfo.qn_namelen", FT_UINT8,
1596 BASE_DEC, NULL, 0x0, NULL, HFILL
1599 { &hf_dlm_qn_domain,
1600 { "Domain Name", "ocfs2.dlm_query_nodeinfo.qn_domain",
1601 FT_STRING, BASE_NONE, NULL, 0x0, NULL,
1602 HFILL
1605 { &hf_dlm_qn_node,
1606 { "Node", "ocfs2.dlm_query_nodeinfo.node",
1607 FT_UINT8, BASE_DEC, NULL, 0x0, NULL,
1608 HFILL
1611 { &hf_dlm_qn_port,
1612 { "Port", "ocfs2.dlm_query_nodeinfo.port",
1613 FT_UINT16, BASE_DEC, NULL, 0x0, NULL,
1614 HFILL
1617 { &hf_dlm_qn_ip,
1618 { "IP Address", "ocfs2.dlm_query_nodeinfo.ip",
1619 FT_IPv4, BASE_NONE, NULL, 0x0, NULL,
1620 HFILL
1623 { &hf_dlm_reco_lvb,
1624 { "Recovery LVB", "ocfs2.reco_lvb",
1625 FT_BYTES, BASE_NONE, NULL, 0x0, NULL,
1626 HFILL
1629 { &hf_dlm_pad8,
1630 { "Pad", "ocfs2.dlm.pad",
1631 FT_UINT8, BASE_DEC, NULL, 0x0, NULL,
1632 HFILL
1635 { &hf_dlm_pad16,
1636 { "Pad", "ocfs2.dlm.pad",
1637 FT_UINT16, BASE_HEX, NULL, 0x0, NULL,
1638 HFILL
1641 { &hf_dlm_pad32,
1642 { "Pad", "ocfs2.dlm.pad",
1643 FT_UINT32, BASE_HEX, NULL, 0x0, NULL,
1644 HFILL
1647 { &hf_dlm_flags,
1648 { "Flags", "ocfs2.dlm.flags",
1649 FT_UINT32, BASE_HEX, NULL, 0x0, NULL,
1650 HFILL
1653 { &hf_dlm_payload,
1654 { "Payload", "ocfs2.dlm.payload",
1655 FT_BYTES, BASE_NONE, NULL, 0x0, NULL,
1656 HFILL
1661 static int *ett[] = {
1662 &ett_ocfs2,
1663 &ett_dtm_lock_flags,
1664 &ett_mres_flags,
1665 &ett_migrate_lockres_locks,
1666 &ett_query_nodeinfo,
1669 proto_ocfs2 = proto_register_protocol("OCFS2 Networking", "OCFS2", "ocfs2");
1670 proto_register_field_array(proto_ocfs2, hf, array_length(hf));
1671 proto_register_subtree_array(ett, array_length(ett));
1673 ocfs2_handle = register_dissector("ocfs2", dissect_ocfs2, proto_ocfs2);
1676 void proto_reg_handoff_ocfs2(void)
1678 dissector_add_for_decode_as_with_preference("tcp.port", ocfs2_handle);
1683 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1685 * Local variables:
1686 * c-basic-offset: 8
1687 * tab-width: 8
1688 * indent-tabs-mode: t
1689 * End:
1691 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1692 * :indentSize=8:tabSize=8:noTabs=false: