xref: /libbtbb/lib/src/pcapng-bt.h (revision fa25b38e965ab04a28cb5cef4f7d141324639453)
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;
478f3e7eeaSChristopher Kilgour } pcapng_bredr_packet;
488f3e7eeaSChristopher Kilgour 
498f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
508f3e7eeaSChristopher Kilgour   uint8_t bd_addr[6];
518f3e7eeaSChristopher Kilgour   uint8_t uap_mask;
528f3e7eeaSChristopher Kilgour   uint8_t nap_valid;
538f3e7eeaSChristopher Kilgour } bredr_bd_addr_info;
548f3e7eeaSChristopher Kilgour 
558f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
568f3e7eeaSChristopher Kilgour   option_header header;
578f3e7eeaSChristopher Kilgour   bredr_bd_addr_info bd_addr_info;
588f3e7eeaSChristopher Kilgour } bredr_br_addr_option;
598f3e7eeaSChristopher Kilgour 
608f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
618f3e7eeaSChristopher Kilgour   uint64_t ts;
628f3e7eeaSChristopher Kilgour   uint32_t lap_uap;
638f3e7eeaSChristopher Kilgour   uint32_t clk;
648f3e7eeaSChristopher Kilgour   uint32_t clk_mask;
658f3e7eeaSChristopher Kilgour } bredr_clk_info;
668f3e7eeaSChristopher Kilgour 
678f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
688f3e7eeaSChristopher Kilgour   option_header header;
698f3e7eeaSChristopher Kilgour   bredr_clk_info clock_info;
708f3e7eeaSChristopher Kilgour } bredr_clk_option;
718f3e7eeaSChristopher Kilgour 
728f3e7eeaSChristopher Kilgour #define PCAPNG_BREDR_OPTION_BD_ADDR           0xd340
738f3e7eeaSChristopher Kilgour #define PCAPNG_BREDR_OPTION_MASTER_CLOCK_INFO 0xd341
748f3e7eeaSChristopher Kilgour 
758f3e7eeaSChristopher Kilgour /* --------------------------------- Low Energy ---------------------------- */
768f3e7eeaSChristopher Kilgour 
778f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
788f3e7eeaSChristopher Kilgour   enhanced_packet_block blk_header;
798f3e7eeaSChristopher Kilgour   pcap_bluetooth_le_ll_header le_ll_header;
800e05cc66SDominic Spill   uint8_t le_packet[LE_MAX_PAYLOAD];
81*1ce7419bSTheodore A. Roth 
82*1ce7419bSTheodore A. Roth   /* Force 32 bit alignment for options and blk_tot_length. */
83*1ce7419bSTheodore A. Roth   uint8_t pad[2];
84*1ce7419bSTheodore A. Roth 
85*1ce7419bSTheodore A. Roth   /* Add space for OPTIONS and BLOCK_TOTAL_LENGTH at end of
86*1ce7419bSTheodore A. Roth      block. These won't be at this position in the structure unless
87*1ce7419bSTheodore A. Roth      the LE PDU is the full 39 bytes. */
88*1ce7419bSTheodore A. Roth   uint32_t options;
89*1ce7419bSTheodore A. Roth   uint32_t blk_tot_length;
908f3e7eeaSChristopher Kilgour } pcapng_le_packet;
918f3e7eeaSChristopher Kilgour 
928f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
938f3e7eeaSChristopher Kilgour   uint64_t ns;
948f3e7eeaSChristopher Kilgour   union {
958f3e7eeaSChristopher Kilgour     struct {
968f3e7eeaSChristopher Kilgour       uint8_t InitA[6];
978f3e7eeaSChristopher Kilgour       uint8_t AdvA[6];
988f3e7eeaSChristopher Kilgour       uint8_t AA[4];
998f3e7eeaSChristopher Kilgour       uint8_t CRCInit[3];
1008f3e7eeaSChristopher Kilgour       uint8_t WinSize;
1018f3e7eeaSChristopher Kilgour       uint8_t WinOffset[2];
1028f3e7eeaSChristopher Kilgour       uint8_t Interval[2];
1038f3e7eeaSChristopher Kilgour       uint8_t Latency[2];
1048f3e7eeaSChristopher Kilgour       uint8_t Timeout[2];
1058f3e7eeaSChristopher Kilgour       uint8_t ChM[5];
1068f3e7eeaSChristopher Kilgour       uint8_t HopSCA;
1078f3e7eeaSChristopher Kilgour     } fields;
1088f3e7eeaSChristopher Kilgour     uint8_t bytes[0];
1098f3e7eeaSChristopher Kilgour   } pdu;
1108f3e7eeaSChristopher Kilgour } le_ll_connection_info;
1118f3e7eeaSChristopher Kilgour 
1128f3e7eeaSChristopher Kilgour typedef struct __attribute__((packed)) {
1138f3e7eeaSChristopher Kilgour   option_header header;
1148f3e7eeaSChristopher Kilgour   le_ll_connection_info connection_info;
1158f3e7eeaSChristopher Kilgour } le_ll_connection_info_option;
1168f3e7eeaSChristopher Kilgour 
1178f3e7eeaSChristopher Kilgour #define PCAPNG_LE_LL_CONNECTION_INFO 0xd380
1188f3e7eeaSChristopher Kilgour 
1198f3e7eeaSChristopher Kilgour #endif /* PCAPNG_BT_DOT_H */
120