allow to specify max nr of packets in hci_dump log

This commit is contained in:
matthias.ringwald 2010-12-05 22:22:46 +00:00
parent 32e5266308
commit 2992c13168
4 changed files with 25 additions and 6 deletions

View File

@ -3,17 +3,18 @@
2009-11-08: Release 0.1 2009-11-08: Release 0.1
2010-06-20: Release 0.2 - SDP + iOS 4 support 2010-06-20: Release 0.2 - SDP + iOS 4 support
2010-11-2x: Release 0.2 - revsion 973 for WeBe++ 2010-11-2x: Release 0.2 - revsion 973 for WeBe++
- fix regression bug in 0.2-899 that prevented disabling of Apple Bluetooth stack, less crashes - Fix for regression bug in 0.2-899 that prevented automatic disabling of Apple Bluetooth stack, less crashes
- Startup: send kill signal to BlueTool and BTServer, if necessary - Startup: send kill signal to BlueTool and BTServer, if necessary
- Connection establishment: don't close baseband during authentication, - Connection setup: don't close baseband during authentication
- Remote Device DB: automatic link key handling in BTdaemon, provide cached remote names during inquiry - Remote Device DB: automatic link key handling in BTdaemon, provide cached remote names during inquiry
- SDP: use 1000 bytes MTU, fix partial responses, fix an incompatibility with Windows native statck - SDP: use 1000 bytes MTU, fix partial responses, fix an incompatibility with Windows native statck
- Cocoa run_loop: added timeouts, include in libBTstack.dylib build - Cocoa run_loop: added timeouts, include in libBTstack.dylib build
2010-xxxx: Release 0.2 - revions xxx
- limit size of /tmp/hci_dump.pklg to 1000 packets (max 1 MB)
NEXT: NEXT:
- figure out how to receive iPhone System Power IONotifications (in BTdaemon) to detect, when phone gets locked - figure out how to receive iPhone System Power IONotifications (in BTdaemon) to detect, when phone gets locked
- limit size of /tmp/hci_dump.pklg
- e.g. rm hci_dump.old.pklg, mv hci_dump.pkg->hci_dump.old.pklg
- have a look at External Accessory interface by Apple - it's quite similar - have a look at External Accessory interface by Apple - it's quite similar
- move RFCOMM code into BTdaemon - move RFCOMM code into BTdaemon
- HCI CMD packet is limited to 1024 bytes payload. SDP records could be larger than that. Options: - HCI CMD packet is limited to 1024 bytes payload. SDP records could be larger than that. Options:

View File

@ -366,6 +366,7 @@ int main (int argc, char * const * argv){
// use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT // use logger: format HCI_DUMP_PACKETLOGGER, HCI_DUMP_BLUEZ or HCI_DUMP_STDOUT
hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER); hci_dump_open("/tmp/hci_dump.pklg", HCI_DUMP_PACKETLOGGER);
hci_dump_set_max_packets(1000);
// hci_dump_open(NULL, HCI_DUMP_STDOUT); // hci_dump_open(NULL, HCI_DUMP_STDOUT);
// init HCI // init HCI

View File

@ -80,6 +80,8 @@ static int dump_format;
static hcidump_hdr header_bluez; static hcidump_hdr header_bluez;
static pktlog_hdr header_packetlogger; static pktlog_hdr header_packetlogger;
static char time_string[40]; static char time_string[40];
static int max_nr_packets = -1;
static int nr_packets = 0;
#endif #endif
void hci_dump_open(char *filename, hci_dump_format_t format){ void hci_dump_open(char *filename, hci_dump_format_t format){
@ -88,16 +90,30 @@ void hci_dump_open(char *filename, hci_dump_format_t format){
if (dump_format == HCI_DUMP_STDOUT) { if (dump_format == HCI_DUMP_STDOUT) {
dump_file = fileno(stdout); dump_file = fileno(stdout);
} else { } else {
dump_file = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); dump_file = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
} }
#endif #endif
} }
void hci_dump_set_max_packets(int packets){
max_nr_packets = packets;
}
void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len) { void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len) {
#ifndef EMBEDDED #ifndef EMBEDDED
if (dump_file < 0) return; // not activated yet if (dump_file < 0) return; // not activated yet
// don't grow bigger than max_nr_packets
if (dump_format != HCI_DUMP_STDOUT && max_nr_packets > 0){
if (nr_packets >= max_nr_packets){
lseek(dump_file, 0, SEEK_SET);
ftruncate(dump_file, 0);
nr_packets = 0;
}
nr_packets++;
}
// get time // get time
struct timeval curr_time; struct timeval curr_time;
struct tm* ptm; struct tm* ptm;

View File

@ -46,5 +46,6 @@ typedef enum {
} hci_dump_format_t; } hci_dump_format_t;
void hci_dump_open(char *filename, hci_dump_format_t format); void hci_dump_open(char *filename, hci_dump_format_t format);
void hci_dump_set_max_packets(int packets); // -1 for unlimited
void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len); void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len);
void hci_dump_close(); void hci_dump_close();