ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: [Wireshark-dev] [PATCH] Fix IPMI Completion Codes

From: Flavio Leitner <flavio.leitner@xxxxxxxxx>
Date: Thu, 24 May 2007 20:15:04 -0300
(please, keep myself on CC as I'm not subscribed)

Hi,

The IPMI Completion Codes in range 80-BEh are command-specific so
it must consider the command before translate it.

The Get Session Challenge completion code response is implemented
according with IPMIv2_0rev1_0.pdf, page 306, table 22-20.
(patch attached)

-- 
Flávio
[PATCH]: Fix IPMI Completion Code translation.

The IPMI Completion Codes in range 80-BEh are command-specific so 
it must consider the command before translate it.

The Get Session Challenge completion code response is implemented
according with IPMIv2_0rev1_0.pdf, page 306, table 22-20.
 
Signed-of-by Flavio Leitner <flavio.leitner@xxxxxxxxx>


Index: wireshark-0.99.5/epan/dissectors/packet-ipmi.c
===================================================================
--- wireshark-0.99.5.orig/epan/dissectors/packet-ipmi.c
+++ wireshark-0.99.5/epan/dissectors/packet-ipmi.c
@@ -569,6 +569,13 @@ static const true_false_string ipmi_payl
   "Payload is unencrypted"
 };
 
+/* IPMIv2_0rev1_0.pdf, page 306, table 22-20 */
+static const value_string ipmi_chccode_vals[] = {
+	{ 0x81, "Invalid user name" },
+	{ 0x82, "Null user name (User 1) not enabled" },
+	{ 0x00, NULL },
+};
+
 static const value_string ipmi_ccode_vals[] = {
 	{ 0x00, "Command completed normally" },
 	/* added by lane */
@@ -3970,6 +3977,23 @@ get_netfn_cmd_text(guint8 netfn, guint8 
 	}
 }
 
+static const char *
+get_ccode_cmd_text(guint8 cmd, guint8 ccode)
+{
+
+	/* command-specific codes 80-BEh */
+	if (ccode >= 0x80 && ccode <= 0xBE) {
+		switch (cmd) {
+			/* Get Session Challenge */
+			case 0x39:
+				return val_to_str(ccode, ipmi_chccode_vals, 
+					    "Unknown (0x%02x)");
+		}
+	}
+
+	return val_to_str(ccode, ipmi_ccode_vals, "Unknown (0x%02x)");
+}
+
 static void
 dissect_ipmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
@@ -4053,7 +4077,7 @@ dissect_ipmi(tvbuff_t *tvb, packet_info 
 				col_add_fstr(pinfo->cinfo, COL_INFO, "%s, %s: %s",
 				     get_netfn_cmd_text(netfn, cmd),
 				     val_to_str(netfn, ipmi_netfn_vals,	"Unknown (0x%02x)"),
-				     val_to_str(ccode, ipmi_ccode_vals,	"Unknown (0x%02x)"));
+				     get_ccode_cmd_text(cmd, ccode));
 			else
 				col_add_fstr(pinfo->cinfo, COL_INFO, "%s, %s",
 				     get_netfn_cmd_text(netfn, cmd),
@@ -4251,8 +4275,9 @@ dissect_ipmi(tvbuff_t *tvb, packet_info 
 
 	/* completion code */
 	if (tree && response) {
-		proto_tree_add_item(ipmi_tree, hf_ipmi_msg_ccode,
-				    tvb, offset++, 1, TRUE);
+		proto_tree_add_text(ipmi_tree, tvb, offset++, 1,
+				    "Completion Code: %s (0x%02x)",
+				    get_ccode_cmd_text(cmd, ccode), ccode);
 	}