25 #ifndef INCLUDED_BLUETOOTH_PACKET_H 26 #define INCLUDED_BLUETOOTH_PACKET_H 31 #include <boost/enable_shared_from_this.hpp> 36 typedef boost::shared_ptr<bluetooth_packet> bluetooth_packet_sptr;
45 uint32_t clkn,
int channel);
54 uint32_t clkn,
int channel);
60 static const int MAX_SYMBOLS = 3125;
63 static const int ID_THRESHOLD = 5;
66 static const uint8_t INDICES[64];
69 static const uint8_t WHITENING_DATA[127];
72 static const uint8_t PREAMBLE_DISTANCE[32];
75 static const uint8_t TRAILER_DISTANCE[2048];
78 static const string TYPE_NAMES[16];
83 char d_symbols[MAX_SYMBOLS];
101 char d_packet_header[18];
105 char d_payload_header[16];
109 int d_payload_header_length;
112 uint8_t d_payload_llid;
115 uint8_t d_payload_flow;
124 int d_payload_length;
132 char d_payload[2744];
160 bool decode_payload_header(
char *stream,
int clock,
int header_bytes,
int size,
bool fec);
163 void unwhiten(
char* input,
char* output,
int clock,
int length,
int skip);
175 static int sniff_ac(
char *stream,
int stream_length);
178 static uint8_t *lfsr(uint8_t *data,
int length,
int k, uint8_t *g);
181 static uint8_t reverse(
char byte);
184 static uint8_t *acgen(
int LAP);
187 static void convert_to_grformat(uint8_t input, uint8_t *output);
190 static bool unfec13(
char *input,
char *output,
int length);
193 static char *unfec23(
char *input,
int length);
196 static char *fec23gen(
char *data);
199 static bool check_ac(
char *stream,
int LAP);
202 static uint8_t air_to_host8(
char *air_order,
int bits);
203 static uint16_t air_to_host16(
char *air_order,
int bits);
204 static uint32_t air_to_host32(
char *air_order,
int bits);
208 static void host_to_air(uint8_t host_order,
char *air_order,
int bits);
211 static uint16_t crcgen(
char *payload,
int length,
int UAP);
214 static int UAP_from_hec(uint16_t data, uint8_t hec);
217 int crc_check(
int clock);
220 bool decode_header();
223 void decode_payload();
241 void set_UAP(uint8_t UAP);
244 void set_NAP(uint16_t NAP);
250 void set_whitened(
bool whitened);
256 uint32_t get_clock();
259 void set_clock(uint32_t clk6,
bool have27);
262 int get_payload_length();
269 uint8_t try_clock(
int clock);
272 bool header_present();
275 uint32_t lap_from_fhs();
278 uint8_t uap_from_fhs();
281 uint16_t nap_from_fhs();
284 uint32_t clock_from_fhs();
Definition: bluetooth_packet.h:48
bluetooth_packet_sptr bluetooth_make_packet(char *stream, int length)
Return a shared_ptr to a new instance of bluetooth_packet.
int d_channel
Definition: bluetooth_packet.h:169
uint32_t d_clkn
Definition: bluetooth_packet.h:172