[Ocfs2-tools-devel] [PATCH 1/1] wireshark-ocfs2: add dlm_query_join_request handler
Jeff Liu
jeff.liu at oracle.com
Wed Jul 15 08:11:41 PDT 2009
this patch add dlm_query_join_request handler in dissector, it could deal with the message variants
for both ocfs2-1.2.x and the newer.
Signed-off-by: Jeff Liu <jeff.liu at oracle.com>
---
epan/dissectors/packet-ocfs2.c | 69 ++++++++++++++++++++++++++++++++++------
1 files changed, 59 insertions(+), 10 deletions(-)
diff --git a/epan/dissectors/packet-ocfs2.c b/epan/dissectors/packet-ocfs2.c
index ce57c3f..264294b 100644
--- a/epan/dissectors/packet-ocfs2.c
+++ b/epan/dissectors/packet-ocfs2.c
@@ -235,7 +235,6 @@ enum dlm_query_join_response {
JOIN_OK_NO_MAP,
};
-
/* DLM lock modes */
enum {
LKM_IVMODE = -1,
@@ -776,13 +775,35 @@ struct dlm_master_requery {
guint32 pad3;
guint8 name[O2NM_MAX_NAME_LEN];
};
-struct dlm_query_join_request
-{
+
+#define O2NM_MAX_NODES 255
+#define BITS_PER_BYTE 8
+#define BITS_TO_BYTES(bits) (((bits)+BITS_PER_BYTE-1)/BITS_PER_BYTE)
+/* dlm_query_join_request for ocfs2-1.2.x */
+struct dlm_query_join_request_129 {
guint8 node_idx;
guint8 pad1[2]; // unused
guint8 name_len;
guint8 domain[O2NM_MAX_NAME_LEN];
+ guint8 node_map[BITS_TO_BYTES(O2NM_MAX_NODES)];
+};
+
+struct dlm_protocol_version {
+ guint8 pv_major;
+ guint8 pv_minor;
+};
+
+/* the latest msg layout */
+struct dlm_query_join_request {
+ guint8 node_idx;
+ guint8 pad1[2];
+ guint8 name_len;
+ struct dlm_protocol_version dlm_proto;
+ struct dlm_protocol_version fs_proto;
+ guint8 domain[O2NM_MAX_NAME_LEN];
+ guint8 node_map[BITS_TO_BYTES(O2NM_MAX_NODES)];
};
+
struct dlm_assert_joined
{
guint8 node_idx;
@@ -946,12 +967,6 @@ static struct dlm_msg_struct_def dlm_struct_defs[] = {
{ "dead_node", &hf_dlm_dead_node, FIELD_OFFSET_AND_SIZE(struct dlm_begin_reco,dead_node), dlm_node_idx_handler},
{ DLM_MSG_STRUCT_DEF_END } }
},
-{ "dlm_query_join_request", "DLM Query Join Request", DLM_QUERY_JOIN_MSG, &ett_dlm_query_join, {
- { "node_idx", &hf_dlm_node_idx, FIELD_OFFSET_AND_SIZE(struct dlm_query_join_request,node_idx), dlm_node_idx_handler},
- { "name_len", &hf_dlm_domain_name_len,FIELD_OFFSET_AND_SIZE(struct dlm_query_join_request,name_len), dlm_domain_namelen_handler},
- { "domain", &hf_dlm_domain_name, FIELD_OFFSET_AND_SIZE(struct dlm_query_join_request,domain), dlm_domain_name_handler},
- { DLM_MSG_STRUCT_DEF_END } }
-},
{ "dlm_assert_joined", "DLM Assert Joined", DLM_ASSERT_JOINED_MSG, &ett_dlm_assert_joined, {
{ "node_idx", &hf_dlm_node_idx, FIELD_OFFSET_AND_SIZE(struct dlm_assert_joined,node_idx), dlm_node_idx_handler},
{ "name_len", &hf_dlm_domain_name_len,FIELD_OFFSET_AND_SIZE(struct dlm_assert_joined,name_len), dlm_domain_namelen_handler},
@@ -1148,6 +1163,36 @@ static void msg_struct_enumerate_fields(struct dlm_msg_struct_def *def, proto_tr
}
}
+static void dissect_dlm_query_join_request(proto_tree *tree, tvbuff_t *tvb,
+ int offset)
+{
+ guint8 namelen;
+ gint len;
+ int msg_len;
+
+ proto_tree_add_item(tree, hf_dlm_node_idx, tvb, offset, 1, FALSE);
+
+ /* skip follow 2 padding bytes */
+ offset += 3;
+ namelen = tvb_get_guint8(tvb, offset);
+ proto_tree_add_item(tree, hf_dlm_namelen, tvb, offset, 1, FALSE);
+
+ len = tvb_reported_length_remaining(tvb, offset);
+
+ ++offset;
+ /* if the left message length more than namelen, its most likely
+ * ocfs2-1.4 or newer we are dealing with, or else ocfs2-1.2 or
+ * mismatch */
+ if (len > (namelen +
+ sizeof(((struct dlm_query_join_request *)0L)->node_map)))
+ proto_tree_add_item(tree, hf_dlm_domain_name, tvb,
+ offset + 4, namelen, FALSE);
+ else if (len == (namelen +
+ sizeof(((struct dlm_query_join_request_129 *)0L)->node_map)))
+ proto_tree_add_item(tree, hf_dlm_domain_name, tvb,
+ offset, namelen, FALSE);
+}
+
static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *subtree = NULL;
@@ -1240,13 +1285,17 @@ static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
}
-
if (magic == O2NET_MSG_MAGIC) {
struct dlm_msg_struct_def *def;
def = msg_struct_lookup_by_type(msg_type);
if (def)
msg_struct_enumerate_fields(def, subtree, tvb, O2NET_MSG_HDR_OFF_PAYLOAD);
}
+
+ if (msg_type == DLM_QUERY_JOIN_MSG)
+ if (magic == O2NET_MSG_MAGIC)
+ dissect_dlm_query_join_request(subtree,
+ tvb, O2NET_MSG_HDR_OFF_PAYLOAD);
}
out:
return ret;
--
1.5.4.3
More information about the Ocfs2-tools-devel
mailing list