diff -Nru libbtbb-2014.11.26+gitf83b85c/cmake/modules/FindPCAP.cmake libbtbb-2015.09.R2/cmake/modules/FindPCAP.cmake --- libbtbb-2014.11.26+gitf83b85c/cmake/modules/FindPCAP.cmake 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/cmake/modules/FindPCAP.cmake 2015-09-05 07:46:31.000000000 +0000 @@ -72,11 +72,15 @@ NAMES pcap/pcap.h pcap.h + HINTS + /usr/local/opt/libpcap/include ) FIND_LIBRARY(PCAP_LIBRARY NAMES pcap + HINTS + /usr/local/opt/libpcap/lib ) ENDIF(EXISTS $ENV{PCAPDIR}) diff -Nru libbtbb-2014.11.26+gitf83b85c/debian/changelog libbtbb-2015.09.R2/debian/changelog --- libbtbb-2014.11.26+gitf83b85c/debian/changelog 2014-12-14 23:18:07.000000000 +0000 +++ libbtbb-2015.09.R2/debian/changelog 2015-09-09 06:52:26.000000000 +0000 @@ -1,3 +1,21 @@ +libbtbb (2015.09.R2-1) unstable; urgency=low + + * New upstream release + * debian/control: + - Added "Multi-Arch: same" to allow libbtbb0 to be + installed for multiple architectures + - Fixed small typo in long description + - Make python-libbtbb-pcapdump arch:all + - Changed the dependency for python-libbtbb-pcapdump + from (= ${binary:Version}) to (>= ${source:Version}) + to avoid lintian. + * debian/copyright: + - Fixes related to new upstream release + * debian/libbtbb0.symbols + - Added new symbols + + -- Ruben Undheim Mon, 07 Sep 2015 23:57:45 +0200 + libbtbb (2014.11.26+gitf83b85c-1) unstable; urgency=low * Initial release (Closes: #772575) diff -Nru libbtbb-2014.11.26+gitf83b85c/debian/control libbtbb-2015.09.R2/debian/control --- libbtbb-2014.11.26+gitf83b85c/debian/control 2014-12-14 23:18:07.000000000 +0000 +++ libbtbb-2015.09.R2/debian/control 2015-09-09 06:52:26.000000000 +0000 @@ -16,6 +16,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends} Pre-Depends: ${misc:Pre-Depends} +Multi-Arch: same Description: Bluetooth baseband decoding library This is the Bluetooth baseband decoding library, forked from the GR-Bluetooth project. It can be used to extract Bluetooth packet and piconet information @@ -27,6 +28,7 @@ Depends: libbtbb0 (= ${binary:Version}), libpcap-dev, ${misc:Depends} +Multi-Arch: same Description: Bluetooth baseband decoding library - development files This is the Bluetooth baseband decoding library, forked from the GR-Bluetooth project. It can be used to extract Bluetooth packet and piconet information @@ -40,6 +42,7 @@ Priority: extra Depends: libbtbb0 (= ${binary:Version}), ${misc:Depends} +Multi-Arch: same Description: Bluetooth baseband decoding library - debugging symbols This is the Bluetooth baseband decoding library, forked from the GR-Bluetooth project. It can be used to extract Bluetooth packet and piconet information @@ -49,12 +52,12 @@ the btbb library. Package: python-libbtbb-pcapdump -Architecture: any +Architecture: all Section: python -Depends: libbtbb0 (= ${binary:Version}), +Depends: libbtbb0 (>= ${source:Version}), python, ${misc:Depends} Description: pcapdump is a Python module for pcap delivered by libbtbb This module may be used to read and write pcap files produced by libbtbb. Actually libbtbb doesn't produce such files by itself at this - 3 time, but you can produce them with the Ubertooth tools. + time, but you can produce them with the Ubertooth tools. diff -Nru libbtbb-2014.11.26+gitf83b85c/debian/copyright libbtbb-2015.09.R2/debian/copyright --- libbtbb-2014.11.26+gitf83b85c/debian/copyright 2014-12-14 23:18:07.000000000 +0000 +++ libbtbb-2015.09.R2/debian/copyright 2015-09-09 06:52:26.000000000 +0000 @@ -40,8 +40,6 @@ wireshark/plugins/btsm/Makefile.common wireshark/plugins/btsm/Makefile.am wireshark/plugins/btbb/CMakeLists.txt - wireshark/plugins/btbb/Makefile.common - wireshark/plugins/btbb/Makefile.am Copyright: 1998 Gerald Combs License: GPL-2+ @@ -111,7 +109,7 @@ License: GPL-2+ Files: lib/src/uthash.h -Copyright: 2003-2013 Troy D. Hanson +Copyright: 2003-2014 Troy D. Hanson License: uthash-license Files: debian/* diff -Nru libbtbb-2014.11.26+gitf83b85c/debian/libbtbb0.symbols libbtbb-2015.09.R2/debian/libbtbb0.symbols --- libbtbb-2014.11.26+gitf83b85c/debian/libbtbb0.symbols 2014-12-14 23:18:07.000000000 +0000 +++ libbtbb-2015.09.R2/debian/libbtbb0.symbols 2015-09-09 06:52:26.000000000 +0000 @@ -55,6 +55,7 @@ btbb_pcapng_record_btclock@Base 2014.11.26+gitf83b85c btbb_piconet_get_afh_map@Base 2014.11.26+gitf83b85c btbb_piconet_get_bdaddr@Base 2014.11.26+gitf83b85c + btbb_piconet_get_channel_seen@Base 2015.09.R2 btbb_piconet_get_clk_offset@Base 2014.11.26+gitf83b85c btbb_piconet_get_flag@Base 2014.11.26+gitf83b85c btbb_piconet_get_lap@Base 2014.11.26+gitf83b85c @@ -76,6 +77,7 @@ btbb_version@Base 2014.11.26+gitf83b85c btbb_winnow@Base 2014.11.26+gitf83b85c clock_from_fhs@Base 2014.11.26+gitf83b85c + count_bits@Base 2015.09.R2 crc_check@Base 2014.11.26+gitf83b85c fast_perm@Base 2014.11.26+gitf83b85c fhs@Base 2014.11.26+gitf83b85c diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/CMakeLists.txt libbtbb-2015.09.R2/lib/CMakeLists.txt --- libbtbb-2014.11.26+gitf83b85c/lib/CMakeLists.txt 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/CMakeLists.txt 2015-09-05 07:46:31.000000000 +0000 @@ -19,6 +19,8 @@ # Boston, MA 02110-1301, USA. # +include(GNUInstallDirs) + # Based heavily upon the hackrf cmake setup. project(libbtbb C) diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/libbtbb.pc.in libbtbb-2015.09.R2/lib/libbtbb.pc.in --- libbtbb-2014.11.26+gitf83b85c/lib/libbtbb.pc.in 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/libbtbb.pc.in 2015-09-05 07:46:31.000000000 +0000 @@ -1,7 +1,7 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ Name: Bluetooth Baseband Library Description: C Utility Library diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/bluetooth_packet.c libbtbb-2015.09.R2/lib/src/bluetooth_packet.c --- libbtbb-2014.11.26+gitf83b85c/lib/src/bluetooth_packet.c 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/bluetooth_packet.c 2015-09-05 07:46:31.000000000 +0000 @@ -79,17 +79,6 @@ 0x00000203ef526bd1ULL, 0x000001033511ab3cULL, 0x000000819a88d59eULL, 0x00000040cd446acfULL, 0x00000022a41aabb3ULL, 0x0000001390b5cb0dULL, 0x0000000b0ae27b52ULL, 0x0000000585713da9ULL}; -static const uint64_t syndrome_matrix[] = { - 0x4be2573a00000000ULL, 0x25f12b9d00000000ULL, 0x591ac2f480000000ULL, 0x676f364040000000ULL, - 0x33b79b2020000000ULL, 0x19dbcd9010000000ULL, 0x0cede6c808000000ULL, 0x0676f36404000000ULL, - 0x48d92e8802000000ULL, 0x246c974401000000ULL, 0x59d41c9800800000ULL, 0x2cea0e4c00400000ULL, - 0x5d97501c00200000ULL, 0x6529ff3400100000ULL, 0x7976a8a000080000ULL, 0x3cbb545000040000ULL, - 0x1e5daa2800020000ULL, 0x0f2ed51400010000ULL, 0x4c753db000008000ULL, 0x263a9ed800004000ULL, - 0x131d4f6c00002000ULL, 0x426cf08c00001000ULL, 0x6ad42f7c00000800ULL, 0x7e88408400000400ULL, - 0x74a6777800000200ULL, 0x3a533bbc00000100ULL, 0x56cbcae400000080ULL, 0x6087b24800000040ULL, - 0x3043d92400000020ULL, 0x53c3bba800000010ULL, 0x29e1ddd400000008ULL, 0x5f12b9d000000004ULL, - 0x2f895ce800000002ULL, 0x97c4ae7400000001ULL}; - static const uint64_t barker_correct[] = { 0xb000000000000000ULL, 0x4e00000000000000ULL, 0x4e00000000000000ULL, 0x4e00000000000000ULL, 0x4e00000000000000ULL, 0x4e00000000000000ULL, 0x4e00000000000000ULL, 0x4e00000000000000ULL, @@ -253,20 +242,25 @@ return host_order; } -/* Convert some number of bits in a host order integer to an air order array */ -static void host_to_air(const uint8_t host_order, char *air_order, const int bits) -{ - int i; - for (i = 0; i < bits; i++) - air_order[i] = (host_order >> i) & 0x01; -} +///* Convert some number of bits in a host order integer to an air order array */ +//static void host_to_air(const uint8_t host_order, char *air_order, const int bits) +//{ +// int i; +// for (i = 0; i < bits; i++) +// air_order[i] = (host_order >> i) & 0x01; +//} + /* count the number of 1 bits in a uint64_t */ static uint8_t count_bits(uint64_t n) { +#ifdef __GNUC__ + return (uint8_t) __builtin_popcountll (n); +#else uint8_t i = 0; for (i = 0; n != 0; i++) n &= n - 1; return i; +#endif } #ifndef RELEASE @@ -302,7 +296,10 @@ btbb_packet_new(void) { btbb_packet *pkt = (btbb_packet *)calloc(1, sizeof(btbb_packet)); - pkt->refcount = 1; + if(pkt) + pkt->refcount = 1; + else + fprintf(stderr, "Unable to allocate packet"); return pkt; } @@ -369,8 +366,9 @@ return pkt->ac_errors; } -int promiscuous_packet_search(char *stream, int search_length, uint32_t *lap, int max_ac_errors, uint8_t *ac_errors) { - uint64_t syncword, codeword, syndrome, corrected_barker, ac; +int promiscuous_packet_search(char *stream, int search_length, uint32_t *lap, + int max_ac_errors, uint8_t *ac_errors) { + uint64_t syncword, codeword, syndrome, corrected_barker; syndrome_struct *errors; char *symbols; int count, offset = -1; @@ -423,9 +421,9 @@ } /* Matching a specific LAP */ -int find_known_lap(char *stream, int search_length, uint32_t lap, int max_ac_errors, uint8_t *ac_errors) { - uint64_t syncword, codeword, syndrome, corrected_barker, ac; - syndrome_struct *errors; +int find_known_lap(char *stream, int search_length, uint32_t lap, + int max_ac_errors, uint8_t *ac_errors) { + uint64_t syncword, ac; char *symbols; int count, offset = -1; @@ -437,7 +435,6 @@ if (*ac_errors <= max_ac_errors) { offset = count; - //printf("Offset = %d\n", offset); break; } } @@ -445,7 +442,8 @@ } /* Looks for an AC in the stream */ -int btbb_find_ac(char *stream, int search_length, uint32_t lap, int max_ac_errors, btbb_packet **pkt_ptr) { +int btbb_find_ac(char *stream, int search_length, uint32_t lap, + int max_ac_errors, btbb_packet **pkt_ptr) { int offset; uint8_t ac_errors; @@ -467,7 +465,8 @@ } /* Copy data (symbols) into packet and set rx data. */ -void btbb_packet_set_data(btbb_packet *pkt, char *data, int length, uint8_t channel, uint32_t clkn) +void btbb_packet_set_data(btbb_packet *pkt, char *data, int length, + uint8_t channel, uint32_t clkn) { int i; @@ -543,22 +542,6 @@ return air_to_host32(&pkt->packet_header[0], 18); } -/* Compare stream with sync word - * Unused, but useful to correct >3 bit errors with known LAP - */ -static int check_syncword(uint64_t streamword, uint64_t syncword) -{ - uint8_t biterrors; - - //FIXME do error correction instead of detection - biterrors = count_bits(streamword ^ syncword); - - if (biterrors >= 5) - return 0; - - return 1; -} - /* Reverse the bits in a byte */ static uint8_t reverse(char byte) { @@ -1300,6 +1283,7 @@ case PACKET_TYPE_EV5: /* assuming EV5 but could be 3-EV5 */ rv = EV5(pkt->clock, pkt); + break; case PACKET_TYPE_DM5: /* assuming DM5 but could be 2-DH5 */ rv = DM(pkt->clock, pkt); diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/bluetooth_piconet.c libbtbb-2015.09.R2/lib/src/bluetooth_piconet.c --- libbtbb-2014.11.26+gitf83b85c/lib/src/bluetooth_piconet.c 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/bluetooth_piconet.c 2015-09-05 07:46:31.000000000 +0000 @@ -29,6 +29,15 @@ int perm_table_initialized = 0; char perm_table[0x20][0x20][0x200]; +/* count the number of 1 bits in a uint64_t */ +int count_bits(uint8_t n) +{ + int i = 0; + for (i = 0; n != 0; i++) + n &= n - 1; + return i; +} + btbb_piconet * btbb_piconet_new(void) { @@ -109,9 +118,14 @@ void btbb_piconet_set_afh_map(btbb_piconet *pn, uint8_t *afh_map) { int i; + pn->used_channels = 0; // DGS: Unroll this? - for(i=0; i<10; i++) + for(i=0; i<10; i++) { pn->afh_map[i] = afh_map[i]; + pn->used_channels += count_bits(pn->afh_map[i]); + } + if(btbb_piconet_get_flag(pn, BTBB_UAP_VALID)) + get_hop_pattern(pn); } uint8_t *btbb_piconet_get_afh_map(btbb_piconet *pn) { @@ -120,17 +134,44 @@ void btbb_piconet_set_channel_seen(btbb_piconet *pn, uint8_t channel) { - pn->afh_map[channel/8] |= 0x1 << (channel % 8); + if(!(pn->afh_map[channel/8] & 0x1 << (channel % 8))) { + pn->afh_map[channel/8] |= 0x1 << (channel % 8); + pn->used_channels++; + if(btbb_piconet_get_flag(pn, BTBB_UAP_VALID)) + get_hop_pattern(pn); + } +} + +uint8_t btbb_piconet_get_channel_seen(btbb_piconet *pn, uint8_t channel) +{ + if(channel < BT_NUM_CHANNELS) + return ( pn->afh_map[channel/8] & (1 << (channel % 8)) ) != 0; + else + return 1; } /* do all the precalculation that can be done before knowing the address */ void precalc(btbb_piconet *pn) { - int i; + int i = 0; + int j = 0; + int chan; /* populate frequency register bank*/ - for (i = 0; i < BT_NUM_CHANNELS; i++) + for (i = 0; i < BT_NUM_CHANNELS; i++) { + + /* AFH is used, hopping sequence contains only used channels */ + if(btbb_piconet_get_flag(pn, BTBB_IS_AFH)) { + chan = (i * 2) % BT_NUM_CHANNELS; + if(btbb_piconet_get_channel_seen(pn, chan)) + pn->bank[j++] = chan; + } + + /* all channels are used */ + else { pn->bank[i] = ((i * 2) % BT_NUM_CHANNELS); + } + } /* actual frequency is 2402 + pn->bank[i] MHz */ } @@ -255,13 +296,16 @@ /* a, b, c, d, e, f, x, y1, y2 are variable names used in section 2.6 of the spec */ /* b is already defined */ /* e is already defined */ - int a, c, d, f, x; + int a, c, d, x; + uint32_t base_f, f, f_dash; int h, i, j, k, c_flipped, perm_in, perm_out; /* sequence index = clock >> 1 */ /* (hops only happen at every other clock value) */ int index = 0; + base_f = 0; f = 0; + f_dash = 0; /* nested loops for optimization (not recalculating every variable with every clock tick) */ for (h = 0; h < 0x04; h++) { /* clock bits 26-27 */ @@ -274,19 +318,26 @@ d = pn->d1 ^ k; for (x = 0; x < 0x20; x++) { /* clock bits 2-6 */ perm_in = ((x + a) % 32) ^ pn->b; + /* y1 (clock bit 1) = 0, y2 = 0 */ perm_out = fast_perm(perm_in, c, d); - pn->sequence[index] = pn->bank[(perm_out + pn->e + f) % BT_NUM_CHANNELS]; - if (btbb_piconet_get_flag(pn, BTBB_IS_AFH)) { - pn->sequence[index + 1] = pn->sequence[index]; - } else { - /* y1 (clock bit 1) = 1, y2 = 32 */ - perm_out = fast_perm(perm_in, c_flipped, d); + if (btbb_piconet_get_flag(pn, BTBB_IS_AFH)) + pn->sequence[index] = pn->bank[(perm_out + pn->e + f_dash) % pn->used_channels]; + else + pn->sequence[index] = pn->bank[(perm_out + pn->e + f) % BT_NUM_CHANNELS]; + + /* y1 (clock bit 1) = 1, y2 = 32 */ + perm_out = fast_perm(perm_in, c_flipped, d); + if (btbb_piconet_get_flag(pn, BTBB_IS_AFH)) + pn->sequence[index + 1] = pn->bank[(perm_out + pn->e + f_dash + 32) % pn->used_channels]; + else pn->sequence[index + 1] = pn->bank[(perm_out + pn->e + f + 32) % BT_NUM_CHANNELS]; - } + index += 2; } - f += 16; + base_f += 16; + f = base_f % BT_NUM_CHANNELS; + f_dash = f % pn->used_channels; } } } @@ -319,31 +370,32 @@ /* Function to fetch piconet hopping patterns */ void get_hop_pattern(btbb_piconet *pn) { - hopping_struct *s; - uint64_t key; - - /* Two stages to avoid "left shift count >= width of type" warning */ - key = btbb_piconet_get_flag(pn, BTBB_IS_AFH); - key = (key<<32) | (pn->UAP<<24) | pn->LAP; - HASH_FIND(hh, hopping_map, &key, 4, s); - - if (s == NULL) { - gen_hop_pattern(pn); - s = malloc(sizeof(hopping_struct)); - s->key = key; - s->sequence = pn->sequence; - HASH_ADD(hh, hopping_map, key, 4, s); - } else { - printf("\nFound hopping sequence in cache.\n"); - pn->sequence = s->sequence; - } + hopping_struct *s; + uint64_t key; + + /* Two stages to avoid "left shift count >= width of type" warning */ + key = btbb_piconet_get_flag(pn, BTBB_IS_AFH); + key = (key<<39) | ((uint64_t)pn->used_channels<<32) | (pn->UAP<<24) | pn->LAP; + HASH_FIND(hh, hopping_map, &key, 4, s); + + if (s == NULL) { + gen_hop_pattern(pn); + s = malloc(sizeof(hopping_struct)); + s->key = key; + s->sequence = pn->sequence; + HASH_ADD(hh, hopping_map, key, 4, s); + } else { + printf("\nFound hopping sequence in cache.\n"); + pn->sequence = s->sequence; + } } /* determine channel for a particular hop */ -/* replaced with gen_hops() for a complete sequence but could still come in handy */ +/* borrowed from ubertooth firmware to support AFH */ char single_hop(int clock, btbb_piconet *pn) { - int a, c, d, f, x, y1, y2; + int a, c, d, x, y1, y2, perm, next_channel; + uint32_t base_f, f, f_dash; /* following variable names used in section 2.6 of the spec */ x = (clock >> 2) & 0x1f; @@ -354,10 +406,21 @@ c = (pn->c1 ^ (clock >> 16)) & 0x1f; d = (pn->d1 ^ (clock >> 7)) & 0x1ff; /* e is already defined */ - f = (clock >> 3) & 0x1fffff0; + base_f = (clock >> 3) & 0x1fffff0; + f = base_f % BT_NUM_CHANNELS; + perm = fast_perm( + ((x + a) % 32) ^ pn->b, + (y1 * 0x1f) ^ c, + d); /* hop selection */ - return(pn->bank[(fast_perm(((x + a) % 32) ^ pn->b, (y1 * 0x1f) ^ c, d) + pn->e + f + y2) % BT_NUM_CHANNELS]); + if(btbb_piconet_get_flag(pn, BTBB_IS_AFH)) { + f_dash = base_f % pn->used_channels; + next_channel = pn->bank[(perm + pn->e + f_dash + y2) % pn->used_channels]; + } else { + next_channel = pn->bank[(perm + pn->e + f + y2) % BT_NUM_CHANNELS]; + } + return next_channel; } /* look up channel for a particular hop */ @@ -368,7 +431,7 @@ static char aliased_channel(char channel) { - return ((channel + 24) % ALIASED_CHANNELS) + 26; + return ((channel + 24) % ALIASED_CHANNELS) + 26; } /* create list of initial candidate clock values (hops with same channel as first observed hop) */ @@ -447,7 +510,6 @@ } else { if (btbb_uap_from_header(pkt, pn)) { if (filter_uap == pn->UAP) { - printf("got CLK1-6\n"); btbb_init_hop_reversal(0, pn); btbb_winnow(pn); } else { @@ -486,7 +548,7 @@ */ btbb_piconet_set_flag(pn, BTBB_IS_AFH, btbb_piconet_get_flag(pn, BTBB_LOOKS_LIKE_AFH)); - btbb_piconet_set_flag(pn, BTBB_LOOKS_LIKE_AFH, 0); + // btbb_piconet_set_flag(pn, BTBB_LOOKS_LIKE_AFH, 0); //int i; //for(i=0; i<10; i++) // pn->afh_map[i] = 0; @@ -579,7 +641,7 @@ pn->first_pkt_time = clkn; // Set afh channel map - pn->afh_map[pkt->channel/8] |= 0x1 << (pkt->channel % 8); + btbb_piconet_set_channel_seen(pn, pkt->channel); if (pn->packets_observed < MAX_PATTERN_LENGTH) { pn->pattern_indices[pn->packets_observed] = clkn - pn->first_pkt_time; @@ -651,10 +713,10 @@ if (remaining == 1) { pn->clk_offset = (first_clock - (pn->first_pkt_time & 0x3f)) & 0x3f; if (!btbb_piconet_get_flag(pn, BTBB_UAP_VALID)) - printf("We have a winner! UAP = 0x%x found after %d total packets.\n", + printf("UAP = 0x%x found after %d total packets.\n", pn->clock6_candidates[first_clock], pn->total_packets_observed); else - printf("We have a winner! CLK6 = 0x%x found after %d total packets.\n", + printf("CLK6 = 0x%x found after %d total packets.\n", pn->clk_offset, pn->total_packets_observed); pn->UAP = pn->clock6_candidates[first_clock]; btbb_piconet_set_flag(pn, BTBB_CLK6_VALID, 1); @@ -670,40 +732,44 @@ return 0; } -/* add a packet to the queue */ -static void enqueue(btbb_packet *pkt, btbb_piconet *pn) -{ - pkt_queue *head; - //pkt_queue item; - - btbb_packet_ref(pkt); - pkt_queue item = {pkt, NULL}; - head = pn->queue; - - if (head == NULL) { - pn->queue = &item; - } else { - for(; head->next != NULL; head = head->next) - ; - head->next = &item; - } -} - -/* pull the first packet from the queue (FIFO) */ -static btbb_packet *dequeue(btbb_piconet *pn) -{ - btbb_packet *pkt; - - if (pn->queue == NULL) { - pkt = NULL; - } else { - pkt = pn->queue->pkt; - pn->queue = pn->queue->next; - btbb_packet_unref(pkt); - } - - return pkt; -} +/* FIXME: comment out enqueue and dequeue because they are + * never used. Try to find out what tey were meant to be + * used for before the next release. + */ +///* add a packet to the queue */ +//static void enqueue(btbb_packet *pkt, btbb_piconet *pn) +//{ +// pkt_queue *head; +// //pkt_queue item; +// +// btbb_packet_ref(pkt); +// pkt_queue item = {pkt, NULL}; +// head = pn->queue; +// +// if (head == NULL) { +// pn->queue = &item; +// } else { +// for(; head->next != NULL; head = head->next) +// ; +// head->next = &item; +// } +//} +// +///* pull the first packet from the queue (FIFO) */ +//static btbb_packet *dequeue(btbb_piconet *pn) +//{ +// btbb_packet *pkt; +// +// if (pn->queue == NULL) { +// pkt = NULL; +// } else { +// pkt = pn->queue->pkt; +// pn->queue = pn->queue->next; +// btbb_packet_unref(pkt); +// } +// +// return pkt; +//} /* decode the whole packet */ int btbb_decode(btbb_packet* pkt, btbb_piconet *pn) @@ -774,10 +840,15 @@ uint8_t *afh_map; afh_map = pn->afh_map; - /* Printed ch78 -> ch0 */ - printf("\tAFH Map=0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", - afh_map[9], afh_map[8], afh_map[7], afh_map[6], afh_map[5], - afh_map[4], afh_map[3], afh_map[2], afh_map[1], afh_map[0]); + /* Print like hcitool does */ + printf("AFH map: 0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", + afh_map[0], afh_map[1], afh_map[2], afh_map[3], afh_map[4], + afh_map[5], afh_map[6], afh_map[7], afh_map[8], afh_map[9]); + + // /* Printed ch78 -> ch0 */ + // printf("\tAFH Map=0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", + // afh_map[9], afh_map[8], afh_map[7], afh_map[6], afh_map[5], + // afh_map[4], afh_map[3], afh_map[2], afh_map[1], afh_map[0]); } /* Container for survey piconets */ @@ -839,6 +910,10 @@ btbb_uap_from_header(pkt, pn); return 0; } + + if(pn) + btbb_piconet_set_channel_seen(pn, pkt->channel); + /* If piconet structure is given, a LAP is given, and packet * header is readable, do further analysis. If UAP has not yet * been determined, attempt to calculate it from headers. Once diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/bluetooth_piconet.h libbtbb-2015.09.R2/lib/src/bluetooth_piconet.h --- libbtbb-2014.11.26+gitf83b85c/lib/src/bluetooth_piconet.h 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/bluetooth_piconet.h 2015-09-05 07:46:31.000000000 +0000 @@ -41,6 +41,9 @@ /* AFH channel map - either read or derived from observed packets */ uint8_t afh_map[10]; + /* Number of used channel derived from AFH channel map */ + uint8_t used_channels; + /* lower address part (of master's BD_ADDR) */ uint32_t LAP; @@ -123,4 +126,6 @@ void try_hop(btbb_packet *pkt, btbb_piconet *pn); +void get_hop_pattern(btbb_piconet *pn); + #endif /* INCLUDED_BLUETOOTH_PICONET_H */ diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/btbb.h libbtbb-2015.09.R2/lib/src/btbb.h --- libbtbb-2014.11.26+gitf83b85c/lib/src/btbb.h 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/btbb.h 2015-09-05 07:46:31.000000000 +0000 @@ -106,6 +106,8 @@ void btbb_packet_set_modulation(btbb_packet *pkt, uint8_t modulation); void btbb_packet_set_transport(btbb_packet *pkt, uint8_t transport); +uint8_t btbb_packet_get_modulation(const btbb_packet *pkt); +uint8_t btbb_packet_get_transport(const btbb_packet *pkt); uint8_t btbb_packet_get_channel(const btbb_packet *pkt); uint8_t btbb_packet_get_ac_errors(const btbb_packet *pkt); @@ -222,20 +224,8 @@ const uint64_t ns, const uint32_t clk, const uint32_t clkmask); int btbb_pcapng_close(btbb_pcapng_handle * h); -#if defined(USE_PCAP) -typedef struct btbb_pcap_handle btbb_pcap_handle; -/* create a PCAP file for BREDR captures with LINKTYPE_BLUETOOTH_BREDR_BB */ -int btbb_pcap_create_file(const char *filename, btbb_pcap_handle ** ph); -/* write a BREDR packet to PCAP file */ -int btbb_pcap_append_packet(btbb_pcap_handle * h, const uint64_t ns, - const int8_t sigdbm, const int8_t noisedbm, - const uint32_t reflap, const uint8_t refuap, - const btbb_packet *pkt); -int btbb_pcap_close(btbb_pcap_handle * h); -#endif - -/* BTLE support */ +/* BLE support */ typedef struct lell_packet lell_packet; /* decode and allocate LE packet */ void lell_allocate_and_decode(const uint8_t *stream, uint16_t phys_channel, uint32_t clk100ns, lell_packet **pkt); @@ -261,7 +251,19 @@ int lell_pcapng_record_connect_req(lell_pcapng_handle * h, const uint64_t ns, const uint8_t * pdu); int lell_pcapng_close(lell_pcapng_handle *h); -#if defined(USE_PCAP) + +/* PCAP Support */ +#if defined(ENABLE_PCAP) +typedef struct btbb_pcap_handle btbb_pcap_handle; +/* create a PCAP file for BREDR captures with LINKTYPE_BLUETOOTH_BREDR_BB */ +int btbb_pcap_create_file(const char *filename, btbb_pcap_handle ** ph); +/* write a BREDR packet to PCAP file */ +int btbb_pcap_append_packet(btbb_pcap_handle * h, const uint64_t ns, + const int8_t sigdbm, const int8_t noisedbm, + const uint32_t reflap, const uint8_t refuap, + const btbb_packet *pkt); +int btbb_pcap_close(btbb_pcap_handle * h); + typedef struct lell_pcap_handle lell_pcap_handle; /* create a PCAP file for LE captures using LINKTYPE_BLUETOOTH_LE_LL_WITH_PHDR */ int lell_pcap_create_file(const char *filename, lell_pcap_handle ** ph); @@ -277,7 +279,7 @@ const int8_t rssi_avg, const uint8_t rssi_count, const lell_packet *pkt); int lell_pcap_close(lell_pcap_handle *h); -#endif +#endif // ENABLE_PCAP #ifdef __cplusplus } // __cplusplus defined. diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/CMakeLists.txt libbtbb-2015.09.R2/lib/src/CMakeLists.txt --- libbtbb-2014.11.26+gitf83b85c/lib/src/CMakeLists.txt 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/CMakeLists.txt 2015-09-05 07:46:31.000000000 +0000 @@ -65,13 +65,21 @@ set_target_properties(btbb PROPERTIES CLEAN_DIRECT_OUTPUT 1) -# Conditional libpcap support -find_package(PCAP) -if( ${PCAP_FOUND} ) - include_directories(${PCAP_INCLUDE_DIRS}) - target_link_libraries(btbb ${PCAP_LIBRARIES}) - add_definitions( -DUSE_PCAP ) -endif( ${PCAP_FOUND} ) +# PCAP Support +if( (NOT DEFINED USE_PCAP) OR USE_PCAP ) + find_package(PCAP) + + if( USE_PCAP AND NOT ${PCAP_FOUND} ) + message( FATAL_ERROR + "Cannot find libpcap, which is required for USE_PCAP") + endif() + + if( ${PCAP_FOUND} ) + include_directories(${PCAP_INCLUDE_DIRS}) + target_link_libraries(btbb ${PCAP_LIBRARIES}) + add_definitions( -DENABLE_PCAP ) + endif( ${PCAP_FOUND} ) +endif( (NOT DEFINED USE_PCAP) OR USE_PCAP ) if( ${UNIX} ) install(TARGETS btbb diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/pcap.c libbtbb-2015.09.R2/lib/src/pcap.c --- libbtbb-2014.11.26+gitf83b85c/lib/src/pcap.c 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/pcap.c 2015-09-05 07:46:31.000000000 +0000 @@ -34,14 +34,14 @@ PCAP_NO_MEMORY, } PCAP_RESULT; -#if defined(USE_PCAP) +#if defined(ENABLE_PCAP) /* BT BR/EDR support */ -typedef struct btbb_pcap_handle { +struct btbb_pcap_handle { pcap_t * pcap; pcap_dumper_t * dumper; -} btbb_pcap_handle; +}; int btbb_pcap_create_file(const char *filename, btbb_pcap_handle ** ph) @@ -91,7 +91,7 @@ static void assemble_pcapng_bredr_packet( pcap_bredr_packet * pkt, - const uint32_t interface_id, + const uint32_t interface_id __attribute__((unused)), const uint64_t ns, const uint32_t caplen, const uint8_t rf_channel, @@ -195,12 +195,12 @@ /* BTLE support */ -typedef struct lell_pcap_handle { +struct lell_pcap_handle { pcap_t * pcap; pcap_dumper_t * dumper; int dlt; uint8_t btle_ppi_version; -} lell_pcap_handle; +}; static int lell_pcap_create_file_dlt(const char *filename, int dlt, lell_pcap_handle ** ph) @@ -267,7 +267,7 @@ static void assemble_pcapng_le_packet( pcap_le_packet * pkt, - const uint32_t interface_id, + const uint32_t interface_id __attribute__((unused)), const uint64_t ns, const uint32_t caplen, const uint8_t rf_channel, @@ -363,9 +363,9 @@ const int8_t rssi_avg, const uint8_t rssi_count, const lell_packet *pkt) { - const ppi_packet_header_sz = sizeof(ppi_packet_header_t); - const ppi_fieldheader_sz = sizeof(ppi_fieldheader_t); - const le_ll_ppi_header_sz = sizeof(ppi_btle_t); + const uint16_t ppi_packet_header_sz = sizeof(ppi_packet_header_t); + const uint16_t ppi_fieldheader_sz = sizeof(ppi_fieldheader_t); + const uint16_t le_ll_ppi_header_sz = sizeof(ppi_btle_t); if (h && h->dumper && (h->dlt == DLT_PPI)) { @@ -419,4 +419,4 @@ return -PCAP_INVALID_HANDLE; } -#endif /* USE_PCAP */ +#endif /* ENABLE_PCAP */ diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/pcap-common.h libbtbb-2015.09.R2/lib/src/pcap-common.h --- libbtbb-2014.11.26+gitf83b85c/lib/src/pcap-common.h 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/pcap-common.h 2015-09-05 07:46:31.000000000 +0000 @@ -23,10 +23,10 @@ #define PCAP_COMMON_DOT_H /* pull definitions for BT DLTs and pseudoheaders from libpcap, if possible */ -#if defined(USE_PCAP) +#if defined(ENABLE_PCAP) #include #include -#endif +#endif /* ENABLE_PCAP */ #if defined( __APPLE__ ) #include diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/pcapng-bt.c libbtbb-2015.09.R2/lib/src/pcapng-bt.c --- libbtbb-2014.11.26+gitf83b85c/lib/src/pcapng-bt.c 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/pcapng-bt.c 2015-09-05 07:46:31.000000000 +0000 @@ -29,6 +29,7 @@ #include #include #include +#include /* generic section options indicating libbtbb */ const struct { @@ -411,6 +412,11 @@ return pcapng_append_packet( handle, ( const enhanced_packet_block *) pkt ); } +/* Size of a PCAPNG enhanced packet block with no packet data. + NOTE: The pcap_bluetooth_le_ll_header is part of the packet data of + the enhanced block. */ +#define PCAPNG_ENHANCED_BLK_SZ 36 + static void assemble_pcapng_le_packet( pcapng_le_packet * pkt, const uint32_t interface_id, @@ -425,7 +431,9 @@ const uint8_t * lepkt ) { uint32_t pcapng_caplen = sizeof(pcap_bluetooth_le_ll_header)+caplen; - uint32_t block_length = 4*((36+pcapng_caplen+3)/4); + uint32_t block_length = 4*((PCAPNG_ENHANCED_BLK_SZ+pcapng_caplen+3)/4); + + assert(caplen <= LE_MAX_PAYLOAD); pkt->blk_header.block_type = BLOCK_TYPE_ENHANCED_PACKET; pkt->blk_header.block_total_length = block_length; @@ -455,6 +463,11 @@ ((noisedbm < sigdbm) ? LE_NOISEPOWER_VALID : 0) | (lell_packet_is_data(pkt) ? 0 : LE_REF_AA_VALID); pcapng_le_packet pcapng_pkt; + + /* The extra 9 bytes added to the packet length are for: + 4 bytes for Access Address + 2 bytes for PDU header + 3 bytes for CRC */ assemble_pcapng_le_packet( &pcapng_pkt, 0, ns, diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/pcapng-bt.h libbtbb-2015.09.R2/lib/src/pcapng-bt.h --- libbtbb-2014.11.26+gitf83b85c/lib/src/pcapng-bt.h 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/pcapng-bt.h 2015-09-05 07:46:31.000000000 +0000 @@ -79,6 +79,15 @@ enhanced_packet_block blk_header; pcap_bluetooth_le_ll_header le_ll_header; uint8_t le_packet[LE_MAX_PAYLOAD]; + + /* Force 32 bit alignment for options and blk_tot_length. */ + uint8_t pad[2]; + + /* Add space for OPTIONS and BLOCK_TOTAL_LENGTH at end of + block. These won't be at this position in the structure unless + the LE PDU is the full 39 bytes. */ + uint32_t options; + uint32_t blk_tot_length; } pcapng_le_packet; typedef struct __attribute__((packed)) { diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/pcapng.c libbtbb-2015.09.R2/lib/src/pcapng.c --- libbtbb-2014.11.26+gitf83b85c/lib/src/pcapng.c 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/pcapng.c 2015-09-05 07:46:31.000000000 +0000 @@ -45,7 +45,8 @@ { PCAPNG_RESULT retval = PCAPNG_OK; int PGSZ = getpagesize( ); - size_t zeroes = 0, result = -1; + size_t zeroes = 0; + ssize_t result = -1; handle->section_header = NULL; handle->interface_description = NULL; diff -Nru libbtbb-2014.11.26+gitf83b85c/lib/src/uthash.h libbtbb-2015.09.R2/lib/src/uthash.h --- libbtbb-2014.11.26+gitf83b85c/lib/src/uthash.h 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/lib/src/uthash.h 2015-09-05 07:46:31.000000000 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2013, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2003-2014, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -22,7 +22,7 @@ */ #ifndef UTHASH_H -#define UTHASH_H +#define UTHASH_H #include /* memcmp,strlen */ #include /* ptrdiff_t */ @@ -32,13 +32,16 @@ As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ source) this code uses whatever method is needed or, for VS2008 where neither is available, uses casting workarounds. */ -#ifdef _MSC_VER /* MS compiler */ +#if defined(_MSC_VER) /* MS compiler */ #if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ #define DECLTYPE(x) (decltype(x)) #else /* VS2008 or older (or VS2010 in C mode) */ #define NO_DECLTYPE #define DECLTYPE(x) #endif +#elif defined(__BORLANDC__) || defined(__LCC__) || defined(__WATCOMC__) +#define NO_DECLTYPE +#define DECLTYPE(x) #else /* GNU, Sun and other compilers */ #define DECLTYPE(x) (__typeof(x)) #endif @@ -49,22 +52,28 @@ char **_da_dst = (char**)(&(dst)); \ *_da_dst = (char*)(src); \ } while(0) -#else +#else #define DECLTYPE_ASSIGN(dst,src) \ do { \ (dst) = DECLTYPE(dst)(src); \ } while(0) #endif -/* a number of the hash function use uint32_t which isn't defined on win32 */ -#ifdef _MSC_VER +/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */ +#if defined (_WIN32) +#if defined(_MSC_VER) && _MSC_VER >= 1600 +#include +#elif defined(__WATCOMC__) +#include +#else typedef unsigned int uint32_t; typedef unsigned char uint8_t; +#endif #else -#include /* uint32_t */ +#include #endif -#define UTHASH_VERSION 1.9.8 +#define UTHASH_VERSION 1.9.9 #ifndef uthash_fatal #define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */ @@ -93,9 +102,9 @@ #define HASH_FIND(hh,head,keyptr,keylen,out) \ do { \ - unsigned _hf_bkt,_hf_hashv; \ out=NULL; \ if (head) { \ + unsigned _hf_bkt,_hf_hashv; \ HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \ if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \ HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \ @@ -114,12 +123,12 @@ if (!((tbl)->bloom_bv)) { uthash_fatal( "out of memory"); } \ memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \ (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ -} while (0) +} while (0) #define HASH_BLOOM_FREE(tbl) \ do { \ uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ -} while (0) +} while (0) #define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8] |= (1U << ((idx)%8))) #define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8] & (1U << ((idx)%8))) @@ -131,9 +140,9 @@ HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) #else -#define HASH_BLOOM_MAKE(tbl) -#define HASH_BLOOM_FREE(tbl) -#define HASH_BLOOM_ADD(tbl,hashv) +#define HASH_BLOOM_MAKE(tbl) +#define HASH_BLOOM_FREE(tbl) +#define HASH_BLOOM_ADD(tbl,hashv) #define HASH_BLOOM_TEST(tbl,hashv) (1) #define HASH_BLOOM_BYTELEN 0 #endif @@ -166,16 +175,16 @@ HASH_FIND(hh,head,&((add)->fieldname),keylen_in,replaced); \ if (replaced!=NULL) { \ HASH_DELETE(hh,head,replaced); \ - }; \ + } \ HASH_ADD(hh,head,fieldname,keylen_in,add); \ } while(0) - + #define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \ do { \ unsigned _ha_bkt; \ (add)->hh.next = NULL; \ - (add)->hh.key = (char*)keyptr; \ - (add)->hh.keylen = (unsigned)keylen_in; \ + (add)->hh.key = (char*)(keyptr); \ + (add)->hh.keylen = (unsigned)(keylen_in); \ if (!(head)) { \ head = (add); \ (head)->hh.prev = NULL; \ @@ -214,7 +223,6 @@ */ #define HASH_DELETE(hh,head,delptr) \ do { \ - unsigned _hd_bkt; \ struct UT_hash_handle *_hd_hh_del; \ if ( ((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL) ) { \ uthash_free((head)->hh.tbl->buckets, \ @@ -223,6 +231,7 @@ uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ head = NULL; \ } else { \ + unsigned _hd_bkt; \ _hd_hh_del = &((delptr)->hh); \ if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \ (head)->hh.tbl->tail = \ @@ -250,11 +259,11 @@ /* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ #define HASH_FIND_STR(head,findstr,out) \ - HASH_FIND(hh,head,findstr,strlen(findstr),out) + HASH_FIND(hh,head,findstr,(unsigned)strlen(findstr),out) #define HASH_ADD_STR(head,strfield,add) \ - HASH_ADD(hh,head,strfield,strlen(add->strfield),add) + HASH_ADD(hh,head,strfield[0],strlen(add->strfield),add) #define HASH_REPLACE_STR(head,strfield,add,replaced) \ - HASH_REPLACE(hh,head,strfield,strlen(add->strfield),add,replaced) + HASH_REPLACE(hh,head,strfield[0],(unsigned)strlen(add->strfield),add,replaced) #define HASH_FIND_INT(head,findint,out) \ HASH_FIND(hh,head,findint,sizeof(int),out) #define HASH_ADD_INT(head,intfield,add) \ @@ -265,7 +274,7 @@ HASH_FIND(hh,head,findptr,sizeof(void *),out) #define HASH_ADD_PTR(head,ptrfield,add) \ HASH_ADD(hh,head,ptrfield,sizeof(void *),add) -#define HASH_REPLACE_PTR(head,ptrfield,add) \ +#define HASH_REPLACE_PTR(head,ptrfield,add,replaced) \ HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced) #define HASH_DEL(head,delptr) \ HASH_DELETE(hh,head,delptr) @@ -277,14 +286,14 @@ #define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0) #define HASH_FSCK(hh,head) \ do { \ - unsigned _bkt_i; \ - unsigned _count, _bkt_count; \ - char *_prev; \ struct UT_hash_handle *_thh; \ if (head) { \ + unsigned _bkt_i; \ + unsigned _count; \ + char *_prev; \ _count = 0; \ for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \ - _bkt_count = 0; \ + unsigned _bkt_count = 0; \ _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \ _prev = NULL; \ while (_thh) { \ @@ -298,12 +307,12 @@ } \ _count += _bkt_count; \ if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \ - HASH_OOPS("invalid bucket count %d, actual %d\n", \ + HASH_OOPS("invalid bucket count %u, actual %u\n", \ (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \ } \ } \ if (_count != (head)->hh.tbl->num_items) { \ - HASH_OOPS("invalid hh item count %d, actual %d\n", \ + HASH_OOPS("invalid hh item count %u, actual %u\n", \ (head)->hh.tbl->num_items, _count ); \ } \ /* traverse hh in app order; check next/prev integrity, count */ \ @@ -321,16 +330,16 @@ (head)->hh.tbl->hho) : NULL ); \ } \ if (_count != (head)->hh.tbl->num_items) { \ - HASH_OOPS("invalid app item count %d, actual %d\n", \ + HASH_OOPS("invalid app item count %u, actual %u\n", \ (head)->hh.tbl->num_items, _count ); \ } \ } \ } while (0) #else -#define HASH_FSCK(hh,head) +#define HASH_FSCK(hh,head) #endif -/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to +/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to * the descriptor to which this macro is defined for tuning the hash function. * The app can #include to get the prototype for write(2). */ #ifdef HASH_EMIT_KEYS @@ -340,29 +349,29 @@ write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \ write(HASH_EMIT_KEYS, keyptr, fieldlen); \ } while (0) -#else -#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) +#else +#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) #endif /* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ -#ifdef HASH_FUNCTION +#ifdef HASH_FUNCTION #define HASH_FCN HASH_FUNCTION #else #define HASH_FCN HASH_JEN #endif -/* The Bernstein hash function, used in Perl prior to v5.6 */ +/* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */ #define HASH_BER(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _hb_keylen=keylen; \ char *_hb_key=(char*)(key); \ (hashv) = 0; \ - while (_hb_keylen--) { (hashv) = ((hashv) * 33) + *_hb_key++; } \ + while (_hb_keylen--) { (hashv) = (((hashv) << 5) + (hashv)) + *_hb_key++; } \ bkt = (hashv) & (num_bkts-1); \ } while (0) -/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at +/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */ #define HASH_SAX(key,keylen,num_bkts,hashv,bkt) \ do { \ @@ -373,17 +382,19 @@ hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \ bkt = hashv & (num_bkts-1); \ } while (0) - +/* FNV-1a variation */ #define HASH_FNV(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _fn_i; \ char *_hf_key=(char*)(key); \ hashv = 2166136261UL; \ - for(_fn_i=0; _fn_i < keylen; _fn_i++) \ - hashv = (hashv * 16777619) ^ _hf_key[_fn_i]; \ + for(_fn_i=0; _fn_i < keylen; _fn_i++) { \ + hashv = hashv ^ _hf_key[_fn_i]; \ + hashv = hashv * 16777619; \ + } \ bkt = hashv & (num_bkts-1); \ -} while(0) - +} while(0) + #define HASH_OAT(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _ho_i; \ @@ -419,7 +430,7 @@ unsigned char *_hj_key=(unsigned char*)(key); \ hashv = 0xfeedbeef; \ _hj_i = _hj_j = 0x9e3779b9; \ - _hj_k = (unsigned)keylen; \ + _hj_k = (unsigned)(keylen); \ while (_hj_k >= 12) { \ _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \ + ( (unsigned)_hj_key[2] << 16 ) \ @@ -507,12 +518,12 @@ hashv ^= hashv << 25; \ hashv += hashv >> 6; \ bkt = hashv & (num_bkts-1); \ -} while(0) +} while(0) #ifdef HASH_USING_NO_STRICT_ALIASING /* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads. * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error. - * MurmurHash uses the faster approach only on CPU's where we know it's safe. + * MurmurHash uses the faster approach only on CPU's where we know it's safe. * * Note the preprocessor built-in defines can be emitted using: * @@ -591,7 +602,7 @@ #endif /* HASH_USING_NO_STRICT_ALIASING */ /* key comparison function; return 0 if keys equal */ -#define HASH_KEYCMP(a,b,len) memcmp(a,b,len) +#define HASH_KEYCMP(a,b,len) memcmp(a,b,len) /* iterate over items in a known bucket to find desired item */ #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \ @@ -632,36 +643,36 @@ } \ if (hh_del->hh_next) { \ hh_del->hh_next->hh_prev = hh_del->hh_prev; \ - } + } /* Bucket expansion has the effect of doubling the number of buckets * and redistributing the items into the new buckets. Ideally the * items will distribute more or less evenly into the new buckets * (the extent to which this is true is a measure of the quality of - * the hash function as it applies to the key domain). - * + * the hash function as it applies to the key domain). + * * With the items distributed into more buckets, the chain length * (item count) in each bucket is reduced. Thus by expanding buckets - * the hash keeps a bound on the chain length. This bounded chain + * the hash keeps a bound on the chain length. This bounded chain * length is the essence of how a hash provides constant time lookup. - * + * * The calculation of tbl->ideal_chain_maxlen below deserves some * explanation. First, keep in mind that we're calculating the ideal * maximum chain length based on the *new* (doubled) bucket count. * In fractions this is just n/b (n=number of items,b=new num buckets). - * Since the ideal chain length is an integer, we want to calculate + * Since the ideal chain length is an integer, we want to calculate * ceil(n/b). We don't depend on floating point arithmetic in this * hash, so to calculate ceil(n/b) with integers we could write - * + * * ceil(n/b) = (n/b) + ((n%b)?1:0) - * + * * and in fact a previous version of this hash did just that. * But now we have improved things a bit by recognizing that b is * always a power of two. We keep its base 2 log handy (call it lb), * so now we can write this with a bit shift and logical AND: - * + * * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) - * + * */ #define HASH_EXPAND_BUCKETS(tbl) \ do { \ @@ -713,7 +724,7 @@ /* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */ -/* Note that HASH_SORT assumes the hash handle name to be hh. +/* Note that HASH_SORT assumes the hash handle name to be hh. * HASH_SRT was added to allow the hash handle name to be passed in. */ #define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn) #define HASH_SRT(hh,head,cmpfcn) \ @@ -803,10 +814,10 @@ } \ } while (0) -/* This function selects items from one hash into another hash. - * The end result is that the selected items have dual presence - * in both hashes. There is no copy of the items made; rather - * they are added into the new hash through a secondary hash +/* This function selects items from one hash into another hash. + * The end result is that the selected items have dual presence + * in both hashes. There is no copy of the items made; rather + * they are added into the new hash through a secondary hash * hash handle that must be present in the structure. */ #define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \ do { \ @@ -858,15 +869,16 @@ } while(0) #define HASH_OVERHEAD(hh,head) \ + ((head) ? ( \ (size_t)((((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \ ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \ (sizeof(UT_hash_table)) + \ - (HASH_BLOOM_BYTELEN))) + (HASH_BLOOM_BYTELEN)))) : 0) #ifdef NO_DECLTYPE #define HASH_ITER(hh,head,el,tmp) \ for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); \ - el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL)) + el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL)) #else #define HASH_ITER(hh,head,el,tmp) \ for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); \ @@ -874,7 +886,7 @@ #endif /* obtain a count of items in the hash */ -#define HASH_COUNT(head) HASH_CNT(hh,head) +#define HASH_COUNT(head) HASH_CNT(hh,head) #define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0) typedef struct UT_hash_bucket { @@ -883,7 +895,7 @@ /* expand_mult is normally set to 0. In this situation, the max chain length * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If - * the bucket's chain exceeds this length, bucket expansion is triggered). + * the bucket's chain exceeds this length, bucket expansion is triggered). * However, setting expand_mult to a non-zero value delays bucket expansion * (that would be triggered by additions to this particular bucket) * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. @@ -891,7 +903,7 @@ * multiplier is to reduce bucket expansions, since they are expensive, in * situations where we know that a particular bucket tends to be overused. * It is better to let its chain length grow to a longer yet-still-bounded - * value, than to do an O(n) bucket expansion too often. + * value, than to do an O(n) bucket expansion too often. */ unsigned expand_mult; @@ -917,7 +929,7 @@ * hash distribution; reaching them in a chain traversal takes >ideal steps */ unsigned nonideal_items; - /* ineffective expands occur when a bucket doubling was performed, but + /* ineffective expands occur when a bucket doubling was performed, but * afterward, more than half the items in the hash had nonideal chain * positions. If this happens on two consecutive expansions we inhibit any * further expansion, as it's not helping; this happens when the hash diff -Nru libbtbb-2014.11.26+gitf83b85c/README.cmake libbtbb-2015.09.R2/README.cmake --- libbtbb-2014.11.26+gitf83b85c/README.cmake 1970-01-01 00:00:00.000000000 +0000 +++ libbtbb-2015.09.R2/README.cmake 2015-09-05 07:46:31.000000000 +0000 @@ -0,0 +1,12 @@ +CMake Settings +============== +The following are flags that may be of use when configuing this project. + + * DISABLE_PYTHON + * A boolean flag for building and installing btaptap python tool. + + * USE_PCAP + * USE_PCAP=ON - Build with pcap support, the build will fail if + libpcap is not found. + * USE_PCAP=OFF - Disable pcap support will be disabled. + * If left undefined pcap support will be enabled if libpcap is present. diff -Nru libbtbb-2014.11.26+gitf83b85c/tests/test_header.c libbtbb-2015.09.R2/tests/test_header.c --- libbtbb-2014.11.26+gitf83b85c/tests/test_header.c 1970-01-01 00:00:00.000000000 +0000 +++ libbtbb-2015.09.R2/tests/test_header.c 2015-09-05 07:46:31.000000000 +0000 @@ -0,0 +1,118 @@ +/* -*- c -*- */ +/* + * Copyright 2012 Dominic Spill + * + * This file is part of libbtbb + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with libbtbb; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ +/* +UAP Data HEC Header (octal) +---------------------------------- +00 123 e1 770007 007070 000777 +47 123 06 770007 007007 700000 +00 124 32 007007 007007 007700 +47 124 d5 007007 007070 707077 +00 125 5a 707007 007007 077070 +47 125 bd 707007 007070 777707 +00 126 e2 077007 007007 000777 +47 126 05 077007 007070 700000 +00 127 8a 777007 007007 070007 +47 127 6d 777007 007070 770770 +00 11b 9e 770770 007007 777007 +47 11b 79 770770 007070 077770 +00 11c 4d 007770 007070 770070 +47 11c aa 007770 007007 070707 +00 11d 25 707770 007070 700700 +47 11d c2 707770 007007 000077 +00 11e 9d 077770 007070 777007 +47 11e 7a 077770 007007 077770 +00 11f f5 777770 007070 707777 +47 11f 12 777770 007007 007000 +*/ + +#include "../bluetooth_packet_tx.h" +#include + +int test_gen_packet_header() { + char *optr; + int i, j, ret, err; + ret = 0; + + printf("Testing header\n"); + printf("---------------\n"); + + /* lt_addr, type, flow, arqn, seqn, UAP, HEC */ + uint8_t data[20][7] = { + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {} + UAP Data HE + ----------- + 00 123 e1 + 47 123 06 + 00 124 32 + 47 124 d5 + 00 125 5a + 47 125 bd + 00 126 e2 + 47 126 05 + 00 127 8a + 47 127 6d + 00 11b 9e + 47 11b 79 + 00 11c 4d + 47 11c aa + 00 11d 25 + 47 11d c2 + 00 11e 9d + 47 11e 7a + 00 11f f5 + 47 11f 12 + + }; + + for(i = 0; i < 20; i++) { + gen_packet_header(uint8_t lt_addr, uint8_t type, uint8_t flow, uint8_t arqn, uint8_t seqn) + if (uap == 1) { + printf("E"); + ret++; + } + else + printf("."); + } + + if (ret > 0) + printf("%d errors\n", ret); + printf("\n--------------------\n"); + printf("Done testing unfec23\n"); + return ret; +} + +int main(int argc, char** argv) { + int ret = 0; + + ret += test_unfec23(); + + exit(ret); +} diff -Nru libbtbb-2014.11.26+gitf83b85c/.travis.yml libbtbb-2015.09.R2/.travis.yml --- libbtbb-2014.11.26+gitf83b85c/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ libbtbb-2015.09.R2/.travis.yml 2015-09-05 07:46:31.000000000 +0000 @@ -0,0 +1,21 @@ +language: c + +cache: apt + +sudo: false + +addons: + apt: + packages: + - libpcap-dev + +compiler: + - clang + - gcc + +before_script: + - mkdir build + - cd build + - CFLAGS="-g -Wall -Wextra -Werror -Wno-zero-length-array" cmake .. + +script: make diff -Nru libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/Makefile.am libbtbb-2015.09.R2/wireshark/plugins/btbb/Makefile.am --- libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/Makefile.am 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/wireshark/plugins/btbb/Makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ -# Makefile.am -# Automake file for AgentX plugin -# -# $Id: Makefile.am 24488 2008-02-27 16:18:30Z stig $ -# -# Wireshark - Network traffic analyzer -# By Gerald Combs -# Copyright 1998 Gerald Combs -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -INCLUDES = -I$(top_srcdir) -I$(includedir) - -include Makefile.common - -#if HAVE_WARNINGS_AS_ERRORS -#AM_CFLAGS = -Werror -#endif - -plugindir = @plugindir@ - -plugin_LTLIBRARIES = btbb.la -btbb_la_SOURCES = \ - plugin.c \ - moduleinfo.h \ - $(DISSECTOR_SRC) \ - $(DISSECTOR_SUPPORT_SRC) \ - $(DISSECTOR_INCLUDES) -btbb_la_LDFLAGS = -module -avoid-version -btbb_la_LIBADD = @PLUGIN_LIBS@ - -# Libs must be cleared, or else libtool won't create a shared module. -# If your module needs to be linked against any particular libraries, -# add them here. -LIBS = - -# -# Build plugin.c, which contains the plugin version[] string, a -# function plugin_register() that calls the register routines for all -# protocols, and a function plugin_reg_handoff() that calls the handoff -# registration routines for all protocols. -# -# We do this by scanning sources. If that turns out to be too slow, -# maybe we could just require every .o file to have an register routine -# of a given name (packet-aarp.o -> proto_register_aarp, etc.). -# -# Formatting conventions: The name of the proto_register_* routines an -# proto_reg_handoff_* routines must start in column zero, or must be -# preceded only by "void " starting in column zero, and must not be -# inside #if. -# -# DISSECTOR_SRC is assumed to have all the files that need to be scanned. -# -# For some unknown reason, having a big "for" loop in the Makefile -# to scan all the files doesn't work with some "make"s; they seem to -# pass only the first few names in the list to the shell, for some -# reason. -# -# Therefore, we have a script to generate the plugin.c file. -# The shell script runs slowly, as multiple greps and seds are run -# for each input file; this is especially slow on Windows. Therefore, -# if Python is present (as indicated by PYTHON being defined), we run -# a faster Python script to do that work instead. -# -# The first argument is the directory in which the source files live. -# The second argument is "plugin", to indicate that we should build -# a plugin.c file for a plugin. -# All subsequent arguments are the files to scan. -# -plugin.c: $(DISSECTOR_SRC) $(top_srcdir)/tools/make-dissector-reg \ - $(top_srcdir)/tools/make-dissector-reg.py - @if test -n "$(PYTHON)"; then \ - echo Making plugin.c with python ; \ - $(PYTHON) $(top_srcdir)/tools/make-dissector-reg.py $(srcdir) \ - plugin $(DISSECTOR_SRC) ; \ - else \ - echo Making plugin.c with shell script ; \ - $(top_srcdir)/tools/make-dissector-reg $(srcdir) \ - $(plugin_src) plugin $(DISSECTOR_SRC) ; \ - fi - -# -# Currently plugin.c can be included in the distribution because -# we always build all protocol dissectors. We used to have to check -# whether or not to build the snmp dissector. If we again need to -# variably build something, making plugin.c non-portable, uncomment -# the dist-hook line below. -# -# Oh, yuk. We don't want to include "plugin.c" in the distribution, as -# its contents depend on the configuration, and therefore we want it -# to be built when the first "make" is done; however, Automake insists -# on putting *all* source into the distribution. -# -# We work around this by having a "dist-hook" rule that deletes -# "plugin.c", so that "dist" won't pick it up. -# -#dist-hook: -# @rm -f $(distdir)/plugin.c - -CLEANFILES = \ - btbb \ - *~ - -MAINTAINERCLEANFILES = \ - Makefile.in \ - plugin.c - -EXTRA_DIST = \ - Makefile.common \ - Makefile.nmake \ - moduleinfo.nmake \ - plugin.rc.in diff -Nru libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/Makefile.common libbtbb-2015.09.R2/wireshark/plugins/btbb/Makefile.common --- libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/Makefile.common 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/wireshark/plugins/btbb/Makefile.common 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -# Makefile.common for AgentX plugin -# Contains the stuff from Makefile.am and Makefile.nmake that is -# a) common to both files and -# b) portable between both files -# -# $Id: Makefile.common 23848 2007-12-12 22:10:50Z jake $ -# -# Wireshark - Network traffic analyzer -# By Gerald Combs -# Copyright 1998 Gerald Combs -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -# the name of the plugin -PLUGIN_NAME = btbb - -# the dissector sources (without any helpers) -DISSECTOR_SRC = \ - packet-btbb.c \ - packet-btlmp.c - -# corresponding headers -DISSECTOR_INCLUDES = - -# Dissector helpers. They're included in the source files in this -# directory, but they're not dissectors themselves, i.e. they're not -# used to generate "plugin.c". -DISSECTOR_SUPPORT_SRC = diff -Nru libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/Makefile.nmake libbtbb-2015.09.R2/wireshark/plugins/btbb/Makefile.nmake --- libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/Makefile.nmake 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/wireshark/plugins/btbb/Makefile.nmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -# Makefile.nmake -# nmake file for Wireshark plugin -# -# $Id: Makefile.nmake 24520 2008-03-01 12:31:01Z jake $ -# - -include ..\..\config.nmake -include moduleinfo.nmake - -include Makefile.common - -CFLAGS=/WX /DHAVE_CONFIG_H /I../.. /I../../wiretap $(GLIB_CFLAGS) \ - /I$(PCAP_DIR)\include -D_U_="" $(LOCAL_CFLAGS) - -.c.obj:: - $(CC) $(CFLAGS) -Fd.\ -c $< - -LDFLAGS = $(PLUGIN_LDFLAGS) - -!IFDEF ENABLE_LIBWIRESHARK -LINK_PLUGIN_WITH=..\..\epan\libwireshark.lib -CFLAGS=/DHAVE_WIN32_LIBWIRESHARK_LIB /D_NEED_VAR_IMPORT_ $(CFLAGS) - -DISSECTOR_OBJECTS = $(DISSECTOR_SRC:.c=.obj) - -DISSECTOR_SUPPORT_OBJECTS = $(DISSECTOR_SUPPORT_SRC:.c=.obj) - -OBJECTS = $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS) plugin.obj - -RESOURCE=$(PLUGIN_NAME).res - -all: $(PLUGIN_NAME).dll - -$(PLUGIN_NAME).rc : moduleinfo.nmake - sed -e s/@PLUGIN_NAME@/$(PLUGIN_NAME)/ \ - -e s/@RC_MODULE_VERSION@/$(RC_MODULE_VERSION)/ \ - -e s/@RC_VERSION@/$(RC_VERSION)/ \ - -e s/@MODULE_VERSION@/$(MODULE_VERSION)/ \ - -e s/@PACKAGE@/$(PACKAGE)/ \ - -e s/@VERSION@/$(VERSION)/ \ - -e s/@MSVC_VARIANT@/$(MSVC_VARIANT)/ \ - < plugin.rc.in > $@ - -$(PLUGIN_NAME).dll $(PLUGIN_NAME).exp $(PLUGIN_NAME).lib : $(OBJECTS) $(LINK_PLUGIN_WITH) $(RESOURCE) - link -dll /out:$(PLUGIN_NAME).dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \ - $(GLIB_LIBS) $(RESOURCE) - -# -# Build plugin.c, which contains the plugin version[] string, a -# function plugin_register() that calls the register routines for all -# protocols, and a function plugin_reg_handoff() that calls the handoff -# registration routines for all protocols. -# -# We do this by scanning sources. If that turns out to be too slow, -# maybe we could just require every .o file to have an register routine -# of a given name (packet-aarp.o -> proto_register_aarp, etc.). -# -# Formatting conventions: The name of the proto_register_* routines an -# proto_reg_handoff_* routines must start in column zero, or must be -# preceded only by "void " starting in column zero, and must not be -# inside #if. -# -# DISSECTOR_SRC is assumed to have all the files that need to be scanned. -# -# For some unknown reason, having a big "for" loop in the Makefile -# to scan all the files doesn't work with some "make"s; they seem to -# pass only the first few names in the list to the shell, for some -# reason. -# -# Therefore, we have a script to generate the plugin.c file. -# The shell script runs slowly, as multiple greps and seds are run -# for each input file; this is especially slow on Windows. Therefore, -# if Python is present (as indicated by PYTHON being defined), we run -# a faster Python script to do that work instead. -# -# The first argument is the directory in which the source files live. -# The second argument is "plugin", to indicate that we should build -# a plugin.c file for a plugin. -# All subsequent arguments are the files to scan. -# -!IFDEF PYTHON -plugin.c: $(DISSECTOR_SRC) moduleinfo.h ../../tools/make-dissector-reg.py - @echo Making plugin.c (using python) - @$(PYTHON) "../../tools/make-dissector-reg.py" . plugin $(DISSECTOR_SRC) -!ELSE -plugin.c: $(DISSECTOR_SRC) moduleinfo.h ../../tools/make-dissector-reg - @echo Making plugin.c (using sh) - @$(SH) ../../tools/make-dissector-reg . plugin $(DISSECTOR_SRC) -!ENDIF - -!ENDIF - -clean: - rm -f $(OBJECTS) $(RESOURCE) plugin.c *.pdb \ - $(PLUGIN_NAME).dll $(PLUGIN_NAME).dll.manifest $(PLUGIN_NAME).lib \ - $(PLUGIN_NAME).exp $(PLUGIN_NAME).rc - -distclean: clean - -maintainer-clean: distclean diff -Nru libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/moduleinfo.nmake libbtbb-2015.09.R2/wireshark/plugins/btbb/moduleinfo.nmake --- libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/moduleinfo.nmake 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/wireshark/plugins/btbb/moduleinfo.nmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -# -# $Id: moduleinfo.nmake 20155 2006-12-19 22:22:34Z jake $ -# - -# The name -PACKAGE=btbb - -# The version -MODULE_VERSION_MAJOR=0 -MODULE_VERSION_MINOR=0 -MODULE_VERSION_MICRO=0 -MODULE_VERSION_EXTRA=1 - -# -# The RC_VERSION should be comma-separated, not dot-separated, -# as per Graham Bloice's message in -# -# http://www.ethereal.com/lists/ethereal-dev/200303/msg00283.html -# -# "The RC_VERSION variable in config.nmake should be comma separated. -# This allows the resources to be built correctly and the version -# number to be correctly displayed in the explorer properties dialog -# for the executables, and XP's tooltip, rather than 0.0.0.0." -# - -MODULE_VERSION=$(MODULE_VERSION_MAJOR).$(MODULE_VERSION_MINOR).$(MODULE_VERSION_MICRO).$(MODULE_VERSION_EXTRA) -RC_MODULE_VERSION=$(MODULE_VERSION_MAJOR),$(MODULE_VERSION_MINOR),$(MODULE_VERSION_MICRO),$(MODULE_VERSION_EXTRA) - diff -Nru libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/README libbtbb-2015.09.R2/wireshark/plugins/btbb/README --- libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/README 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/wireshark/plugins/btbb/README 2015-09-05 07:46:31.000000000 +0000 @@ -6,21 +6,12 @@ To build this on Debian/Ubuntu/BackTrack linux distributions: sudo apt-get install wireshark-dev wireshark cd libbtbb/wireshark/plugins/btbb/ - cmake . + mkdir build + cd build + cmake .. make make install This will install to the .wireshark/ in your home directory. To override this set the DESTDIR environment variable when running cmake. -To build the plugin as part of wireshark, use the following commands: - tar xf wireshark-1.8.2.tar.bz2 - cp -R libbtbb/wireshark/plugins/btbb wireshark-1.8.2/plugins/ - patch -p0 < wireshark-1.8.2/plugins/btbb/wireshark-1.8-btbb.patch - - cd wireshark-1.8.2 - ./autogen.sh - ./configure - make - sudo make install - diff -Nru libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/wireshark-1.8-btbb.patch libbtbb-2015.09.R2/wireshark/plugins/btbb/wireshark-1.8-btbb.patch --- libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbb/wireshark-1.8-btbb.patch 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/wireshark/plugins/btbb/wireshark-1.8-btbb.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -diff -urN wireshark-1.8.2.orig//CMakeLists.txt wireshark-1.8.2/CMakeLists.txt ---- wireshark-1.8.2.orig//CMakeLists.txt 2012-06-06 00:33:43.000000000 +0800 -+++ wireshark-1.8.2/CMakeLists.txt 2012-06-25 21:48:57.997186003 +0800 -@@ -409,6 +409,7 @@ - set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}") - set(PLUGIN_SRC_DIRS - plugins/asn1 -+ plugins/btbb - plugins/docsis - plugins/ethercat - plugins/gryphon -diff -urN wireshark-1.8.2.orig//Makefile.am wireshark-1.8.2/Makefile.am ---- wireshark-1.8.2.orig//Makefile.am 2012-06-20 01:47:22.000000000 +0800 -+++ wireshark-1.8.2/Makefile.am 2012-06-25 21:50:00.721186002 +0800 -@@ -273,6 +273,7 @@ - -include plugins/Custom.make - plugin_ldadd = $(_CUSTOM_plugin_ldadd_) \ - -dlopen plugins/asn1/asn1.la \ -+ -dlopen plugins/btbb/btbb.la \ - -dlopen plugins/docsis/docsis.la \ - -dlopen plugins/ethercat/ethercat.la \ - -dlopen plugins/gryphon/gryphon.la \ -diff -urN wireshark-1.8.2.orig//configure.in wireshark-1.8.2/configure.in ---- wireshark-1.8.2.orig//configure.in 2012-06-22 02:21:10.000000000 +0800 -+++ wireshark-1.8.2/configure.in 2012-06-25 21:51:10.925186002 +0800 -@@ -2096,6 +2096,7 @@ - packaging/svr4/pkginfo - plugins/Makefile - plugins/asn1/Makefile -+ plugins/btbb/Makefile - plugins/docsis/Makefile - plugins/ethercat/Makefile - plugins/gryphon/Makefile -diff -urN wireshark-1.8.2.orig//epan/Makefile.am wireshark-1.8.2/epan/Makefile.am ---- wireshark-1.8.2.orig//epan/Makefile.am 2012-06-09 08:46:54.000000000 +0800 -+++ wireshark-1.8.2/epan/Makefile.am 2012-06-25 21:51:55.394186002 +0800 -@@ -209,6 +209,8 @@ - -include ../plugins/Custom.make - plugin_src = \ - ../plugins/asn1/packet-asn1.c \ -+ ../plugins/btbb/packet-btbb.c \ -+ ../plugins/btbb/packet-btlmp.c \ - ../plugins/docsis/packet-bintrngreq.c \ - ../plugins/docsis/packet-bpkmattr.c \ - ../plugins/docsis/packet-bpkmreq.c \ -diff -urN wireshark-1.8.2.orig//packaging/nsis/Makefile.nmake wireshark-1.8.2/packaging/nsis/Makefile.nmake ---- wireshark-1.8.2.orig//packaging/nsis/Makefile.nmake 2012-06-20 01:47:22.000000000 +0800 -+++ wireshark-1.8.2/packaging/nsis/Makefile.nmake 2012-06-25 21:52:34.248186002 +0800 -@@ -46,6 +46,7 @@ - - PLUGINS= \ - ../../plugins/asn1/asn1.dll \ -+ ../../plugins/btbb/btbb.dll \ - ../../plugins/docsis/docsis.dll \ - ../../plugins/ethercat/ethercat.dll \ - ../../plugins/gryphon/gryphon.dll \ -diff -urN wireshark-1.8.2.orig//packaging/nsis/wireshark.nsi wireshark-1.8.2/packaging/nsis/wireshark.nsi ---- wireshark-1.8.2.orig//packaging/nsis/wireshark.nsi 2012-06-20 01:47:22.000000000 +0800 -+++ wireshark-1.8.2/packaging/nsis/wireshark.nsi 2012-06-25 21:54:50.288185993 +0800 -@@ -806,6 +806,7 @@ - ;------------------------------------------- - SetOutPath '$INSTDIR\plugins\${VERSION}' - File "${STAGING_DIR}\plugins\${VERSION}\asn1.dll" -+File "${STAGING_DIR}\plugins\${VERSION}\btbb.dll" - File "${STAGING_DIR}\plugins\${VERSION}\docsis.dll" - File "${STAGING_DIR}\plugins\${VERSION}\ethercat.dll" - File "${STAGING_DIR}\plugins\${VERSION}\gryphon.dll" -diff -urN wireshark-1.8.2.orig//plugins/Makefile.am wireshark-1.8.2/plugins/Makefile.am ---- wireshark-1.8.2.orig//plugins/Makefile.am 2012-06-06 00:33:17.000000000 +0800 -+++ wireshark-1.8.2/plugins/Makefile.am 2012-06-25 21:55:15.766186001 +0800 -@@ -24,6 +24,7 @@ - -include Custom.make - SUBDIRS = $(_CUSTOM_SUBDIRS_) \ - asn1 \ -+ btbb \ - docsis \ - ethercat \ - gryphon \ -diff -urN wireshark-1.8.2.orig//plugins/Makefile.nmake wireshark-1.8.2/plugins/Makefile.nmake ---- wireshark-1.8.2.orig//plugins/Makefile.nmake 2012-06-06 00:33:17.000000000 +0800 -+++ wireshark-1.8.2/plugins/Makefile.nmake 2012-06-25 21:55:32.469186000 +0800 -@@ -8,6 +8,7 @@ - - PLUGIN_LIST = \ - asn1 \ -+ btbb \ - docsis \ - ethercat \ - gryphon \ Binary files /tmp/F1hvn_Rssr/libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbredr/btbredr_test.pcap and /tmp/cxpdx5VAbB/libbtbb-2015.09.R2/wireshark/plugins/btbredr/btbredr_test.pcap differ diff -Nru libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbredr/packet-btbredr.c libbtbb-2015.09.R2/wireshark/plugins/btbredr/packet-btbredr.c --- libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbredr/packet-btbredr.c 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/wireshark/plugins/btbredr/packet-btbredr.c 2015-09-05 07:46:31.000000000 +0000 @@ -31,6 +31,8 @@ #include #include +#include + /* function prototypes */ void proto_reg_handoff_btbredr(void); @@ -188,14 +190,17 @@ } void -dissect_fhs(proto_tree *tree, tvbuff_t *tvb, int offset) +dissect_fhs(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { proto_item *fhs_item, *psmode_item; proto_tree *fhs_tree; const gchar *description; guint8 psmode; - DISSECTOR_ASSERT(tvb_length_remaining(tvb, offset) == 20); + if(tvb_length_remaining(tvb, offset) != 20) { + col_add_str(pinfo->cinfo, COL_INFO, "Encrypted or malformed payload data"); + return; + } fhs_item = proto_tree_add_item(tree, hf_btbredr_payload, tvb, offset, -1, ENC_NA); fhs_tree = proto_item_add_subtree(fhs_item, ett_btbredr_payload); @@ -255,7 +260,10 @@ */ guint16 fake_acl_data; - DISSECTOR_ASSERT(tvb_length_remaining(tvb, offset) >= 3); + if(tvb_length_remaining(tvb, offset) < 3) { + col_add_str(pinfo->cinfo, COL_INFO, "Encrypted or malformed payload data"); + return; + } dm1_item = proto_tree_add_item(tree, hf_btbredr_payload, tvb, offset, -1, ENC_NA); dm1_tree = proto_item_add_subtree(dm1_item, ett_btbredr_payload); @@ -264,8 +272,11 @@ llid = tvb_get_guint8(tvb, offset) & 0x3; offset += 1; - DISSECTOR_ASSERT(tvb_length_remaining(tvb, offset) == len + 2); - + if(tvb_length_remaining(tvb, offset) < len + 2) { + col_add_str(pinfo->cinfo, COL_INFO, "Encrypted or malformed payload data"); + return; + } + if (llid == 3 && btlmp_handle) { /* LMP */ pld_tvb = tvb_new_subset(tvb, offset, len, len); @@ -315,7 +326,7 @@ if (tvb_length(tvb) == 0) { info = "ID"; } else { - type = (tvb_get_guint8(tvb, 6) >> 3) & 0x0f; + type = (tvb_get_guint8(tvb, 16) >> 3) & 0x0f; info = val_to_str(type, packet_types, "Unknown type: 0x%x"); } @@ -383,7 +394,7 @@ case 0x1: /* POLL */ break; case 0x2: /* FHS */ - dissect_fhs(btbredr_tree, tvb, offset); + dissect_fhs(btbredr_tree, tvb, pinfo, offset); break; case 0x3: /* DM1 */ dissect_dm1(btbredr_tree, tvb, pinfo, offset); diff -Nru libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbredr/README libbtbb-2015.09.R2/wireshark/plugins/btbredr/README --- libbtbb-2014.11.26+gitf83b85c/wireshark/plugins/btbredr/README 2014-12-07 23:54:32.000000000 +0000 +++ libbtbb-2015.09.R2/wireshark/plugins/btbredr/README 2015-09-05 07:46:31.000000000 +0000 @@ -6,7 +6,9 @@ To build this on Debian/Ubuntu/BackTrack linux distributions: sudo apt-get install wireshark-dev wireshark cd libbtbb/wireshark/plugins/btbredr/ - cmake . + mkdir build + cd build + cmake .. make make install