[Ocfs2-tools-devel] [PATCH 1/1] wireshark-ocfs2: print 144 bytes of Payload

Jeff Liu jeff.liu at oracle.com
Sun Jun 7 07:07:38 PDT 2009


This patch print Payload raw string up to 144 bytes, splited into 6 lines

Signed-off-by: Jeff Liu <jeff.liu at oracle.com>
---
 epan/dissectors/packet-ocfs2.c |   73 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/epan/dissectors/packet-ocfs2.c b/epan/dissectors/packet-ocfs2.c
index 96da122..0c70512 100644
--- a/epan/dissectors/packet-ocfs2.c
+++ b/epan/dissectors/packet-ocfs2.c
@@ -92,7 +92,12 @@ 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_payload = -1;
+static int hf_msg_payload1 = -1;
+static int hf_msg_payload2 = -1;
+static int hf_msg_payload3 = -1;
+static int hf_msg_payload4 = -1;
+static int hf_msg_payload5 = -1;
+static int hf_msg_payload6 = -1;
 
 static int hf_dlm_node_idx = -1;
 static int hf_dlm_flags = -1;
@@ -777,6 +782,8 @@ struct dlm_finalize_reco
 	guint32 pad2;	// unused
 };
 
+#define DLM_FIELD_BYTES_LEN	24
+
 static struct dlm_msg_struct_def dlm_struct_defs[] = {
 { "dlm_master_request", "DLM Master Request", DLM_MASTER_REQUEST_MSG, &ett_dlm_master_request, {
 	{ "node_idx",	&hf_dlm_node_idx,	FIELD_OFFSET_AND_SIZE(struct dlm_master_request,node_idx),	dlm_node_idx_handler},
@@ -1126,10 +1133,47 @@ static int dissect_ocfs2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 				    FALSE);
 
 		len = tvb_get_ntohs(tvb, O2NET_MSG_HDR_OFF_DATA_LEN);
-		if (len > 0)
-			proto_tree_add_item(subtree, hf_msg_payload,
-					tvb, O2NET_MSG_HDR_OFF_PAYLOAD, len,
-					FALSE);
+		if (len > 0) {
+			int i = 0;
+			int rlen = 0;
+			guint loffset = 0;
+			int hf_msg_payload_array[] = {
+				hf_msg_payload1,
+				hf_msg_payload2,
+				hf_msg_payload3,
+				hf_msg_payload4,
+				hf_msg_payload5,
+				hf_msg_payload6
+			};
+
+			/* print 144 bytes of Payload */
+			if (len > 144)
+				len = 144;
+
+			loffset = O2NET_MSG_HDR_OFF_PAYLOAD;
+			while (tvb_offset_exists(tvb, loffset) && (len > 0) &&
+			(i < sizeof(hf_msg_payload_array)/sizeof(int))) {
+				rlen = tvb_length_remaining(tvb, loffset);
+				if (rlen < DLM_FIELD_BYTES_LEN) {
+					proto_tree_add_item(subtree,
+							hf_msg_payload_array[i],
+							tvb, loffset, rlen,
+							FALSE);
+					break;
+				}
+
+				proto_tree_add_item(subtree,
+						hf_msg_payload_array[i],
+						tvb, loffset,
+						DLM_FIELD_BYTES_LEN,
+						FALSE);
+
+				loffset += DLM_FIELD_BYTES_LEN;
+				len -= DLM_FIELD_BYTES_LEN;
+				++i;
+			}
+		}
+
 
 		if (magic == O2NET_MSG_MAGIC) {
 			struct dlm_msg_struct_def *def;
@@ -1170,9 +1214,24 @@ void proto_register_ocfs2(void)
 		{ &hf_msg_msg_num, { "Num", "ocfs2.msg.msg_num",
 					FT_UINT32, BASE_DEC, NULL, 0x0,
 					"Message identification number", HFILL } },
-		{ &hf_msg_payload, { "Payload", "ocfs2.msg.payload",
+		{ &hf_msg_payload1, { "Payload1", "ocfs2.msg.payload",
+					FT_BYTES, BASE_HEX, NULL, 0x0,
+					"Payload 1", HFILL } },
+		{ &hf_msg_payload2, { "Payload2", "ocfs2.msg.payload",
+					FT_BYTES, BASE_HEX, NULL, 0x0,
+					"Payload 2", HFILL } },
+		{ &hf_msg_payload3, { "Payload3", "ocfs2.msg.payload",
+					FT_BYTES, BASE_HEX, NULL, 0x0,
+					"Payload 3", HFILL } },
+		{ &hf_msg_payload4, { "Payload4", "ocfs2.msg.payload",
+					FT_BYTES, BASE_HEX, NULL, 0x0,
+					"Payload 4", HFILL } },
+		{ &hf_msg_payload5, { "Payload5", "ocfs2.msg.payload",
+					FT_BYTES, BASE_HEX, NULL, 0x0,
+					"Payload 5", HFILL } },
+		{ &hf_msg_payload6, { "Payload6", "ocfs2.msg.payload",
 					FT_BYTES, BASE_HEX, NULL, 0x0,
-					"Payload", HFILL } },
+					"Payload 6", HFILL } },
 		{ &hf_dlm_node_idx, { "Node Index", "ocfs2.dlm.node_idx",
 					FT_UINT8, BASE_DEC, NULL, 0x0,
 					"Node index", HFILL } },
-- 
1.5.4.3




More information about the Ocfs2-tools-devel mailing list