Loading system/btif/include/btif_debug_btsnoop.h +2 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ #include <stdint.h> #define BTSNOOZ_CURRENT_VERSION 0x01 #define BTSNOOZ_CURRENT_VERSION 0x02 // The preamble is stored un-encrypted as the first part // of the file. Loading @@ -32,6 +32,7 @@ typedef struct btsnooz_preamble_t { // One header for each HCI packet typedef struct btsnooz_header_t { uint16_t length; uint16_t packet_length; uint32_t delta_time_ms; uint8_t type; } __attribute__((__packed__)) btsnooz_header_t; Loading system/btif/src/btif_debug_btsnoop.c +23 −3 Original line number Diff line number Diff line Loading @@ -45,9 +45,28 @@ static uint64_t last_timestamp_ms = 0; static void btsnoop_cb(const uint16_t type, const uint8_t *data, const size_t length) { btsnooz_header_t header; // Only log packet content for HCI commands and events (privacy). size_t included_length = 0; switch (type) { case BT_EVT_TO_LM_HCI_CMD: included_length = length; break; case BT_EVT_TO_BTU_HCI_EVT: included_length = length; break; case BT_EVT_TO_LM_HCI_ACL: case BT_EVT_TO_BTU_HCI_ACL: included_length = 4; break; case BT_EVT_TO_LM_HCI_SCO: case BT_EVT_TO_BTU_HCI_SCO: included_length = 2; break; } // Make room in the ring buffer while (ringbuffer_available(buffer) < (length + sizeof(btsnooz_header_t))) { while (ringbuffer_available(buffer) < (included_length + sizeof(btsnooz_header_t))) { ringbuffer_pop(buffer, (uint8_t *)&header, sizeof(btsnooz_header_t)); ringbuffer_delete(buffer, header.length - 1); } Loading @@ -57,12 +76,13 @@ static void btsnoop_cb(const uint16_t type, const uint8_t *data, const size_t le const uint64_t now = btif_debug_ts(); header.type = REDUCE_HCI_TYPE_TO_SIGNIFICANT_BITS(type); header.length = length; header.length = included_length + 1; // +1 for type byte header.packet_length = length + 1; // +1 for type byte. header.delta_time_ms = last_timestamp_ms ? now - last_timestamp_ms : 0; last_timestamp_ms = now; ringbuffer_insert(buffer, (uint8_t *)&header, sizeof(btsnooz_header_t)); ringbuffer_insert(buffer, data, length - 1); ringbuffer_insert(buffer, data, included_length); } static bool btsnoop_compress(ringbuffer_t *rb_dst, ringbuffer_t *rb_src) { Loading system/hci/src/btsnoop_mem.c +9 −4 Original line number Diff line number Diff line Loading @@ -40,19 +40,24 @@ void btsnoop_mem_capture(const BT_HDR *packet) { switch (type) { case BT_EVT_TO_LM_HCI_CMD: if (packet->len > 2) length = data[2] + 4; length = data[2] + 3; break; case BT_EVT_TO_BTU_HCI_EVT: if (packet->len > 1) length = data[1] + 3; length = data[1] + 2; break; // Ignore data for privacy case BT_EVT_TO_LM_HCI_ACL: case BT_EVT_TO_LM_HCI_SCO: case BT_EVT_TO_BTU_HCI_ACL: if (packet->len > 3) length = (data[2] | (data[3] << 8)) + 4; break; case BT_EVT_TO_LM_HCI_SCO: case BT_EVT_TO_BTU_HCI_SCO: if (packet->len > 2) length = data[2] + 3; break; } Loading Loading
system/btif/include/btif_debug_btsnoop.h +2 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ #include <stdint.h> #define BTSNOOZ_CURRENT_VERSION 0x01 #define BTSNOOZ_CURRENT_VERSION 0x02 // The preamble is stored un-encrypted as the first part // of the file. Loading @@ -32,6 +32,7 @@ typedef struct btsnooz_preamble_t { // One header for each HCI packet typedef struct btsnooz_header_t { uint16_t length; uint16_t packet_length; uint32_t delta_time_ms; uint8_t type; } __attribute__((__packed__)) btsnooz_header_t; Loading
system/btif/src/btif_debug_btsnoop.c +23 −3 Original line number Diff line number Diff line Loading @@ -45,9 +45,28 @@ static uint64_t last_timestamp_ms = 0; static void btsnoop_cb(const uint16_t type, const uint8_t *data, const size_t length) { btsnooz_header_t header; // Only log packet content for HCI commands and events (privacy). size_t included_length = 0; switch (type) { case BT_EVT_TO_LM_HCI_CMD: included_length = length; break; case BT_EVT_TO_BTU_HCI_EVT: included_length = length; break; case BT_EVT_TO_LM_HCI_ACL: case BT_EVT_TO_BTU_HCI_ACL: included_length = 4; break; case BT_EVT_TO_LM_HCI_SCO: case BT_EVT_TO_BTU_HCI_SCO: included_length = 2; break; } // Make room in the ring buffer while (ringbuffer_available(buffer) < (length + sizeof(btsnooz_header_t))) { while (ringbuffer_available(buffer) < (included_length + sizeof(btsnooz_header_t))) { ringbuffer_pop(buffer, (uint8_t *)&header, sizeof(btsnooz_header_t)); ringbuffer_delete(buffer, header.length - 1); } Loading @@ -57,12 +76,13 @@ static void btsnoop_cb(const uint16_t type, const uint8_t *data, const size_t le const uint64_t now = btif_debug_ts(); header.type = REDUCE_HCI_TYPE_TO_SIGNIFICANT_BITS(type); header.length = length; header.length = included_length + 1; // +1 for type byte header.packet_length = length + 1; // +1 for type byte. header.delta_time_ms = last_timestamp_ms ? now - last_timestamp_ms : 0; last_timestamp_ms = now; ringbuffer_insert(buffer, (uint8_t *)&header, sizeof(btsnooz_header_t)); ringbuffer_insert(buffer, data, length - 1); ringbuffer_insert(buffer, data, included_length); } static bool btsnoop_compress(ringbuffer_t *rb_dst, ringbuffer_t *rb_src) { Loading
system/hci/src/btsnoop_mem.c +9 −4 Original line number Diff line number Diff line Loading @@ -40,19 +40,24 @@ void btsnoop_mem_capture(const BT_HDR *packet) { switch (type) { case BT_EVT_TO_LM_HCI_CMD: if (packet->len > 2) length = data[2] + 4; length = data[2] + 3; break; case BT_EVT_TO_BTU_HCI_EVT: if (packet->len > 1) length = data[1] + 3; length = data[1] + 2; break; // Ignore data for privacy case BT_EVT_TO_LM_HCI_ACL: case BT_EVT_TO_LM_HCI_SCO: case BT_EVT_TO_BTU_HCI_ACL: if (packet->len > 3) length = (data[2] | (data[3] << 8)) + 4; break; case BT_EVT_TO_LM_HCI_SCO: case BT_EVT_TO_BTU_HCI_SCO: if (packet->len > 2) length = data[2] + 3; break; } Loading