HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-dlm3.c
blobf76cf2816a9fc22c6e275fd93a6232095d8bcd93
1 /* packet-dlm3.c
2 * Routines for dlm3 dissection
3 * Copyright 2007, Masatake YAMATO <jet@gyve.org>
5 * $Id$
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 /* This dissector supports version 3.0 of the dlm(Distributed Lock Manager)
27 protocol
29 Actual implementation for the protocol is in linux kernel.
30 See files under linux/fs/dlm/ */
33 * #defines are mostly copied from
34 * *.[ch] files in linux/fs/dlm/ and linux/include/linux/dlm.h
36 * dlm_internal.h:
37 * -----------------------------------------------------------------------
38 ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
39 ** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
41 ** This copyrighted material is made available to anyone wishing to use,
42 ** modify, copy, or redistribute it subject to the terms and conditions
43 ** of the GNU General Public License v.2.
44 * -----------------------------------------------------------------------
48 #include "config.h"
50 #include <glib.h>
52 #include <epan/packet.h>
53 #include <epan/prefs.h>
57 #define TCP_PORT_DLM3 21064
58 #define SCTP_PORT_DLM3 TCP_PORT_DLM3
60 #define DLM3_MAJOR_VERSION 0x00030000
61 #define DLM3_MINOR_VERSION 0x00000000
63 #define DLM3_MSG 1
64 #define DLM3_RCOM 2
66 #define DLM3_MSG_REQUEST 1
67 #define DLM3_MSG_CONVERT 2
68 #define DLM3_MSG_UNLOCK 3
69 #define DLM3_MSG_CANCEL 4
70 #define DLM3_MSG_REQUEST_REPLY 5
71 #define DLM3_MSG_CONVERT_REPLY 6
72 #define DLM3_MSG_UNLOCK_REPLY 7
73 #define DLM3_MSG_CANCEL_REPLY 8
74 #define DLM3_MSG_GRANT 9
75 #define DLM3_MSG_BAST 10
76 #define DLM3_MSG_LOOKUP 11
77 #define DLM3_MSG_REMOVE 12
78 #define DLM3_MSG_LOOKUP_REPLY 13
79 #define DLM3_MSG_PURGE 14
81 #define DLM3_LKF_NOQUEUE 0x00000001
82 #define DLM3_LKF_CANCEL 0x00000002
83 #define DLM3_LKF_CONVERT 0x00000004
84 #define DLM3_LKF_VALBLK 0x00000008
85 #define DLM3_LKF_QUECVT 0x00000010
86 #define DLM3_LKF_IVVALBLK 0x00000020
87 #define DLM3_LKF_CONVDEADLK 0x00000040
88 #define DLM3_LKF_PERSISTENT 0x00000080
89 #define DLM3_LKF_NODLCKWT 0x00000100
90 #define DLM3_LKF_NODLCKBLK 0x00000200
91 #define DLM3_LKF_EXPEDITE 0x00000400
92 #define DLM3_LKF_NOQUEUEBAST 0x00000800
93 #define DLM3_LKF_HEADQUE 0x00001000
94 #define DLM3_LKF_NOORDER 0x00002000
95 #define DLM3_LKF_ORPHAN 0x00004000
96 #define DLM3_LKF_ALTPR 0x00008000
97 #define DLM3_LKF_ALTCW 0x00010000
98 #define DLM3_LKF_FORCEUNLOCK 0x00020000
99 #define DLM3_LKF_TIMEOUT 0x00040000
101 #define DLM3_SBF_DEMOTED 0x01
102 #define DLM3_SBF_VALNOTVALID 0x02
103 #define DLM3_SBF_ALTMODE 0x04
105 #define DLM3_IFL_USER 0x00000001
106 #define DLM3_IFL_ORPHAN 0x00000002
107 /* They may not be used in receiver side.
108 --------------------------------------
109 #define DLM3_IFL_MSTCPY 0x00010000
110 #define DLM3_IFL_RESEND 0x00020000
111 #define DLM3_IFL_DEAD 0x00040000
112 #define DLM3_IFL_OVERLAP_UNLOCK 0x00080000
113 #define DLM3_IFL_OVERLAP_CANCEL 0x00100000
114 #define DLM3_IFL_ENDOFLIFE 0x00200000
115 #define DLM3_IFL_WATCH_TIMEWARN 0x00400000
116 #define DLM3_IFL_TIMEOUT_CANCEL 0x00800000
117 #define DLM3_IFL_DEADLOCK_CANCEL 0x01000000 */
119 #define DLM3_LKSTS_WAITING 1
120 #define DLM3_LKSTS_GRANTED 2
121 #define DLM3_LKSTS_CONVERT 3
123 #define DLM3_LOCK_IV -1
124 #define DLM3_LOCK_NL 0
125 #define DLM3_LOCK_CR 1
126 #define DLM3_LOCK_CW 2
127 #define DLM3_LOCK_PR 3
128 #define DLM3_LOCK_PW 4
129 #define DLM3_LOCK_EX 5
131 #define DLM3_AST_COMP 1
132 #define DLM3_AST_BAST 2
135 /* see asm-generic/errno-base.h about LINUX_* */
136 #define LINUX_EAGAIN 11
137 #define LINUX_ENOMEM 12
138 #define LINUX_INVAL 22
140 #define DLM3_ERRNO_EDEADLK 35
141 #define DLM3_ERRNO_EBADR 53
142 #define DLM3_ERRNO_EBADSLT 57
143 #define DLM3_ERRNO_EPROTO 71
144 #define DLM3_ERRNO_EOPNOTSUPP 95
145 #define DLM3_ERRNO_ETIMEDOUT 110
146 #define DLM3_ERRNO_EINPROGRESS 115
148 #define DLM3_ECANCEL 0x10001
149 #define DLM3_EUNLOCK 0x10002
152 #define DLM3_RCOM_STATUS 1
153 #define DLM3_RCOM_NAMES 2
154 #define DLM3_RCOM_LOOKUP 3
155 #define DLM3_RCOM_LOCK 4
156 #define DLM3_RCOM_STATUS_REPLY 5
157 #define DLM3_RCOM_NAMES_REPLY 6
158 #define DLM3_RCOM_LOOKUP_REPLY 7
159 #define DLM3_RCOM_LOCK_REPLY 8
161 #define DLM3_RS_NODES 0x00000001
162 #define DLM3_RS_NODES_ALL 0x00000002
163 #define DLM3_RS_DIR 0x00000004
164 #define DLM3_RS_DIR_ALL 0x00000008
165 #define DLM3_RS_LOCKS 0x00000010
166 #define DLM3_RS_LOCKS_ALL 0x00000020
167 #define DLM3_RS_DONE 0x00000040
168 #define DLM3_RS_DONE_ALL 0x00000080
170 #define DLM3_RESNAME_MAXLEN 64
172 /* Forward declaration we need below */
173 void proto_register_dlm3(void);
174 void proto_reg_handoff_dlm3(void);
177 /* Initialize the protocol and registered fields */
178 static int proto_dlm3 = -1;
180 /* fields for struct dlm_header(h) */
181 static int hf_dlm3_h_version = -1;
182 static int hf_dlm3_h_major_version = -1;
183 static int hf_dlm3_h_minor_version = -1;
184 static int hf_dlm3_h_lockspace = -1;
185 static int hf_dlm3_h_nodeid = -1;
186 static int hf_dlm3_h_length = -1;
187 static int hf_dlm3_h_cmd = -1;
188 static int hf_dlm3_h_pad = -1;
190 /* fields for struct dlm_message(m) */
191 static int hf_dlm3_m_type = -1;
192 static int hf_dlm3_m_nodeid = -1;
193 static int hf_dlm3_m_pid = -1;
194 static int hf_dlm3_m_lkid = -1;
195 static int hf_dlm3_m_remid = -1;
196 static int hf_dlm3_m_parent_lkid = -1;
197 static int hf_dlm3_m_parent_remid = -1;
199 /* bit fields for dlm_message::exflags */
200 #define DLM3_DEFINE_HF_EXFLAGS(NAME) \
201 static int hf_dlm3_##NAME = -1; \
202 static int hf_dlm3_##NAME##_noqueue = -1; \
203 static int hf_dlm3_##NAME##_cancel = -1; \
204 static int hf_dlm3_##NAME##_convert = -1; \
205 static int hf_dlm3_##NAME##_valblk = -1; \
206 static int hf_dlm3_##NAME##_quecvt = -1; \
207 static int hf_dlm3_##NAME##_ivvalblk = -1; \
208 static int hf_dlm3_##NAME##_convdeadlk = -1; \
209 static int hf_dlm3_##NAME##_persistent = -1; \
210 static int hf_dlm3_##NAME##_nodlckwt = -1; \
211 static int hf_dlm3_##NAME##_nodlckblk = -1; \
212 static int hf_dlm3_##NAME##_expedite = -1; \
213 static int hf_dlm3_##NAME##_noqueuebast = -1; \
214 static int hf_dlm3_##NAME##_headque = -1; \
215 static int hf_dlm3_##NAME##_noorder = -1; \
216 static int hf_dlm3_##NAME##_orphan = -1; \
217 static int hf_dlm3_##NAME##_altpr = -1; \
218 static int hf_dlm3_##NAME##_altcw = -1; \
219 static int hf_dlm3_##NAME##_forceunlock = -1; \
220 static int hf_dlm3_##NAME##_timeout = -1
221 DLM3_DEFINE_HF_EXFLAGS(m_exflags);
223 /* bit fields for dlm_message::sbflags */
224 static int hf_dlm3_m_sbflags = -1;
225 static int hf_dlm3_m_sbflags_demoted = -1;
226 static int hf_dlm3_m_sbflags_valnotvalid = -1;
227 static int hf_dlm3_m_sbflags_altmode = -1;
229 /* bit fields for dlm_message::flags */
230 #define DLM3_DEFINE_HF_FLAGS(NAME) \
231 static int hf_dlm3_##NAME = -1; \
232 static int hf_dlm3_##NAME##_user = -1; \
233 static int hf_dlm3_##NAME##_orphan = -1
234 DLM3_DEFINE_HF_FLAGS(m_flags);
236 static int hf_dlm3_m_lvbseq = -1;
237 static int hf_dlm3_m_hash = -1;
238 static int hf_dlm3_m_status = -1;
239 static int hf_dlm3_m_grmode = -1;
240 static int hf_dlm3_m_rqmode = -1;
241 static int hf_dlm3_m_bastmode = -1;
243 /* bit fields for dlm_message::asts */
244 #define DLM3_DEFINE_HF_ASTS(NAME) \
245 static int hf_dlm3_##NAME##_asts = -1; \
246 static int hf_dlm3_##NAME##_asts_comp = -1; \
247 static int hf_dlm3_##NAME##_asts_bast = -1
248 DLM3_DEFINE_HF_ASTS(m);
250 static int hf_dlm3_m_result = -1;
251 static int hf_dlm3_m_extra = -1;
253 /* fields for struct dlm_rcom(rc) */
254 static int hf_dlm3_rc_type = -1;
255 static int hf_dlm3_rc_result = -1;
256 static int hf_dlm3_rc_id = -1;
257 static int hf_dlm3_rc_seq = -1;
258 static int hf_dlm3_rc_seq_reply = -1;
259 static int hf_dlm3_rc_buf = -1;
261 /* fields for struct rcom_config(rf) */
262 static int hf_dlm3_rf_lvblen = -1;
263 DLM3_DEFINE_HF_EXFLAGS(rf_lsflags);
264 static int hf_dlm3_rf_unused = -1;
266 /* fields for struct rcom_lock(rl) */
267 static int hf_dlm3_rl_ownpid = -1;
268 static int hf_dlm3_rl_lkid = -1;
269 static int hf_dlm3_rl_remid = -1;
270 static int hf_dlm3_rl_parent_lkid = -1;
271 static int hf_dlm3_rl_parent_remid = -1;
272 DLM3_DEFINE_HF_EXFLAGS(rl_exflags);
273 DLM3_DEFINE_HF_FLAGS(rl_flags);
274 static int hf_dlm3_rl_lvbseq = -1;
275 static int hf_dlm3_rl_result = -1;
276 static int hf_dlm3_rl_rqmode = -1;
277 static int hf_dlm3_rl_grmode = -1;
278 static int hf_dlm3_rl_status = -1;
279 DLM3_DEFINE_HF_ASTS(rl);
280 static int hf_dlm3_rl_wait_type = -1;
281 static int hf_dlm3_rl_namelen = -1;
282 static int hf_dlm3_rl_name = -1;
283 static int hf_dlm3_rl_name_contents = -1;
284 static int hf_dlm3_rl_name_padding = -1;
285 static int hf_dlm3_rl_lvb = -1;
287 /* Initialize the subtree pointers */
288 static gint ett_dlm3 = -1;
289 static gint ett_dlm3_version = -1;
291 static gint ett_dlm3_msg = -1;
292 static gint ett_dlm3_m_exflags = -1;
293 static gint ett_dlm3_sbflags = -1;
294 static gint ett_dlm3_m_flags = -1;
295 static gint ett_dlm3_m_asts = -1;
297 static gint ett_dlm3_rcom = -1;
298 static gint ett_dlm3_rcom_lock = -1;
299 static gint ett_dlm3_rcom_config = -1;
301 static gint ett_dlm3_rf_lsflags = -1;
302 static gint ett_dlm3_rl_exflags = -1;
303 static gint ett_dlm3_rl_flags = -1;
304 static gint ett_dlm3_rl_asts = -1;
305 static gint ett_dlm3_rl_name = -1;
308 /* configurable parameters */
309 static guint dlm3_tcp_port = TCP_PORT_DLM3;
310 static guint dlm3_sctp_port = SCTP_PORT_DLM3;
313 * Value strings
315 static const value_string dlm3_cmd[] = {
316 { DLM3_MSG, "message" },
317 { DLM3_RCOM, "recovery command" },
318 { 0, NULL }
321 static const value_string dlm3_msg[] = {
322 { DLM3_MSG_REQUEST, "request message" },
323 { DLM3_MSG_CONVERT, "conversion message" },
324 { DLM3_MSG_UNLOCK, "unlock message" },
325 { DLM3_MSG_CANCEL, "cancel message" },
326 { DLM3_MSG_REQUEST_REPLY, "request reply" },
327 { DLM3_MSG_CONVERT_REPLY, "conversion reply" },
328 { DLM3_MSG_UNLOCK_REPLY, "unlock reply" },
329 { DLM3_MSG_CANCEL_REPLY, "cancel reply" },
330 { DLM3_MSG_GRANT, "grant message" },
331 { DLM3_MSG_BAST, "bast message" },
332 { DLM3_MSG_LOOKUP, "lookup message" },
333 { DLM3_MSG_REMOVE, "remove message" },
334 { DLM3_MSG_LOOKUP_REPLY, "lookup reply" },
335 { DLM3_MSG_PURGE, "purge orphans" },
336 { 0, NULL }
339 static const value_string dlm3_status[] = {
340 { DLM3_LKSTS_WAITING, "waiting" },
341 { DLM3_LKSTS_GRANTED, "granted" },
342 { DLM3_LKSTS_CONVERT, "convert" },
343 { 0, NULL }
346 static const value_string dlm3_mode[] = {
347 { DLM3_LOCK_IV, "invalid" },
348 { DLM3_LOCK_NL, "null" },
349 { DLM3_LOCK_CR, "concurrent read" },
350 { DLM3_LOCK_CW, "concurrent write" },
351 { DLM3_LOCK_PR, "protected read" },
352 { DLM3_LOCK_PW, "protected write" },
353 { DLM3_LOCK_EX, "exclusive" },
354 { 0, NULL }
357 static const value_string dlm3_result[] = {
358 { -LINUX_EAGAIN, "blocked" },
359 { -LINUX_ENOMEM, "no memory" },
360 { -LINUX_INVAL, "invalid parameters" },
361 { -DLM3_ERRNO_EDEADLK, "Resource deadlock avoided" },
362 { -DLM3_ERRNO_EBADR, "Invalid request descriptor" },
363 { -DLM3_ERRNO_EBADSLT, "Invalid slot" },
364 { -DLM3_ERRNO_EPROTO, "Protocol error" },
365 { -DLM3_ERRNO_EOPNOTSUPP, "Operation not supported" },
366 { -DLM3_ERRNO_ETIMEDOUT, "Connection timed out" },
367 { -DLM3_ERRNO_EINPROGRESS, "Operation now in progress" },
368 { -DLM3_ECANCEL, "cancel completed successfully" },
369 { -DLM3_EUNLOCK, "unlock request was successful" },
370 { 0, "successful" },
371 { 0, NULL }
374 static const value_string dlm3_rcom[] = {
375 { DLM3_RCOM_STATUS, "status command" },
376 { DLM3_RCOM_NAMES, "names command" },
377 { DLM3_RCOM_LOOKUP, "lookup command" },
378 { DLM3_RCOM_LOCK, "lock command" },
379 { DLM3_RCOM_STATUS_REPLY, "status reply" },
380 { DLM3_RCOM_NAMES_REPLY, "names reply" },
381 { DLM3_RCOM_LOOKUP_REPLY, "lookup reply" },
382 { DLM3_RCOM_LOCK_REPLY, "lock reply" },
383 { 0, NULL }
386 static const value_string dlm3_rs[] = {
387 { DLM3_RS_NODES, "recovering nodes" },
388 { DLM3_RS_NODES_ALL, "recovering all nodes" },
389 { DLM3_RS_DIR, "recovering resource directory" },
390 { DLM3_RS_DIR_ALL, "recovering all resource directories" },
391 { DLM3_RS_LOCKS, "recovering lock" },
392 { DLM3_RS_LOCKS_ALL, "recovering all locks" },
393 { DLM3_RS_DONE, "recovering is done" },
394 { DLM3_RS_DONE_ALL, "all recovering is done" },
395 { 0, NULL }
399 * Fields
401 #define DLM3_DEFINE_EXFLAGS_FIELDS(NAME) \
402 static const int* NAME##_fields[] = { \
403 &hf_dlm3_##NAME##_timeout , \
404 &hf_dlm3_##NAME##_forceunlock , \
405 &hf_dlm3_##NAME##_altcw , \
406 &hf_dlm3_##NAME##_altpr , \
407 &hf_dlm3_##NAME##_orphan , \
408 &hf_dlm3_##NAME##_noorder , \
409 &hf_dlm3_##NAME##_headque , \
410 &hf_dlm3_##NAME##_noqueuebast , \
411 &hf_dlm3_##NAME##_expedite , \
412 &hf_dlm3_##NAME##_nodlckblk , \
413 &hf_dlm3_##NAME##_nodlckwt , \
414 &hf_dlm3_##NAME##_persistent , \
415 &hf_dlm3_##NAME##_convdeadlk , \
416 &hf_dlm3_##NAME##_ivvalblk , \
417 &hf_dlm3_##NAME##_quecvt , \
418 &hf_dlm3_##NAME##_valblk , \
419 &hf_dlm3_##NAME##_convert , \
420 &hf_dlm3_##NAME##_cancel , \
421 &hf_dlm3_##NAME##_noqueue , \
422 NULL \
424 DLM3_DEFINE_EXFLAGS_FIELDS(m_exflags);
426 static const int *m_sbflags_fields[] = {
427 &hf_dlm3_m_sbflags_altmode ,
428 &hf_dlm3_m_sbflags_valnotvalid ,
429 &hf_dlm3_m_sbflags_demoted ,
430 NULL
433 #define DLM3_DEFINE_FLAGS_FIELDS(NAME) \
434 static const int* NAME##_fields[] = { \
435 &hf_dlm3_##NAME##_orphan , \
436 &hf_dlm3_##NAME##_user , \
437 NULL \
439 DLM3_DEFINE_FLAGS_FIELDS(m_flags);
441 #define DLM3_DEFINE_ASTS_FIELDS(NAME) \
442 static const int* NAME##_asts_fields[] = { \
443 &hf_dlm3_##NAME##_asts_bast , \
444 &hf_dlm3_##NAME##_asts_comp , \
445 NULL \
447 DLM3_DEFINE_ASTS_FIELDS(m);
449 DLM3_DEFINE_EXFLAGS_FIELDS(rf_lsflags);
451 DLM3_DEFINE_EXFLAGS_FIELDS(rl_exflags);
452 DLM3_DEFINE_FLAGS_FIELDS(rl_flags);
453 DLM3_DEFINE_ASTS_FIELDS(rl);
455 /* Code to actually dissect the packets */
456 static void
457 dissect_dlm3_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
458 guint length, int offset)
460 guint32 m_type;
462 m_type = tvb_get_letohl(tvb, offset);
463 proto_tree_add_uint(tree,
464 hf_dlm3_m_type, tvb, offset, 4, m_type);
465 col_append_fstr(pinfo->cinfo, COL_INFO,
466 ": %s",
467 val_to_str_const(m_type,
468 dlm3_msg,
469 "Unknown"));
471 offset += 4;
472 proto_tree_add_item(tree,
473 hf_dlm3_m_nodeid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
475 offset += 4;
476 proto_tree_add_item(tree,
477 hf_dlm3_m_pid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
479 offset += 4;
480 proto_tree_add_item(tree,
481 hf_dlm3_m_lkid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
482 /* TODO: See `create_lkb'
483 lkid has some structure. We dissect more. */
485 offset += 4;
486 proto_tree_add_item(tree,
487 hf_dlm3_m_remid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
489 offset += 4;
490 proto_tree_add_item(tree,
491 hf_dlm3_m_parent_lkid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
493 offset += 4;
494 proto_tree_add_item(tree,
495 hf_dlm3_m_parent_remid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
497 offset += 4;
498 proto_tree_add_bitmask(tree, tvb, offset,
499 hf_dlm3_m_exflags, ett_dlm3_m_exflags,
500 m_exflags_fields, ENC_LITTLE_ENDIAN);
502 offset += 4;
503 proto_tree_add_bitmask(tree, tvb, offset,
504 hf_dlm3_m_sbflags, ett_dlm3_sbflags,
505 m_sbflags_fields, ENC_LITTLE_ENDIAN);
507 offset += 4;
508 proto_tree_add_bitmask(tree, tvb, offset,
509 hf_dlm3_m_flags, ett_dlm3_m_flags,
510 m_flags_fields, ENC_LITTLE_ENDIAN);
512 offset += 4;
513 proto_tree_add_item(tree,
514 hf_dlm3_m_lvbseq, tvb, offset, 4, ENC_LITTLE_ENDIAN);
516 offset += 4;
517 proto_tree_add_item(tree,
518 hf_dlm3_m_hash, tvb, offset, 4, ENC_LITTLE_ENDIAN);
520 offset += 4;
521 proto_tree_add_item(tree,
522 hf_dlm3_m_status, tvb, offset, 4, ENC_LITTLE_ENDIAN);
524 offset += 4;
525 proto_tree_add_item(tree,
526 hf_dlm3_m_grmode, tvb, offset, 4, ENC_LITTLE_ENDIAN);
528 offset += 4;
529 proto_tree_add_item(tree,
530 hf_dlm3_m_rqmode, tvb, offset, 4, ENC_LITTLE_ENDIAN);
532 offset += 4;
533 proto_tree_add_item(tree,
534 hf_dlm3_m_bastmode, tvb, offset, 4, ENC_LITTLE_ENDIAN);
537 offset += 4;
538 proto_tree_add_bitmask(tree, tvb, offset,
539 hf_dlm3_m_asts, ett_dlm3_m_asts,
540 m_asts_fields, ENC_LITTLE_ENDIAN);
541 offset += 4;
542 proto_tree_add_item(tree,
543 hf_dlm3_m_result, tvb, offset, 4, ENC_LITTLE_ENDIAN);
545 offset += 4;
546 if ((length - offset) > 0) {
547 proto_tree_add_item(tree,
548 hf_dlm3_m_extra,
549 tvb,
550 offset,
552 ENC_NA);
558 static void
559 dissect_dlm3_rcom_lock(tvbuff_t *tvb, proto_tree *tree,
560 guint length, int offset)
562 proto_item *sub_item;
563 proto_tree *sub_tree;
564 int sub_offset;
565 guint16 namelen;
566 guint32 exflags;
569 if ((length - offset) < ( 4 * 8 + 4 + 1 * 4 + 2 * 2
570 + DLM3_RESNAME_MAXLEN ))
571 return;
574 proto_tree_add_item(tree,
575 hf_dlm3_rl_ownpid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
577 offset += 4;
578 proto_tree_add_item(tree,
579 hf_dlm3_rl_lkid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
581 offset += 4;
582 proto_tree_add_item(tree,
583 hf_dlm3_rl_remid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
585 offset += 4;
586 proto_tree_add_item(tree,
587 hf_dlm3_rl_parent_lkid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
589 offset += 4;
590 proto_tree_add_item(tree,
591 hf_dlm3_rl_parent_remid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
593 offset += 4;
594 proto_tree_add_bitmask(tree, tvb, offset,
595 hf_dlm3_rl_exflags, ett_dlm3_rl_exflags,
596 rl_exflags_fields, ENC_LITTLE_ENDIAN);
597 exflags = tvb_get_letohl(tvb, offset);
600 offset += 4;
601 proto_tree_add_bitmask(tree, tvb, offset,
602 hf_dlm3_rl_flags, ett_dlm3_rl_flags,
603 rl_flags_fields, ENC_LITTLE_ENDIAN);
605 offset += 4;
606 proto_tree_add_item(tree,
607 hf_dlm3_rl_lvbseq, tvb, offset, 4, ENC_LITTLE_ENDIAN);
609 offset += 4;
610 proto_tree_add_item(tree,
611 hf_dlm3_rl_result, tvb, offset, 4, ENC_LITTLE_ENDIAN);
613 offset += 4;
614 proto_tree_add_item(tree,
615 hf_dlm3_rl_rqmode, tvb, offset, 1, ENC_LITTLE_ENDIAN);
617 offset += 1;
618 proto_tree_add_item(tree,
619 hf_dlm3_rl_grmode, tvb, offset, 1, ENC_LITTLE_ENDIAN);
621 offset += 1;
622 proto_tree_add_item(tree,
623 hf_dlm3_rl_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
625 offset += 1;
626 proto_tree_add_bitmask(tree, tvb, offset,
627 hf_dlm3_rl_asts, ett_dlm3_rl_asts,
628 rl_asts_fields, ENC_LITTLE_ENDIAN);
630 offset += 1;
631 proto_tree_add_item(tree,
632 hf_dlm3_rl_wait_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
634 offset += 2;
635 namelen = tvb_get_letohs(tvb, offset);
636 proto_tree_add_uint(tree,
637 hf_dlm3_rl_namelen, tvb, offset, 2,
638 namelen);
640 offset += 2;
641 sub_item = proto_tree_add_item(tree,
642 hf_dlm3_rl_name, tvb, offset,
643 DLM3_RESNAME_MAXLEN, ENC_NA);
645 sub_tree = proto_item_add_subtree(sub_item,
646 ett_dlm3_rl_name);
647 sub_offset = offset;
648 proto_tree_add_item(sub_tree,
649 hf_dlm3_rl_name_contents, tvb, sub_offset,
650 namelen, ENC_ASCII|ENC_NA);
652 sub_offset += namelen;
653 proto_tree_add_item(sub_tree,
654 hf_dlm3_rl_name_padding, tvb, sub_offset,
655 DLM3_RESNAME_MAXLEN - namelen, ENC_NA);
657 offset += DLM3_RESNAME_MAXLEN;
658 if (((length - offset) > 0) && (exflags & DLM3_LKF_VALBLK))
659 proto_tree_add_item(tree,
660 hf_dlm3_rl_lvb, tvb, offset,
662 ENC_NA);
666 static void
667 dissect_dlm3_rcom_config(tvbuff_t *tvb, proto_tree *tree,
668 guint length, int offset)
670 if ((length - offset) < ( 4 + 4 + 8 ))
671 return;
673 proto_tree_add_item(tree,
674 hf_dlm3_rf_lvblen, tvb, offset, 4, ENC_LITTLE_ENDIAN);
676 offset += 4;
677 proto_tree_add_bitmask(tree, tvb, offset,
678 hf_dlm3_rf_lsflags, ett_dlm3_rf_lsflags,
679 rf_lsflags_fields, ENC_LITTLE_ENDIAN);
681 offset += 4;
682 proto_tree_add_item(tree,
683 hf_dlm3_rf_unused, tvb, offset, 8, ENC_LITTLE_ENDIAN);
686 /*offset += 8;*/
687 /* END */
690 static void
691 dissect_dlm3_rcom(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
692 guint length, int offset)
694 guint32 rc_type;
696 proto_item *sub_item;
697 proto_tree *sub_tree;
700 rc_type = tvb_get_letohl(tvb, offset);
701 proto_tree_add_uint(tree,
702 hf_dlm3_rc_type, tvb, offset, 4, rc_type);
703 col_append_fstr(pinfo->cinfo, COL_INFO,
704 ": %s",
705 val_to_str_const(rc_type,
706 dlm3_rcom,
707 "Unknown"));
709 offset += 4;
710 proto_tree_add_item(tree,
711 hf_dlm3_rc_result, tvb, offset, 4, ENC_LITTLE_ENDIAN);
713 offset += 4;
714 proto_tree_add_item(tree,
715 hf_dlm3_rc_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
717 offset += 8;
718 proto_tree_add_item(tree,
719 hf_dlm3_rc_seq, tvb, offset, 8, ENC_LITTLE_ENDIAN);
721 offset += 8;
722 proto_tree_add_item(tree,
723 hf_dlm3_rc_seq_reply, tvb, offset, 8, ENC_LITTLE_ENDIAN);
725 offset += 8;
726 if ((length - offset) == 0) {
727 /* No rc_buf: Just return */
728 return;
731 /* Decode rc_buf */
732 sub_item = proto_tree_add_item(tree,
733 hf_dlm3_rc_buf,
734 tvb,
735 offset,
737 ENC_NA);
739 offset += 0;
740 if (rc_type == DLM3_RCOM_LOCK) {
741 sub_tree = proto_item_add_subtree(sub_item,
742 ett_dlm3_rcom_lock);
743 dissect_dlm3_rcom_lock(tvb, sub_tree, length, offset);
744 } else if (rc_type == DLM3_RCOM_STATUS_REPLY) {
745 sub_tree = proto_item_add_subtree(sub_item,
746 ett_dlm3_rcom_config);
747 dissect_dlm3_rcom_config(tvb, sub_tree, length, offset);
752 static int
753 dissect_dlm3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
755 proto_item *item, *sub_item;
756 proto_tree *tree, *sub_tree;
758 int offset;
759 guint length;
760 guint32 h_version;
761 guint8 h_cmd;
764 /* Check that there's enough data */
765 length = tvb_length(tvb);
766 if (length < 4 + 4 + 4 + 2 + 1 + 1)
767 return 0;
769 /* Check the protocol version */
770 h_version = tvb_get_letohl(tvb, 0);
771 if (h_version != (DLM3_MAJOR_VERSION|DLM3_MINOR_VERSION))
772 return 0;
774 /* Check the command */
775 h_cmd = tvb_get_guint8(tvb, 4 + 4 + 4 + 2) ;
776 if ((h_cmd != DLM3_MSG) && (h_cmd != DLM3_RCOM))
777 return 0;
779 if ((h_cmd == DLM3_MSG) && (length < ((4 + 4 + 4 + 2 + 1 + 1)
780 + (4 * 12 + 4 * 6))))
781 return 0;
782 else if ((h_cmd == DLM3_RCOM) && (length < 4 + 4 + 8 + 8 + 8))
783 return 0;
786 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DLM3");
789 col_set_str(pinfo->cinfo, COL_INFO, "DLM3");
791 col_set_str(pinfo->cinfo, COL_INFO,
792 val_to_str_const(h_cmd,
793 dlm3_cmd,
794 "packet-dlm3.c internal bug"));
796 if (parent_tree) {
797 offset = 0;
799 item = proto_tree_add_item(parent_tree, proto_dlm3, tvb, offset,
800 -1, ENC_NA);
801 tree = proto_item_add_subtree(item, ett_dlm3);
803 sub_item = proto_tree_add_uint(tree,
804 hf_dlm3_h_version, tvb, offset, 4,
805 h_version);
806 sub_tree = proto_item_add_subtree(sub_item, ett_dlm3_version);
807 proto_tree_add_uint(sub_tree,
808 hf_dlm3_h_major_version, tvb, offset + 0, 2,
809 (h_version & 0xFFFF0000) >> 16);
810 proto_tree_add_uint(sub_tree,
811 hf_dlm3_h_minor_version, tvb, offset + 2, 2,
812 (h_version & 0x0000FFFF));
815 offset += 4;
816 proto_tree_add_item(tree,
817 hf_dlm3_h_lockspace, tvb, offset, 4, ENC_LITTLE_ENDIAN);
819 offset += 4;
820 proto_tree_add_item(tree,
821 hf_dlm3_h_nodeid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
822 offset += 4;
823 proto_tree_add_item(tree,
824 hf_dlm3_h_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
826 offset += 2;
827 sub_item = proto_tree_add_uint(tree,
828 hf_dlm3_h_cmd, tvb, offset, 1, h_cmd);
830 offset += 1;
831 proto_tree_add_item(tree,
832 hf_dlm3_h_pad, tvb, offset, 1, ENC_LITTLE_ENDIAN);
835 offset += 1;
836 if (h_cmd == DLM3_MSG) {
837 sub_tree = proto_item_add_subtree(sub_item, ett_dlm3_msg);
838 dissect_dlm3_msg(tvb, pinfo, sub_tree, length, offset);
839 } else if (h_cmd== DLM3_RCOM) {
840 sub_tree = proto_item_add_subtree(sub_item, ett_dlm3_rcom);
841 dissect_dlm3_rcom(tvb, pinfo, sub_tree, length, offset);
844 return tvb_length(tvb);
848 /* Register the protocol with Wireshark */
850 #define DLM3_REGISTER_HF_LOCKID(NAME) \
851 { &hf_dlm3_##NAME##_lkid, \
852 { "Lock ID on Sender", "dlm3." #NAME ".lkid", \
853 FT_UINT32, BASE_DEC_HEX, NULL, 0x0, \
854 NULL, HFILL}}, \
855 { &hf_dlm3_##NAME##_remid, \
856 { "Lock ID on Receiver", "dlm3." #NAME ".remid", \
857 FT_UINT32, BASE_DEC_HEX, NULL, 0x0, \
858 NULL, HFILL}}, \
859 { &hf_dlm3_##NAME##_parent_lkid, \
860 { "Parent Lock ID on Sender", "dlm3." #NAME ".parent_lkid", \
861 FT_UINT32, BASE_DEC_HEX, NULL, 0x0, \
862 NULL, HFILL}}, \
863 { &hf_dlm3_##NAME##_parent_remid, \
864 { "Parent Lock ID on Receiver", "dlm3." #NAME ".parent_remid", \
865 FT_UINT32, BASE_DEC_HEX, NULL, 0x0, \
866 NULL, HFILL}}
868 #define DLM3_REGISTER_HF_EXFLAGS(SYMNAME,STRNAME) \
869 { &hf_dlm3_##SYMNAME, \
870 { "External Flags", "dlm3." STRNAME "", \
871 FT_UINT32, BASE_HEX, NULL, 0x0, \
872 NULL, HFILL}}, \
873 { &hf_dlm3_##SYMNAME##_noqueue, \
874 { "Don't queue", "dlm3." STRNAME ".noqueue", \
875 FT_BOOLEAN, 32, NULL, DLM3_LKF_NOQUEUE, \
876 NULL, HFILL}}, \
877 { &hf_dlm3_##SYMNAME##_cancel, \
878 { "Cancel", "dlm3." STRNAME ".cancel", \
879 FT_BOOLEAN, 32, NULL, DLM3_LKF_CANCEL, \
880 NULL, HFILL}}, \
881 { &hf_dlm3_##SYMNAME##_convert, \
882 { "Convert", "dlm3." STRNAME ".convert", \
883 FT_BOOLEAN, 32, NULL, DLM3_LKF_CONVERT, \
884 NULL, HFILL}}, \
885 { &hf_dlm3_##SYMNAME##_valblk, \
886 { "Return the contents of the lock value block", "dlm3." STRNAME ".valblk", \
887 FT_BOOLEAN, 32, NULL, DLM3_LKF_VALBLK, \
888 NULL, HFILL}}, \
889 { &hf_dlm3_##SYMNAME##_quecvt, \
890 { "Force a conversion request to be queued", "dlm3." STRNAME ".quecvt", \
891 FT_BOOLEAN, 32, NULL, DLM3_LKF_QUECVT, \
892 NULL, HFILL}}, \
893 { &hf_dlm3_##SYMNAME##_ivvalblk, \
894 { "Invalidate the lock value block", "dlm3." STRNAME ".ivvalblk", \
895 FT_BOOLEAN, 32, NULL, DLM3_LKF_IVVALBLK, \
896 NULL, HFILL}}, \
897 { &hf_dlm3_##SYMNAME##_convdeadlk, \
898 { "Forced down to NL to resolve a conversion deadlock", "dlm3." STRNAME ".convdeadlk", \
899 FT_BOOLEAN, 32, NULL, DLM3_LKF_CONVDEADLK, \
900 NULL, HFILL}}, \
901 { &hf_dlm3_##SYMNAME##_persistent, \
902 { "Persistent", "dlm3." STRNAME ".persistent", \
903 FT_BOOLEAN, 32, NULL, DLM3_LKF_PERSISTENT, \
904 NULL, HFILL}}, \
905 { &hf_dlm3_##SYMNAME##_nodlckwt, \
906 { "Don't cancel the lock if it gets into conversion deadlock", "dlm3." STRNAME ".nodlckwt", \
907 FT_BOOLEAN, 32, NULL, DLM3_LKF_NODLCKWT, \
908 NULL, HFILL}}, \
909 { &hf_dlm3_##SYMNAME##_nodlckblk, \
910 { "Nodlckblk", "dlm3." STRNAME ".nodlckblk", \
911 FT_BOOLEAN, 32, NULL, DLM3_LKF_NODLCKBLK, \
912 NULL, HFILL}}, \
913 { &hf_dlm3_##SYMNAME##_expedite, \
914 { "Grant a NL lock immediately", "dlm3." STRNAME ".expedite", \
915 FT_BOOLEAN, 32, NULL, DLM3_LKF_EXPEDITE, \
916 NULL, HFILL}}, \
917 { &hf_dlm3_##SYMNAME##_noqueuebast, \
918 { "Send blocking ASTs even for NOQUEUE operations", "dlm3." STRNAME ".noqueuebast", \
919 FT_BOOLEAN, 32, NULL, DLM3_LKF_NOQUEUEBAST, \
920 NULL, HFILL}}, \
921 { &hf_dlm3_##SYMNAME##_headque, \
922 { "Add a lock to the head of the queue", "dlm3." STRNAME ".headque", \
923 FT_BOOLEAN, 32, NULL, DLM3_LKF_HEADQUE, \
924 NULL, HFILL}}, \
925 { &hf_dlm3_##SYMNAME##_noorder, \
926 { "Disregard the standard grant order rules", "dlm3." STRNAME ".noorder", \
927 FT_BOOLEAN, 32, NULL, DLM3_LKF_NOORDER, \
928 NULL, HFILL}}, \
929 { &hf_dlm3_##SYMNAME##_orphan, \
930 { "Orphan", "dlm3." STRNAME ".orphan", \
931 FT_BOOLEAN, 32, NULL, DLM3_LKF_ORPHAN, \
932 NULL, HFILL}}, \
933 { &hf_dlm3_##SYMNAME##_altpr, \
934 { "Try to grant the lock in `protected read' mode", "dlm3." STRNAME ".altpr", \
935 FT_BOOLEAN, 32, NULL, DLM3_LKF_ALTPR, \
936 NULL, HFILL}}, \
937 { &hf_dlm3_##SYMNAME##_altcw, \
938 { "Try to grant the lock in `concurrent read' mode", "dlm3." STRNAME ".altcw", \
939 FT_BOOLEAN, 32, NULL, DLM3_LKF_ALTCW, \
940 NULL, HFILL}}, \
941 { &hf_dlm3_##SYMNAME##_forceunlock, \
942 { "Force unlock", "dlm3." STRNAME ".forceunlock", \
943 FT_BOOLEAN, 32, NULL, DLM3_LKF_FORCEUNLOCK, \
944 NULL, HFILL}}, \
945 { &hf_dlm3_##SYMNAME##_timeout, \
946 { "Timeout", "dlm3." STRNAME ".timeout", \
947 FT_BOOLEAN, 32, NULL, DLM3_LKF_TIMEOUT, \
948 NULL, HFILL}}
951 #define DLM3_REGISTER_HF_FLAGS(SYMNAME,STRNAME) \
952 { &hf_dlm3_##SYMNAME, \
953 { "Internal Flags", "dlm3." STRNAME, \
954 FT_UINT32, BASE_HEX, NULL, 0x0, \
955 NULL, HFILL}}, \
956 { &hf_dlm3_##SYMNAME##_user, \
957 { "User space lock realted", "dlm3." STRNAME ".user", \
958 FT_BOOLEAN, 32, NULL, DLM3_IFL_USER, \
959 NULL, HFILL}}, \
960 { &hf_dlm3_##SYMNAME##_orphan, \
961 { "Orphaned lock", "dlm3." STRNAME ".orphan", \
962 FT_BOOLEAN, 32, NULL, DLM3_IFL_ORPHAN, \
963 NULL, HFILL}}
965 #define DLM3_REGISTER_HF_ASTS(NAME,SIZE) \
966 { &hf_dlm3_##NAME##_asts, \
967 { "Asynchronous Traps", "dlm3." #NAME ".asts", \
968 FT_UINT##SIZE, BASE_HEX, NULL, 0x0, \
969 NULL, HFILL}}, \
970 { &hf_dlm3_##NAME##_asts_comp, \
971 { "Completion", "dlm3." #NAME ".asts.comp", \
972 FT_BOOLEAN, SIZE, NULL, DLM3_AST_COMP, \
973 NULL, HFILL }}, \
974 { &hf_dlm3_##NAME##_asts_bast, \
975 { "Blocking", "dlm3." #NAME ".asts.bast", \
976 FT_BOOLEAN, SIZE, NULL, DLM3_AST_BAST, \
977 NULL, HFILL }}
979 void
980 proto_register_dlm3(void)
982 module_t *dlm3_module;
985 static hf_register_info hf[] = {
986 /* dlm_header */
987 { &hf_dlm3_h_version,
988 { "Version", "dlm3.h.version",
989 FT_UINT32, BASE_HEX, NULL, 0x0,
990 NULL, HFILL }},
991 { &hf_dlm3_h_major_version,
992 { "Major Version", "dlm3.h.major_version",
993 FT_UINT16, BASE_HEX, NULL, 0x0,
994 NULL, HFILL }},
995 { &hf_dlm3_h_minor_version,
996 { "Minor Version", "dlm3.h.minor_version",
997 FT_UINT16, BASE_HEX, NULL, 0x0,
998 NULL, HFILL }},
999 { &hf_dlm3_h_lockspace,
1000 { "Lockspace Global ID", "dlm3.h.lockspac",
1001 FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
1002 NULL, HFILL }},
1003 { &hf_dlm3_h_nodeid,
1004 { "Sender Node ID", "dlm3.h.nodeid",
1005 FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
1006 NULL, HFILL }},
1007 { &hf_dlm3_h_length,
1008 { "Length", "dlm3.h.length",
1009 FT_UINT16, BASE_DEC, NULL, 0x0,
1010 NULL, HFILL }},
1011 { &hf_dlm3_h_cmd,
1012 { "Command", "dlm3.h.cmd",
1013 FT_UINT8, BASE_DEC, VALS(dlm3_cmd), 0x0,
1014 NULL, HFILL }},
1015 { &hf_dlm3_h_pad,
1016 { "Padding", "dlm3.h.pad",
1017 FT_UINT8, BASE_DEC, NULL, 0x0,
1018 NULL, HFILL }},
1020 /* dlm_message */
1021 { &hf_dlm3_m_type,
1022 { "Message Type", "dlm3.m.type",
1023 FT_UINT32, BASE_DEC, VALS(dlm3_msg), 0x0,
1024 NULL, HFILL }},
1025 { &hf_dlm3_m_nodeid,
1026 { "Receiver Node ID", "dlm3.m.nodeid",
1027 FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
1028 NULL, HFILL }},
1029 { &hf_dlm3_m_pid,
1030 { "Process ID of Lock Owner", "dlm3.m.pid",
1031 FT_UINT32, BASE_DEC, NULL, 0x0,
1032 NULL, HFILL }},
1033 DLM3_REGISTER_HF_LOCKID(m),
1035 /* dlm_message::exflags */
1036 DLM3_REGISTER_HF_EXFLAGS(m_exflags, "m.exflags"),
1038 /* dlm_message::sbflags */
1039 { &hf_dlm3_m_sbflags,
1040 { "Status Block Flags", "dlm3.m.sbflags",
1041 FT_UINT32, BASE_HEX, NULL, 0x0,
1042 NULL, HFILL}},
1043 { &hf_dlm3_m_sbflags_demoted,
1044 { "Demoted for deadlock resolution", "dlm3.m.sbflags.demoted",
1045 FT_BOOLEAN, 32, NULL, DLM3_SBF_DEMOTED,
1046 NULL, HFILL}},
1047 { &hf_dlm3_m_sbflags_valnotvalid,
1048 { "Lock Value Block Is Invalid", "dlm3.m.sbflags.valnotvalid",
1049 FT_BOOLEAN, 32, NULL, DLM3_SBF_VALNOTVALID,
1050 NULL, HFILL}},
1051 { &hf_dlm3_m_sbflags_altmode,
1052 { "Try to Grant in Alternative Mode", "dlm3.m.sbflags.altmode",
1053 FT_BOOLEAN, 32, NULL, DLM3_SBF_ALTMODE,
1054 NULL, HFILL}},
1056 /* dlm_message::flags */
1057 DLM3_REGISTER_HF_FLAGS(m_flags, "m.flags"),
1059 { &hf_dlm3_m_lvbseq,
1060 { "Lock Value Block Sequence Number", "dlm3.m.lvbseq",
1061 FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
1062 NULL, HFILL}},
1064 { &hf_dlm3_m_hash,
1065 { "Hash value", "dlm3.m.hash",
1066 FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
1067 NULL, HFILL}},
1069 { &hf_dlm3_m_status,
1070 { "Status", "dlm3.m.status",
1071 FT_INT32, BASE_DEC, VALS(dlm3_status), 0x0,
1072 NULL, HFILL}},
1074 { &hf_dlm3_m_grmode,
1075 { "Granted Mode", "dlm3.m.grmode",
1076 FT_INT32, BASE_DEC, VALS(dlm3_mode), 0x0,
1077 NULL, HFILL}},
1078 { &hf_dlm3_m_rqmode,
1079 { "Request Mode", "dlm3.m.rqmode",
1080 FT_INT32, BASE_DEC, VALS(dlm3_mode), 0x0,
1081 NULL, HFILL}},
1082 { &hf_dlm3_m_bastmode,
1083 { "Mode requested by another node", "dlm3.m.bastmode",
1084 FT_INT32, BASE_DEC, VALS(dlm3_mode), 0x0,
1085 NULL, HFILL}},
1087 /* dlm_message::asts */
1088 DLM3_REGISTER_HF_ASTS(m, 32),
1090 { &hf_dlm3_m_result,
1091 { "Message Result(errno)", "dlm3.m.result",
1092 FT_INT32, BASE_DEC, VALS(dlm3_result), 0x0,
1093 NULL, HFILL}},
1094 { &hf_dlm3_m_extra,
1095 { "Extra Message", "dlm3.m.extra",
1096 FT_BYTES, BASE_NONE, NULL, 0x0,
1097 NULL, HFILL}},
1099 /* dlm_rcom */
1100 { &hf_dlm3_rc_type,
1101 { "Recovery Command Type", "dlm3.rc.type",
1102 FT_UINT32, BASE_DEC, VALS(dlm3_rcom), 0x0,
1103 NULL, HFILL}},
1104 { &hf_dlm3_rc_result,
1105 { "Recovery Command Result", "dlm3.rc.result",
1106 FT_INT32, BASE_DEC, NULL, 0x0,
1107 NULL, HFILL}},
1108 { &hf_dlm3_rc_id,
1109 { "Recovery Command ID", "dlm3.rc.id",
1110 FT_UINT64, BASE_DEC, NULL, 0x0,
1111 NULL, HFILL}},
1112 { &hf_dlm3_rc_seq,
1113 { "Recovery Command Sequence Number of Sender", "dlm3.rc.seq",
1114 FT_UINT64, BASE_DEC, NULL, 0x0,
1115 NULL, HFILL}},
1116 { &hf_dlm3_rc_seq_reply,
1117 { "Recovery Command Sequence Number of Receiver", "dlm3.rc.seq_reply",
1118 FT_UINT64, BASE_DEC, NULL, 0x0,
1119 NULL, HFILL}},
1120 { &hf_dlm3_rc_buf,
1121 { "Recovery Buffer", "dlm3.rc.buf",
1122 FT_BYTES, BASE_NONE, NULL, 0x0,
1123 NULL, HFILL}},
1125 /* rcom_config */
1126 { &hf_dlm3_rf_lvblen,
1127 { "Lock Value Block Length", "dlm3.rf.lvblen",
1128 FT_UINT32, BASE_DEC, NULL, 0x0,
1129 NULL, HFILL}},
1131 /* rcom_config::rf_lsflags */
1132 DLM3_REGISTER_HF_EXFLAGS(rf_lsflags, "rf.lsflags"),
1134 { &hf_dlm3_rf_unused,
1135 { "Unused area", "dlm3.rf.lsflags.unused",
1136 FT_UINT64, BASE_HEX, NULL, 0x0,
1137 NULL, HFILL}},
1139 /* rcom_lock */
1140 { &hf_dlm3_rl_ownpid,
1141 { "Process ID of Lock Owner", "dlm3.rl.ownpid",
1142 FT_UINT32, BASE_DEC, NULL, 0x0,
1143 NULL, HFILL}},
1145 DLM3_REGISTER_HF_LOCKID(rl),
1146 DLM3_REGISTER_HF_EXFLAGS(rl_exflags, "rl.exflags"),
1147 DLM3_REGISTER_HF_FLAGS(rl_flags, "rl.flags"),
1149 { &hf_dlm3_rl_lvbseq,
1150 { "Lock Value Block Sequence Number", "dlm3.rl.lvbseq",
1151 FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
1152 NULL, HFILL}},
1153 { &hf_dlm3_rl_result,
1154 { "Result of Recovering master copy", "dlm3.rl.result",
1155 FT_INT32, BASE_DEC, VALS(dlm3_result), 0x0,
1156 NULL, HFILL}},
1157 { &hf_dlm3_rl_rqmode,
1158 { "Request Mode", "dlm3.rl.rqmode",
1159 FT_INT8, BASE_DEC, VALS(dlm3_mode), 0x0,
1160 NULL, HFILL}},
1161 { &hf_dlm3_rl_grmode,
1162 { "Granted Mode", "dlm3.rl.grmode",
1163 FT_INT8, BASE_DEC, VALS(dlm3_mode), 0x0,
1164 NULL, HFILL}},
1165 { &hf_dlm3_rl_status,
1166 { "Status", "dlm3.rl.status",
1167 FT_INT8, BASE_DEC, VALS(dlm3_rs), 0x0,
1168 NULL, HFILL}},
1169 DLM3_REGISTER_HF_ASTS(rl, 8),
1171 { &hf_dlm3_rl_wait_type,
1172 { "Message Type the waiter is waiting for", "dlm3.rl.wait_type",
1173 FT_UINT16, BASE_DEC, VALS(dlm3_msg), 0x0,
1174 NULL, HFILL }},
1176 { &hf_dlm3_rl_namelen,
1177 { "Length of `name' field", "dlm3.rl.namelen",
1178 FT_UINT16, BASE_DEC, NULL, 0x0,
1179 NULL, HFILL }},
1180 { &hf_dlm3_rl_name,
1181 { "Name of Resource", "dlm3.rl.name",
1182 FT_BYTES, BASE_NONE, NULL, 0x0,
1183 NULL, HFILL }},
1184 { &hf_dlm3_rl_name_contents,
1185 { "Contents actually occupying `name' field", "dlm3.rl.name_contents",
1186 FT_STRING, BASE_NONE, NULL, 0x0,
1187 NULL, HFILL }},
1188 { &hf_dlm3_rl_name_padding,
1189 { "Padding", "dlm3.rl.name_padding",
1190 FT_BYTES, BASE_NONE, NULL, 0x0,
1191 NULL, HFILL }},
1192 { &hf_dlm3_rl_lvb,
1193 { "Lock Value Block", "dlm3.rl.lvb",
1194 FT_BYTES, BASE_NONE, NULL, 0x0,
1195 NULL, HFILL }}
1198 static gint *ett[] = {
1199 &ett_dlm3,
1200 &ett_dlm3_version,
1202 &ett_dlm3_msg,
1203 &ett_dlm3_m_exflags,
1204 &ett_dlm3_sbflags,
1205 &ett_dlm3_m_flags,
1206 &ett_dlm3_m_asts,
1208 &ett_dlm3_rcom,
1209 &ett_dlm3_rcom_lock,
1210 &ett_dlm3_rcom_config,
1212 &ett_dlm3_rf_lsflags,
1213 &ett_dlm3_rl_exflags,
1214 &ett_dlm3_rl_flags,
1215 &ett_dlm3_rl_asts,
1216 &ett_dlm3_rl_name
1219 proto_dlm3 = proto_register_protocol("Distributed Lock Manager",
1220 "DLM3", "dlm3");
1221 proto_register_field_array(proto_dlm3, hf, array_length(hf));
1222 proto_register_subtree_array(ett, array_length(ett));
1224 dlm3_module = prefs_register_protocol(proto_dlm3,
1225 proto_reg_handoff_dlm3);
1227 prefs_register_uint_preference(dlm3_module, "tcp.port",
1228 "DLM3 TCP Port",
1229 "Set the TCP port for Distributed Lock Manager",
1231 &dlm3_tcp_port);
1232 prefs_register_uint_preference(dlm3_module, "sctp.port",
1233 "DLM3 SCTP Port",
1234 "Set the SCTP port for Distributed Lock Manager",
1236 &dlm3_sctp_port);
1240 void
1241 proto_reg_handoff_dlm3(void)
1243 static gboolean dissector_registered = FALSE;
1245 static guint tcp_port;
1246 static guint sctp_port;
1248 static dissector_handle_t dlm3_tcp_handle;
1249 static dissector_handle_t dlm3_sctp_handle;
1251 if (!dissector_registered) {
1252 dlm3_sctp_handle = new_create_dissector_handle(dissect_dlm3, proto_dlm3);
1253 dlm3_tcp_handle = new_create_dissector_handle(dissect_dlm3, proto_dlm3);
1254 dissector_registered = TRUE;
1255 } else {
1256 dissector_delete_uint("tcp.port", tcp_port, dlm3_tcp_handle);
1257 dissector_delete_uint("sctp.port", sctp_port, dlm3_sctp_handle);
1260 tcp_port = dlm3_tcp_port;
1261 sctp_port = dlm3_sctp_port;
1262 dissector_add_uint("tcp.port", tcp_port, dlm3_tcp_handle);
1263 dissector_add_uint("sctp.port", sctp_port, dlm3_sctp_handle);
1266 /* packet-dlm3.c ends here. */