Diff between 8320c28ff15fcd8d9fa717c438ef7fa8ec8104b5 and bd8f8f8b5bf90ea6dabcd8441f8e7e4894f0e385

Changed Files

File Additions Deletions Status
monitor/bnep.c +35 -3 modified

Full Patch

diff --git a/monitor/bnep.c b/monitor/bnep.c
index 15050cb..d73a3bc 100644
--- a/monitor/bnep.c
+++ b/monitor/bnep.c
@@ -158,6 +158,38 @@ static bool setup_conn_req(struct bnep_frame *bnep_frame, uint8_t indent)
 	return true;
 }
 
+static const char *value2str(uint16_t value)
+{
+	switch (value) {
+	case 0x00:
+		return "Operation Successful";
+	case 0x01:
+		return "Operation Failed - Invalid Dst Srv UUID";
+	case 0x02:
+		return "Operation Failed - Invalid Src Srv UUID";
+	case 0x03:
+		return "Operation Failed - Invalid Srv UUID size";
+	case 0x04:
+		return "Operation Failed - Conn not allowed";
+	default:
+		return "Unknown";
+	}
+}
+
+static bool print_rsp_msg(struct bnep_frame *bnep_frame, uint8_t indent)
+{
+	struct l2cap_frame *frame = &bnep_frame->l2cap_frame;
+	uint16_t rsp_msg;
+
+	if (!l2cap_frame_get_be16(frame, &rsp_msg))
+		return false;
+
+	print_field("%*cRsp msg: %s(0x%04x) ", indent, ' ',
+					value2str(rsp_msg), rsp_msg);
+
+	return true;
+}
+
 static bool filter_nettype_req(struct bnep_frame *bnep_frame, uint8_t indent)
 {
 	struct l2cap_frame *frame = &bnep_frame->l2cap_frame;
@@ -219,11 +251,11 @@ struct bnep_control_data {
 static const struct bnep_control_data bnep_control_table[] = {
 	{ 0x00, "Command Not Understood",	cmd_nt_understood	},
 	{ 0x01, "Setup Conn Req",		setup_conn_req		},
-	{ 0x02, "Setup Conn Rsp",		},
+	{ 0x02, "Setup Conn Rsp",		print_rsp_msg		},
 	{ 0x03, "Filter NetType Set",		filter_nettype_req	},
-	{ 0x04, "Filter NetType Rsp",		},
+	{ 0x04, "Filter NetType Rsp",		print_rsp_msg		},
 	{ 0x05, "Filter MultAddr Set",		filter_multaddr_req	},
-	{ 0x06, "Filter MultAddr Rsp",		},
+	{ 0x06, "Filter MultAddr Rsp",		print_rsp_msg		},
 	{ }
 };