summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGowtham Anandha Babu <gowtham.ab@samsung.com>2015-04-02 17:02:05 +0530
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2015-04-10 17:19:57 +0300
commit639fa90c07fb99bb7b614d003079c6d7c5699e8c (patch)
tree5e8d25b8dbf0c454178433a038c94b9e9d8f915e
parent44dbeb329b47612f6236b9184ca9c78b24b064a0 (diff)
downloadbluez-639fa90c07fb99bb7b614d003079c6d7c5699e8c.tar.gz
monitor: Add initial support for BNEP
> ACL Data RX: Handle 71 flags 0x02 dlen 11 Channel: 64 len 7 [PSM 15 mode 0] {chan 0} BNEP: Control (0x01|0) 01 02 11 16 11 15 ...... > ACL Data RX: Handle 71 flags 0x01 dlen 35 Channel: 64 len 1532 [PSM 15 mode 0] {chan 0} BNEP: General Ethernet (0x00|1) 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 0f ................ 05 00 0c 03 00 00 20 00 00 03 00 00 20 00 00 3c ...... ..... ..< > ACL Data RX: Handle 71 flags 0x01 dlen 12 Channel: 64 len 1509 [PSM 15 mode 0] {chan 0} BNEP: Compressed Ethernet Dest Only (0x04|0) 00 00 00 00 00 00 08 00 3c 3b 3a 39 38 37 36 35 ........<;:98765 34 33 32 31 30 2f 2e 2d 2c 2b 2a 29 28 27 26 25 43210/.-,+*)('&%
-rw-r--r--Makefile.tools1
-rw-r--r--android/Android.mk1
-rw-r--r--monitor/bnep.c116
-rw-r--r--monitor/bnep.h25
-rw-r--r--monitor/l2cap.c4
5 files changed, 147 insertions, 0 deletions
diff --git a/Makefile.tools b/Makefile.tools
index 1b8b4b84d..e96ea9f7b 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -28,6 +28,7 @@ monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \
monitor/sdp.h monitor/sdp.c \
monitor/avctp.h monitor/avctp.c \
monitor/rfcomm.h monitor/rfcomm.c \
+ monitor/bnep.h monitor/bnep.c \
monitor/uuid.h monitor/uuid.c \
monitor/hwdb.h monitor/hwdb.c \
monitor/keys.h monitor/keys.c \
diff --git a/android/Android.mk b/android/Android.mk
index 1e22ca685..06f86f98a 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -340,6 +340,7 @@ LOCAL_SRC_FILES := \
bluez/monitor/l2cap.c \
bluez/monitor/avctp.c \
bluez/monitor/rfcomm.c \
+ bluez/monitor/bnep.c \
bluez/monitor/uuid.c \
bluez/monitor/sdp.c \
bluez/monitor/vendor.c \
diff --git a/monitor/bnep.c b/monitor/bnep.c
new file mode 100644
index 000000000..1450f8581
--- /dev/null
+++ b/monitor/bnep.c
@@ -0,0 +1,116 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2011-2014 Intel Corporation
+ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <inttypes.h>
+
+#include "lib/bluetooth.h"
+
+#include "src/shared/util.h"
+#include "bt.h"
+#include "packet.h"
+#include "display.h"
+#include "l2cap.h"
+#include "uuid.h"
+#include "keys.h"
+#include "sdp.h"
+#include "bnep.h"
+
+#define GET_PKT_TYPE(type) (type & 0x7f)
+#define GET_EXTENSION(type) (type & 0x80)
+
+struct bnep_frame {
+ uint8_t type;
+ int extension;
+ struct l2cap_frame l2cap_frame;
+};
+
+struct bnep_data {
+ uint8_t type;
+ const char *str;
+};
+
+static const struct bnep_data bnep_table[] = {
+ { 0x00, "General Ethernet"},
+ { 0x01, "Control"},
+ { 0x02, "Compressed Ethernet"},
+ { 0x03, "Compressed Ethernet Src Only"},
+ { 0x04, "Compressed Ethernet Dest Only"},
+ { }
+};
+
+void bnep_packet(const struct l2cap_frame *frame)
+{
+ uint8_t type;
+ struct bnep_frame bnep_frame;
+ struct l2cap_frame *l2cap_frame;
+ const struct bnep_data *bnep_data = NULL;
+ const char *pdu_color, *pdu_str;
+ int i;
+
+ l2cap_frame_pull(&bnep_frame.l2cap_frame, frame, 0);
+ l2cap_frame = &bnep_frame.l2cap_frame;
+
+ if (!l2cap_frame_get_u8(l2cap_frame, &type))
+ goto fail;
+
+ bnep_frame.extension = GET_EXTENSION(type);
+ bnep_frame.type = GET_PKT_TYPE(type);
+
+ for (i = 0; bnep_table[i].str; i++) {
+ if (bnep_table[i].type == bnep_frame.type) {
+ bnep_data = &bnep_table[i];
+ break;
+ }
+ }
+
+ if (bnep_data) {
+ if (frame->in)
+ pdu_color = COLOR_MAGENTA;
+ else
+ pdu_color = COLOR_BLUE;
+ pdu_str = bnep_data->str;
+ } else {
+ pdu_color = COLOR_WHITE_BG;
+ pdu_str = "Unknown packet type";
+ }
+
+ print_indent(6, pdu_color, "BNEP: ", pdu_str, COLOR_OFF,
+ " (0x%02x|%s)", bnep_frame.type,
+ bnep_frame.extension ? "1" : "0");
+
+ packet_hexdump(l2cap_frame->data, l2cap_frame->size);
+ return;
+
+fail:
+ print_text(COLOR_ERROR, "frame too short");
+ packet_hexdump(frame->data, frame->size);
+}
diff --git a/monitor/bnep.h b/monitor/bnep.h
new file mode 100644
index 000000000..38340d6c1
--- /dev/null
+++ b/monitor/bnep.h
@@ -0,0 +1,25 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2011-2014 Intel Corporation
+ * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+void bnep_packet(const struct l2cap_frame *frame);
diff --git a/monitor/l2cap.c b/monitor/l2cap.c
index 5faa26fdf..fc565b143 100644
--- a/monitor/l2cap.c
+++ b/monitor/l2cap.c
@@ -43,6 +43,7 @@
#include "sdp.h"
#include "avctp.h"
#include "rfcomm.h"
+#include "bnep.h"
/* L2CAP Control Field bit masks */
#define L2CAP_CTRL_SAR_MASK 0xC000
@@ -2951,6 +2952,9 @@ static void l2cap_frame(uint16_t index, bool in, uint16_t handle,
case 0x0003:
rfcomm_packet(&frame);
break;
+ case 0x000f:
+ bnep_packet(&frame);
+ break;
case 0x001f:
att_packet(index, in, handle, cid, data, size);
break;