From 97c5d7942bf351d87b688dbfb03708da2576d828 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 1 Nov 2018 15:55:12 +0200 Subject: [PATCH] monitor: Decode error response 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 --- monitor/sdp.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/monitor/sdp.c b/monitor/sdp.c index ac346d8..f284ebb 100755 --- a/monitor/sdp.c +++ b/monitor/sdp.c @@ -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) -- 2.7.4