monitor: Decode error response
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 1 Nov 2018 13:55:12 +0000 (15:55 +0200)
committerhimanshu <h.himanshu@samsung.com>
Tue, 14 Jan 2020 08:53:35 +0000 (14:23 +0530)
This adds decoding for the error code in the error response:

> test-sdp: User Data RX
      Channel: 0 len 7 [PSM 1 mode 0] {chan 0}
      SDP: Error Response (0x01) tid 2 len 2
        Error code: Invalid Continuation State (0x0005)

Change-Id: Ie72b90f076e36a75a9fef91cdef235070ad28d1b
Signed-off-by: himanshu <h.himanshu@samsung.com>
monitor/sdp.c

index ac346d8..f284ebb 100755 (executable)
@@ -534,6 +534,24 @@ static uint16_t common_rsp(const struct l2cap_frame *frame,
        return bytes;
 }
 
+static const char *error_str(uint16_t code)
+{
+       switch (code) {
+       case 0x0001:
+               return "Invalid Version";
+       case 0x0002:
+               return "Invalid Record Handle";
+       case 0x0003:
+               return "Invalid Syntax";
+       case 0x0004:
+               return "Invalid PDU Size";
+       case 0x0005:
+               return "Invalid Continuation State";
+       default:
+               return "Unknown";
+       }
+}
+
 static void error_rsp(const struct l2cap_frame *frame, struct tid_data *tid)
 {
        uint16_t error;
@@ -548,7 +566,7 @@ static void error_rsp(const struct l2cap_frame *frame, struct tid_data *tid)
 
        error = get_be16(frame->data);
 
-       print_field("Error code: 0x%2.2x", error);
+       print_field("Error code: %s (0x%4.4x)", error_str(error), error);
 }
 
 static void service_req(const struct l2cap_frame *frame, struct tid_data *tid)