diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2014-06-29 22:33:35 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-06-29 22:33:35 +0200 |
commit | 8240f36f3b3e749c2fba9a5f638fda51c71abca1 (patch) | |
tree | 66645e731067c9068b7ab507001865a1b2b05a6a /monitor/control.c | |
parent | 36d58cdd1b1f4efd465f527549365a786904ff02 (diff) | |
download | bluez-8240f36f3b3e749c2fba9a5f638fda51c71abca1.tar.gz |
monitor: Decode Device Added and Device Removed control events
Diffstat (limited to 'monitor/control.c')
-rw-r--r-- | monitor/control.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/monitor/control.c b/monitor/control.c index c808a84ef..083f65dcc 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -540,6 +540,46 @@ static void mgmt_new_csrk(uint16_t len, const void *buf) packet_hexdump(buf, len); } +static void mgmt_device_added(uint16_t len, const void *buf) +{ + const struct mgmt_ev_device_added *ev = buf; + char str[18]; + + if (len < sizeof(*ev)) { + printf("* Malformed Device Added control\n"); + return; + } + + ba2str(&ev->addr.bdaddr, str); + + printf("@ Device Added: %s (%d) %d\n", str, ev->addr.type, ev->action); + + buf += sizeof(*ev); + len -= sizeof(*ev); + + packet_hexdump(buf, len); +} + +static void mgmt_device_removed(uint16_t len, const void *buf) +{ + const struct mgmt_ev_device_removed *ev = buf; + char str[18]; + + if (len < sizeof(*ev)) { + printf("* Malformed Device Removed control\n"); + return; + } + + ba2str(&ev->addr.bdaddr, str); + + printf("@ Device Removed: %s (%d)\n", str, ev->addr.type); + + buf += sizeof(*ev); + len -= sizeof(*ev); + + packet_hexdump(buf, len); +} + void control_message(uint16_t opcode, const void *data, uint16_t size) { switch (opcode) { @@ -612,6 +652,12 @@ void control_message(uint16_t opcode, const void *data, uint16_t size) case MGMT_EV_NEW_CSRK: mgmt_new_csrk(size, data); break; + case MGMT_EV_DEVICE_ADDED: + mgmt_device_added(size, data); + break; + case MGMT_EV_DEVICE_REMOVED: + mgmt_device_removed(size, data); + break; default: printf("* Unknown control (code %d len %d)\n", opcode, size); packet_hexdump(data, size); |