From 1af626dcb24e9ca26af1a96b48e5e7cbbd7fad48 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 22 Feb 2012 20:38:08 +0100 Subject: [PATCH] monitor: Decode some of the management authentication events --- monitor/main.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/monitor/main.c b/monitor/main.c index eeb182441..f17099c5b 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -710,6 +710,46 @@ static void mgmt_local_name_changed(uint16_t len, void *buf) hexdump(buf, len); } +static void mgmt_new_link_key(uint16_t len, void *buf) +{ + struct mgmt_ev_new_link_key *ev = buf; + char str[18]; + + if (len < sizeof(*ev)) { + printf("* Malformed New Link Key control\n"); + return; + } + + ba2str(&ev->key.addr.bdaddr, str); + + printf("@ New Link Key: %s (%d)\n", str, ev->key.addr.type); + + buf += sizeof(*ev); + len -= sizeof(*ev); + + hexdump(buf, len); +} + +static void mgmt_new_long_term_key(uint16_t len, void *buf) +{ + struct mgmt_ev_new_long_term_key *ev = buf; + char str[18]; + + if (len < sizeof(*ev)) { + printf("* Malformed New Long Term Key control\n"); + return; + } + + ba2str(&ev->key.addr.bdaddr, str); + + printf("@ New Long Term Key: %s (%d)\n", str, ev->key.addr.type); + + buf += sizeof(*ev); + len -= sizeof(*ev); + + hexdump(buf, len); +} + static void mgmt_device_connected(uint16_t len, void *buf) { struct mgmt_ev_device_connected *ev = buf; @@ -771,6 +811,27 @@ static void mgmt_connect_failed(uint16_t len, void *buf) hexdump(buf, len); } +static void mgmt_auth_failed(uint16_t len, void *buf) +{ + struct mgmt_ev_auth_failed *ev = buf; + char str[18]; + + if (len < sizeof(*ev)) { + printf("* Malformed Authentication Failed control\n"); + return; + } + + ba2str(&ev->addr.bdaddr, str); + + printf("@ Authentication Failed: %s (%d) status 0x%2.2x\n", + str, ev->addr.type, ev->status); + + buf += sizeof(*ev); + len -= sizeof(*ev); + + hexdump(buf, len); +} + static void mgmt_discovering(uint16_t len, void *buf) { struct mgmt_ev_discovering *ev = buf; @@ -869,6 +930,12 @@ static void process_control(uint16_t opcode, uint16_t pktlen, void *buf) case MGMT_EV_LOCAL_NAME_CHANGED: mgmt_local_name_changed(pktlen, buf); break; + case MGMT_EV_NEW_LINK_KEY: + mgmt_new_link_key(pktlen, buf); + break; + case MGMT_EV_NEW_LONG_TERM_KEY: + mgmt_new_long_term_key(pktlen, buf); + break; case MGMT_EV_DEVICE_CONNECTED: mgmt_device_connected(pktlen, buf); break; @@ -878,6 +945,9 @@ static void process_control(uint16_t opcode, uint16_t pktlen, void *buf) case MGMT_EV_CONNECT_FAILED: mgmt_connect_failed(pktlen, buf); break; + case MGMT_EV_AUTH_FAILED: + mgmt_auth_failed(pktlen, buf); + break; case MGMT_EV_DISCOVERING: mgmt_discovering(pktlen, buf); break; -- 2.47.3