summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ocfs2.c
blob: 2f44bf46ff5279fe00caac3ca3553be1fcda7d95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
/*
 * packet-ocfs2.c
 *
 * Routines for OCFS2's networking protocol disassembly (o2net and o2dlm)
 * The OCFS2 cluster file system is available in the mainline Linux kernel.
 *
 * Copyright (C) 2006, 2011 Oracle. All rights reserved.
 *
 * Authors:
 * Kurt Hackel		<kurt.hackel@oracle.com>
 * Zach Brown		<zach.brown@oracle.com>
 * Sunil Mushran	<sunil.mushran@oracle.com>
 * Jeff Liu		<jeff.liu@oracle.com>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"


#include <epan/packet.h>
#include "packet-tcp.h"

void proto_register_ocfs2(void);
void proto_reg_handoff_ocfs2(void);

static dissector_handle_t ocfs2_handle;

static gint ett_ocfs2 = -1;
static gint ett_dtm_lock_flags = -1;
static gint ett_mres_flags = -1;
static gint ett_migrate_lockres_locks = -1;
static gint ett_query_nodeinfo = -1;

static int proto_ocfs2 = -1;
static int hf_msg_magic = -1;
static int hf_msg_data_len = -1;
static int hf_msg_msg_type = -1;
static int hf_msg_sys_status = -1;
static int hf_msg_status = -1;
static int hf_msg_key = -1;
static int hf_msg_msg_num = -1;
static int hf_msg_pad = -1;

static int hf_dlm_node_idx = -1;
static int hf_dlm_lock_flags = -1;
static int hf_dlm_lock_flag_unused1 = -1;
static int hf_dlm_lock_flag_orphan = -1;
static int hf_dlm_lock_flag_parentable = -1;
static int hf_dlm_lock_flag_block = -1;
static int hf_dlm_lock_flag_local = -1;
static int hf_dlm_lock_flag_valblk = -1;
static int hf_dlm_lock_flag_noqueue = -1;
static int hf_dlm_lock_flag_convert = -1;
static int hf_dlm_lock_flag_nodlckwt = -1;
static int hf_dlm_lock_flag_unlock = -1;
static int hf_dlm_lock_flag_cancel = -1;
static int hf_dlm_lock_flag_deqall = -1;
static int hf_dlm_lock_flag_invvalblk = -1;
static int hf_dlm_lock_flag_syncsts = -1;
static int hf_dlm_lock_flag_timeout = -1;
static int hf_dlm_lock_flag_sngldlck = -1;
static int hf_dlm_lock_flag_findlocal = -1;
static int hf_dlm_lock_flag_proc_owned = -1;
static int hf_dlm_lock_flag_xid = -1;
static int hf_dlm_lock_flag_xid_conflict = -1;
static int hf_dlm_lock_flag_force = -1;
static int hf_dlm_lock_flag_revvalblk = -1;
static int hf_dlm_lock_flag_unused2 = -1;
static int hf_dlm_lock_flag_migration = -1;
static int hf_dlm_lock_flag_put_lvb = -1;
static int hf_dlm_lock_flag_get_lvb = -1;
static int hf_dlm_lock_flag_recovery = -1;
static int hf_dlm_am_flags = -1;
static int hf_dlm_fr_flags = -1;
static int hf_dlm_namelen = -1;
static int hf_dlm_name = -1;
static int hf_dlm_cookie = -1;
static int hf_dlm_requested_type = -1;
static int hf_dlm_lvb1 = -1;
static int hf_dlm_lvb2 = -1;
static int hf_dlm_lvb3 = -1;
static int hf_dlm_ast_type = -1;
static int hf_dlm_blocked_type = -1;
static int hf_dlm_dead_node = -1;
static int hf_dlm_domain_name_len = -1;
static int hf_dlm_domain_name = -1;
static int hf_dlm_proto_ver = -1;
static int hf_dlm_fs_proto_ver = -1;
static int hf_dlm_node_map = -1;
static int hf_dlm_master = -1;
static int hf_dlm_new_master = -1;
static int hf_dlm_mres_num_locks = -1;
static int hf_dlm_mres_flags = -1;
static int hf_dlm_mres_flag_recovery = -1;
static int hf_dlm_mres_flag_migration = -1;
static int hf_dlm_mres_flag_all_done = -1;
static int hf_dlm_mres_total_locks = -1;
static int hf_dlm_mres_mig_cookie = -1;
static int hf_dlm_mres_list = -1;
static int hf_dlm_mres_ml_flags = -1;
static int hf_dlm_mres_type = -1;
static int hf_dlm_mres_convert_type = -1;
static int hf_dlm_mres_highest_blocked = -1;
static int hf_dlm_mres_node = -1;
static int hf_dlm_qr_node = -1;
static int hf_dlm_qr_numregions = -1;
static int hf_dlm_qr_namelen = -1;
static int hf_dlm_qr_domain = -1;
static int hf_dlm_qr_region = -1;
static int hf_dlm_qn_nodenum = -1;
static int hf_dlm_qn_numnodes = -1;
static int hf_dlm_qn_namelen = -1;
static int hf_dlm_qn_domain = -1;
static int hf_dlm_qn_node = -1;
static int hf_dlm_qn_port = -1;
static int hf_dlm_qn_ip = -1;
static int hf_dlm_reco_lvb = -1;
static int hf_dlm_pad8 = -1;
static int hf_dlm_pad16 = -1;
static int hf_dlm_pad32 = -1;
static int hf_dlm_flags = -1;
static int hf_dlm_payload = -1;

#define O2NM_MAX_NAME_LEN	64
#define O2NM_NODE_MAP_IN_BYTES	32

#define OCFS2_DENTRY_LOCK_INO_START 18

/*
 * generic o2net constants
 */

#define O2NET_MSG_MAGIC			0xfa55
#define O2NET_MSG_STATUS_MAGIC		0xfa56
#define O2NET_MSG_KEEP_REQ_MAGIC	0xfa57
#define O2NET_MSG_KEEP_RESP_MAGIC	0xfa58
static const value_string o2net_magic[] = {
	{ O2NET_MSG_MAGIC,	     "Request" },
	{ O2NET_MSG_STATUS_MAGIC,    "Response" },
	{ O2NET_MSG_KEEP_REQ_MAGIC,  "Keepalive Request" },
	{ O2NET_MSG_KEEP_RESP_MAGIC, "Keepalive Response" },
	{ 0x0000,  NULL  }
};

/* DLM constants */
#define DLM_LVB_LEN  64
#define DLM_MOD_KEY (0x666c6172)

#if 0
enum dlm_query_join_response {
	JOIN_DISALLOW = 0,
	JOIN_OK,
	JOIN_OK_NO_MAP,
	JOIN_PROTOCOL_MISMATCH
};
#endif

/* DLM lock modes */
enum {
	LKM_IVMODE = -1,
	LKM_NLMODE = 0,
	LKM_CRMODE,
	LKM_CWMODE,
	LKM_PRMODE,
	LKM_PWMODE,
	LKM_EXMODE,
	LKM_MAXMODE
};

static const value_string dlm_lock_modes[] = {
	{ LKM_IVMODE, "IV" },
	{ LKM_NLMODE, "NL" },
	{ LKM_CRMODE, "CR" },
	{ LKM_CWMODE, "CW" },
	{ LKM_PRMODE, "PR" },
	{ LKM_PWMODE, "PW" },
	{ LKM_EXMODE, "EX" },
	{ 0x0000,  NULL  }
};

/* DLM message types */
enum {
	DLM_MASTER_REQUEST_MSG		= 500,
	DLM_UNUSED_MSG1			= 501,
	DLM_ASSERT_MASTER_MSG		= 502,
	DLM_CREATE_LOCK_MSG		= 503,
	DLM_CONVERT_LOCK_MSG		= 504,
	DLM_PROXY_AST_MSG		= 505,
	DLM_UNLOCK_LOCK_MSG		= 506,
	DLM_DEREF_LOCKRES_MSG		= 507,
	DLM_MIGRATE_REQUEST_MSG		= 508,
	DLM_MIG_LOCKRES_MSG		= 509,
	DLM_QUERY_JOIN_MSG		= 510,
	DLM_ASSERT_JOINED_MSG		= 511,
	DLM_CANCEL_JOIN_MSG		= 512,
	DLM_EXIT_DOMAIN_MSG		= 513,
	DLM_MASTER_REQUERY_MSG		= 514,
	DLM_LOCK_REQUEST_MSG		= 515,
	DLM_RECO_DATA_DONE_MSG		= 516,
	DLM_BEGIN_RECO_MSG		= 517,
	DLM_FINALIZE_RECO_MSG		= 518,
	DLM_QUERY_REGION_MSG		= 519,
	DLM_QUERY_NODEINFO_MSG		= 520
};

static const value_string dlm_magic[] = {
	{ DLM_MASTER_REQUEST_MSG,  "Master Request" },
	{ DLM_UNUSED_MSG1,	   "Unused 1" },
	{ DLM_ASSERT_MASTER_MSG,   "Assert Master" },
	{ DLM_CREATE_LOCK_MSG,	   "Create Lock" },
	{ DLM_CONVERT_LOCK_MSG,	   "Convert Lock" },
	{ DLM_PROXY_AST_MSG,	   "Proxy AST" },
	{ DLM_UNLOCK_LOCK_MSG,	   "Unlock Lock" },
	{ DLM_DEREF_LOCKRES_MSG,   "Deref Lockres" },
	{ DLM_MIGRATE_REQUEST_MSG, "Migrate Request" },
	{ DLM_MIG_LOCKRES_MSG,	   "Migrate Lockres" },
	{ DLM_QUERY_JOIN_MSG,	   "Query Join" },
	{ DLM_ASSERT_JOINED_MSG,   "Assert Join" },
	{ DLM_CANCEL_JOIN_MSG,	   "Cancel Join" },
	{ DLM_EXIT_DOMAIN_MSG,	   "Exit Domain" },
	{ DLM_MASTER_REQUERY_MSG,  "Master Requery" },
	{ DLM_LOCK_REQUEST_MSG,	   "Lock Request" },
	{ DLM_RECO_DATA_DONE_MSG,  "Recovery Data Done" },
	{ DLM_BEGIN_RECO_MSG,	   "Begin Recovery" },
	{ DLM_FINALIZE_RECO_MSG,   "Finalize Recovery" },
	{ DLM_QUERY_REGION_MSG,	   "Query Region" },
	{ DLM_QUERY_NODEINFO_MSG,  "Query Node Info" },
	{ 0x0000, NULL }
};

static value_string_ext ext_dlm_magic = VALUE_STRING_EXT_INIT(dlm_magic);


enum {
	DLM_GRANTED_LIST = 0,
	DLM_CONVERTING_LIST,
	DLM_BLOCKED_LIST,
	DLM_MAX_LIST
};

static const value_string dlm_lockres_list[] = {
	{ DLM_GRANTED_LIST,    "Granted" },
	{ DLM_CONVERTING_LIST, "Converting" },
	{ DLM_BLOCKED_LIST,    "Blocked" },
	{ 0x0000, NULL }
};


#if 0
enum dlm_status {
	DLM_NORMAL = 0,
	DLM_GRANTED,
	DLM_DENIED,
	DLM_DENIED_NOLOCKS,
	DLM_WORKING,
	DLM_BLOCKED,
	DLM_BLOCKED_ORPHAN,
	DLM_DENIED_GRACE_PERIOD,
	DLM_SYSERR,
	DLM_NOSUPPORT,
	DLM_CANCELGRANT,
	DLM_IVLOCKID,
	DLM_SYNC,
	DLM_BADTYPE,
	DLM_BADRESOURCE,
	DLM_MAXHANDLES,
	DLM_NOCLINFO,
	DLM_NOLOCKMGR,
	DLM_NOPURGED,
	DLM_BADARGS,
	DLM_VOID,
	DLM_NOTQUEUED,
	DLM_IVBUFLEN,
	DLM_CVTUNGRANT,
	DLM_BADPARAM,
	DLM_VALNOTVALID,
	DLM_REJECTED,
	DLM_ABORT,
	DLM_CANCEL,
	DLM_IVRESHANDLE,
	DLM_DEADLOCK,
	DLM_DENIED_NOASTS,
	DLM_FORWARD,
	DLM_TIMEOUT,
	DLM_IVGROUPID,
	DLM_VERS_CONFLICT,
	DLM_BAD_DEVICE_PATH,
	DLM_NO_DEVICE_PERMISSION,
	DLM_NO_CONTROL_DEVICE,
	DLM_RECOVERING,
	DLM_MIGRATING,
	DLM_MAXSTATS
};

static const value_string dlm_errnames[] = {
	{ DLM_NORMAL,		    "DLM_NORMAL" },
	{ DLM_GRANTED,		    "DLM_GRANTED" },
	{ DLM_DENIED,		    "DLM_DENIED" },
	{ DLM_DENIED_NOLOCKS,	    "DLM_DENIED_NOLOCKS" },
	{ DLM_WORKING,		    "DLM_WORKING" },
	{ DLM_BLOCKED,		    "DLM_BLOCKED" },
	{ DLM_BLOCKED_ORPHAN,	    "DLM_BLOCKED_ORPHAN" },
	{ DLM_DENIED_GRACE_PERIOD,  "DLM_DENIED_GRACE_PERIOD" },
	{ DLM_SYSERR,		    "DLM_SYSERR" },
	{ DLM_NOSUPPORT,	    "DLM_NOSUPPORT" },
	{ DLM_CANCELGRANT,	    "DLM_CANCELGRANT" },
	{ DLM_IVLOCKID,		    "DLM_IVLOCKID" },
	{ DLM_SYNC,		    "DLM_SYNC" },
	{ DLM_BADTYPE,		    "DLM_BADTYPE" },
	{ DLM_BADRESOURCE,	    "DLM_BADRESOURCE" },
	{ DLM_MAXHANDLES,	    "DLM_MAXHANDLES" },
	{ DLM_NOCLINFO,		    "DLM_NOCLINFO" },
	{ DLM_NOLOCKMGR,	    "DLM_NOLOCKMGR" },
	{ DLM_NOPURGED,		    "DLM_NOPURGED" },
	{ DLM_BADARGS,		    "DLM_BADARGS" },
	{ DLM_VOID,		    "DLM_VOID" },
	{ DLM_NOTQUEUED,	    "DLM_NOTQUEUED" },
	{ DLM_IVBUFLEN,		    "DLM_IVBUFLEN" },
	{ DLM_CVTUNGRANT,	    "DLM_CVTUNGRANT" },
	{ DLM_BADPARAM,		    "DLM_BADPARAM" },
	{ DLM_VALNOTVALID,	    "DLM_VALNOTVALID" },
	{ DLM_REJECTED,		    "DLM_REJECTED" },
	{ DLM_ABORT,		    "DLM_ABORT" },
	{ DLM_CANCEL,		    "DLM_CANCEL" },
	{ DLM_IVRESHANDLE,	    "DLM_IVRESHANDLE" },
	{ DLM_DEADLOCK,		    "DLM_DEADLOCK" },
	{ DLM_DENIED_NOASTS,	    "DLM_DENIED_NOASTS" },
	{ DLM_FORWARD,		    "DLM_FORWARD" },
	{ DLM_TIMEOUT,		    "DLM_TIMEOUT" },
	{ DLM_IVGROUPID,	    "DLM_IVGROUPID" },
	{ DLM_VERS_CONFLICT,	    "DLM_VERS_CONFLICT" },
	{ DLM_BAD_DEVICE_PATH,	    "DLM_BAD_DEVICE_PATH" },
	{ DLM_NO_DEVICE_PERMISSION, "DLM_NO_DEVICE_PERMISSION" },
	{ DLM_NO_CONTROL_DEVICE ,   "DLM_NO_CONTROL_DEVICE " },
	{ DLM_RECOVERING,	    "DLM_RECOVERING" },
	{ DLM_MIGRATING,	    "DLM_MIGRATING" },
	{ DLM_MAXSTATS,		    "DLM_MAXSTATS" },
	{ 0x0000,  NULL }
};

value_string_ext ext_dlm_errnames = VALUE_STRING_EXT_INIT(dlm_errnames);

static const value_string dlm_errmsgs[] = {
	{ DLM_NORMAL,		    "request in progress" },
	{ DLM_GRANTED,		    "request granted" },
	{ DLM_DENIED,		    "request denied" },
	{ DLM_DENIED_NOLOCKS,	    "request denied, out of system resources" },
	{ DLM_WORKING,		    "async request in progress" },
	{ DLM_BLOCKED,		    "lock request blocked" },
	{ DLM_BLOCKED_ORPHAN,	    "lock request blocked by a orphan lock" },
	{ DLM_DENIED_GRACE_PERIOD,  "topological change in progress" },
	{ DLM_SYSERR,		    "system error" },
	{ DLM_NOSUPPORT,	    "unsupported" },
	{ DLM_CANCELGRANT,	    "can't cancel convert: already granted" },
	{ DLM_IVLOCKID,		    "bad lockid" },
	{ DLM_SYNC,		    "synchronous request granted" },
	{ DLM_BADTYPE,		    "bad resource type" },
	{ DLM_BADRESOURCE,	    "bad resource handle" },
	{ DLM_MAXHANDLES,	    "no more resource handles" },
	{ DLM_NOCLINFO,		    "can't contact cluster manager" },
	{ DLM_NOLOCKMGR,	    "can't contact lock manager" },
	{ DLM_NOPURGED,		    "can't contact purge daemon" },
	{ DLM_BADARGS,		    "bad api args" },
	{ DLM_VOID,		    "no status" },
	{ DLM_NOTQUEUED,	    "NOQUEUE was specified and request failed" },
	{ DLM_IVBUFLEN,		    "invalid resource name length" },
	{ DLM_CVTUNGRANT,	    "attempted to convert ungranted lock" },
	{ DLM_BADPARAM,		    "invalid lock mode specified" },
	{ DLM_VALNOTVALID,	    "value block has been invalidated" },
	{ DLM_REJECTED,		    "request rejected, unrecognized client" },
	{ DLM_ABORT,		    "blocked lock request cancelled" },
	{ DLM_CANCEL,		    "conversion request cancelled" },
	{ DLM_IVRESHANDLE,	    "invalid resource handle" },
	{ DLM_DEADLOCK,		    "deadlock recovery refused this request" },
	{ DLM_DENIED_NOASTS,	    "failed to allocate AST" },
	{ DLM_FORWARD,		    "request must wait for primary's response" },
	{ DLM_TIMEOUT,		    "timeout value for lock has expired" },
	{ DLM_IVGROUPID,	    "invalid group specification" },
	{ DLM_VERS_CONFLICT,	    "version conflicts prevent request handling" },
	{ DLM_BAD_DEVICE_PATH,	    "Locks device does not exist or path wrong" },
	{ DLM_NO_DEVICE_PERMISSION, "Client has insufficient perms for device" },
	{ DLM_NO_CONTROL_DEVICE,    "Cannot set options on opened device " },
	{ DLM_RECOVERING,	    "lock resource being recovered" },
	{ DLM_MIGRATING,	    "lock resource being migrated" },
	{ DLM_MAXSTATS,		    "invalid error number" },
	{ 0x0000,  NULL }
};

value_string_ext ext_dlm_errmsgs = VALUE_STRING_EXT_INIT(dlm_errmsgs);
#endif


#define DLM_ASSERT_MASTER_MLE_CLEANUP      0x00000001
#define DLM_ASSERT_MASTER_REQUERY          0x00000002
#define DLM_ASSERT_MASTER_FINISH_MIGRATION 0x00000004
static const value_string dlm_assert_master_flags[] = {
	{ DLM_ASSERT_MASTER_MLE_CLEANUP,      "cleanup" },
	{ DLM_ASSERT_MASTER_REQUERY,          "requery" },
	{ DLM_ASSERT_MASTER_FINISH_MIGRATION, "finish" },
	{ 0x0000,  NULL }
};

#define DLM_FINALIZE_STAGE2  0x01
static const value_string dlm_finalize_reco_flags[] = {
	{ DLM_FINALIZE_STAGE2, "stage2" },
	{ 0x0000,  NULL }
};

enum dlm_ast_type {
	DLM_AST = 0,
	DLM_BAST,
	DLM_ASTUNLOCK
};

static const value_string dlm_proxy_ast_types[] = {
	{ DLM_AST,       "AST" },
	{ DLM_BAST,      "BAST" },
	{ DLM_ASTUNLOCK, "Unlock AST (unused)" },
	{ 0x0000,  NULL }
};

/* DLM lock flag types */
enum {
	DLM_LOCK_FLAGS_PUT_LVB = 0x20000000,
	DLM_LOCK_FLAGS_GET_LVB = 0x40000000
};


static int dlm_cookie_handler(proto_tree *tree, tvbuff_t *tvb, guint offset, int hf_cookie)
{
	proto_item *item;
	guint64 cookie;
	guint64 seq;
	guint8 node_idx;

	item = proto_tree_add_item(tree, hf_cookie, tvb, offset, 8, ENC_BIG_ENDIAN);
	cookie = tvb_get_ntoh64(tvb, offset);

	cookie >>= 56;
	node_idx = (guint8)((cookie >> 56) & G_GINT64_CONSTANT(0xff));
	seq = cookie & G_GINT64_CONSTANT(0x00ffffffffffffff);

	proto_item_append_text(item, " (%u:%" PRIu64 ")", node_idx, seq);

	return offset + 8;
}

static int dlm_lkm_flags_handler(proto_tree *tree, tvbuff_t *tvb, guint offset,
				 guint32 *dlm_lock_flags_ptr)
{
	static int * const flags[] = {
		&hf_dlm_lock_flag_unused1,
		&hf_dlm_lock_flag_orphan,
		&hf_dlm_lock_flag_parentable,
		&hf_dlm_lock_flag_block,
		&hf_dlm_lock_flag_local,
		&hf_dlm_lock_flag_valblk,
		&hf_dlm_lock_flag_noqueue,
		&hf_dlm_lock_flag_convert,
		&hf_dlm_lock_flag_nodlckwt,
		&hf_dlm_lock_flag_unlock,
		&hf_dlm_lock_flag_cancel,
		&hf_dlm_lock_flag_deqall,
		&hf_dlm_lock_flag_invvalblk,
		&hf_dlm_lock_flag_syncsts,
		&hf_dlm_lock_flag_timeout,
		&hf_dlm_lock_flag_sngldlck,
		&hf_dlm_lock_flag_findlocal,
		&hf_dlm_lock_flag_proc_owned,
		&hf_dlm_lock_flag_xid,
		&hf_dlm_lock_flag_xid_conflict,
		&hf_dlm_lock_flag_force,
		&hf_dlm_lock_flag_revvalblk,
		&hf_dlm_lock_flag_unused2,
		&hf_dlm_lock_flag_migration,
		&hf_dlm_lock_flag_put_lvb,
		&hf_dlm_lock_flag_get_lvb,
		&hf_dlm_lock_flag_recovery,
		NULL
	};

	if(dlm_lock_flags_ptr != NULL){
		*dlm_lock_flags_ptr = tvb_get_ntohl(tvb, offset);
	}
	proto_tree_add_bitmask_with_flags(tree, tvb, offset, hf_dlm_lock_flags,
					ett_dtm_lock_flags, flags, ENC_BIG_ENDIAN, BMT_NO_INT | BMT_NO_FALSE | BMT_NO_TFS);
	return offset + 4;
}

static int dlm_name_handler(proto_tree *tree, tvbuff_t *tvb, guint offset, int namelen)
{
	guint8 lock_type;
	guint64 blkno;
	proto_item *ti;

	ti = proto_tree_add_item(tree, hf_dlm_name, tvb, offset, namelen, ENC_ASCII);
	lock_type = tvb_get_guint8(tvb, offset);
	if (lock_type == 'N') {
		blkno = tvb_get_ntoh64(tvb, offset + OCFS2_DENTRY_LOCK_INO_START);
		proto_item_append_text(ti, "%08x", (unsigned int)blkno);
	}

	return offset + namelen;
}

/*
 * We would like to get one whole lockres into a single network
 * message whenever possible.  Generally speaking, there will be
 * at most one dlm_lock on a lockres for each node in the cluster,
 * plus (infrequently) any additional locks coming in from userdlm.
 *
 * struct _dlm_lockres_page
 * {
 *	dlm_migratable_lockres mres;
 *	dlm_migratable_lock ml[DLM_MAX_MIGRATABLE_LOCKS];
 *	guint8 pad[DLM_MIG_LOCKRES_RESERVED];
 * };
 *
 * from ../cluster/tcp.h
 *    NET_MAX_PAYLOAD_BYTES  (4096 - sizeof(net_msg))
 *    (roughly 4080 bytes)
 * and sizeof(dlm_migratable_lockres) = 112 bytes
 * and sizeof(dlm_migratable_lock) = 16 bytes
 *
 * Choosing DLM_MAX_MIGRATABLE_LOCKS=240 and
 * DLM_MIG_LOCKRES_RESERVED=128 means we have this:
 *
 *  (DLM_MAX_MIGRATABLE_LOCKS * sizeof(dlm_migratable_lock)) +
 *     sizeof(dlm_migratable_lockres) + DLM_MIG_LOCKRES_RESERVED =
 *        NET_MAX_PAYLOAD_BYTES
 *  (240 * 16) + 112 + 128 = 4080
 *
 * So a lockres would need more than 240 locks before it would
 * use more than one network packet to recover.  Not too bad.
 */

static void dissect_dlm_migrate_lockres(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	unsigned int i;
	guint32 num_locks;

	static int * const mres_flags[] = {
		&hf_dlm_mres_flag_recovery,
		&hf_dlm_mres_flag_migration,
		&hf_dlm_mres_flag_all_done,
		NULL
	};

	/* master */
	proto_tree_add_item(tree, hf_dlm_master, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	/* lockname_len */
	proto_tree_add_item(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	/* num_locks */
	proto_tree_add_item_ret_uint(tree, hf_dlm_mres_num_locks, tvb, offset, 1, ENC_BIG_ENDIAN, &num_locks);
	offset += 1;

	/* no locks were found on this lockres! done! */
	if (num_locks == 0)
		return;

	/* flags */
	proto_tree_add_bitmask_with_flags(tree, tvb, offset, hf_dlm_mres_flags,
					ett_mres_flags, mres_flags, ENC_BIG_ENDIAN, BMT_NO_INT | BMT_NO_FALSE | BMT_NO_TFS);
	offset += 1;

	/* total_locks */
	proto_tree_add_item(tree, hf_dlm_mres_total_locks, tvb, offset, 4, ENC_BIG_ENDIAN);
	offset += 4;

	/* mig_cookie */
	offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_mres_mig_cookie);

	/* lockname */
	proto_tree_add_item(tree, hf_dlm_name, tvb, offset, 32, ENC_ASCII);
	offset += 32;

	/* lvb */
	proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
	offset += 24;

	proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
	offset += 24;

	proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
	offset += 16;

	/* dlm_migratable_lock */
	for (i = 0; i < num_locks; i++) {
		proto_tree *subtree;

		subtree = proto_tree_add_subtree_format(tree, tvb, offset, 16,
					   ett_migrate_lockres_locks, NULL, "Locks%d: ", i + 1);

		/* cookie */
		offset = dlm_cookie_handler(subtree, tvb, offset, hf_dlm_mres_mig_cookie);

		proto_tree_add_item(subtree, hf_dlm_pad8, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;

		/* list */
		proto_tree_add_item(subtree, hf_dlm_mres_list, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;

		/* flags */
		proto_tree_add_item(subtree, hf_dlm_mres_ml_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;

		/* type */
		proto_tree_add_item(subtree, hf_dlm_mres_type, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;

		/* convert_type */
		proto_tree_add_item(subtree, hf_dlm_mres_convert_type, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;

		/* highest_blocked */
		proto_tree_add_item(subtree, hf_dlm_mres_highest_blocked, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;

		proto_tree_add_item(subtree, hf_dlm_mres_node, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;
	}
}

static void
dlm_fmt_revision( gchar *result, guint32 revision )
{
	snprintf( result, ITEM_LABEL_LENGTH, "%d.%02d", (guint8)(( revision & 0xFF00 ) >> 8), (guint8)(revision & 0xFF) );
}

#define DLM_QUERY_JOIN_REQUEST_OFF_DLMPROTO	4
#define DLM_QUERY_JOIN_REQUEST_OFF_FSPROTO	6
#define DLM_QUERY_JOIN_REQUEST_OFF_DOMAIN	8
#define DLM_QUERY_JOIN_REQUEST_OFF_NODEMAP	72
#define DLM_QUERY_JOIN_REQUEST_LEN_DLMPROTO	2
#define DLM_QUERY_JOIN_REQUEST_LEN_FSPROTO	2
#define DLM_QUERY_JOIN_REQUEST_LEN_DOMAIN	64
#define DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP	32

#define DLM_QUERY_JOIN_REQUEST_OLD_LEN		100
static void dissect_dlm_query_join_request(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	guint8 cc, *node_bits_array;
	guint8 *node_map;
	gint len;
	unsigned int i, j;
	gboolean oldver = FALSE;

	node_bits_array = (guint8 *)wmem_alloc0(wmem_packet_scope(), (DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP*8)+1);

	len = tvb_reported_length_remaining(tvb, offset);
	if (len == DLM_QUERY_JOIN_REQUEST_OLD_LEN)
		oldver = TRUE;

	/* node_idx */
	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	/* name_len */
	proto_tree_add_item(tree, hf_dlm_domain_name_len, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	if (!oldver)
	{
	    /* dlm_proto */
	    proto_tree_add_item(tree, hf_dlm_proto_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
	    offset += 2;

	    /* fs_proto */
	    proto_tree_add_item(tree, hf_dlm_fs_proto_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
	    offset += 2;
	}

	/* domain */
	proto_tree_add_item(tree, hf_dlm_domain_name, tvb, offset, 64, ENC_ASCII);
	offset += 64;

	/* node_map */
	node_map = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, offset, DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP);

	for (i = 0; i < DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP; i++) {
		cc = node_map[i];
		for (j = 0; j < 8; j++)
			node_bits_array[i * 8 + j] =
					(((cc >> j) & 1) ? '1' : '0');
	}

	/* NULL terminate string */
	node_bits_array[(DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP*8)] = 0;
	proto_tree_add_bytes_format_value(tree, hf_dlm_node_map, tvb, offset, DLM_QUERY_JOIN_REQUEST_LEN_NODEMAP, NULL, "%s", node_bits_array);
}

#define O2HB_MAX_REGION_NAME_LEN 32

static void dissect_dlm_query_region(proto_tree *tree, tvbuff_t *tvb,
				     guint offset)
{
	guint32 i, num_regions;
	guchar *region;

	/* qr_node */
	proto_tree_add_item(tree, hf_dlm_qr_node, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	/* qr_numregions */
	proto_tree_add_item_ret_uint(tree, hf_dlm_qr_numregions, tvb, offset, 1, ENC_BIG_ENDIAN, &num_regions);
	offset += 1;

	/* qr_namelen */
	proto_tree_add_item(tree, hf_dlm_qr_namelen, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	/* qr_domain */
	proto_tree_add_item(tree, hf_dlm_qr_domain, tvb, offset, 64, ENC_ASCII);
	offset += 64;

	/* qr_regions */
	for (i = 0; i < num_regions; i++, offset += O2HB_MAX_REGION_NAME_LEN) {
		region = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, O2HB_MAX_REGION_NAME_LEN, ENC_ASCII);
		proto_tree_add_string_format(tree, hf_dlm_qr_region, tvb, offset, 1,
					   region, "Region%d: %s", i + 1, region);
	}
}

static void dissect_dlm_query_nodeinfo(proto_tree *tree, tvbuff_t *tvb, guint offset)
{
	guint32 i, num_nodes;

	/* qn_nodenum */
	proto_tree_add_item(tree, hf_dlm_qn_nodenum, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	/* qn_numnodes */
	proto_tree_add_item_ret_uint(tree, hf_dlm_qn_numnodes, tvb, offset, 1, ENC_BIG_ENDIAN, &num_nodes);
	offset += 1;

	/* qn_namelen */
	proto_tree_add_item(tree, hf_dlm_qn_namelen, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	/* qn_domain */
	proto_tree_add_item(tree, hf_dlm_qn_domain, tvb, offset, 64, ENC_ASCII);
	offset += 64;

	/* qn_nodes */
	for (i = 0; i < num_nodes; i++) {
		proto_tree *subtree;

		/* ni_nodenum */
		subtree = proto_tree_add_subtree_format(tree, tvb, offset, 8,
					   ett_query_nodeinfo, NULL, "Node%d: ", i+1);

		proto_tree_add_item(subtree, hf_dlm_qn_node, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;

		proto_tree_add_item(subtree, hf_dlm_pad8, tvb, offset, 1, ENC_BIG_ENDIAN);
		offset += 1;

		proto_tree_add_item(subtree, hf_dlm_qn_port, tvb, offset, 2, ENC_BIG_ENDIAN);
		offset += 2;

		proto_tree_add_item(subtree, hf_dlm_qn_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
		offset += 4;
	}
}

static int dissect_master_msg(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_flag)
{
	guint32 namelen;

	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	if (hf_flag == -1)
		proto_tree_add_item(tree, hf_dlm_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
	else
		proto_tree_add_item(tree, hf_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
	offset += 4;

	return dlm_name_handler(tree, tvb, offset, namelen);
}

static int dissect_create_lock_msg(proto_tree *tree, tvbuff_t *tvb, int offset,
				   guint32 *dlm_lock_flags_ptr)
{
	guint32 namelen;

	offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_cookie);
	offset = dlm_lkm_flags_handler(tree, tvb, offset, dlm_lock_flags_ptr);

	proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_requested_type, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
	offset += 1;

	dlm_name_handler(tree, tvb, offset, namelen);
	return offset + O2NM_MAX_NAME_LEN;
}

static int dissect_convert_lock_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	guint32 dlm_lock_flags;
	offset = dissect_create_lock_msg(tree, tvb, offset, &dlm_lock_flags);

	if(dlm_lock_flags & DLM_LOCK_FLAGS_PUT_LVB){
		proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
		offset += 24;

		proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
		offset += 24;

		proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
		offset += 16;
	}

	return offset;
}

static int dissect_unlock_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	guint32 namelen;
	guint32 dlm_lock_flags;

	offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_cookie);
	offset = dlm_lkm_flags_handler(tree, tvb, offset, &dlm_lock_flags);

	proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
	offset += 1;

	dlm_name_handler(tree, tvb, offset, namelen);
	offset += O2NM_MAX_NAME_LEN;

	if(dlm_lock_flags & DLM_LOCK_FLAGS_PUT_LVB){
		proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
		offset += 24;

		proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
		offset += 24;

		proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
		offset += 16;
	}

	return offset;
}

static int dissect_proxy_ast_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	guint32 namelen;
	guint32 dlm_lock_flags;

	offset = dlm_cookie_handler(tree, tvb, offset, hf_dlm_cookie);
	offset = dlm_lkm_flags_handler(tree, tvb, offset, &dlm_lock_flags);

	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_ast_type, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_blocked_type, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
	offset += 1;

	dlm_name_handler(tree, tvb, offset, namelen);
	offset += O2NM_MAX_NAME_LEN;

	if(dlm_lock_flags & DLM_LOCK_FLAGS_GET_LVB){
		proto_tree_add_item(tree, hf_dlm_lvb1, tvb, offset, 24, ENC_NA);
		offset += 24;

		proto_tree_add_item(tree, hf_dlm_lvb2, tvb, offset, 24, ENC_NA);
		offset += 24;

		proto_tree_add_item(tree, hf_dlm_lvb3, tvb, offset, 16, ENC_NA);
		offset += 16;
	}
	return offset;
}

static int dissect_deref_lockres_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	guint32 namelen;

	proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
	offset += 4;

	proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
	offset += 1;

	return dlm_name_handler(tree, tvb, offset, namelen);
}

static int dissect_migrate_request_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	guint32 namelen;

	proto_tree_add_item(tree, hf_dlm_master, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_new_master, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
	offset += 4;

	return dlm_name_handler(tree, tvb, offset, namelen);
}

static int dissect_dlm_joined_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	proto_tree_add_item(tree, hf_dlm_domain_name_len, tvb, offset, 1, ENC_BIG_ENDIAN);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_domain_name, tvb, offset, 64, ENC_ASCII);
	offset += 64;

	return offset;
}

static int dissect_master_requery_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	guint32 namelen;

	proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item_ret_uint(tree, hf_dlm_namelen, tvb, offset, 1, ENC_BIG_ENDIAN, &namelen);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
	offset += 4;

	return dlm_name_handler(tree, tvb, offset, namelen);
}

static int dissect_lock_request_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_dead_node, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_pad16, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
	offset += 4;

	return offset;
}

static int dissect_reco_data_done_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	offset = dissect_lock_request_msg(tree, tvb, offset);

	proto_tree_add_item(tree, hf_dlm_reco_lvb, tvb, offset, 64, ENC_NA);
	offset += 64;

	return offset;
}

static int dissect_finalize_reco_msg(proto_tree *tree, tvbuff_t *tvb, int offset)
{
	proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_dead_node, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_fr_flags, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_pad8, tvb, offset, 1, ENC_NA);
	offset += 1;

	proto_tree_add_item(tree, hf_dlm_pad32, tvb, offset, 4, ENC_BIG_ENDIAN);
	offset += 4;

	return offset;
}

static int dissect_ocfs2_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	proto_tree *subtree;
	proto_item *ti;
	guint32 len, msg_type;
	guint32 magic;
	tvbuff_t   *next_tvb;
	int offset = 0;

	magic = tvb_get_ntohs(tvb, offset);
	if (try_val_to_str(magic, o2net_magic) == NULL)
		return 0;

	col_set_str(pinfo->cinfo, COL_PROTOCOL, "OCFS2");
	col_clear(pinfo->cinfo, COL_INFO);

	ti = proto_tree_add_item(tree, proto_ocfs2, tvb, offset, -1, ENC_NA);
	subtree = proto_item_add_subtree(ti, ett_ocfs2);

	proto_tree_add_item(subtree, hf_msg_magic, tvb, offset, 2, ENC_BIG_ENDIAN);
	offset += 2;

	proto_tree_add_item_ret_uint(subtree, hf_msg_data_len, tvb, 2, 2, ENC_BIG_ENDIAN, &len);
	offset += 2;

	proto_tree_add_item_ret_uint(subtree, hf_msg_msg_type, tvb, 4, 2, ENC_BIG_ENDIAN, &msg_type);
	offset += 2;

	switch(magic){
	case O2NET_MSG_KEEP_REQ_MAGIC:
		col_append_sep_str(pinfo->cinfo, COL_INFO, " | ", "Keepalive Request");
		break;
	case O2NET_MSG_KEEP_RESP_MAGIC:
		col_append_sep_str(pinfo->cinfo, COL_INFO, " | ", "Keepalive Response");
		break;
	default:
		col_append_sep_str(pinfo->cinfo, COL_INFO, " | ",
			val_to_str_ext(msg_type, &ext_dlm_magic, "Unknown Type (0x%02x)") );
		break;
	}

	col_set_fence(pinfo->cinfo, COL_INFO);

	proto_tree_add_item(subtree, hf_msg_pad, tvb, 4, 2, ENC_BIG_ENDIAN);
	offset += 2;

	proto_tree_add_item(subtree, hf_msg_sys_status, tvb, 8, 4, ENC_BIG_ENDIAN);
	offset += 4;

	proto_tree_add_item(subtree, hf_msg_status, tvb, 12, 4, ENC_BIG_ENDIAN);
	offset += 4;

	proto_tree_add_item(subtree, hf_msg_key, tvb, 16, 4, ENC_BIG_ENDIAN);
	offset += 4;

	proto_tree_add_item(subtree, hf_msg_msg_num, tvb, 20, 4, ENC_BIG_ENDIAN);
	offset += 4;

	if (magic == O2NET_MSG_MAGIC) {
		switch (msg_type) {
		case DLM_MASTER_REQUEST_MSG:
			dissect_master_msg(subtree, tvb, offset, -1);
			break;
		case DLM_ASSERT_MASTER_MSG:
			dissect_master_msg(subtree, tvb, offset, hf_dlm_am_flags);
			break;
		case DLM_CREATE_LOCK_MSG:
			dissect_create_lock_msg(subtree, tvb, offset, NULL);
			break;
		case DLM_CONVERT_LOCK_MSG:
			dissect_convert_lock_msg(subtree, tvb, offset);
			break;
		case DLM_PROXY_AST_MSG:
			dissect_proxy_ast_msg(subtree, tvb, offset);
			break;
		case DLM_UNLOCK_LOCK_MSG:
			dissect_unlock_msg(subtree, tvb, offset);
			break;
		case DLM_DEREF_LOCKRES_MSG:
			dissect_deref_lockres_msg(subtree, tvb, offset);
			break;
		case DLM_MIGRATE_REQUEST_MSG:
			dissect_migrate_request_msg(subtree, tvb, offset);
			break;
		case DLM_MIG_LOCKRES_MSG:
			dissect_dlm_migrate_lockres(subtree, tvb, offset);
			break;
		case DLM_QUERY_JOIN_MSG:
			dissect_dlm_query_join_request(subtree, tvb, offset);
			break;
		case DLM_ASSERT_JOINED_MSG:
		case DLM_CANCEL_JOIN_MSG:
			dissect_dlm_joined_msg(subtree, tvb, offset);
			break;
		case DLM_EXIT_DOMAIN_MSG:
			proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, ENC_NA);
			break;
		case DLM_MASTER_REQUERY_MSG:
			dissect_master_requery_msg(subtree, tvb, offset);
			break;
		case DLM_LOCK_REQUEST_MSG:
		case DLM_BEGIN_RECO_MSG:
			dissect_lock_request_msg(subtree, tvb, offset);
			break;
		case DLM_RECO_DATA_DONE_MSG:
			dissect_reco_data_done_msg(subtree, tvb, offset);
			break;
		case DLM_FINALIZE_RECO_MSG:
			dissect_finalize_reco_msg(subtree, tvb, offset);
			break;
		case DLM_QUERY_REGION_MSG:
			dissect_dlm_query_region(subtree, tvb, offset);
			break;
		case DLM_QUERY_NODEINFO_MSG:
			dissect_dlm_query_nodeinfo(subtree, tvb, offset);
			break;
		default:
			proto_tree_add_item(tree, hf_dlm_payload, tvb, offset, len, ENC_NA);
			break;
		}
	} else {
		next_tvb = tvb_new_subset_length(tvb, offset, len);
		call_data_dissector(next_tvb, pinfo, tree);
	}

	return tvb_reported_length(tvb);
}

static guint
get_ocfs2_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
	guint16 plen;

	/* Get the length of the data from header. */
	plen = tvb_get_ntohs(tvb, offset + 2);

	/* That length doesn't include the header itself, add that in. */
	return plen + 24;
}

static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
	guint32 magic;
	int offset = 0;

	if (!tvb_bytes_exist(tvb, offset, 2))
		return 0;

	magic = tvb_get_ntohs(tvb, offset);
	if (try_val_to_str(magic, o2net_magic) == NULL)
		return 0;

	tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, get_ocfs2_pdu_len, dissect_ocfs2_pdu, data);
	return tvb_captured_length(tvb);
}

void proto_register_ocfs2(void)
{
	static hf_register_info hf[] = {
		/* ocfs2_msg */
		{ &hf_msg_magic,
			{ "Magic", "ocfs2.msg.magic", FT_UINT16, BASE_HEX,
			  VALS(o2net_magic), 0x0,
			  "Magic number identifier of O2NET-over-TCPmessage",
			  HFILL
			}
		},
		{ &hf_msg_data_len,
			{ "Len", "ocfs2.msg.data_len", FT_UINT16, BASE_DEC,
			  NULL, 0x0, "Data length", HFILL
			}
		},
		{ &hf_msg_msg_type,
			{ "Type", "ocfs2.msg.msg_type", FT_UINT16, BASE_DEC|BASE_EXT_STRING,
			  &ext_dlm_magic, 0x0, "Message type", HFILL
			}
		},
		{ &hf_msg_pad,
			{ "Pad", "ocfs2.msg.pad", FT_UINT16, BASE_HEX,
			  NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_msg_sys_status,
			{ "Sys Status",	"ocfs2.msg.sys_status", FT_UINT32,
			  BASE_DEC, NULL, 0x0,
			  "System level status return code", HFILL
			}
		},
		{ &hf_msg_status,
			{ "Status", "ocfs2.msg.status", FT_UINT32, BASE_DEC,
			  NULL, 0x0, "Return code", HFILL
			}
		},
		{ &hf_msg_key,
			{ "Key", "ocfs2.msg.key", FT_UINT32, BASE_HEX, NULL,
			  0x0, NULL, HFILL
			}
		},
		{ &hf_msg_msg_num,
			{ "Num", "ocfs2.msg.msg_num", FT_UINT32, BASE_DEC, NULL,
			  0x0, "Message identification number", HFILL
			}
		},
		{ &hf_dlm_node_idx,
			{ "Node", "ocfs2.dlm.node_idx", FT_UINT8, BASE_DEC,
			  NULL, 0x0, "Node index", HFILL
			}
		},
		{ &hf_dlm_lock_flags,
			{ "Flags", "ocfs2.dlm.lock.flags", FT_UINT32, BASE_HEX,
			  NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_unused1,
			{ "unused", "ocfs2.dlm.lock.flags.unused", FT_UINT32, BASE_HEX,
			  NULL, 0x0000000F, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_orphan,
			{ "orphan", "ocfs2.dlm.lock.flags.orphan", FT_BOOLEAN, 32,
			  NULL, 0x00000010, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_parentable,
			{ "parentable", "ocfs2.dlm.lock.flags.parentable", FT_BOOLEAN, 32,
			  NULL, 0x00000020, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_block,
			{ "block", "ocfs2.dlm.lock.flags.block", FT_BOOLEAN, 32,
			  NULL, 0x00000040, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_local,
			{ "local", "ocfs2.dlm.lock.flags.local", FT_BOOLEAN, 32,
			  NULL, 0x00000080, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_valblk,
			{ "valblk", "ocfs2.dlm.lock.flags.valblk", FT_BOOLEAN, 32,
			  NULL, 0x00000100, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_noqueue,
			{ "noqueue", "ocfs2.dlm.lock.flags.noqueue", FT_BOOLEAN, 32,
			  NULL, 0x00000200, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_convert,
			{ "convert", "ocfs2.dlm.lock.flags.convert", FT_BOOLEAN, 32,
			  NULL, 0x00000400, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_nodlckwt,
			{ "nodlckwt", "ocfs2.dlm.lock.flags.nodlckwt", FT_BOOLEAN, 32,
			  NULL, 0x00000800, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_unlock,
			{ "unlock", "ocfs2.dlm.lock.flags.unlock", FT_BOOLEAN, 32,
			  NULL, 0x00001000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_cancel,
			{ "cancel", "ocfs2.dlm.lock.flags.cancel", FT_BOOLEAN, 32,
			  NULL, 0x00002000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_deqall,
			{ "deqall", "ocfs2.dlm.lock.flags.deqall", FT_BOOLEAN, 32,
			  NULL, 0x00004000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_invvalblk,
			{ "invvalblk", "ocfs2.dlm.lock.flags.invvalblk", FT_BOOLEAN, 32,
			  NULL, 0x00008000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_syncsts,
			{ "syncsts", "ocfs2.dlm.lock.flags.syncsts", FT_BOOLEAN, 32,
			  NULL, 0x00010000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_timeout,
			{ "timeout", "ocfs2.dlm.lock.flags.timeout", FT_BOOLEAN, 32,
			  NULL, 0x00020000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_sngldlck,
			{ "sngldlck", "ocfs2.dlm.lock.flags.sngldlck", FT_BOOLEAN, 32,
			  NULL, 0x00040000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_findlocal,
			{ "findlocal", "ocfs2.dlm.lock.flags.findlocal", FT_BOOLEAN, 32,
			  NULL, 0x00080000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_proc_owned,
			{ "proc_owned", "ocfs2.dlm.lock.flags.proc_owned", FT_BOOLEAN, 32,
			  NULL, 0x00100000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_xid,
			{ "xid", "ocfs2.dlm.lock.flags.xid", FT_BOOLEAN, 32,
			  NULL, 0x00200000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_xid_conflict,
			{ "xid_conflict", "ocfs2.dlm.lock.flags.xid_conflict", FT_BOOLEAN, 32,
			  NULL, 0x00400000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_force,
			{ "force", "ocfs2.dlm.lock.flags.force", FT_BOOLEAN, 32,
			  NULL, 0x00800000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_revvalblk,
			{ "revvalblk", "ocfs2.dlm.lock.flags.revvalblk", FT_BOOLEAN, 32,
			  NULL, 0x01000000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_unused2,
			{ "unused", "ocfs2.dlm.lock.flags.unused", FT_UINT32, BASE_HEX,
			  NULL, 0x0E000000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_migration,
			{ "migration", "ocfs2.dlm.lock.flags.migration", FT_BOOLEAN, 32,
			  NULL, 0x10000000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_put_lvb,
			{ "put_lvb", "ocfs2.dlm.lock.flags.put_lvb", FT_BOOLEAN, 32,
			  NULL, 0x20000000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_get_lvb,
			{ "get_lvb", "ocfs2.dlm.lock.flags.get_lvb", FT_BOOLEAN, 32,
			  NULL, 0x40000000, NULL, HFILL
			}
		},
		{ &hf_dlm_lock_flag_recovery,
			{ "recovery", "ocfs2.dlm.lock.flags.recovery", FT_BOOLEAN, 32,
			  NULL, 0x80000000, NULL, HFILL
			}
		},
		{ &hf_dlm_am_flags,
			{ "Flags", "ocfs2.dlm.am_flags", FT_UINT32, BASE_HEX,
			  VALS(dlm_assert_master_flags), 0x0,
			  "Assert Master Flags", HFILL
			}
		},
		{ &hf_dlm_fr_flags,
			{ "Flags", "ocfs2.dlm.fr_flags", FT_UINT32, BASE_HEX,
			  VALS(dlm_finalize_reco_flags), 0x0,
			  "Finalize Recovery Flags", HFILL
			}
		},
		{ &hf_dlm_namelen,
			{ "Namelen", "ocfs2.dlm.namelen", FT_UINT8, BASE_DEC,
			  NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_name,
			{ "Name", "ocfs2.dlm.name", FT_STRING, BASE_NONE, NULL,
			  0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_cookie,
			{ "Cookie", "ocfs2.dlm.cookie", FT_UINT64, BASE_HEX,
			  NULL, 0x0,
			  "Unique ID for a single lock on a resource", HFILL
			}
		},
		{ &hf_dlm_requested_type,
			{ "Requested", "ocfs2.dlm.requested_type", FT_UINT8,
			  BASE_DEC, VALS(dlm_lock_modes), 0x0,
			  "Requested lock level", HFILL
			}
		},
		{ &hf_dlm_blocked_type,
			{ "Blocked", "ocfs2.dlm.blocked_type", FT_UINT8,
			  BASE_DEC, VALS(dlm_lock_modes), 0x0,
			  "Blocked lock type", HFILL
			}
		},
		{ &hf_dlm_ast_type,
			{ "AST Type", "ocfs2.dlm.ast_type", FT_UINT8, BASE_DEC,
			  VALS(dlm_proxy_ast_types), 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_dead_node,
			{ "Dead Node", "ocfs2.dlm.dead_node", FT_UINT8,
			  BASE_DEC, NULL, 0x0, "Dead node index", HFILL
			}
		},
		{ &hf_dlm_lvb1,
			{ "LVB1", "ocfs2.dlm.lvb", FT_BYTES, BASE_NONE, NULL,
			  0x0, "Lock value block", HFILL
			}
		},
		{ &hf_dlm_lvb2,
			{ "LVB2", "ocfs2.dlm.lvb", FT_BYTES, BASE_NONE, NULL,
			  0x0, "Lock value block", HFILL
			}
		},
		{ &hf_dlm_lvb3,
			{ "LVB3", "ocfs2.dlm.lvb", FT_BYTES, BASE_NONE, NULL,
			  0x0, "Lock value block", HFILL
			}
		},
		{ &hf_dlm_domain_name_len,
			{ "Domain Namelen", "ocfs2.dlm.domain_namelen",
			  FT_UINT8, BASE_DEC, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_proto_ver,
			{ "DLM Protocol", "ocfs2.dlm.proto_ver",
			  FT_UINT16, BASE_CUSTOM, CF_FUNC(dlm_fmt_revision), 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_fs_proto_ver,
			{ "FS Protocol", "ocfs2.dlm.fs_proto_ver",
			  FT_UINT16, BASE_CUSTOM, CF_FUNC(dlm_fmt_revision), 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_node_map,
			{ "Node Map", "ocfs2.dlm.node_map", FT_BYTES,
			  BASE_NONE, NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_domain_name,
			{ "Domain Name", "ocfs2.dlm.domain_name", FT_STRING,
			  BASE_NONE, NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_master,
			{ "Master", "ocfs2.dlm.master", FT_UINT8, BASE_DEC,
			  NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_new_master,
			{ "New Master", "ocfs2.dlm.new_master", FT_UINT8,
			  BASE_DEC, NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_mres_num_locks,
			{ "Num Locks", "ocfs2.dlm.num_locks", FT_UINT8,
			  BASE_DEC, NULL, 0x0, "Migres Num Locks", HFILL
			}
		},
		{ &hf_dlm_mres_flags,
			{ "Flags", "ocfs2.dlm.mres_flags", FT_UINT8, BASE_HEX,
			  NULL, 0x06, "Migres Flags", HFILL
			}
		},
		{ &hf_dlm_mres_flag_recovery,
			{ "recovery", "ocfs2.dlm.mres_flags.recovery", FT_BOOLEAN, 8,
			  NULL, 0x02, NULL, HFILL
			}
		},
		{ &hf_dlm_mres_flag_migration,
			{ "migration", "ocfs2.dlm.mres_flags.migration", FT_BOOLEAN, 8,
			  NULL, 0x04, NULL, HFILL
			}
		},
		/* TODO: what should this flag be? Should also be added to hf_dlm_mres_flags above */
		{ &hf_dlm_mres_flag_all_done,
			{ "all_done", "ocfs2.dlm.mres_flags.all_done", FT_BOOLEAN, 8,
			  NULL, 0xff, NULL, HFILL
			}
		},
		{ &hf_dlm_mres_total_locks,
			{ "Total Locks", "ocfs2.dlm.total_locks", FT_UINT32,
			  BASE_DEC, NULL, 0x0, "Migres Total Locks", HFILL
			}
		},
		{ &hf_dlm_mres_mig_cookie,
			{ "Cookie", "ocfs2.dlm.migratable_lock.mig_cookie",
			  FT_UINT64, BASE_DEC, NULL, 0x0, "Migres Cookie", HFILL
			}
		},
		{ &hf_dlm_mres_list,
			{ "List", "ocfs2.dlm.migratable_lock.list", FT_UINT8,
			  BASE_DEC, VALS(dlm_lockres_list), 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_mres_ml_flags,
			{ "List", "ocfs2.dlm.migratable_lock.flags", FT_UINT8,
			  BASE_HEX, NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_mres_type,
			{ "Type", "ocfs2.dlm.migratable_lock.type", FT_UINT8,
			  BASE_DEC, VALS(dlm_lock_modes), 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_mres_convert_type,
			{ "Convert type", "ocfs2.dlm.migratable_lock.convert_type", FT_UINT8,
			  BASE_DEC, NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_mres_highest_blocked,
			{ "Highest blocked", "ocfs2.dlm.migratable_lock.highest_blocked", FT_UINT8,
			  BASE_DEC, NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_mres_node,
			{ "Node", "ocfs2.dlm.migratable_lock.node", FT_UINT8,
			  BASE_DEC, NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_qr_node,
			{ "Node", "ocfs2.dlm.query_region.qr_node", FT_UINT8,
			  BASE_DEC, NULL, 0x0, "Query Region Node", HFILL
			}
		},
		{ &hf_dlm_qr_numregions,
			{ "Num Regions", "ocfs2.dlm.query_region.qr_numregions",
			  FT_UINT8, BASE_DEC, NULL, 0x0,
			  "The number of regions to compare with", HFILL
			}
		},
		{ &hf_dlm_qr_namelen,
			{ "Domain Namelen", "ocfs2.dlm.query_region.qr_namelen",
			  FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_qr_domain,
			{ "Domain Name", "ocfs2.dlm.query_region.qr_domain",
			  FT_STRING, BASE_NONE, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_qr_region,
			{ "Region", "ocfs2.dlm.query_region.region",
			  FT_STRING, BASE_NONE, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_qn_nodenum,
			{ "Node", "ocfs2.dlm_query_nodeinfo.qn_nodenum",
			  FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_qn_numnodes,
			{ "Num Nodes", "ocfs2.dlm_query_nodeinfo.qn_numnodes",
			  FT_UINT8, BASE_DEC, NULL, 0x0,
			  "The number of nodes to query", HFILL
			}
		},
		{ &hf_dlm_qn_namelen,
			{ "Domain Namelen",
			  "ocfs2.dlm_query_nodeinfo.qn_namelen", FT_UINT8,
			  BASE_DEC, NULL, 0x0, NULL, HFILL
			}
		},
		{ &hf_dlm_qn_domain,
			{ "Domain Name", "ocfs2.dlm_query_nodeinfo.qn_domain",
			  FT_STRING, BASE_NONE, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_qn_node,
			{ "Node", "ocfs2.dlm_query_nodeinfo.node",
			  FT_UINT8, BASE_DEC, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_qn_port,
			{ "Port", "ocfs2.dlm_query_nodeinfo.port",
			  FT_UINT16, BASE_DEC, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_qn_ip,
			{ "IP Address", "ocfs2.dlm_query_nodeinfo.ip",
			  FT_IPv4, BASE_NONE, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_reco_lvb,
			{ "Recovery LVB", "ocfs2.reco_lvb",
			  FT_BYTES, BASE_NONE, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_pad8,
			{ "Pad", "ocfs2.dlm.pad",
			  FT_UINT8, BASE_DEC, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_pad16,
			{ "Pad", "ocfs2.dlm.pad",
			  FT_UINT16, BASE_HEX, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_pad32,
			{ "Pad", "ocfs2.dlm.pad",
			  FT_UINT32, BASE_HEX, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_flags,
			{ "Flags", "ocfs2.dlm.flags",
			  FT_UINT32, BASE_HEX, NULL, 0x0, NULL,
			  HFILL
			}
		},
		{ &hf_dlm_payload,
			{ "Payload", "ocfs2.dlm.payload",
			  FT_BYTES, BASE_NONE, NULL, 0x0, NULL,
			  HFILL
			}
		},
	};

	static gint *ett[] = {
		&ett_ocfs2,
		&ett_dtm_lock_flags,
		&ett_mres_flags,
		&ett_migrate_lockres_locks,
		&ett_query_nodeinfo,
	};

	proto_ocfs2 = proto_register_protocol("OCFS2 Networking", "OCFS2", "ocfs2");
	proto_register_field_array(proto_ocfs2, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));

	ocfs2_handle = register_dissector("ocfs2", dissect_ocfs2, proto_ocfs2);
}

void proto_reg_handoff_ocfs2(void)
{
	dissector_add_for_decode_as_with_preference("tcp.port", ocfs2_handle);
}


/*
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 8
 * tab-width: 8
 * indent-tabs-mode: t
 * End:
 *
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
 * :indentSize=8:tabSize=8:noTabs=false:
 */