Extend the BLUETOOTH_LE_LL_WITH_PHDR format

Introduce backwards compatible meanings to previously RFU flag bits.
This allows indicating packet direction and supporting BLE5 features.

0x0380 indicates the PDU type
0xC000 indicates the PHY mode

PDU types are:
0: Advertising or Data (Unspecified Direction)
1: Auxiliary Advertising
2: Data, Master to Slave
3: Data, Slave to Master
4: Connected Isochronous, Master to Slave
5: Connected Isochronous, Slave to Master
6: Broadcast Isochronous
7: Reserved

PHY modes are:
0: LE 1M
1: LE 2M
2: LE Coded
3: Reserved

For PDU type 1 (auxiliary advertising), MIC bits 0x3000 are repurposed
to indicate auxiliary advertisement type.

Auxiliary advertisement types are:
0: AUX_ADV_IND
1: AUX_CHAIN_IND
2: AUX_SYNC_IND
3: AUX_SCAN_RSP

Change-Id: I1e6ddc1488d4cf5c05af4a179c9ad362e94f42f6
Reviewed-on: https://code.wireshark.org/review/37142
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Sultan Qasim Khan 2020-05-04 22:37:33 -04:00 committed by Anders Broman
parent 474f8c9a17
commit 2b6f38b37d
1 changed files with 87 additions and 12 deletions

View File

@ -1,5 +1,5 @@
/* packet-btle_rf.c
* http://www.whiterocker.com/bt/LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR.html
* https://www.tcpdump.org/linktypes/LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR.html
*
* Copyright 2014, Christopher D. Kilgour, techie at whiterocker dot com
*
@ -24,10 +24,12 @@
#define LE_REF_AA_VALID 0x0010
#define LE_AA_OFFENSES_VALID 0x0020
#define LE_CHANNEL_ALIASED 0x0040
#define LE_PDU_TYPE 0x0380
#define LE_CRC_CHECKED 0x0400
#define LE_CRC_VALID 0x0800
#define LE_MIC_CHECKED 0x1000
#define LE_MIC_VALID 0x2000
#define LE_PHY 0xC000
#define BTLE_RF_OCTETS 10
@ -49,12 +51,12 @@ static int hf_btle_rf_packet_decrypted_flag = -1;
static int hf_btle_rf_ref_aa_valid_flag = -1;
static int hf_btle_rf_aa_offenses_valid_flag = -1;
static int hf_btle_rf_channel_aliased_flag = -1;
static int hf_btle_rf_flags_rfu_1 = -1;
static int hf_btle_rf_pdu_type = -1;
static int hf_btle_rf_crc_checked_flag = -1;
static int hf_btle_rf_crc_valid_flag = -1;
static int hf_btle_rf_mic_checked_flag = -1;
static int hf_btle_rf_mic_valid_flag = -1;
static int hf_btle_rf_flags_rfu_2 = -1;
static int hf_btle_rf_phy = -1;
static int * const hfs_btle_rf_flags[] = {
&hf_btle_rf_dewhitened_flag,
@ -64,12 +66,12 @@ static int * const hfs_btle_rf_flags[] = {
&hf_btle_rf_ref_aa_valid_flag,
&hf_btle_rf_aa_offenses_valid_flag,
&hf_btle_rf_channel_aliased_flag,
&hf_btle_rf_flags_rfu_1,
&hf_btle_rf_pdu_type,
&hf_btle_rf_crc_checked_flag,
&hf_btle_rf_crc_valid_flag,
&hf_btle_rf_mic_checked_flag,
&hf_btle_rf_mic_valid_flag,
&hf_btle_rf_flags_rfu_2,
&hf_btle_rf_phy,
NULL
};
@ -82,6 +84,28 @@ static dissector_handle_t btle_handle;
void proto_register_btle_rf(void);
void proto_reg_handoff_btle_rf(void);
static const value_string le_phys[] =
{
{ 0, "LE 1M" },
{ 1, "LE 2M" },
{ 2, "LE Coded" },
{ 3, "Reserved" },
{ 0, NULL }
};
static const value_string le_pdus[] =
{
{ 0, "Advertising or Data (Unspecified Direction)" },
{ 1, "Auxiliary Advertising" },
{ 2, "Data, Master to Slave" },
{ 3, "Data, Slave to Master" },
{ 4, "Connected Isochronous, Master to Slave" },
{ 5, "Connected Isochronous, Slave to Master" },
{ 6, "Broadcast Isochronous" },
{ 7, "Reserved" },
{ 0, NULL }
};
static const char *
btle_rf_channel_type(guint8 rf_channel)
{
@ -149,7 +173,54 @@ dissect_btle_rf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
context.crc_valid_at_capture = !!(flags & LE_CRC_VALID);
context.mic_checked_at_capture = !!(flags & LE_MIC_CHECKED);
context.mic_valid_at_capture = !!(flags & LE_MIC_VALID);
context.pdu_type = BTLE_PDU_TYPE_UNKNOWN;
switch ((flags & LE_PDU_TYPE) >> 7)
{
case 0: // Advertising or Data (Unspecified Direction)
// backwards compatible path
context.pdu_type = BTLE_PDU_TYPE_UNKNOWN;
break;
case 1: // Auxiliary Advertising
// advertising is never encrypted, so MIC flags are repurposed
context.pdu_type = BTLE_PDU_TYPE_ADVERTISING;
context.mic_checked_at_capture = FALSE;
context.mic_valid_at_capture = FALSE;
// context.aux_pdu_type values defined in aux_pdu_common_vals of packet-btle.c
// they match with the definition for this link type
context.aux_pdu_type = (flags & 0x3000) >> 12;
context.aux_pdu_type_valid = TRUE;
break;
case 2: // Data, Master to Slave
context.pdu_type = BTLE_PDU_TYPE_DATA;
context.direction = BTLE_DIR_MASTER_SLAVE;
pinfo->p2p_dir = P2P_DIR_SENT;
break;
case 3: // Data, Slave to Master
context.pdu_type = BTLE_PDU_TYPE_DATA;
context.direction = BTLE_DIR_SLAVE_MASTER;
pinfo->p2p_dir = P2P_DIR_RECV;
break;
case 4: // Connected Isochronous, Master to Slave
// Isochronous not yet supported by common link layer dissector
context.pdu_type = BTLE_PDU_TYPE_UNKNOWN;
context.direction = BTLE_DIR_MASTER_SLAVE;
pinfo->p2p_dir = P2P_DIR_SENT;
break;
case 5: // Connected Isochronous, Slave to Master
// Isochronous not yet supported by common link layer dissector
context.pdu_type = BTLE_PDU_TYPE_UNKNOWN;
context.direction = BTLE_DIR_SLAVE_MASTER;
pinfo->p2p_dir = P2P_DIR_RECV;
break;
case 6: // Broadcast Isochronous
// Isochronous not yet supported by common link layer dissector
context.pdu_type = BTLE_PDU_TYPE_UNKNOWN;
break;
case 7: // Reserved
context.pdu_type = BTLE_PDU_TYPE_UNKNOWN;
break;
}
ti = proto_tree_add_item(tree, proto_btle_rf, tvb, 0, tvb_captured_length(tvb), ENC_NA);
btle_rf_tree = proto_item_add_subtree(ti, ett_btle_rf);
@ -165,6 +236,8 @@ dissect_btle_rf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
proto_item_append_text(ti, " [aliased]");
}
context.phy = (flags & LE_PHY) >> 14;
if (flags & LE_SIGPOWER_VALID) {
proto_tree_add_item(btle_rf_tree, hf_btle_rf_signal_dbm, tvb, 1, 1, ENC_LITTLE_ENDIAN);
}
@ -313,9 +386,10 @@ proto_register_btle_rf(void)
NULL, LE_CHANNEL_ALIASED,
NULL, HFILL }
},
{ &hf_btle_rf_flags_rfu_1,
{ "RFU", "btle_rf.flags.rfu.1",
FT_UINT16, BASE_DEC, NULL, 0x380,
{ &hf_btle_rf_pdu_type,
{ "PDU Type", "btle_rf.pdu_type",
FT_UINT16, BASE_DEC,
VALS(le_pdus), LE_PDU_TYPE,
NULL, HFILL }
},
{ &hf_btle_rf_crc_checked_flag,
@ -342,9 +416,10 @@ proto_register_btle_rf(void)
NULL, LE_MIC_VALID,
NULL, HFILL }
},
{ &hf_btle_rf_flags_rfu_2,
{ "RFU", "btle_rf.flags.rfu.2",
FT_UINT16, BASE_DEC, NULL, 0xc000,
{ &hf_btle_rf_phy,
{ "PHY", "btle_rf.phy",
FT_UINT16, BASE_DEC,
VALS(le_phys), LE_PHY,
NULL, HFILL }
},
};