diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2013-01-15 21:16:59 -0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2013-01-15 21:16:59 -0800 |
commit | 7fb8db0aabc6e30ccf18e5fcda2a90596cf2cfe2 (patch) | |
tree | 29c2d54b484c5b18636d98b8fbdd96f844710401 /monitor | |
parent | d46572878f6fcca80faf4b28cceb38cd5ebc3809 (diff) |
monitor: Differentiate between E0 and AES-CCM encryption
Diffstat (limited to 'monitor')
-rw-r--r-- | monitor/packet.c | 90 |
1 files changed, 89 insertions, 1 deletions
diff --git a/monitor/packet.c b/monitor/packet.c index db579a268..f92f0a2a1 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -72,6 +72,53 @@ static unsigned long filter_mask = 0; static bool index_filter = false; static uint16_t index_number = 0; +#define MAX_CONN 16 + +struct conn_data { + uint16_t handle; + uint8_t type; +}; + +static struct conn_data conn_list[MAX_CONN]; + +static void assign_handle(uint16_t handle, uint8_t type) +{ + int i; + + for (i = 0; i < MAX_CONN; i++) { + if (conn_list[i].handle == 0x0000) { + conn_list[i].handle = handle; + conn_list[i].type = type; + break; + } + } +} + +static void release_handle(uint16_t handle) +{ + int i; + + for (i = 0; i < MAX_CONN; i++) { + if (conn_list[i].handle == handle) { + conn_list[i].handle = 0x0000; + conn_list[i].type = 0x00; + break; + } + } +} + +static uint8_t get_type(uint16_t handle) +{ + int i; + + for (i = 0; i < MAX_CONN; i++) { + if (conn_list[i].handle == handle) + return conn_list[i].type; + } + + return 0xff; +} + void packet_set_filter(unsigned long filter) { filter_mask = filter; @@ -848,6 +895,38 @@ static void print_encr_mode(uint8_t encr_mode) print_field("Encryption: %s (0x%2.2x)", str, encr_mode); } +static void print_encr_mode_change(uint8_t encr_mode, uint16_t handle) +{ + const char *str; + uint8_t conn_type; + + conn_type = get_type(btohs(handle)); + + switch (encr_mode) { + case 0x00: + str = "Disabled"; + break; + case 0x01: + switch (conn_type) { + case 0x00: + str = "Enabled with E0"; + break; + case 0x01: + str = "Enabled with AES-CCM"; + break; + default: + str = "Enabled"; + break; + } + break; + default: + str = "Reserved"; + break; + } + + print_field("Encryption: %s (0x%2.2x)", str, encr_mode); +} + static void print_pin_type(uint8_t pin_type) { const char *str; @@ -3903,6 +3982,9 @@ static void conn_complete_evt(const void *data, uint8_t size) print_bdaddr(evt->bdaddr); print_link_type(evt->link_type); print_encr_mode(evt->encr_mode); + + if (evt->status == 0x00) + assign_handle(btohs(evt->handle), 0x00); } static void conn_request_evt(const void *data, uint8_t size) @@ -3921,6 +4003,9 @@ static void disconnect_complete_evt(const void *data, uint8_t size) print_status(evt->status); print_handle(evt->handle); print_reason(evt->reason); + + if (evt->status == 0x00) + release_handle(btohs(evt->handle)); } static void auth_complete_evt(const void *data, uint8_t size) @@ -3946,7 +4031,7 @@ static void encrypt_change_evt(const void *data, uint8_t size) print_status(evt->status); print_handle(evt->handle); - print_encr_mode(evt->encr_mode); + print_encr_mode_change(evt->encr_mode, evt->handle); } static void change_conn_link_key_complete_evt(const void *data, uint8_t size) @@ -4570,6 +4655,9 @@ static void le_conn_complete_evt(const void *data, uint8_t size) print_field("Supervision timeout: %d msec (0x%4.4x)", btohs(evt->supv_timeout) * 10, btohs(evt->supv_timeout)); print_field("Master clock accuracy: 0x%2.2x", evt->clock_accuracy); + + if (evt->status == 0x00) + assign_handle(btohs(evt->handle), 0x01); } static void le_adv_report_evt(const void *data, uint8_t size) |