From 3112a1be16d59f528d4dc396447a29f0759b617b Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 7 Oct 2015 23:15:23 +0200 Subject: [PATCH] monitor: Decode the LMP name request procedure --- monitor/bt.h | 12 ++++++++++++ monitor/lmp.c | 25 +++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/monitor/bt.h b/monitor/bt.h index 504041107..5024e57f0 100644 --- a/monitor/bt.h +++ b/monitor/bt.h @@ -101,6 +101,18 @@ struct bt_ll_reject_ind { #define LMP_ESC4(x) ((127 << 8) | (x)) +#define BT_LMP_NAME_REQ 1 +struct bt_lmp_name_req { + uint8_t offset; +} __attribute__ ((packed)); + +#define BT_LMP_NAME_RSP 2 +struct bt_lmp_name_rsp { + uint8_t offset; + uint8_t length; + uint8_t fragment[14]; +} __attribute__ ((packed)); + #define BT_LMP_ACCEPTED 3 struct bt_lmp_accepted { uint8_t opcode; diff --git a/monitor/lmp.c b/monitor/lmp.c index d36861aac..f85b4d871 100644 --- a/monitor/lmp.c +++ b/monitor/lmp.c @@ -27,6 +27,7 @@ #endif #include +#include #include "src/shared/util.h" #include "display.h" @@ -54,6 +55,26 @@ static void print_opcode(uint16_t opcode) print_field("Operation: %s (%u)", str, opcode); } +static void name_req(const void *data, uint8_t size) +{ + const struct bt_lmp_name_req *pdu = data; + + print_field("Offset: %u", pdu->offset); +} + +static void name_rsp(const void *data, uint8_t size) +{ + const struct bt_lmp_name_rsp *pdu = data; + char str[15]; + + memcpy(str, pdu->fragment, 14); + str[14] = '\0'; + + print_field("Offset: %u", pdu->offset); + print_field("Length: %u", pdu->length); + print_field("Fragment: %s", str); +} + static void accepted(const void *data, uint8_t size) { const struct bt_lmp_accepted *pdu = data; @@ -625,8 +646,8 @@ struct lmp_data { }; static const struct lmp_data lmp_table[] = { - { 1, "LMP_name_req" }, - { 2, "LMP_name_res" }, + { 1, "LMP_name_req", name_req, 1, true }, + { 2, "LMP_name_res", name_rsp, 16, true }, { 3, "LMP_accepted", accepted, 1, true }, { 4, "LMP_not_accepted", not_accepted, 2, true }, { 5, "LMP_clkoffset_req", clkoffset_req, 0, true }, -- 2.47.3