From 7163013a596c66424fb78ac0bc6827dc9fd3f059 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 29 Feb 2004 01:14:47 +0000 Subject: [PATCH] hcidump: Add support for dynamic PSM's --- tools/hcidump.c | 128 +++++++++++++++++++++++++----------------------- 1 file changed, 68 insertions(+), 60 deletions(-) diff --git a/tools/hcidump.c b/tools/hcidump.c index fdb0b9a84..45522920a 100644 --- a/tools/hcidump.c +++ b/tools/hcidump.c @@ -45,8 +45,9 @@ #include #include -#include "parser.h" #include "hcidump.h" +#include "parser.h" +#include "sdp.h" /* Default options */ static int device; @@ -73,14 +74,15 @@ static void process_frames(int dev, int sock, int file) perror("Can't allocate data buffer"); exit(1); } + dh = (void *) buf; frm.data = buf + DUMP_HDR_SIZE; - + if (!(ctrl = malloc(100))) { perror("Can't allocate control buffer"); exit(1); } - + printf("device: hci%d snap_len: %d filter: 0x%lx\n", dev, snap_len, filter); @@ -120,7 +122,7 @@ static void process_frames(int dev, int sock, int file) switch (mode) { case WRITE: - /* Save dump */ + /* Save dump */ dh->len = htobs(frm.data_len); dh->in = frm.in; dh->ts_sec = htobl(frm.ts.tv_sec); @@ -149,12 +151,12 @@ static void read_dump(int file) perror("Can't allocate data buffer"); exit(1); } - + while (1) { if ((err = read_n(file, (void *) &dh, DUMP_HDR_SIZE)) < 0) goto failed; if (!err) return; - + frm.data_len = btohs(dh.len); if ((err = read_n(file, frm.data, frm.data_len)) < 0) @@ -166,7 +168,7 @@ static void read_dump(int file) frm.in = dh.in; frm.ts.tv_sec = btohl(dh.ts_sec); frm.ts.tv_usec = btohl(dh.ts_usec); - + parse(&frm); } @@ -202,7 +204,7 @@ static int open_socket(int dev) perror("Can't create HCI socket"); exit(1); } - + opt = 1; if (setsockopt(s, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) { perror("Can't enable data direction info"); @@ -239,23 +241,23 @@ static struct { char *name; int flag; } filters[] = { - { "hci", FILT_HCI }, - { "l2cap", FILT_L2CAP }, - { "sco", FILT_SCO }, - { "rfcomm", FILT_RFCOMM }, - { "sdp", FILT_SDP }, - { "bnep", FILT_BNEP }, - { "cmtp", FILT_CMTP }, - { "hidp", FILT_HIDP }, + { "hci", FILT_HCI }, + { "sco", FILT_SCO }, + { "l2cap", FILT_L2CAP }, + { "rfcomm", FILT_RFCOMM }, + { "sdp", FILT_SDP }, + { "bnep", FILT_BNEP }, + { "cmtp", FILT_CMTP }, + { "hidp", FILT_HIDP }, { 0 } }; static void parse_filter(int argc, char **argv) { int i,n; - - for (i=0; i 0) parse_filter(argc, argv); @@ -376,5 +383,6 @@ int main(int argc, char *argv[]) read_dump(open_file(dump_file, mode)); break; } + return 0; } -- 2.47.3