HTTPS (almost) everywhere.
[metze/wireshark/wip.git] / epan / dissectors / packet-ocfs2.c
1 /*
2  * packet-ocfs2.c
3  *
4  * Routines for OCFS2's networking protocol disassembly (o2net and o2dlm)
5  * The OCFS2 cluster file system is available in the mainline Linux kernel.
6  *
7  * Copyright (C) 2006, 2011 Oracle. All rights reserved.
8  *
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>
14  *
15  * SPDX-License-Identifier: GPL-2.0-or-later
16  */
17
18 #include "config.h"
19
20
21 #include <epan/packet.h>
22 #include "packet-tcp.h"
23
24 void proto_register_ocfs2(void);
25 void proto_reg_handoff_ocfs2(void);
26
27 static gint ett_ocfs2 = -1;
28 static gint ett_dtm_lock_flags = -1;
29 static gint ett_mres_flags = -1;
30 static gint ett_migrate_lockres_locks = -1;
31 static gint ett_query_nodeinfo = -1;
32
33 static int proto_ocfs2 = -1;
34 static int hf_msg_magic = -1;
35 static int hf_msg_data_len = -1;
36 static int hf_msg_msg_type = -1;
37 static int hf_msg_sys_status = -1;
38 static int hf_msg_status = -1;
39 static int hf_msg_key = -1;
40 static int hf_msg_msg_num = -1;
41 static int hf_msg_pad = -1;
42
43 static int hf_dlm_node_idx = -1;
44 static int hf_dlm_lock_flags = -1;
45 static int hf_dlm_lock_flag_unused1 = -1;
46 static int hf_dlm_lock_flag_orphan = -1;
47 static int hf_dlm_lock_flag_parentable = -1;
48 static int hf_dlm_lock_flag_block = -1;
49 static int hf_dlm_lock_flag_local = -1;
50 static int hf_dlm_lock_flag_valblk = -1;
51 static int hf_dlm_lock_flag_noqueue = -1;
52 static int hf_dlm_lock_flag_convert = -1;
53 static int hf_dlm_lock_flag_nodlckwt = -1;
54 static int hf_dlm_lock_flag_unlock = -1;
55 static int hf_dlm_lock_flag_cancel = -1;
56 static int hf_dlm_lock_flag_deqall = -1;
57 static int hf_dlm_lock_flag_invvalblk = -1;
58 static int hf_dlm_lock_flag_syncsts = -1;
59 static int hf_dlm_lock_flag_timeout = -1;
60 static int hf_dlm_lock_flag_sngldlck = -1;
61 static int hf_dlm_lock_flag_findlocal = -1;
62 static int hf_dlm_lock_flag_proc_owned = -1;
63 static int hf_dlm_lock_flag_xid = -1;
64 static int hf_dlm_lock_flag_xid_conflict = -1;
65 static int hf_dlm_lock_flag_force = -1;
66 static int hf_dlm_lock_flag_revvalblk = -1;
67 static int hf_dlm_lock_flag_unused2 = -1;
68 static int hf_dlm_lock_flag_migration = -1;
69 static int hf_dlm_lock_flag_put_lvb = -1;
70 static int hf_dlm_lock_flag_get_lvb = -1;
71 static int hf_dlm_lock_flag_recovery = -1;
72 static int hf_dlm_am_flags = -1;
73 static int hf_dlm_fr_flags = -1;
74 static int hf_dlm_namelen = -1;
75 static int hf_dlm_name = -1;
76 static int hf_dlm_cookie = -1;
77 static int hf_dlm_requested_type = -1;
78 static int hf_dlm_lvb1 = -1;
79 static int hf_dlm_lvb2 = -1;
80 static int hf_dlm_lvb3 = -1;
81 static int hf_dlm_ast_type = -1;
82 static int hf_dlm_blocked_type = -1;
83 static int hf_dlm_dead_node = -1;
84 static int hf_dlm_domain_name_len = -1;
85 static int hf_dlm_domain_name = -1;
86 static int hf_dlm_proto_ver = -1;
87 static int hf_dlm_fs_proto_ver = -1;
88 static int hf_dlm_node_map = -1;
89 static int hf_dlm_master = -1;
90 static int hf_dlm_new_master = -1;
91 static int hf_dlm_mres_num_locks = -1;
92 static int hf_dlm_mres_flags = -1;
93 static int hf_dlm_mres_flag_recovery = -1;
94 static int hf_dlm_mres_flag_migration = -1;
95 static int hf_dlm_mres_flag_all_done = -1;
96 static int hf_dlm_mres_total_locks = -1;
97 static int hf_dlm_mres_mig_cookie = -1;
98 static int hf_dlm_mres_list = -1;
99 static int hf_dlm_mres_ml_flags = -1;
100 static int hf_dlm_mres_type = -1;
101 static int hf_dlm_mres_convert_type = -1;
102 static int hf_dlm_mres_highest_blocked = -1;
103 static int hf_dlm_mres_node = -1;
104 static int hf_dlm_qr_node = -1;
105 static int hf_dlm_qr_numregions = -1;
106 static int hf_dlm_qr_namelen = -1;
107 static int hf_dlm_qr_domain = -1;
108 static int hf_dlm_qr_region = -1;
109 static int hf_dlm_qn_nodenum = -1;
110 static int hf_dlm_qn_numnodes = -1;
111 static int hf_dlm_qn_namelen = -1;
112 static int hf_dlm_qn_domain = -1;
113 static int hf_dlm_qn_node = -1;
114 static int hf_dlm_qn_port = -1;
115 static int hf_dlm_qn_ip = -1;
116 static int hf_dlm_reco_lvb = -1;
117 static int hf_dlm_pad8 = -1;
118 static int hf_dlm_pad16 = -1;
119 static int hf_dlm_pad32 = -1;
120 static int hf_dlm_flags = -1;
121 static int hf_dlm_payload = -1;
122
123 #define O2NM_MAX_NAME_LEN       64
124 #define O2NM_NODE_MAP_IN_BYTES  32
125
126 #define OCFS2_DENTRY_LOCK_INO_START 18
127
128 /*
129  * generic o2net constants
130  */
131
132 #define O2NET_MSG_MAGIC                 0xfa55
133 #define O2NET_MSG_STATUS_MAGIC          0xfa56
134 #define O2NET_MSG_KEEP_REQ_MAGIC        0xfa57
135 #define O2NET_MSG_KEEP_RESP_MAGIC       0xfa58
136 static const value_string o2net_magic[] = {
137         { O2NET_MSG_MAGIC,           "Request" },
138         { O2NET_MSG_STATUS_MAGIC,    "Response" },
139         { O2NET_MSG_KEEP_REQ_MAGIC,  "Keepalive Request" },
140         { O2NET_MSG_KEEP_RESP_MAGIC, "Keepalive Response" },
141         { 0x0000,  NULL  }
142 };
143
144 /* DLM constants */
145 #define DLM_LVB_LEN  64
146 #define DLM_MOD_KEY (0x666c6172)
147
148 #if 0
149 enum dlm_query_join_response {
150         JOIN_DISALLOW = 0,
151         JOIN_OK,
152         JOIN_OK_NO_MAP,
153         JOIN_PROTOCOL_MISMATCH
154 };
155 #endif
156
157 /* DLM lock modes */
158 enum {
159         LKM_IVMODE = -1,
160         LKM_NLMODE = 0,
161         LKM_CRMODE,
162         LKM_CWMODE,
163         LKM_PRMODE,
164         LKM_PWMODE,
165         LKM_EXMODE,
166         LKM_MAXMODE
167 };
168
169 static const value_string dlm_lock_modes[] = {
170         { LKM_IVMODE, "IV" },
171         { LKM_NLMODE, "NL" },
172         { LKM_CRMODE, "CR" },
173         { LKM_CWMODE, "CW" },
174         { LKM_PRMODE, "PR" },
175         { LKM_PWMODE, "PW" },
176         { LKM_EXMODE, "EX" },
177         { 0x0000,  NULL  }
178 };
179
180 /* DLM message types */
181 enum {
182         DLM_MASTER_REQUEST_MSG          = 500,
183         DLM_UNUSED_MSG1                 = 501,
184         DLM_ASSERT_MASTER_MSG           = 502,
185         DLM_CREATE_LOCK_MSG             = 503,
186         DLM_CONVERT_LOCK_MSG            = 504,
187         DLM_PROXY_AST_MSG               = 505,
188         DLM_UNLOCK_LOCK_MSG             = 506,
189         DLM_DEREF_LOCKRES_MSG           = 507,
190         DLM_MIGRATE_REQUEST_MSG         = 508,
191         DLM_MIG_LOCKRES_MSG             = 509,
192         DLM_QUERY_JOIN_MSG              = 510,
193         DLM_ASSERT_JOINED_MSG           = 511,
194         DLM_CANCEL_JOIN_MSG             = 512,
195         DLM_EXIT_DOMAIN_MSG             = 513,
196         DLM_MASTER_REQUERY_MSG          = 514,
197         DLM_LOCK_REQUEST_MSG            = 515,
198         DLM_RECO_DATA_DONE_MSG          = 516,
199         DLM_BEGIN_RECO_MSG              = 517,
200         DLM_FINALIZE_RECO_MSG           = 518,
201         DLM_QUERY_REGION_MSG            = 519,
202         DLM_QUERY_NODEINFO_MSG          = 520
203 };
204
205 static const value_string dlm_magic[] = {
206         { DLM_MASTER_REQUEST_MSG,  "Master Request" },
207         { DLM_UNUSED_MSG1,         "Unused 1" },
208         { DLM_ASSERT_MASTER_MSG,   "Assert Master" },
209         { DLM_CREATE_LOCK_MSG,     "Create Lock" },
210         { DLM_CONVERT_LOCK_MSG,    "Convert Lock" },
211         { DLM_PROXY_AST_MSG,       "Proxy AST" },
212         { DLM_UNLOCK_LOCK_MSG,     "Unlock Lock" },
213         { DLM_DEREF_LOCKRES_MSG,   "Deref Lockres" },
214         { DLM_MIGRATE_REQUEST_MSG, "Migrate Request" },
215         { DLM_MIG_LOCKRES_MSG,     "Migrate Lockres" },
216         { DLM_QUERY_JOIN_MSG,      "Query Join" },
217         { DLM_ASSERT_JOINED_MSG,   "Assert Join" },
218         { DLM_CANCEL_JOIN_MSG,     "Cancel Join" },
219         { DLM_EXIT_DOMAIN_MSG,     "Exit Domain" },
220         { DLM_MASTER_REQUERY_MSG,  "Master Requery" },
221         { DLM_LOCK_REQUEST_MSG,    "Lock Request" },
222         { DLM_RECO_DATA_DONE_MSG,  "Recovery Data Done" },
223         { DLM_BEGIN_RECO_MSG,      "Begin Recovery" },
224         { DLM_FINALIZE_RECO_MSG,   "Finalize Recovery" },
225         { DLM_QUERY_REGION_MSG,    "Query Region" },
226         { DLM_QUERY_NODEINFO_MSG,  "Query Node Info" },
227         { 0x0000, NULL }
228 };
229
230 value_string_ext ext_dlm_magic = VALUE_STRING_EXT_INIT(dlm_magic);
231
232
233 enum {
234         DLM_GRANTED_LIST = 0,
235         DLM_CONVERTING_LIST,
236         DLM_BLOCKED_LIST,
237         DLM_MAX_LIST
238 };
239
240 static const value_string dlm_lockres_list[] = {
241         { DLM_GRANTED_LIST,    "Granted" },
242         { DLM_CONVERTING_LIST, "Converting" },
243         { DLM_BLOCKED_LIST,    "Blocked" },
244         { 0x0000, NULL }
245 };
246
247
248 #if 0
249 enum dlm_status {
250         DLM_NORMAL = 0,
251         DLM_GRANTED,
252         DLM_DENIED,
253         DLM_DENIED_NOLOCKS,
254         DLM_WORKING,
255         DLM_BLOCKED,
256         DLM_BLOCKED_ORPHAN,
257         DLM_DENIED_GRACE_PERIOD,
258         DLM_SYSERR,
259         DLM_NOSUPPORT,
260         DLM_CANCELGRANT,
261         DLM_IVLOCKID,
262         DLM_SYNC,
263         DLM_BADTYPE,
264         DLM_BADRESOURCE,
265         DLM_MAXHANDLES,
266         DLM_NOCLINFO,
267         DLM_NOLOCKMGR,
268         DLM_NOPURGED,
269         DLM_BADARGS,
270         DLM_VOID,
271         DLM_NOTQUEUED,
272         DLM_IVBUFLEN,
273         DLM_CVTUNGRANT,
274         DLM_BADPARAM,
275         DLM_VALNOTVALID,
276         DLM_REJECTED,
277         DLM_ABORT,
278         DLM_CANCEL,
279         DLM_IVRESHANDLE,
280         DLM_DEADLOCK,
281         DLM_DENIED_NOASTS,
282         DLM_FORWARD,
283         DLM_TIMEOUT,
284         DLM_IVGROUPID,
285         DLM_VERS_CONFLICT,
286         DLM_BAD_DEVICE_PATH,
287         DLM_NO_DEVICE_PERMISSION,
288         DLM_NO_CONTROL_DEVICE,
289         DLM_RECOVERING,
290         DLM_MIGRATING,
291         DLM_MAXSTATS
292 };
293
294 static const value_string dlm_errnames[] = {
295         { DLM_NORMAL,               "DLM_NORMAL" },
296         { DLM_GRANTED,              "DLM_GRANTED" },
297         { DLM_DENIED,               "DLM_DENIED" },
298         { DLM_DENIED_NOLOCKS,       "DLM_DENIED_NOLOCKS" },
299         { DLM_WORKING,              "DLM_WORKING" },
300         { DLM_BLOCKED,              "DLM_BLOCKED" },
301         { DLM_BLOCKED_ORPHAN,       "DLM_BLOCKED_ORPHAN" },
302         { DLM_DENIED_GRACE_PERIOD,  "DLM_DENIED_GRACE_PERIOD" },
303         { DLM_SYSERR,               "DLM_SYSERR" },
304         { DLM_NOSUPPORT,            "DLM_NOSUPPORT" },
305         { DLM_CANCELGRANT,          "DLM_CANCELGRANT" },
306         { DLM_IVLOCKID,             "DLM_IVLOCKID" },
307         { DLM_SYNC,                 "DLM_SYNC" },
308         { DLM_BADTYPE,              "DLM_BADTYPE" },
309         { DLM_BADRESOURCE,          "DLM_BADRESOURCE" },
310         { DLM_MAXHANDLES,           "DLM_MAXHANDLES" },
311         { DLM_NOCLINFO,             "DLM_NOCLINFO" },
312         { DLM_NOLOCKMGR,            "DLM_NOLOCKMGR" },
313         { DLM_NOPURGED,             "DLM_NOPURGED" },
314         { DLM_BADARGS,              "DLM_BADARGS" },
315         { DLM_VOID,                 "DLM_VOID" },
316         { DLM_NOTQUEUED,            "DLM_NOTQUEUED" },
317         { DLM_IVBUFLEN,             "DLM_IVBUFLEN" },
318         { DLM_CVTUNGRANT,           "DLM_CVTUNGRANT" },
319         { DLM_BADPARAM,             "DLM_BADPARAM" },
320         { DLM_VALNOTVALID,          "DLM_VALNOTVALID" },
321         { DLM_REJECTED,             "DLM_REJECTED" },
322         { DLM_ABORT,                "DLM_ABORT" },
323         { DLM_CANCEL,               "DLM_CANCEL" },
324         { DLM_IVRESHANDLE,          "DLM_IVRESHANDLE" },
325         { DLM_DEADLOCK,             "DLM_DEADLOCK" },
326         { DLM_DENIED_NOASTS,        "DLM_DENIED_NOASTS" },
327         { DLM_FORWARD,              "DLM_FORWARD" },
328         { DLM_TIMEOUT,              "DLM_TIMEOUT" },
329         { DLM_IVGROUPID,            "DLM_IVGROUPID" },
330         { DLM_VERS_CONFLICT,        "DLM_VERS_CONFLICT" },
331         { DLM_BAD_DEVICE_PATH,      "DLM_BAD_DEVICE_PATH" },
332         { DLM_NO_DEVICE_PERMISSION, "DLM_NO_DEVICE_PERMISSION" },
333         { DLM_NO_CONTROL_DEVICE ,   "DLM_NO_CONTROL_DEVICE " },
334         { DLM_RECOVERING,           "DLM_RECOVERING" },
335         { DLM_MIGRATING,            "DLM_MIGRATING" },
336         { DLM_MAXSTATS,             "DLM_MAXSTATS" },
337         { 0x0000,  NULL }
338 };
339
340 value_string_ext ext_dlm_errnames = VALUE_STRING_EXT_INIT(dlm_errnames);
341
342 static const value_string dlm_errmsgs[] = {
343         { DLM_NORMAL,               "request in progress" },
344         { DLM_GRANTED,              "request granted" },
345         { DLM_DENIED,               "request denied" },
346         { DLM_DENIED_NOLOCKS,       "request denied, out of system resources" },
347         { DLM_WORKING,              "async request in progress" },
348         { DLM_BLOCKED,              "lock request blocked" },
349         { DLM_BLOCKED_ORPHAN,       "lock request blocked by a orphan lock" },
350         { DLM_DENIED_GRACE_PERIOD,  "topological change in progress" },
351         { DLM_SYSERR,               "system error" },
352         { DLM_NOSUPPORT,            "unsupported" },
353         { DLM_CANCELGRANT,          "can't cancel convert: already granted" },
354         { DLM_IVLOCKID,             "bad lockid" },
355         { DLM_SYNC,                 "synchronous request granted" },
356         { DLM_BADTYPE,              "bad resource type" },
357         { DLM_BADRESOURCE,          "bad resource handle" },
358         { DLM_MAXHANDLES,           "no more resource handles" },
359         { DLM_NOCLINFO,             "can't contact cluster manager" },
360         { DLM_NOLOCKMGR,            "can't contact lock manager" },
361         { DLM_NOPURGED,             "can't contact purge daemon" },
362         { DLM_BADARGS,              "bad api args" },
363         { DLM_VOID,                 "no status" },
364         { DLM_NOTQUEUED,            "NOQUEUE was specified and request failed" },
365         { DLM_IVBUFLEN,             "invalid resource name length" },
366         { DLM_CVTUNGRANT,           "attempted to convert ungranted lock" },
367         { DLM_BADPARAM,             "invalid lock mode specified" },
368         { DLM_VALNOTVALID,          "value block has been invalidated" },
369         { DLM_REJECTED,             "request rejected, unrecognized client" },
370         { DLM_ABORT,                "blocked lock request cancelled" },
371         { DLM_CANCEL,               "conversion request cancelled" },
372         { DLM_IVRESHANDLE,          "invalid resource handle" },
373         { DLM_DEADLOCK,             "deadlock recovery refused this request" },
374         { DLM_DENIED_NOASTS,        "failed to allocate AST" },
375         { DLM_FORWARD,              "request must wait for primary's response" },
376         { DLM_TIMEOUT,              "timeout value for lock has expired" },
377         { DLM_IVGROUPID,            "invalid group specification" },
378         { DLM_VERS_CONFLICT,        "version conflicts prevent request handling" },
379         { DLM_BAD_DEVICE_PATH,      "Locks device does not exist or path wrong" },
380         { DLM_NO_DEVICE_PERMISSION, "Client has insufficient perms for device" },
381         { DLM_NO_CONTROL_DEVICE,    "Cannot set options on opened device " },
382         { DLM_RECOVERING,           "lock resource being recovered" },
383         { DLM_MIGRATING,            "lock resource being migrated" },
384         { DLM_MAXSTATS,             "invalid error number" },
385         { 0x0000,  NULL }
386 };
387
388 value_string_ext ext_dlm_errmsgs = VALUE_STRING_EXT_INIT(dlm_errmsgs);
389 #endif
390
391
392 #define DLM_ASSERT_MASTER_MLE_CLEANUP      0x00000001
393 #define DLM_ASSERT_MASTER_REQUERY          0x00000002
394 #define DLM_ASSERT_MASTER_FINISH_MIGRATION 0x00000004
395 static const value_string dlm_assert_master_flags[] = {
396         { DLM_ASSERT_MASTER_MLE_CLEANUP,      "cleanup" },
397         { DLM_ASSERT_MASTER_REQUERY,          "requery" },
398         { DLM_ASSERT_MASTER_FINISH_MIGRATION, "finish" },
399         { 0x0000,  NULL }
400 };
401
402 #define DLM_FINALIZE_STAGE2  0x01
403 static const value_string dlm_finalize_reco_flags[] = {
404         { DLM_FINALIZE_STAGE2, "stage2" },
405         { 0x0000,  NULL }
406 };
407
408 enum dlm_ast_type {
409         DLM_AST = 0,
410         DLM_BAST,
411         DLM_ASTUNLOCK
412 };
413
414 static const value_string dlm_proxy_ast_types[] = {
415         { DLM_AST,       "AST" },
416         { DLM_BAST,      "BAST" },
417         { DLM_ASTUNLOCK, "Unlock AST (unused)" },
418         { 0x0000,  NULL }
419 };
420
421 /* DLM lock flag types */
422 enum {
423         DLM_LOCK_FLAGS_PUT_LVB = 0x20000000,
424         DLM_LOCK_FLAGS_GET_LVB = 0x40000000
425 };
426
427
428 static int dlm_cookie_handler(proto_tree *tree, tvbuff_t *tvb, guint offset, int hf_cookie)
429 {
430         proto_item *item;
431         guint64 cookie;
432         guint64 seq;
433         guint8 node_idx;
434
435         item = proto_tree_add_item(tree, hf_cookie, tvb, offset, 8, ENC_BIG_ENDIAN);
436         cookie = tvb_get_ntoh64(tvb, offset);
437
438         cookie >>= 56;
439         node_idx = (guint8)((cookie >> 56) & G_GINT64_CONSTANT(0xff));
440         seq = cookie & G_GINT64_CONSTANT(0x00ffffffffffffff);
441
442         proto_item_append_text(item, " (%u:%" G_GINT64_MODIFIER "u)", node_idx, seq);
443
444         return offset + 8;
445 }
446
447 static int dlm_lkm_flags_handler(proto_tree *tree, tvbuff_t *tvb, guint offset,
448                                  guint32 *dlm_lock_flags_ptr)
449 {
450         static const int *flags[] = {
451                 &hf_dlm_lock_flag_unused1,
452                 &hf_dlm_lock_flag_orphan,
453                 &hf_dlm_lock_flag_parentable,
454                 &hf_dlm_lock_flag_block,
455                 &hf_dlm_lock_flag_local,
456                 &hf_dlm_lock_flag_valblk,
457                 &hf_dlm_lock_flag_noqueue,
458                 &hf_dlm_lock_flag_convert,
459                 &hf_dlm_lock_flag_nodlckwt,
460                 &hf_dlm_lock_flag_unlock,
461                 &hf_dlm_lock_flag_cancel,
462                 &hf_dlm_lock_flag_deqall,
463                 &hf_dlm_lock_flag_invvalblk,
464                 &hf_dlm_lock_flag_syncsts,
465                 &hf_dlm_lock_flag_timeout,
466                 &hf_dlm_lock_flag_sngldlck,
467                 &hf_dlm_lock_flag_findlocal,
468                 &hf_dlm_lock_flag_proc_owned,
469                 &hf_dlm_lock_flag_xid,
470                 &hf_dlm_lock_flag_xid_conflict,
471                 &hf_dlm_lock_flag_force,
472                 &hf_dlm_lock_flag_revvalblk,
473                 &hf_dlm_lock_flag_unused2,
474                 &hf_dlm_lock_flag_migration,
475                 &hf_dlm_lock_flag_put_lvb,
476                 &hf_dlm_lock_flag_get_lvb,
477                 &hf_dlm_lock_flag_recovery,
478                 NULL
479         };
480
481         if(dlm_lock_flags_ptr != NULL){
482                 *dlm_lock_flags_ptr = tvb_get_ntohl(tvb, offset);
483         }
484         proto_tree_add_bitmask_with_flags(tree, tvb, offset, hf_dlm_lock_flags,
485                                         ett_dtm_lock_flags, flags, ENC_BIG_ENDIAN, BMT_NO_INT | BMT_NO_FALSE | BMT_NO_TFS);
486         return offset + 4;
487 }
488
489 static int dlm_name_handler(proto_tree *tree, tvbuff_t *tvb, guint offset, int namelen)
490 {
491         guint8 lock_type;
492         guint64 blkno;
493         proto_item *ti;
494
495         ti = proto_tree_add_item(tree, hf_dlm_name, tvb, offset, namelen, ENC_ASCII|ENC_NA);
496         lock_type = tvb_get_guint8(tvb, offset);
497         if (lock_type == 'N') {
498                 blkno = tvb_get_ntoh64(tvb, offset + OCFS2_DENTRY_LOCK_INO_START);
499                 proto_item_append_text(ti, "%08x", (unsigned int)blkno);
500         }
501
502         return offset + namelen;
503 }
504
505 /*
506  * We would like to get one whole lockres into a single network
507  * message whenever possible.  Generally speaking, there will be
508  * at most one dlm_lock on a lockres for each node in the cluster,
509  * plus (infrequently) any additional locks coming in from userdlm.
510  *
511  * struct _dlm_lockres_page
512  * {
513  *      dlm_migratable_lockres mres;
514  *      dlm_migratable_lock ml[DLM_MAX_MIGRATABLE_LOCKS];
515  *      guint8 pad[DLM_MIG_LOCKRES_RESERVED];
516  * };
517  *
518  * from ../cluster/tcp.h
519  *    NET_MAX_PAYLOAD_BYTES  (4096 - sizeof(net_msg))
520  *    (roughly 4080 bytes)
521  * and sizeof(dlm_migratable_lockres) = 112 bytes
522  * and sizeof(dlm_migratable_lock) = 16 bytes
523  *
524  * Choosing DLM_MAX_MIGRATABLE_LOCKS=240 and
525  * DLM_MIG_LOCKRES_RESERVED=128 means we have this:
526  *
527  *  (DLM_MAX_MIGRATABLE_LOCKS * sizeof(dlm_migratable_lock)) +
528  *     sizeof(dlm_migratable_lockres) + DLM_MIG_LOCKRES_RESERVED =
529  *        NET_MAX_PAYLOAD_BYTES
530  *  (240 * 16) + 112 + 128 = 4080
531  *
532  * So a lockres would need more than 240 locks before it would
533  * use more than one network packet to recover.  Not too bad.
534  */
535
536 static void dissect_dlm_migrate_lockres(proto_tree *tree, tvbuff_t *tvb, int offset)
537 {
538         unsigned int i;
539         guint32 num_locks;
540
541         static const int * mres_flags[] = {
542                 &hf_dlm_mres_flag_recovery,
543                 &hf_dlm_mres_flag_migration,
544                 &hf_dlm_mres_flag_all_done,
545                 NULL
546         };
547
548         /* master */
549         proto_tree_add_item(tree, hf_dlm_master, tvb, offset, 1, ENC_BIG_ENDIAN);
550         offset += 1;
551
552         /* lockname_len */
553         proto_tree_add_item(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN);
554         offset += 1;
555
556         /* num_locks */
557         proto_tree_add_item_ret_uint(tree, hf_dlm_mres_num_locks, tvb, offset, 1, ENC_BIG_ENDIAN, &num_locks);
558         offset += 1;
559
560         /* no locks were found on this lockres! done! */
561         if (num_locks == 0)
562                 return;
563
564         /* flags */
565         proto_tree_add_bitmask_with_flags(tree, tvb, offset, hf_dlm_mres_flags,
566                                         ett_mres_flags, mres_flags, ENC_BIG_ENDIAN, BMT_NO_INT | BMT_NO_FALSE | BMT_NO_TFS);
567         offset += 1;
568
569         /* total_locks */
570         proto_tree_add_item(tree, hf_dlm_mres_total_locks, tvb, offset, 4, ENC_BIG_ENDIAN);
571         offset += 4;
572
573         /* mig_cookie */
574         offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_mres_mig_cookie);
575
576         /* lockname */
577         proto_tree_add_item(tree, hf_dlm_name, tvb, offset, 32, ENC_ASCII|ENC_NA);
578         offset += 32;
579
580         /* lvb */
581         proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
582         offset += 24;
583
584         proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
585         offset += 24;
586
587         proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
588         offset += 16;
589
590         /* dlm_migratable_lock */
591         for (i = 0; i < num_locks; i++) {
592                 proto_tree *subtree;
593
594                 subtree = proto_tree_add_subtree_format(tree, tvb, offset, 16,
595                                            ett_migrate_lockres_locks, NULL, "Locks%d: ", i + 1);
596
597                 /* cookie */
598                 offset = dlm_cookie_handler(subtree, tvb, offset, hf_dlm_mres_mig_cookie);
599
600                 proto_tree_add_item(subtree, hf_dlm_pad8, tvb, offset, 1, ENC_BIG_ENDIAN);
601                 offset += 1;
602
603                 /* list */
604                 proto_tree_add_item(subtree, hf_dlm_mres_list, tvb, offset, 1, ENC_BIG_ENDIAN);
605                 offset += 1;
606
607                 /* flags */
608                 proto_tree_add_item(subtree, hf_dlm_mres_ml_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
609                 offset += 1;
610
611                 /* type */
612                 proto_tree_add_item(subtree, hf_dlm_mres_type, tvb, offset, 1, ENC_BIG_ENDIAN);
613                 offset += 1;
614
615                 /* convert_type */
616                 proto_tree_add_item(subtree, hf_dlm_mres_convert_type, tvb, offset, 1, ENC_BIG_ENDIAN);
617                 offset += 1;
618
619                 /* highest_blocked */
620                 proto_tree_add_item(subtree, hf_dlm_mres_highest_blocked, tvb, offset, 1, ENC_BIG_ENDIAN);
621                 offset += 1;
622
623                 proto_tree_add_item(subtree, hf_dlm_mres_node, tvb, offset, 1, ENC_BIG_ENDIAN);
624                 offset += 1;
625         }
626 }
627
628 static void
629 dlm_fmt_revision( gchar *result, guint32 revision )
630 {
631         g_snprintf( result, ITEM_LABEL_LENGTH, "%d.%02d", (guint8)(( revision & 0xFF00 ) >> 8), (guint8)(revision & 0xFF) );
632 }
633
634 #define DLM_QUERY_JOIN_REQUEST_OFF_DLMPROTO     4
635 #define DLM_QUERY_JOIN_REQUEST_OFF_FSPROTO      6
636 #define DLM_QUERY_JOIN_REQUEST_OFF_DOMAIN       8
637 #define DLM_QUERY_JOIN_REQUEST_OFF_NODEMAP      72
638 #define DLM_QUERY_JOIN_REQUEST_LEN_DLMPROTO     2
639 #define DLM_QUERY_JOIN_REQUEST_LEN_FSPROTO      2
640 #define DLM_QUERY_JOIN_REQUEST_LEN_DOMAIN       64
641 #define DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP      32
642
643 #define DLM_QUERY_JOIN_REQUEST_OLD_LEN          100
644 static void dissect_dlm_query_join_request(proto_tree *tree, tvbuff_t *tvb, int offset)
645 {
646         guint8 cc, *node_bits_array;
647         guint8 *node_map;
648         gint len;
649         unsigned int i, j;
650         gboolean oldver = FALSE;
651
652         node_bits_array = (guint8 *)wmem_alloc0(wmem_packet_scope(), (DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP*8)+1);
653
654         len = tvb_reported_length_remaining(tvb, offset);
655         if (len == DLM_QUERY_JOIN_REQUEST_OLD_LEN)
656                 oldver = TRUE;
657
658         /* node_idx */
659         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_BIG_ENDIAN);
660         offset += 1;
661
662         proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
663         offset += 2;
664
665         /* name_len */
666         proto_tree_add_item(tree, hf_dlm_domain_name_len, tvb, offset, 1, ENC_BIG_ENDIAN);
667         offset += 1;
668
669         if (!oldver)
670         {
671             /* dlm_proto */
672             proto_tree_add_item(tree, hf_dlm_proto_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
673             offset += 2;
674
675             /* fs_proto */
676             proto_tree_add_item(tree, hf_dlm_fs_proto_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
677             offset += 2;
678         }
679
680         /* domain */
681         proto_tree_add_item(tree, hf_dlm_domain_name, tvb, offset, 64, ENC_ASCII|ENC_NA);
682         offset += 64;
683
684         /* node_map */
685         node_map = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, offset, DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP);
686
687         for (i = 0; i < DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP; i++) {
688                 cc = node_map[i];
689                 for (j = 0; j < 8; j++)
690                         node_bits_array[i * 8 + j] =
691                                         (((cc >> j) & 1) ? '1' : '0');
692         }
693
694         /* NULL terminate string */
695         node_bits_array[(DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP*8)] = 0;
696         proto_tree_add_bytes_format_value(tree, hf_dlm_node_map, tvb, offset, DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP, NULL, "%s", node_bits_array);
697 }
698
699 #define O2HB_MAX_REGION_NAME_LEN 32
700
701 static void dissect_dlm_query_region(proto_tree *tree, tvbuff_t *tvb,
702                                      guint offset)
703 {
704         guint32 i, num_regions;
705         guchar *region;
706
707         /* qr_node */
708         proto_tree_add_item(tree, hf_dlm_qr_node, tvb, offset, 1, ENC_BIG_ENDIAN);
709         offset += 1;
710
711         /* qr_numregions */
712         proto_tree_add_item_ret_uint(tree, hf_dlm_qr_numregions, tvb, offset, 1, ENC_BIG_ENDIAN, &num_regions);
713         offset += 1;
714
715         /* qr_namelen */
716         proto_tree_add_item(tree, hf_dlm_qr_namelen, tvb, offset, 1, ENC_BIG_ENDIAN);
717         offset += 1;
718
719         proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_BIG_ENDIAN);
720         offset += 1;
721
722         /* qr_domain */
723         proto_tree_add_item(tree, hf_dlm_qr_domain, tvb, offset, 64, ENC_ASCII|ENC_NA);
724         offset += 64;
725
726         /* qr_regions */
727         for (i = 0; i < num_regions; i++, offset += O2HB_MAX_REGION_NAME_LEN) {
728                 region = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, O2HB_MAX_REGION_NAME_LEN, ENC_ASCII);
729                 proto_tree_add_string_format(tree, hf_dlm_qr_region, tvb, offset, 1,
730                                            region, "Region%d: %s", i + 1, region);
731         }
732 }
733
734 static void dissect_dlm_query_nodeinfo(proto_tree *tree, tvbuff_t *tvb, guint offset)
735 {
736         guint32 i, num_nodes;
737
738         /* qn_nodenum */
739         proto_tree_add_item(tree, hf_dlm_qn_nodenum, tvb, offset, 1, ENC_BIG_ENDIAN);
740         offset += 1;
741
742         /* qn_numnodes */
743         proto_tree_add_item_ret_uint(tree, hf_dlm_qn_numnodes, tvb, offset, 1, ENC_BIG_ENDIAN, &num_nodes);
744         offset += 1;
745
746         /* qn_namelen */
747         proto_tree_add_item(tree, hf_dlm_qn_namelen, tvb, offset, 1, ENC_BIG_ENDIAN);
748         offset += 1;
749
750         /* qn_domain */
751         proto_tree_add_item(tree, hf_dlm_qn_domain, tvb, offset, 64, ENC_ASCII|ENC_NA);
752         offset += 64;
753
754         /* qn_nodes */
755         for (i = 0; i < num_nodes; i++) {
756                 proto_tree *subtree;
757
758                 /* ni_nodenum */
759                 subtree = proto_tree_add_subtree_format(tree, tvb, offset, 8,
760                                            ett_query_nodeinfo, NULL, "Node%d: ", i+1);
761
762                 proto_tree_add_item(subtree, hf_dlm_qn_node, tvb, offset, 1, ENC_BIG_ENDIAN);
763                 offset += 1;
764
765                 proto_tree_add_item(subtree, hf_dlm_pad8, tvb, offset, 1, ENC_BIG_ENDIAN);
766                 offset += 1;
767
768                 proto_tree_add_item(subtree, hf_dlm_qn_port, tvb, offset, 2, ENC_BIG_ENDIAN);
769                 offset += 2;
770
771                 proto_tree_add_item(subtree, hf_dlm_qn_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
772                 offset += 4;
773         }
774 }
775
776 static int dissect_master_msg(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_flag)
777 {
778         guint32 namelen;
779
780         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
781         offset += 1;
782
783         proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
784         offset += 1;
785
786         proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
787         offset += 2;
788
789         if (hf_flag == -1)
790                 proto_tree_add_item(tree, hf_dlm_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
791         else
792                 proto_tree_add_item(tree, hf_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
793         offset += 4;
794
795         return dlm_name_handler(tree, tvb, offset, namelen);
796 }
797
798 static int dissect_create_lock_msg(proto_tree *tree, tvbuff_t *tvb, int offset,
799                                    guint32 *dlm_lock_flags_ptr)
800 {
801         guint32 namelen;
802
803         offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_cookie);
804         offset = dlm_lkm_flags_handler(tree, tvb, offset, dlm_lock_flags_ptr);
805
806         proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_NA);
807         offset += 1;
808
809         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
810         offset += 1;
811
812         proto_tree_add_item(tree, hf_dlm_requested_type, tvb, offset, 1, ENC_BIG_ENDIAN);
813         offset += 1;
814
815         proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
816         offset += 1;
817
818         dlm_name_handler(tree, tvb, offset, namelen);
819         return offset + O2NM_MAX_NAME_LEN;
820 }
821
822 static int dissect_convert_lock_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
823 {
824         guint32 dlm_lock_flags;
825         offset = dissect_create_lock_msg(tree, tvb, offset, &dlm_lock_flags);
826
827         if(dlm_lock_flags & DLM_LOCK_FLAGS_PUT_LVB){
828                 proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
829                 offset += 24;
830
831                 proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
832                 offset += 24;
833
834                 proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
835                 offset += 16;
836         }
837
838         return offset;
839 }
840
841 static int dissect_unlock_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
842 {
843         guint32 namelen;
844         guint32 dlm_lock_flags;
845
846         offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_cookie);
847         offset = dlm_lkm_flags_handler(tree, tvb, offset, &dlm_lock_flags);
848
849         proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
850         offset += 2;
851
852         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
853         offset += 1;
854
855         proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
856         offset += 1;
857
858         dlm_name_handler(tree, tvb, offset, namelen);
859         offset += O2NM_MAX_NAME_LEN;
860
861         if(dlm_lock_flags & DLM_LOCK_FLAGS_PUT_LVB){
862                 proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
863                 offset += 24;
864
865                 proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
866                 offset += 24;
867
868                 proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
869                 offset += 16;
870         }
871
872         return offset;
873 }
874
875 static int dissect_proxy_ast_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
876 {
877         guint32 namelen;
878         guint32 dlm_lock_flags;
879
880         offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_cookie);
881         offset = dlm_lkm_flags_handler(tree, tvb, offset, &dlm_lock_flags);
882
883         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
884         offset += 1;
885
886         proto_tree_add_item(tree, hf_dlm_ast_type, tvb, offset, 1, ENC_BIG_ENDIAN);
887         offset += 1;
888
889         proto_tree_add_item(tree, hf_dlm_blocked_type, tvb, offset, 1, ENC_BIG_ENDIAN);
890         offset += 1;
891
892         proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
893         offset += 1;
894
895         dlm_name_handler(tree, tvb, offset, namelen);
896         offset += O2NM_MAX_NAME_LEN;
897
898         if(dlm_lock_flags & DLM_LOCK_FLAGS_GET_LVB){
899                 proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
900                 offset += 24;
901
902                 proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
903                 offset += 24;
904
905                 proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
906                 offset += 16;
907         }
908         return offset;
909 }
910
911 static int dissect_deref_lockres_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
912 {
913         guint32 namelen;
914
915         proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
916         offset += 4;
917
918         proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
919         offset += 2;
920
921         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
922         offset += 1;
923
924         proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
925         offset += 1;
926
927         return dlm_name_handler(tree, tvb, offset, namelen);
928 }
929
930 static int dissect_migrate_request_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
931 {
932         guint32 namelen;
933
934         proto_tree_add_item(tree, hf_dlm_master, tvb, offset, 1, ENC_NA);
935         offset += 1;
936
937         proto_tree_add_item(tree, hf_dlm_new_master, tvb, offset, 1, ENC_NA);
938         offset += 1;
939
940         proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
941         offset += 1;
942
943         proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_NA);
944         offset += 1;
945
946         proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
947         offset += 4;
948
949         return dlm_name_handler(tree, tvb, offset, namelen);
950 }
951
952 static int dissect_dlm_joined_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
953 {
954         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
955         offset += 1;
956
957         proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
958         offset += 2;
959
960         proto_tree_add_item(tree, hf_dlm_domain_name_len, tvb, offset, 1, ENC_BIG_ENDIAN);
961         offset += 1;
962
963         proto_tree_add_item(tree, hf_dlm_domain_name, tvb, offset, 64, ENC_ASCII|ENC_NA);
964         offset += 64;
965
966         return offset;
967 }
968
969 static int dissect_master_requery_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
970 {
971         guint32 namelen;
972
973         proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
974         offset += 2;
975
976         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
977         offset += 1;
978
979         proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
980         offset += 1;
981
982         proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
983         offset += 4;
984
985         return dlm_name_handler(tree, tvb, offset, namelen);
986 }
987
988 static int dissect_lock_request_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
989 {
990         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
991         offset += 1;
992
993         proto_tree_add_item(tree, hf_dlm_dead_node, tvb, offset, 1, ENC_NA);
994         offset += 1;
995
996         proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
997         offset += 2;
998
999         proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
1000         offset += 4;
1001
1002         return offset;
1003 }
1004
1005 static int dissect_reco_data_done_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
1006 {
1007         offset = dissect_lock_request_msg(tree, tvb, offset);
1008
1009         proto_tree_add_item(tree, hf_dlm_reco_lvb, tvb, offset, 64, ENC_NA);
1010         offset += 64;
1011
1012         return offset;
1013 }
1014
1015 static int dissect_finalize_reco_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
1016 {
1017         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
1018         offset += 1;
1019
1020         proto_tree_add_item(tree, hf_dlm_dead_node, tvb, offset, 1, ENC_NA);
1021         offset += 1;
1022
1023         proto_tree_add_item(tree, hf_dlm_fr_flags, tvb, offset, 1, ENC_NA);
1024         offset += 1;
1025
1026         proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_NA);
1027         offset += 1;
1028
1029         proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
1030         offset += 4;
1031
1032         return offset;
1033 }
1034
1035 static int dissect_ocfs2_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1036 {
1037         proto_tree *subtree;
1038         proto_item *ti;
1039         guint32 len, msg_type;
1040         guint32 magic;
1041         tvbuff_t   *next_tvb;
1042         int offset = 0;
1043
1044         magic = tvb_get_ntohs(tvb, offset);
1045         if (try_val_to_str(magic, o2net_magic) == NULL)
1046                 return 0;
1047
1048         col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCFS2");
1049         col_clear(pinfo->cinfo, COL_INFO);
1050
1051         ti = proto_tree_add_item(tree, proto_ocfs2, tvb, offset, -1, ENC_NA);
1052         subtree = proto_item_add_subtree(ti, ett_ocfs2);
1053
1054         proto_tree_add_item(subtree, hf_msg_magic, tvb, offset, 2, ENC_BIG_ENDIAN);
1055         offset += 2;
1056
1057         proto_tree_add_item_ret_uint(subtree, hf_msg_data_len, tvb, 2, 2, ENC_BIG_ENDIAN, &len);
1058         offset += 2;
1059
1060         proto_tree_add_item_ret_uint(subtree, hf_msg_msg_type, tvb, 4, 2, ENC_BIG_ENDIAN, &msg_type);
1061         offset += 2;
1062
1063         switch(magic){
1064         case O2NET_MSG_KEEP_REQ_MAGIC:
1065                 col_append_sep_str(pinfo->cinfo, COL_INFO, " | ", "Keepalive Request");
1066                 break;
1067         case O2NET_MSG_KEEP_RESP_MAGIC:
1068                 col_append_sep_str(pinfo->cinfo, COL_INFO, " | ", "Keepalive Response");
1069                 break;
1070         default:
1071                 col_append_sep_str(pinfo->cinfo, COL_INFO, " | ",
1072                         val_to_str_ext(msg_type, &ext_dlm_magic, "Unknown Type (0x%02x)") );
1073                 break;
1074         }
1075
1076         col_set_fence(pinfo->cinfo, COL_INFO);
1077
1078         proto_tree_add_item(subtree, hf_msg_pad, tvb, 4, 2, ENC_BIG_ENDIAN);
1079         offset += 2;
1080
1081         proto_tree_add_item(subtree, hf_msg_sys_status, tvb, 8, 4, ENC_BIG_ENDIAN);
1082         offset += 4;
1083
1084         proto_tree_add_item(subtree, hf_msg_status, tvb, 12, 4, ENC_BIG_ENDIAN);
1085         offset += 4;
1086
1087         proto_tree_add_item(subtree, hf_msg_key, tvb, 16, 4, ENC_BIG_ENDIAN);
1088         offset += 4;
1089
1090         proto_tree_add_item(subtree, hf_msg_msg_num, tvb, 20, 4, ENC_BIG_ENDIAN);
1091         offset += 4;
1092
1093         if (magic == O2NET_MSG_MAGIC) {
1094                 switch (msg_type) {
1095                 case DLM_MASTER_REQUEST_MSG:
1096                         dissect_master_msg(subtree, tvb, offset, -1);
1097                         break;
1098                 case DLM_ASSERT_MASTER_MSG:
1099                         dissect_master_msg(subtree, tvb, offset, hf_dlm_am_flags);
1100                         break;
1101                 case DLM_CREATE_LOCK_MSG:
1102                         dissect_create_lock_msg(subtree, tvb, offset, NULL);
1103                         break;
1104                 case DLM_CONVERT_LOCK_MSG:
1105                         dissect_convert_lock_msg(subtree, tvb, offset);
1106                         break;
1107                 case DLM_PROXY_AST_MSG:
1108                         dissect_proxy_ast_msg(subtree, tvb, offset);
1109                         break;
1110                 case DLM_UNLOCK_LOCK_MSG:
1111                         dissect_unlock_msg(subtree, tvb, offset);
1112                         break;
1113                 case DLM_DEREF_LOCKRES_MSG:
1114                         dissect_deref_lockres_msg(subtree, tvb, offset);
1115                         break;
1116                 case DLM_MIGRATE_REQUEST_MSG:
1117                         dissect_migrate_request_msg(subtree, tvb, offset);
1118                         break;
1119                 case DLM_MIG_LOCKRES_MSG:
1120                         dissect_dlm_migrate_lockres(subtree, tvb, offset);
1121                         break;
1122                 case DLM_QUERY_JOIN_MSG:
1123                         dissect_dlm_query_join_request(subtree, tvb, offset);
1124                         break;
1125                 case DLM_ASSERT_JOINED_MSG:
1126                 case DLM_CANCEL_JOIN_MSG:
1127                         dissect_dlm_joined_msg(subtree, tvb, offset);
1128                         break;
1129                 case DLM_EXIT_DOMAIN_MSG:
1130                         proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
1131                         break;
1132                 case DLM_MASTER_REQUERY_MSG:
1133                         dissect_master_requery_msg(subtree, tvb, offset);
1134                         break;
1135                 case DLM_LOCK_REQUEST_MSG:
1136                 case DLM_BEGIN_RECO_MSG:
1137                         dissect_lock_request_msg(subtree, tvb, offset);
1138                         break;
1139                 case DLM_RECO_DATA_DONE_MSG:
1140                         dissect_reco_data_done_msg(subtree, tvb, offset);
1141                         break;
1142                 case DLM_FINALIZE_RECO_MSG:
1143                         dissect_finalize_reco_msg(subtree, tvb, offset);
1144                         break;
1145                 case DLM_QUERY_REGION_MSG:
1146                         dissect_dlm_query_region(subtree, tvb, offset);
1147                         break;
1148                 case DLM_QUERY_NODEINFO_MSG:
1149                         dissect_dlm_query_nodeinfo(subtree, tvb, offset);
1150                         break;
1151                 default:
1152                         proto_tree_add_item(tree, hf_dlm_payload, tvb, offset, len, ENC_NA);
1153                         break;
1154                 }
1155         } else {
1156                 next_tvb = tvb_new_subset_length(tvb, offset, len);
1157                 call_data_dissector(next_tvb, pinfo, tree);
1158         }
1159
1160         return tvb_reported_length(tvb);
1161 }
1162
1163 static guint
1164 get_ocfs2_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
1165 {
1166         guint16 plen;
1167
1168         /* Get the length of the data from header. */
1169         plen = tvb_get_ntohs(tvb, offset + 2);
1170
1171         /* That length doesn't include the header itself, add that in. */
1172         return plen + 24;
1173 }
1174
1175 static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
1176 {
1177         guint32 magic;
1178         int offset = 0;
1179
1180         if (!tvb_bytes_exist(tvb, offset, 2))
1181                 return 0;
1182
1183         magic = tvb_get_ntohs(tvb, offset);
1184         if (try_val_to_str(magic, o2net_magic) == NULL)
1185                 return 0;
1186
1187         tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, get_ocfs2_pdu_len, dissect_ocfs2_pdu, data);
1188         return tvb_captured_length(tvb);
1189 }
1190
1191 void proto_register_ocfs2(void)
1192 {
1193         static hf_register_info hf[] = {
1194                 /* ocfs2_msg */
1195                 { &hf_msg_magic,
1196                         { "Magic", "ocfs2.msg.magic", FT_UINT16, BASE_HEX,
1197                           VALS(o2net_magic), 0x0,
1198                           "Magic number identifier of O2NET-over-TCPmessage",
1199                           HFILL
1200                         }
1201                 },
1202                 { &hf_msg_data_len,
1203                         { "Len", "ocfs2.msg.data_len", FT_UINT16, BASE_DEC,
1204                           NULL, 0x0, "Data length", HFILL
1205                         }
1206                 },
1207                 { &hf_msg_msg_type,
1208                         { "Type", "ocfs2.msg.msg_type", FT_UINT16, BASE_DEC|BASE_EXT_STRING,
1209                           &ext_dlm_magic, 0x0, "Message type", HFILL
1210                         }
1211                 },
1212                 { &hf_msg_pad,
1213                         { "Pad", "ocfs2.msg.pad", FT_UINT16, BASE_HEX,
1214                           NULL, 0x0, NULL, HFILL
1215                         }
1216                 },
1217                 { &hf_msg_sys_status,
1218                         { "Sys Status", "ocfs2.msg.sys_status", FT_UINT32,
1219                           BASE_DEC, NULL, 0x0,
1220                           "System level status return code", HFILL
1221                         }
1222                 },
1223                 { &hf_msg_status,
1224                         { "Status", "ocfs2.msg.status", FT_UINT32, BASE_DEC,
1225                           NULL, 0x0, "Return code", HFILL
1226                         }
1227                 },
1228                 { &hf_msg_key,
1229                         { "Key", "ocfs2.msg.key", FT_UINT32, BASE_HEX, NULL,
1230                           0x0, NULL, HFILL
1231                         }
1232                 },
1233                 { &hf_msg_msg_num,
1234                         { "Num", "ocfs2.msg.msg_num", FT_UINT32, BASE_DEC, NULL,
1235                           0x0, "Message identification number", HFILL
1236                         }
1237                 },
1238                 { &hf_dlm_node_idx,
1239                         { "Node", "ocfs2.dlm.node_idx", FT_UINT8, BASE_DEC,
1240                           NULL, 0x0, "Node index", HFILL
1241                         }
1242                 },
1243                 { &hf_dlm_lock_flags,
1244                         { "Flags", "ocfs2.dlm.lock.flags", FT_UINT32, BASE_HEX,
1245                           NULL, 0x0, NULL, HFILL
1246                         }
1247                 },
1248                 { &hf_dlm_lock_flag_unused1,
1249                         { "unused", "ocfs2.dlm.lock.flags.unused", FT_UINT32, BASE_HEX,
1250                           NULL, 0x0000000F, NULL, HFILL
1251                         }
1252                 },
1253                 { &hf_dlm_lock_flag_orphan,
1254                         { "orphan", "ocfs2.dlm.lock.flags.orphan", FT_BOOLEAN, 32,
1255                           NULL, 0x00000010, NULL, HFILL
1256                         }
1257                 },
1258                 { &hf_dlm_lock_flag_parentable,
1259                         { "parentable", "ocfs2.dlm.lock.flags.parentable", FT_BOOLEAN, 32,
1260                           NULL, 0x00000020, NULL, HFILL
1261                         }
1262                 },
1263                 { &hf_dlm_lock_flag_block,
1264                         { "block", "ocfs2.dlm.lock.flags.block", FT_BOOLEAN, 32,
1265                           NULL, 0x00000040, NULL, HFILL
1266                         }
1267                 },
1268                 { &hf_dlm_lock_flag_local,
1269                         { "local", "ocfs2.dlm.lock.flags.local", FT_BOOLEAN, 32,
1270                           NULL, 0x00000080, NULL, HFILL
1271                         }
1272                 },
1273                 { &hf_dlm_lock_flag_valblk,
1274                         { "valblk", "ocfs2.dlm.lock.flags.valblk", FT_BOOLEAN, 32,
1275                           NULL, 0x00000100, NULL, HFILL
1276                         }
1277                 },
1278                 { &hf_dlm_lock_flag_noqueue,
1279                         { "noqueue", "ocfs2.dlm.lock.flags.noqueue", FT_BOOLEAN, 32,
1280                           NULL, 0x00000200, NULL, HFILL
1281                         }
1282                 },
1283                 { &hf_dlm_lock_flag_convert,
1284                         { "convert", "ocfs2.dlm.lock.flags.convert", FT_BOOLEAN, 32,
1285                           NULL, 0x00000400, NULL, HFILL
1286                         }
1287                 },
1288                 { &hf_dlm_lock_flag_nodlckwt,
1289                         { "nodlckwt", "ocfs2.dlm.lock.flags.nodlckwt", FT_BOOLEAN, 32,
1290                           NULL, 0x00000800, NULL, HFILL
1291                         }
1292                 },
1293                 { &hf_dlm_lock_flag_unlock,
1294                         { "unlock", "ocfs2.dlm.lock.flags.unlock", FT_BOOLEAN, 32,
1295                           NULL, 0x00001000, NULL, HFILL
1296                         }
1297                 },
1298                 { &hf_dlm_lock_flag_cancel,
1299                         { "cancel", "ocfs2.dlm.lock.flags.cancel", FT_BOOLEAN, 32,
1300                           NULL, 0x00002000, NULL, HFILL
1301                         }
1302                 },
1303                 { &hf_dlm_lock_flag_deqall,
1304                         { "deqall", "ocfs2.dlm.lock.flags.deqall", FT_BOOLEAN, 32,
1305                           NULL, 0x00004000, NULL, HFILL
1306                         }
1307                 },
1308                 { &hf_dlm_lock_flag_invvalblk,
1309                         { "invvalblk", "ocfs2.dlm.lock.flags.invvalblk", FT_BOOLEAN, 32,
1310                           NULL, 0x00008000, NULL, HFILL
1311                         }
1312                 },
1313                 { &hf_dlm_lock_flag_syncsts,
1314                         { "syncsts", "ocfs2.dlm.lock.flags.syncsts", FT_BOOLEAN, 32,
1315                           NULL, 0x00010000, NULL, HFILL
1316                         }
1317                 },
1318                 { &hf_dlm_lock_flag_timeout,
1319                         { "timeout", "ocfs2.dlm.lock.flags.timeout", FT_BOOLEAN, 32,
1320                           NULL, 0x00020000, NULL, HFILL
1321                         }
1322                 },
1323                 { &hf_dlm_lock_flag_sngldlck,
1324                         { "sngldlck", "ocfs2.dlm.lock.flags.sngldlck", FT_BOOLEAN, 32,
1325                           NULL, 0x00040000, NULL, HFILL
1326                         }
1327                 },
1328                 { &hf_dlm_lock_flag_findlocal,
1329                         { "findlocal", "ocfs2.dlm.lock.flags.findlocal", FT_BOOLEAN, 32,
1330                           NULL, 0x00080000, NULL, HFILL
1331                         }
1332                 },
1333                 { &hf_dlm_lock_flag_proc_owned,
1334                         { "proc_owned", "ocfs2.dlm.lock.flags.proc_owned", FT_BOOLEAN, 32,
1335                           NULL, 0x00100000, NULL, HFILL
1336                         }
1337                 },
1338                 { &hf_dlm_lock_flag_xid,
1339                         { "xid", "ocfs2.dlm.lock.flags.xid", FT_BOOLEAN, 32,
1340                           NULL, 0x00200000, NULL, HFILL
1341                         }
1342                 },
1343                 { &hf_dlm_lock_flag_xid_conflict,
1344                         { "xid_conflict", "ocfs2.dlm.lock.flags.xid_conflict", FT_BOOLEAN, 32,
1345                           NULL, 0x00400000, NULL, HFILL
1346                         }
1347                 },
1348                 { &hf_dlm_lock_flag_force,
1349                         { "force", "ocfs2.dlm.lock.flags.force", FT_BOOLEAN, 32,
1350                           NULL, 0x00800000, NULL, HFILL
1351                         }
1352                 },
1353                 { &hf_dlm_lock_flag_revvalblk,
1354                         { "revvalblk", "ocfs2.dlm.lock.flags.revvalblk", FT_BOOLEAN, 32,
1355                           NULL, 0x01000000, NULL, HFILL
1356                         }
1357                 },
1358                 { &hf_dlm_lock_flag_unused2,
1359                         { "unused", "ocfs2.dlm.lock.flags.unused", FT_UINT32, BASE_HEX,
1360                           NULL, 0x0E000000, NULL, HFILL
1361                         }
1362                 },
1363                 { &hf_dlm_lock_flag_migration,
1364                         { "migration", "ocfs2.dlm.lock.flags.migration", FT_BOOLEAN, 32,
1365                           NULL, 0x10000000, NULL, HFILL
1366                         }
1367                 },
1368                 { &hf_dlm_lock_flag_put_lvb,
1369                         { "put_lvb", "ocfs2.dlm.lock.flags.put_lvb", FT_BOOLEAN, 32,
1370                           NULL, 0x20000000, NULL, HFILL
1371                         }
1372                 },
1373                 { &hf_dlm_lock_flag_get_lvb,
1374                         { "get_lvb", "ocfs2.dlm.lock.flags.get_lvb", FT_BOOLEAN, 32,
1375                           NULL, 0x40000000, NULL, HFILL
1376                         }
1377                 },
1378                 { &hf_dlm_lock_flag_recovery,
1379                         { "recovery", "ocfs2.dlm.lock.flags.recovery", FT_BOOLEAN, 32,
1380                           NULL, 0x80000000, NULL, HFILL
1381                         }
1382                 },
1383                 { &hf_dlm_am_flags,
1384                         { "Flags", "ocfs2.dlm.am_flags", FT_UINT32, BASE_HEX,
1385                           VALS(dlm_assert_master_flags), 0x0,
1386                           "Assert Master Flags", HFILL
1387                         }
1388                 },
1389                 { &hf_dlm_fr_flags,
1390                         { "Flags", "ocfs2.dlm.fr_flags", FT_UINT32, BASE_HEX,
1391                           VALS(dlm_finalize_reco_flags), 0x0,
1392                           "Finalize Recovery Flags", HFILL
1393                         }
1394                 },
1395                 { &hf_dlm_namelen,
1396                         { "Namelen", "ocfs2.dlm.namelen", FT_UINT8, BASE_DEC,
1397                           NULL, 0x0, NULL, HFILL
1398                         }
1399                 },
1400                 { &hf_dlm_name,
1401                         { "Name", "ocfs2.dlm.name", FT_STRING, BASE_NONE, NULL,
1402                           0x0, NULL, HFILL
1403                         }
1404                 },
1405                 { &hf_dlm_cookie,
1406                         { "Cookie", "ocfs2.dlm.cookie", FT_UINT64, BASE_HEX,
1407                           NULL, 0x0,
1408                           "Unique ID for a single lock on a resource", HFILL
1409                         }
1410                 },
1411                 { &hf_dlm_requested_type,
1412                         { "Requested", "ocfs2.dlm.requested_type", FT_UINT8,
1413                           BASE_DEC, VALS(dlm_lock_modes), 0x0,
1414                           "Requested lock level", HFILL
1415                         }
1416                 },
1417                 { &hf_dlm_blocked_type,
1418                         { "Blocked", "ocfs2.dlm.blocked_type", FT_UINT8,
1419                           BASE_DEC, VALS(dlm_lock_modes), 0x0,
1420                           "Blocked lock type", HFILL
1421                         }
1422                 },
1423                 { &hf_dlm_ast_type,
1424                         { "AST Type", "ocfs2.dlm.ast_type", FT_UINT8, BASE_DEC,
1425                           VALS(dlm_proxy_ast_types), 0x0, NULL, HFILL
1426                         }
1427                 },
1428                 { &hf_dlm_dead_node,
1429                         { "Dead Node", "ocfs2.dlm.dead_node", FT_UINT8,
1430                           BASE_DEC, NULL, 0x0, "Dead node index", HFILL
1431                         }
1432                 },
1433                 { &hf_dlm_lvb1,
1434                         { "LVB1", "ocfs2.dlm.lvb", FT_BYTES, BASE_NONE, NULL,
1435                           0x0, "Lock value block", HFILL
1436                         }
1437                 },
1438                 { &hf_dlm_lvb2,
1439                         { "LVB2", "ocfs2.dlm.lvb", FT_BYTES, BASE_NONE, NULL,
1440                           0x0, "Lock value block", HFILL
1441                         }
1442                 },
1443                 { &hf_dlm_lvb3,
1444                         { "LVB3", "ocfs2.dlm.lvb", FT_BYTES, BASE_NONE, NULL,
1445                           0x0, "Lock value block", HFILL
1446                         }
1447                 },
1448                 { &hf_dlm_domain_name_len,
1449                         { "Domain Namelen", "ocfs2.dlm.domain_namelen",
1450                           FT_UINT8, BASE_DEC, NULL, 0x0, NULL,
1451                           HFILL
1452                         }
1453                 },
1454                 { &hf_dlm_proto_ver,
1455                         { "DLM Protocol", "ocfs2.dlm.proto_ver",
1456                           FT_UINT16, BASE_CUSTOM, CF_FUNC(dlm_fmt_revision), 0x0, NULL,
1457                           HFILL
1458                         }
1459                 },
1460                 { &hf_dlm_fs_proto_ver,
1461                         { "FS Protocol", "ocfs2.dlm.fs_proto_ver",
1462                           FT_UINT16, BASE_CUSTOM, CF_FUNC(dlm_fmt_revision), 0x0, NULL,
1463                           HFILL
1464                         }
1465                 },
1466                 { &hf_dlm_node_map,
1467                         { "Node Map", "ocfs2.dlm.node_map", FT_BYTES,
1468                           BASE_NONE, NULL, 0x0, NULL, HFILL
1469                         }
1470                 },
1471                 { &hf_dlm_domain_name,
1472                         { "Domain Name", "ocfs2.dlm.domain_name", FT_STRING,
1473                           BASE_NONE, NULL, 0x0, NULL, HFILL
1474                         }
1475                 },
1476                 { &hf_dlm_master,
1477                         { "Master", "ocfs2.dlm.master", FT_UINT8, BASE_DEC,
1478                           NULL, 0x0, NULL, HFILL
1479                         }
1480                 },
1481                 { &hf_dlm_new_master,
1482                         { "New Master", "ocfs2.dlm.new_master", FT_UINT8,
1483                           BASE_DEC, NULL, 0x0, NULL, HFILL
1484                         }
1485                 },
1486                 { &hf_dlm_mres_num_locks,
1487                         { "Num Locks", "ocfs2.dlm.num_locks", FT_UINT8,
1488                           BASE_DEC, NULL, 0x0, "Migres Num Locks", HFILL
1489                         }
1490                 },
1491                 { &hf_dlm_mres_flags,
1492                         { "Flags", "ocfs2.dlm.mres_flags", FT_UINT8, BASE_HEX,
1493                           NULL, 0x01, "Migres Flags", HFILL
1494                         }
1495                 },
1496                 { &hf_dlm_mres_flag_recovery,
1497                         { "recovery", "ocfs2.dlm.mres_flags.recovery", FT_BOOLEAN, 8,
1498                           NULL, 0x02, NULL, HFILL
1499                         }
1500                 },
1501                 { &hf_dlm_mres_flag_migration,
1502                         { "migration", "ocfs2.dlm.mres_flags.migration", FT_BOOLEAN, 8,
1503                           NULL, 0x04, NULL, HFILL
1504                         }
1505                 },
1506                 { &hf_dlm_mres_flag_all_done,
1507                         { "all_done", "ocfs2.dlm.mres_flags.all_done", FT_BOOLEAN, 8,
1508                           NULL, 0x0, NULL, HFILL
1509                         }
1510                 },
1511                 { &hf_dlm_mres_total_locks,
1512                         { "Total Locks", "ocfs2.dlm.total_locks", FT_UINT32,
1513                           BASE_DEC, NULL, 0x0, "Migres Total Locks", HFILL
1514                         }
1515                 },
1516                 { &hf_dlm_mres_mig_cookie,
1517                         { "Cookie", "ocfs2.dlm.migratable_lock.mig_cookie",
1518                           FT_UINT64, BASE_DEC, NULL, 0x0, "Migres Cookie", HFILL
1519                         }
1520                 },
1521                 { &hf_dlm_mres_list,
1522                         { "List", "ocfs2.dlm.migratable_lock.list", FT_UINT8,
1523                           BASE_DEC, VALS(dlm_lockres_list), 0x0, NULL, HFILL
1524                         }
1525                 },
1526                 { &hf_dlm_mres_ml_flags,
1527                         { "List", "ocfs2.dlm.migratable_lock.flags", FT_UINT8,
1528                           BASE_HEX, NULL, 0x0, NULL, HFILL
1529                         }
1530                 },
1531                 { &hf_dlm_mres_type,
1532                         { "Type", "ocfs2.dlm.migratable_lock.type", FT_UINT8,
1533                           BASE_DEC, VALS(dlm_lock_modes), 0x0, NULL, HFILL
1534                         }
1535                 },
1536                 { &hf_dlm_mres_convert_type,
1537                         { "Convert type", "ocfs2.dlm.migratable_lock.convert_type", FT_UINT8,
1538                           BASE_DEC, NULL, 0x0, NULL, HFILL
1539                         }
1540                 },
1541                 { &hf_dlm_mres_highest_blocked,
1542                         { "Highest blocked", "ocfs2.dlm.migratable_lock.highest_blocked", FT_UINT8,
1543                           BASE_DEC, NULL, 0x0, NULL, HFILL
1544                         }
1545                 },
1546                 { &hf_dlm_mres_node,
1547                         { "Node", "ocfs2.dlm.migratable_lock.node", FT_UINT8,
1548                           BASE_DEC, NULL, 0x0, NULL, HFILL
1549                         }
1550                 },
1551                 { &hf_dlm_qr_node,
1552                         { "Node", "ocfs2.dlm.query_region.qr_node", FT_UINT8,
1553                           BASE_DEC, NULL, 0x0, "Query Region Node", HFILL
1554                         }
1555                 },
1556                 { &hf_dlm_qr_numregions,
1557                         { "Num Regions", "ocfs2.dlm.query_region.qr_numregions",
1558                           FT_UINT8, BASE_DEC, NULL, 0x0,
1559                           "The number of regions to compare with", HFILL
1560                         }
1561                 },
1562                 { &hf_dlm_qr_namelen,
1563                         { "Domain Namelen", "ocfs2.dlm.query_region.qr_namelen",
1564                           FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
1565                         }
1566                 },
1567                 { &hf_dlm_qr_domain,
1568                         { "Domain Name", "ocfs2.dlm.query_region.qr_domain",
1569                           FT_STRING, BASE_NONE, NULL, 0x0, NULL,
1570                           HFILL
1571                         }
1572                 },
1573                 { &hf_dlm_qr_region,
1574                         { "Region", "ocfs2.dlm.query_region.region",
1575                           FT_STRING, BASE_NONE, NULL, 0x0, NULL,
1576                           HFILL
1577                         }
1578                 },
1579                 { &hf_dlm_qn_nodenum,
1580                         { "Node", "ocfs2.dlm_query_nodeinfo.qn_nodenum",
1581                           FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
1582                         }
1583                 },
1584                 { &hf_dlm_qn_numnodes,
1585                         { "Num Nodes", "ocfs2.dlm_query_nodeinfo.qn_numnodes",
1586                           FT_UINT8, BASE_DEC, NULL, 0x0,
1587                           "The number of nodes to query", HFILL
1588                         }
1589                 },
1590                 { &hf_dlm_qn_namelen,
1591                         { "Domain Namelen",
1592                           "ocfs2.dlm_query_nodeinfo.qn_namelen", FT_UINT8,
1593                           BASE_DEC, NULL, 0x0, NULL, HFILL
1594                         }
1595                 },
1596                 { &hf_dlm_qn_domain,
1597                         { "Domain Name", "ocfs2.dlm_query_nodeinfo.qn_domain",
1598                           FT_UINT8, BASE_DEC, NULL, 0x0, NULL,
1599                           HFILL
1600                         }
1601                 },
1602                 { &hf_dlm_qn_node,
1603                         { "Node", "ocfs2.dlm_query_nodeinfo.node",
1604                           FT_UINT8, BASE_DEC, NULL, 0x0, NULL,
1605                           HFILL
1606                         }
1607                 },
1608                 { &hf_dlm_qn_port,
1609                         { "Port", "ocfs2.dlm_query_nodeinfo.port",
1610                           FT_UINT16, BASE_DEC, NULL, 0x0, NULL,
1611                           HFILL
1612                         }
1613                 },
1614                 { &hf_dlm_qn_ip,
1615                         { "IP Address", "ocfs2.dlm_query_nodeinfo.ip",
1616                           FT_IPv4, BASE_NONE, NULL, 0x0, NULL,
1617                           HFILL
1618                         }
1619                 },
1620                 { &hf_dlm_reco_lvb,
1621                         { "Recovery LVB", "ocfs2.reco_lvb",
1622                           FT_BYTES, BASE_NONE, NULL, 0x0, NULL,
1623                           HFILL
1624                         }
1625                 },
1626                 { &hf_dlm_pad8,
1627                         { "Pad", "ocfs2.dlm.pad",
1628                           FT_UINT8, BASE_DEC, NULL, 0x0, NULL,
1629                           HFILL
1630                         }
1631                 },
1632                 { &hf_dlm_pad16,
1633                         { "Pad", "ocfs2.dlm.pad",
1634                           FT_UINT16, BASE_HEX, NULL, 0x0, NULL,
1635                           HFILL
1636                         }
1637                 },
1638                 { &hf_dlm_pad32,
1639                         { "Pad", "ocfs2.dlm.pad",
1640                           FT_UINT32, BASE_HEX, NULL, 0x0, NULL,
1641                           HFILL
1642                         }
1643                 },
1644                 { &hf_dlm_flags,
1645                         { "Flags", "ocfs2.dlm.flags",
1646                           FT_UINT32, BASE_HEX, NULL, 0x0, NULL,
1647                           HFILL
1648                         }
1649                 },
1650                 { &hf_dlm_payload,
1651                         { "Payload", "ocfs2.dlm.payload",
1652                           FT_BYTES, BASE_NONE, NULL, 0x0, NULL,
1653                           HFILL
1654                         }
1655                 },
1656         };
1657
1658         static gint *ett[] = {
1659                 &ett_ocfs2,
1660                 &ett_dtm_lock_flags,
1661                 &ett_mres_flags,
1662                 &ett_migrate_lockres_locks,
1663                 &ett_query_nodeinfo,
1664         };
1665
1666         proto_ocfs2 = proto_register_protocol("OCFS2 Networking", "OCFS2", "ocfs2");
1667         proto_register_field_array(proto_ocfs2, hf, array_length(hf));
1668         proto_register_subtree_array(ett, array_length(ett));
1669 }
1670
1671 void proto_reg_handoff_ocfs2(void)
1672 {
1673         dissector_handle_t ocfs2_handle;
1674
1675         ocfs2_handle = create_dissector_handle(dissect_ocfs2, proto_ocfs2);
1676
1677         dissector_add_for_decode_as_with_preference("tcp.port", ocfs2_handle);
1678 }
1679
1680
1681 /*
1682  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
1683  *
1684  * Local variables:
1685  * c-basic-offset: 8
1686  * tab-width: 8
1687  * indent-tabs-mode: t
1688  * End:
1689  *
1690  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1691  * :indentSize=8:tabSize=8:noTabs=false:
1692  */