diff options
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | parser/Makefile.am | 3 | ||||
-rw-r--r-- | parser/avdtp.c | 113 | ||||
-rw-r--r-- | parser/l2cap.c | 7 | ||||
-rw-r--r-- | parser/parser.h | 2 | ||||
-rw-r--r-- | src/hcidump.8 | 3 | ||||
-rw-r--r-- | src/hcidump.c | 1 |
7 files changed, 128 insertions, 2 deletions
@@ -16,3 +16,4 @@ Marcel Holtmann <marcel@holtmann.org> HIDP parser. HCRP parser. CAPI parser. + AVDTP parser. diff --git a/parser/Makefile.am b/parser/Makefile.am index bb6d89a..b7462f9 100644 --- a/parser/Makefile.am +++ b/parser/Makefile.am @@ -7,4 +7,5 @@ noinst_LIBRARIES = libparser.a libparser_a_SOURCES = \ parser.c parser.h hci.c l2cap.c \ rfcomm.c rfcomm.h sdp.c sdp.h \ - bnep.c cmtp.c hidp.c hcrp.c capi.c + bnep.c cmtp.c hidp.c hcrp.c avdtp.c \ + capi.c diff --git a/parser/avdtp.c b/parser/avdtp.c new file mode 100644 index 0000000..96f7049 --- /dev/null +++ b/parser/avdtp.c @@ -0,0 +1,113 @@ +/* + * + * Bluetooth packet analyzer - AVDTP parser + * + * Copyright (C) 2004 Marcel Holtmann <marcel@holtmann.org> + * + * + * 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 + * + * + * $Id$ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <string.h> + +#include <sys/types.h> +#include <netinet/in.h> + +#include "parser.h" + + +static char *si2str(uint8_t si) +{ + switch (si & 0x7f) { + case 0x01: + return "Discover"; + case 0x02: + return "Capabilities"; + case 0x03: + return "Set config"; + case 0x04: + return "Get config"; + case 0x05: + return "Reconfigure"; + case 0x06: + return "Open"; + case 0x07: + return "Start"; + case 0x08: + return "Close"; + case 0x09: + return "Suspend"; + case 0x0a: + return "Abort"; + case 0x0b: + return "Security"; + default: + return "Unknown"; + } +} + +static char *pt2str(uint8_t hdr) +{ + switch (hdr & 0x0c) { + case 0x00: + return "Single"; + case 0x04: + return "Start"; + case 0x08: + return "Cont"; + case 0x0c: + return "End"; + default: + return "Unk"; + } +} + +static char *mt2str(uint8_t hdr) +{ + switch (hdr & 0x03) { + case 0x00: + return "cmd"; + case 0x08: + return "rsp"; + case 0x0c: + return "rej"; + default: + return "rfa"; + } +} + +void avdtp_dump(int level, struct frame *frm) +{ + uint8_t hdr, sid = 0xff, nsp; + + hdr = get_u8(frm); + + nsp = (hdr & 0x0c) == 0x04 ? get_u8(frm) : 0; + sid = hdr & 0x08 ? 0x00 : get_u8(frm); + + p_indent(level, frm); + + printf("AVDTP(s): %s %s: transaction %d\n", + sid & 0x08 ? pt2str(hdr) : si2str(sid), mt2str(hdr), hdr >> 8); + + raw_dump(level, frm); +} diff --git a/parser/l2cap.c b/parser/l2cap.c index 8b8e5fb..2a86ba6 100644 --- a/parser/l2cap.c +++ b/parser/l2cap.c @@ -427,6 +427,13 @@ static void l2cap_parse(int level, struct frame *frm) raw_dump(level + 1, frm); break; + case 0x19: + if (!p_filter(FILT_AVDTP)) + avdtp_dump(level, frm); + else + raw_dump(level + 1, frm); + break; + default: proto = get_proto(frm->handle, psm); diff --git a/parser/parser.h b/parser/parser.h index cfdf39f..49f2d2b 100644 --- a/parser/parser.h +++ b/parser/parser.h @@ -58,6 +58,7 @@ struct frame { #define FILT_CMTP 0x0040 #define FILT_HIDP 0x0080 #define FILT_HCRP 0x0100 +#define FILT_AVDTP 0x0200 #define FILT_CAPI 0x00010000 @@ -168,6 +169,7 @@ void bnep_dump(int level, struct frame *frm); void cmtp_dump(int level, struct frame *frm); void hidp_dump(int level, struct frame *frm); void hcrp_dump(int level, struct frame *frm); +void avdtp_dump(int level, struct frame *frm); void capi_dump(int level, struct frame *frm); diff --git a/src/hcidump.8 b/src/hcidump.8 index 181d311..fcb0e35 100644 --- a/src/hcidump.8 +++ b/src/hcidump.8 @@ -81,7 +81,8 @@ is a space-separated list of packet categories: available categories are .IR bnep , .IR cmtp , .IR hidp , -.IR hcrp +.IR hcrp , +.IR avdtp and .IR capi . If filters are used, only packets belonging to the specified categories are diff --git a/src/hcidump.c b/src/hcidump.c index 3ef3648..6f34096 100644 --- a/src/hcidump.c +++ b/src/hcidump.c @@ -302,6 +302,7 @@ static struct { { "cmtp", FILT_CMTP }, { "hidp", FILT_HIDP }, { "hcrp", FILT_HCRP }, + { "avdtp", FILT_AVDTP }, { "capi", FILT_CAPI }, { 0 } }; |