xref: /libbtbb/lib/src/pcapng-bt.h (revision 1ce7419bbb03f024d1c530588c1f2bea485249c3)
18f3e7eeaSChristopher Kilgour /* -*- c -*- */
28f3e7eeaSChristopher Kilgour /*
38f3e7eeaSChristopher Kilgour  * Copyright 2014 Christopher D. Kilgour techie AT whiterocker.com
48f3e7eeaSChristopher Kilgour  *
58f3e7eeaSChristopher Kilgour  * This file is part of libbtbb
68f3e7eeaSChristopher Kilgour  *
78f3e7eeaSChristopher Kilgour  * This program is free software; you can redistribute it and/or modify
88f3e7eeaSChristopher Kilgour  * it under the terms of the GNU General Public License as published by
98f3e7eeaSChristopher Kilgour  * the Free Software Foundation; either version 2, or (at your option)
108f3e7eeaSChristopher Kilgour  * any later version.
118f3e7eeaSChristopher Kilgour  *
128f3e7eeaSChristopher Kilgour  * This program is distributed in the hope that it will be useful,
138f3e7eeaSChristopher Kilgour  * but WITHOUT ANY WARRANTY; without even the implied warranty of
148f3e7eeaSChristopher Kilgour  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
158f3e7eeaSChristopher Kilgour  * GNU General Public License for more details.
168f3e7eeaSChristopher Kilgour  *
178f3e7eeaSChristopher Kilgour  * You should have received a copy of the GNU General Public License
188f3e7eeaSChristopher Kilgour  * along with libbtbb; see the file COPYING.  If not, write to
198f3e7eeaSChristopher Kilgour  * the Free Software Foundation, Inc., 51 Franklin Street,
208f3e7eeaSChristopher Kilgour  * Boston, MA 02110-1301, USA.
218f3e7eeaSChristopher Kilgour  */
228f3e7eeaSChristopher Kilgour #ifndef PCAPNG_BT_DOT_H
238f3e7eeaSChristopher Kilgour #define PCAPNG_BT_DOT_H
248f3e7eeaSChristopher Kilgour 
258f3e7eeaSChristopher Kilgour #include "pcap-common.h"
268f3e7eeaSChristopher Kilgour #include "pcapng.h"
278f3e7eeaSChristopher Kilgour 
288f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
298f3e7eeaSChristopher Kilgour 	uint32_t centre_freq;
308f3e7eeaSChristopher Kilgour 	uint32_t analog_bandwidth;
318f3e7eeaSChristopher Kilgour 	int32_t  intermediate_freq;
328f3e7eeaSChristopher Kilgour 	uint32_t sampling_bandwidth;
338f3e7eeaSChristopher Kilgour } bt_wideband_rf_info;
348f3e7eeaSChristopher Kilgour 
358f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
368f3e7eeaSChristopher Kilgour   option_header header;
378f3e7eeaSChristopher Kilgour   bt_wideband_rf_info wideband_rf_info;
388f3e7eeaSChristopher Kilgour } bt_wideband_rf_option;
398f3e7eeaSChristopher Kilgour 
408f3e7eeaSChristopher Kilgour #define PCAPNG_BT_WIDEBAND_RF_INFO 0xd300
418f3e7eeaSChristopher Kilgour 
428f3e7eeaSChristopher Kilgour /* --------------------------------- BR/EDR ----------------------------- */
438f3e7eeaSChristopher Kilgour 
448f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
458f3e7eeaSChristopher Kilgour   enhanced_packet_block blk_header;
468f3e7eeaSChristopher Kilgour   pcap_bluetooth_bredr_bb_header bredr_bb_header;
470e05cc66SDominic Spill   uint8_t bredr_payload[BREDR_MAX_PAYLOAD];
488f3e7eeaSChristopher Kilgour } pcapng_bredr_packet;
498f3e7eeaSChristopher Kilgour 
508f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
518f3e7eeaSChristopher Kilgour   uint8_t bd_addr[6];
528f3e7eeaSChristopher Kilgour   uint8_t uap_mask;
538f3e7eeaSChristopher Kilgour   uint8_t nap_valid;
548f3e7eeaSChristopher Kilgour } bredr_bd_addr_info;
558f3e7eeaSChristopher Kilgour 
568f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
578f3e7eeaSChristopher Kilgour   option_header header;
588f3e7eeaSChristopher Kilgour   bredr_bd_addr_info bd_addr_info;
598f3e7eeaSChristopher Kilgour } bredr_br_addr_option;
608f3e7eeaSChristopher Kilgour 
618f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
628f3e7eeaSChristopher Kilgour   uint64_t ts;
638f3e7eeaSChristopher Kilgour   uint32_t lap_uap;
648f3e7eeaSChristopher Kilgour   uint32_t clk;
658f3e7eeaSChristopher Kilgour   uint32_t clk_mask;
668f3e7eeaSChristopher Kilgour } bredr_clk_info;
678f3e7eeaSChristopher Kilgour 
688f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
698f3e7eeaSChristopher Kilgour   option_header header;
708f3e7eeaSChristopher Kilgour   bredr_clk_info clock_info;
718f3e7eeaSChristopher Kilgour } bredr_clk_option;
728f3e7eeaSChristopher Kilgour 
738f3e7eeaSChristopher Kilgour #define PCAPNG_BREDR_OPTION_BD_ADDR           0xd340
748f3e7eeaSChristopher Kilgour #define PCAPNG_BREDR_OPTION_MASTER_CLOCK_INFO 0xd341
758f3e7eeaSChristopher Kilgour 
768f3e7eeaSChristopher Kilgour /* --------------------------------- Low Energy ---------------------------- */
778f3e7eeaSChristopher Kilgour 
788f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
798f3e7eeaSChristopher Kilgour   enhanced_packet_block blk_header;
808f3e7eeaSChristopher Kilgour   pcap_bluetooth_le_ll_header le_ll_header;
810e05cc66SDominic Spill   uint8_t le_packet[LE_MAX_PAYLOAD];
82*1ce7419bSTheodore A. Roth 
83*1ce7419bSTheodore A. Roth   /* Force 32 bit alignment for options and blk_tot_length. */
84*1ce7419bSTheodore A. Roth   uint8_t pad[2];
85*1ce7419bSTheodore A. Roth 
86*1ce7419bSTheodore A. Roth   /* Add space for OPTIONS and BLOCK_TOTAL_LENGTH at end of
87*1ce7419bSTheodore A. Roth      block. These won't be at this position in the structure unless
88*1ce7419bSTheodore A. Roth      the LE PDU is the full 39 bytes. */
89*1ce7419bSTheodore A. Roth   uint32_t options;
90*1ce7419bSTheodore A. Roth   uint32_t blk_tot_length;
918f3e7eeaSChristopher Kilgour } pcapng_le_packet;
928f3e7eeaSChristopher Kilgour 
938f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
948f3e7eeaSChristopher Kilgour   uint64_t ns;
958f3e7eeaSChristopher Kilgour   union {
968f3e7eeaSChristopher Kilgour     struct {
978f3e7eeaSChristopher Kilgour       uint8_t InitA[6];
988f3e7eeaSChristopher Kilgour       uint8_t AdvA[6];
998f3e7eeaSChristopher Kilgour       uint8_t AA[4];
1008f3e7eeaSChristopher Kilgour       uint8_t CRCInit[3];
1018f3e7eeaSChristopher Kilgour       uint8_t WinSize;
1028f3e7eeaSChristopher Kilgour       uint8_t WinOffset[2];
1038f3e7eeaSChristopher Kilgour       uint8_t Interval[2];
1048f3e7eeaSChristopher Kilgour       uint8_t Latency[2];
1058f3e7eeaSChristopher Kilgour       uint8_t Timeout[2];
1068f3e7eeaSChristopher Kilgour       uint8_t ChM[5];
1078f3e7eeaSChristopher Kilgour       uint8_t HopSCA;
1088f3e7eeaSChristopher Kilgour     } fields;
1098f3e7eeaSChristopher Kilgour     uint8_t bytes[0];
1108f3e7eeaSChristopher Kilgour   } pdu;
1118f3e7eeaSChristopher Kilgour } le_ll_connection_info;
1128f3e7eeaSChristopher Kilgour 
1138f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
1148f3e7eeaSChristopher Kilgour   option_header header;
1158f3e7eeaSChristopher Kilgour   le_ll_connection_info connection_info;
1168f3e7eeaSChristopher Kilgour } le_ll_connection_info_option;
1178f3e7eeaSChristopher Kilgour 
1188f3e7eeaSChristopher Kilgour #define PCAPNG_LE_LL_CONNECTION_INFO 0xd380
1198f3e7eeaSChristopher Kilgour 
1208f3e7eeaSChristopher Kilgour #endif /* PCAPNG_BT_DOT_H */
121