[BTLE] Change address from unknown_0x... to master or slave.

Change-Id: I571a2f6f96c37e608201092e7ea7f53862b8d2ad
Reviewed-on: https://code.wireshark.org/review/16844
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
AndersBroman 2016-08-02 17:07:14 +02:00 committed by Anders Broman
parent b6e0335d0f
commit 3c1db69189
3 changed files with 38 additions and 10 deletions

View File

@ -677,10 +677,13 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
if (wmem_tree) {
connection_address = (connection_address_t *) wmem_tree_lookup32_le(wmem_tree, pinfo->num);
if (connection_address) {
gchar *str_addr;
gchar *str_addr_src, *str_addr_dst;
gint tmp_dir = 0;
/* Holds "unknown" + access_address + NULL, which is the longest string*/
int str_addr_len = 18 + 1;
str_addr = (gchar *) wmem_alloc(pinfo->pool, str_addr_len);
str_addr_src = (gchar *) wmem_alloc(pinfo->pool, str_addr_len);
str_addr_dst = (gchar *) wmem_alloc(pinfo->pool, str_addr_len);
sub_item = proto_tree_add_ether(btle_tree, hf_master_bd_addr, tvb, 0, 0, connection_address->master_bd_addr);
PROTO_ITEM_SET_GENERATED(sub_item);
@ -688,13 +691,31 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
sub_item = proto_tree_add_ether(btle_tree, hf_slave_bd_addr, tvb, 0, 0, connection_address->slave_bd_addr);
PROTO_ITEM_SET_GENERATED(sub_item);
g_snprintf(str_addr, str_addr_len, "unknown_0x%08x", connection_address->access_address);
if (btle_context) {
tmp_dir = btle_context->direction;
}
set_address(&pinfo->net_src, AT_STRINGZ, str_addr_len, str_addr);
switch (tmp_dir) {
case BTLE_DIR_MASTER_SLAVE:
g_snprintf(str_addr_src, str_addr_len, "Master_0x%08x", connection_address->access_address);
g_snprintf(str_addr_dst, str_addr_len, "Slave_0x%08x", connection_address->access_address);
break;
case BTLE_DIR_SLAVE_MASTER:
g_snprintf(str_addr_src, str_addr_len, "Slave_0x%08x", connection_address->access_address);
g_snprintf(str_addr_dst, str_addr_len, "Master_0x%08x", connection_address->access_address);
break;
default:
/* BTLE_DIR_UNKNOWN */
g_snprintf(str_addr_src, str_addr_len, "Unknown_0x%08x", connection_address->access_address);
g_snprintf(str_addr_dst, str_addr_len, "Unknown_0x%08x", connection_address->access_address);
break;
}
set_address(&pinfo->net_src, AT_STRINGZ, str_addr_len, str_addr_src);
copy_address_shallow(&pinfo->dl_src, &pinfo->net_src);
copy_address_shallow(&pinfo->src, &pinfo->net_src);
set_address(&pinfo->net_dst, AT_STRINGZ, str_addr_len, str_addr);
set_address(&pinfo->net_dst, AT_STRINGZ, str_addr_len, str_addr_dst);
copy_address_shallow(&pinfo->dl_dst, &pinfo->net_dst);
copy_address_shallow(&pinfo->dst, &pinfo->net_dst);

View File

@ -52,14 +52,19 @@ typedef enum {
E_AA_ILLEGAL
} btle_AA_category_t;
#define BTLE_DIR_UNKNOWN 0
#define BTLE_DIR_MASTER_SLAVE 1
#define BTLE_DIR_SLAVE_MASTER 2
typedef struct {
btle_AA_category_t aa_category;
btle_CONNECT_REQ_t connection_info;
gint connection_info_valid: 1;
gint crc_checked_at_capture: 1;
gint crc_valid_at_capture: 1;
gint mic_checked_at_capture: 1;
gint mic_valid_at_capture: 1;
guint connection_info_valid: 1;
guint crc_checked_at_capture: 1;
guint crc_valid_at_capture: 1;
guint mic_checked_at_capture: 1;
guint mic_valid_at_capture: 1;
guint direction: 2; /* 0 Unknown, 1 Master -> Slave, 2 Slave -> Master */
union {
void *data;

View File

@ -367,10 +367,12 @@ dissect_flags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, btle_context_
if (dir) {
set_address(&pinfo->src, AT_STRINGZ, 7, "Master");
set_address(&pinfo->dst, AT_STRINGZ, 6, "Slave");
context->direction = BTLE_DIR_MASTER_SLAVE;
}
else {
set_address(&pinfo->src, AT_STRINGZ, 6, "Slave");
set_address(&pinfo->dst, AT_STRINGZ, 7, "Master");
context->direction = BTLE_DIR_SLAVE_MASTER;
}