linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing
@ 2011-11-03  0:56 Peter Krystad
  2011-11-03  0:56 ` [PATCH v2 hcidump 1/5] Add L2CAP Create/Move channel definitions Peter Krystad
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Peter Krystad @ 2011-11-03  0:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Peter Krystad

This patch adds parsing and display of BT 3.0+HS signaling

v2 - updates to match revised a2mp.h from bluez

Peter Krystad (5):
  Add L2CAP Create/Move channel definitions
  Add A2MP definitions
  Add parsing of L2CAP Create/Move Channel signals
  Add parsing of A2MP signals
  Minor cleanup of indentation in output

 lib/a2mp.h      |  137 +++++++++++++++
 lib/l2cap.h     |   44 +++++
 parser/hci.c    |   15 +-
 parser/l2cap.c  |  495 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 parser/parser.h |    1 +
 src/hcidump.c   |    1 +
 6 files changed, 688 insertions(+), 5 deletions(-)
 create mode 100644 lib/a2mp.h

-- 
1.7.7

--
Peter Krystad
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 hcidump 1/5] Add L2CAP Create/Move channel definitions
  2011-11-03  0:56 [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Peter Krystad
@ 2011-11-03  0:56 ` Peter Krystad
  2011-11-03  0:56 ` [PATCH v2 hcidump 2/5] Add A2MP definitions Peter Krystad
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Peter Krystad @ 2011-11-03  0:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Peter Krystad

---
 lib/l2cap.h |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/lib/l2cap.h b/lib/l2cap.h
index 3880551..23a14a5 100644
--- a/lib/l2cap.h
+++ b/lib/l2cap.h
@@ -82,6 +82,12 @@ struct l2cap_conninfo {
 #define L2CAP_ECHO_RSP		0x09
 #define L2CAP_INFO_REQ		0x0a
 #define L2CAP_INFO_RSP		0x0b
+#define L2CAP_CREATE_REQ	0x0c
+#define L2CAP_CREATE_RSP	0x0d
+#define L2CAP_MOVE_REQ		0x0e
+#define L2CAP_MOVE_RSP		0x0f
+#define L2CAP_MOVE_CFM		0x10
+#define L2CAP_MOVE_CFM_RSP	0x11
 
 /* L2CAP extended feature mask */
 #define L2CAP_FEAT_FLOWCTL	0x00000001
@@ -270,6 +276,44 @@ typedef struct {
 #define L2CAP_IR_SUCCESS	0x0000
 #define L2CAP_IR_NOTSUPP	0x0001
 
+typedef struct {
+	uint16_t	psm;
+	uint16_t	scid;
+	uint8_t		id;
+} __attribute__ ((packed)) l2cap_create_req;
+#define L2CAP_CREATE_REQ_SIZE 5
+
+typedef struct {
+	uint16_t	dcid;
+	uint16_t	scid;
+	uint16_t	result;
+	uint16_t	status;
+} __attribute__ ((packed)) l2cap_create_rsp;
+#define L2CAP_CREATE_RSP_SIZE 8
+
+typedef struct {
+	uint16_t	icid;
+	uint8_t		id;
+} __attribute__ ((packed)) l2cap_move_req;
+#define L2CAP_MOVE_REQ_SIZE 3
+
+typedef struct {
+	uint16_t	icid;
+	uint16_t	result;
+} __attribute__ ((packed)) l2cap_move_rsp;
+#define L2CAP_MOVE_RSP_SIZE 4
+
+typedef struct {
+	uint16_t	icid;
+	uint16_t	result;
+} __attribute__ ((packed)) l2cap_move_cfm;
+#define L2CAP_MOVE_CFM_SIZE 4
+
+typedef struct {
+	uint16_t	icid;
+} __attribute__ ((packed)) l2cap_move_cfm_rsp;
+#define L2CAP_MOVE_CFM_RSP_SIZE 2
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.7

--
Peter Krystad
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 hcidump 2/5] Add A2MP definitions
  2011-11-03  0:56 [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Peter Krystad
  2011-11-03  0:56 ` [PATCH v2 hcidump 1/5] Add L2CAP Create/Move channel definitions Peter Krystad
@ 2011-11-03  0:56 ` Peter Krystad
  2011-11-03  0:56 ` [PATCH v2 hcidump 3/5] Add parsing of L2CAP Create/Move Channel signals Peter Krystad
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Peter Krystad @ 2011-11-03  0:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Peter Krystad

---
 lib/a2mp.h |  137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 137 insertions(+), 0 deletions(-)
 create mode 100644 lib/a2mp.h

diff --git a/lib/a2mp.h b/lib/a2mp.h
new file mode 100644
index 0000000..ce4bf53
--- /dev/null
+++ b/lib/a2mp.h
@@ -0,0 +1,137 @@
+/*
+ *
+ *	BlueZ - Bluetooth protocol stack for Linux
+ *
+ *	Copyright (C) 2010-2011 Code Aurora Forum.  All rights reserved.
+ *
+ *	This program is free software; you can redistribute it and/or modify
+ *	it under the terms of the GNU General Public License version 2 and
+ *	only version 2 as published by the Free Software Foundation.
+ *
+ *	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.
+ *
+ */
+
+#ifndef __A2MP_H
+#define __A2MP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A2MP Protocol */
+
+/* A2MP command codes */
+
+#define A2MP_COMMAND_REJ	0x01
+#define A2MP_DISCOVER_REQ	0x02
+#define A2MP_DISCOVER_RSP	0x03
+#define A2MP_CHANGE_NOTIFY	0x04
+#define A2MP_CHANGE_RSP		0x05
+#define A2MP_INFO_REQ		0x06
+#define A2MP_INFO_RSP		0x07
+#define A2MP_ASSOC_REQ		0x08
+#define A2MP_ASSOC_RSP		0x09
+#define A2MP_CREATE_REQ		0x0a
+#define A2MP_CREATE_RSP		0x0b
+#define A2MP_DISCONN_REQ	0x0c
+#define A2MP_DISCONN_RSP	0x0d
+
+struct a2mp_hdr {
+	uint8_t		code;
+	uint8_t		ident;
+	uint16_t	len;
+} __attribute__ ((packed));
+#define A2MP_HDR_SIZE 4
+
+struct a2mp_command_rej {
+	uint16_t	reason;
+} __attribute__ ((packed));
+
+struct a2mp_discover_req {
+	uint16_t	mtu;
+	uint16_t	mask;
+} __attribute__ ((packed));
+
+struct a2mp_ctrl {
+	uint8_t		id;
+	uint8_t		type;
+	uint8_t		status;
+} __attribute__ ((packed));
+
+struct a2mp_discover_rsp {
+	uint16_t	mtu;
+	uint16_t	mask;
+	struct a2mp_ctrl ctrl_list[0];
+} __attribute__ ((packed));
+
+struct a2mp_info_req {
+	uint8_t		id;
+} __attribute__ ((packed));
+
+struct a2mp_info_rsp {
+	uint8_t		id;
+	uint8_t		status;
+	uint32_t	total_bw;
+	uint32_t	max_bw;
+	uint32_t	min_latency;
+	uint16_t	pal_caps;
+	uint16_t	assoc_size;
+} __attribute__ ((packed));
+
+struct a2mp_assoc_rsp {
+	uint8_t		id;
+	uint8_t		status;
+	uint8_t		assoc_data[0];
+} __attribute__ ((packed));
+
+struct a2mp_create_req {
+	uint8_t		local_id;
+	uint8_t		remote_id;
+	uint8_t		assoc_data[0];
+} __attribute__ ((packed));
+
+struct a2mp_create_rsp {
+	uint8_t		local_id;
+	uint8_t		remote_id;
+	uint8_t		status;
+} __attribute__ ((packed));
+
+struct a2mp_disconn_req {
+	uint8_t		local_id;
+	uint8_t		remote_id;
+} __attribute__ ((packed));
+
+#define A2MP_COMMAND_NOT_RECOGNIZED 0x0000
+
+/* AMP controller type */
+#define AMP_CTRL_BR_EDR		0x00
+#define AMP_CTRL_802_11		0x01
+
+/* AMP controller status */
+#define AMP_CTRL_POWERED_DOWN		0x00
+#define AMP_CTRL_BLUETOOTH_ONLY		0x01
+#define AMP_CTRL_NO_CAPACITY		0x02
+#define AMP_CTRL_LOW_CAPACITY		0x03
+#define AMP_CTRL_MEDIUM_CAPACITY	0x04
+#define AMP_CTRL_HIGH_CAPACITY		0x05
+#define AMP_CTRL_FULL_CAPACITY		0x06
+
+/* A2MP response status */
+#define A2MP_STATUS_SUCCESS				0x00
+#define A2MP_STATUS_INVALID_CTRL_ID			0x01
+#define A2MP_STATUS_UNABLE_START_LINK_CREATION		0x02
+#define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS		0x02
+#define A2MP_STATUS_COLLISION_OCCURED			0x03
+#define A2MP_STATUS_DISCONN_REQ_RECVD			0x04
+#define A2MP_STATUS_PHYS_LINK_EXISTS			0x05
+#define A2MP_STATUS_SECURITY_VIOLATION			0x06
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __A2MP_H */
-- 
1.7.7

--
Peter Krystad
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 hcidump 3/5] Add parsing of L2CAP Create/Move Channel signals
  2011-11-03  0:56 [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Peter Krystad
  2011-11-03  0:56 ` [PATCH v2 hcidump 1/5] Add L2CAP Create/Move channel definitions Peter Krystad
  2011-11-03  0:56 ` [PATCH v2 hcidump 2/5] Add A2MP definitions Peter Krystad
@ 2011-11-03  0:56 ` Peter Krystad
  2011-11-03  0:56 ` [PATCH v2 hcidump 4/5] Add parsing of A2MP signals Peter Krystad
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Peter Krystad @ 2011-11-03  0:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Peter Krystad

---
 parser/l2cap.c |   97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 97 insertions(+), 0 deletions(-)

diff --git a/parser/l2cap.c b/parser/l2cap.c
index 696456a..1a4c288 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -409,6 +409,7 @@ static char *supervisory2str(uint8_t supervisory)
 	}
 }
 
+
 static inline void command_rej(int level, struct frame *frm)
 {
 	l2cap_cmd_rej *h = frm->ptr;
@@ -868,6 +869,78 @@ static void l2cap_ctrl_parse(int level, struct frame *frm, uint32_t ctrl)
 		printf(" F-bit");
 }
 
+static inline void create_req(int level, l2cap_cmd_hdr *cmd, struct frame *frm)
+{
+	l2cap_create_req *h = frm->ptr;
+	uint16_t psm = btohs(h->psm);
+	uint16_t scid = btohs(h->scid);
+
+	if (p_filter(FILT_L2CAP))
+		return;
+
+	printf("Create req: psm %d scid 0x%4.4x id %d\n", psm, scid, h->id);
+}
+
+static inline void create_rsp(int level, l2cap_cmd_hdr *cmd, struct frame *frm)
+{
+	l2cap_create_rsp *h = frm->ptr;
+	uint16_t scid = btohs(h->scid);
+	uint16_t dcid = btohs(h->dcid);
+	uint16_t result = btohs(h->result);
+	uint16_t status = btohs(h->status);
+
+	if (p_filter(FILT_L2CAP))
+		return;
+
+	printf("Create rsp: dcid 0x%4.4x scid 0x%4.4x result %d status %d\n", dcid, scid, result, status);
+}
+
+static inline void move_req(int level, l2cap_cmd_hdr *cmd, struct frame *frm)
+{
+	l2cap_move_req *h = frm->ptr;
+	uint16_t icid = btohs(h->icid);
+
+	if (p_filter(FILT_L2CAP))
+		return;
+
+	printf("Move req: icid 0x%4.4x id %d\n", icid, h->id);
+}
+
+static inline void move_rsp(int level, l2cap_cmd_hdr *cmd, struct frame *frm)
+{
+	l2cap_move_rsp *h = frm->ptr;
+	uint16_t icid = btohs(h->icid);
+	uint16_t result = btohs(h->result);
+
+	if (p_filter(FILT_L2CAP))
+		return;
+
+	printf("Move rsp: icid 0x%4.4x result %d\n", icid, result);
+}
+
+static inline void move_cfm(int level, l2cap_cmd_hdr *cmd, struct frame *frm)
+{
+	l2cap_move_cfm *h = frm->ptr;
+	uint16_t icid = btohs(h->icid);
+	uint16_t result = btohs(h->result);
+
+	if (p_filter(FILT_L2CAP))
+		return;
+
+	printf("Move cfm: icid 0x%4.4x result %d\n", icid, result);
+}
+
+static inline void move_cfm_rsp(int level, l2cap_cmd_hdr *cmd, struct frame *frm)
+{
+	l2cap_move_cfm_rsp *h = frm->ptr;
+	uint16_t icid = btohs(h->icid);
+
+	if (p_filter(FILT_L2CAP))
+		return;
+
+	printf("Move cfm rsp: icid 0x%4.4x\n", icid);
+}
+
 static void l2cap_parse(int level, struct frame *frm)
 {
 	l2cap_hdr *hdr = (void *)frm->ptr;
@@ -937,6 +1010,30 @@ static void l2cap_parse(int level, struct frame *frm)
 				info_rsp(level, hdr, frm);
 				break;
 
+			case L2CAP_CREATE_REQ:
+				create_req(level, hdr, frm);
+				break;
+
+			case L2CAP_CREATE_RSP:
+				create_rsp(level, hdr, frm);
+				break;
+
+			case L2CAP_MOVE_REQ:
+				move_req(level, hdr, frm);
+				break;
+
+			case L2CAP_MOVE_RSP:
+				move_rsp(level, hdr, frm);
+				break;
+
+			case L2CAP_MOVE_CFM:
+				move_cfm(level, hdr, frm);
+				break;
+
+			case L2CAP_MOVE_CFM_RSP:
+				move_cfm_rsp(level, hdr, frm);
+				break;
+
 			default:
 				if (p_filter(FILT_L2CAP))
 					break;
-- 
1.7.7

--
Peter Krystad
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 hcidump 4/5] Add parsing of A2MP signals
  2011-11-03  0:56 [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Peter Krystad
                   ` (2 preceding siblings ...)
  2011-11-03  0:56 ` [PATCH v2 hcidump 3/5] Add parsing of L2CAP Create/Move Channel signals Peter Krystad
@ 2011-11-03  0:56 ` Peter Krystad
  2011-11-11 14:24   ` Andrei Emeltchenko
  2011-11-03  0:56 ` [PATCH v2 hcidump 5/5] Minor cleanup of indentation in output Peter Krystad
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: Peter Krystad @ 2011-11-03  0:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Peter Krystad

---
 parser/l2cap.c  |  398 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 parser/parser.h |    1 +
 src/hcidump.c   |    1 +
 3 files changed, 400 insertions(+), 0 deletions(-)

diff --git a/parser/l2cap.c b/parser/l2cap.c
index 1a4c288..ebe693d 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -37,6 +37,7 @@
 #include "parser/sdp.h"
 #include "lib/hci.h"
 #include "lib/l2cap.h"
+#include "lib/a2mp.h"
 
 typedef struct {
 	uint16_t handle;
@@ -269,6 +270,16 @@ static char *reason2str(uint16_t reason)
 	}
 }
 
+static char *a2mpreason2str(uint16_t reason)
+{
+	switch (reason) {
+	case A2MP_COMMAND_NOT_RECOGNIZED:
+		return "Command not recognized";
+	default:
+		return "Reserved";
+	}
+}
+
 static char *connresult2str(uint16_t result)
 {
 	switch (result) {
@@ -409,6 +420,88 @@ static char *supervisory2str(uint8_t supervisory)
 	}
 }
 
+static char *ampctrltype2str(uint8_t type)
+{
+	switch (type) {
+	case AMP_CTRL_BR_EDR:
+		return "BR-EDR";
+	case AMP_CTRL_802_11:
+		return "802.11 AMP";
+	default:
+		return "Reserved";
+	}
+}
+
+static char *ampctrlstatus2str(uint8_t status)
+{
+	switch (status) {
+	case AMP_CTRL_POWERED_DOWN:
+		return "Powered down";
+	case AMP_CTRL_BLUETOOTH_ONLY:
+		return "Bluetooth only";
+	case AMP_CTRL_NO_CAPACITY:
+		return "No capacity";
+	case AMP_CTRL_LOW_CAPACITY:
+		return "Low capacity";
+	case AMP_CTRL_MEDIUM_CAPACITY:
+		return "Medium capacity";
+	case AMP_CTRL_HIGH_CAPACITY:
+		return "High capacity";
+	case AMP_CTRL_FULL_CAPACITY:
+		return "Full capacity";
+	default:
+		return "Reserved";
+
+	}
+}
+
+static char *a2mpstatus2str(uint8_t status)
+{
+	switch (status) {
+	case A2MP_STATUS_SUCCESS:
+		return "Success";
+	case A2MP_STATUS_INVALID_CTRL_ID:
+		return "Invalid Controller ID";
+	default:
+		return "Reserved";
+	}
+}
+
+static char *a2mpcplstatus2str(uint8_t status)
+{
+	switch (status) {
+	case A2MP_STATUS_SUCCESS:
+		return "Success";
+	case A2MP_STATUS_INVALID_CTRL_ID:
+		return "Invalid Controller ID";
+	case A2MP_STATUS_UNABLE_START_LINK_CREATION:
+		return "Failed - Unable to start link creation";
+	case A2MP_STATUS_COLLISION_OCCURED:
+		return "Failed - Collision occured";
+	case A2MP_STATUS_DISCONN_REQ_RECVD:
+		return "Failed - Disconnect physical link received";
+	case A2MP_STATUS_PHYS_LINK_EXISTS:
+		return "Failed - Physical link already exists";
+	case A2MP_STATUS_SECURITY_VIOLATION:
+		return "Failed - Security violation";
+	default:
+		return "Reserved";
+	}
+}
+
+static char *a2mpdplstatus2str(uint8_t status)
+{
+	switch (status) {
+	case A2MP_STATUS_SUCCESS:
+		return "Success";
+	case A2MP_STATUS_INVALID_CTRL_ID:
+		return "Invalid Controller ID";
+	case A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS:
+		return "Failed - No Physical Link exists";
+	default:
+		return "Reserved";
+	}
+}
 
 static inline void command_rej(int level, struct frame *frm)
 {
@@ -941,6 +1034,241 @@ static inline void move_cfm_rsp(int level, l2cap_cmd_hdr *cmd, struct frame *frm
 	printf("Move cfm rsp: icid 0x%4.4x\n", icid);
 }
 
+static inline void a2mp_command_rej(int level, struct frame *frm)
+{
+	struct a2mp_command_rej *h = frm->ptr;
+	uint16_t reason = btohs(h->reason);
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Command Reject: reason %d\n", reason);
+	p_indent(level + 1, frm);
+	printf("%s\n", a2mpreason2str(reason));
+}
+
+static inline void a2mp_discover_req(int level, struct frame *frm, uint16_t len)
+{
+	struct a2mp_discover_req *h = frm->ptr;
+	uint16_t mtu = btohs(h->mtu);
+	uint8_t	 *octet = (uint8_t *)&(h->mask);
+	uint16_t mask;
+	uint8_t  extension;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Discover req: mtu/mps %d ", mtu);
+	len -= 2;
+
+	printf("mask:");
+
+	do {
+		len -= 2;
+		mask = btohs(*(uint16_t *)(&octet[0]));
+		printf(" 0x%4.4x", mask);
+
+		extension = octet[1] & 0x80;
+		octet += 2;
+	} while ((extension != 0) && (len >= 2));
+
+	printf("\n");
+}
+
+static inline void a2mp_ctrl_list_dump(int level, struct a2mp_ctrl *list, uint16_t len)
+{
+	if (p_filter(FILT_A2MP))
+		return;
+
+	p_indent(level, 0);
+	printf("Controller list:\n");
+
+	while (len >= 3) {
+		p_indent(level + 1, 0);
+		printf("id %d type %d (%s) status 0x%2.2x (%s)\n",
+			   list->id, list->type, ampctrltype2str(list->type), list->status, ampctrlstatus2str(list->status));
+		list++;
+		len -= 3;
+	}
+
+}
+
+static inline void a2mp_discover_rsp(int level, struct frame *frm, uint16_t len)
+{
+	struct a2mp_discover_rsp *h = frm->ptr;
+	uint16_t mtu = btohs(h->mtu);
+	uint8_t	 *octet = (uint8_t *)&(h->mask);
+	uint16_t mask;
+	uint8_t  extension;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Discover rsp: mtu/mps %d ", mtu);
+	len -= 2;
+
+	printf("mask:");
+
+	do {
+		len -= 2;
+		mask = btohs(*(uint16_t *)(&octet[0]));
+		printf(" 0x%4.4x", mask);
+
+		extension = octet[1] & 0x80;
+		octet += 2;
+	} while ((extension != 0) && (len >= 2));
+
+	printf("\n");
+
+	if (len >= 3) {
+		a2mp_ctrl_list_dump(level + 1, (struct a2mp_ctrl *) octet, len);
+	}
+}
+
+static inline void a2mp_change_notify(int level, struct frame *frm, uint16_t len)
+{
+	struct a2mp_ctrl *list = frm->ptr;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Change Notify\n");
+
+	if (len >= 3) {
+		a2mp_ctrl_list_dump(level + 1, list, len);
+	}
+}
+
+static inline void a2mp_change_rsp(int level, struct frame *frm)
+{
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Change Response\n");
+}
+
+static inline void a2mp_info_req(int level, struct frame *frm)
+{
+	struct a2mp_info_req *h = frm->ptr;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Get Info req: id %d\n", h->id);
+}
+
+static inline void a2mp_info_rsp(int level, struct frame *frm)
+{
+	struct a2mp_info_rsp *h = frm->ptr;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Get Info rsp: id %d status %d (%s)\n",
+		   h->id, h->status, a2mpstatus2str(h->status));
+
+	p_indent(level + 1, frm);
+	printf("Total bandwidth %d\n", btohl(h->total_bw));
+	p_indent(level + 1, frm);
+	printf("Max guaranteed bandwidth %d\n", btohl(h->max_bw));
+	p_indent(level + 1, frm);
+	printf("Min latency %d\n", btohl(h->min_latency));
+	p_indent(level + 1, frm);
+	printf("Pal capabilities 0x%4.4x\n", btohs(h->pal_caps));
+	p_indent(level + 1, frm);
+	printf("Assoc size %d\n", btohs(h->assoc_size));
+}
+
+static inline void a2mp_assoc_req(int level, struct frame *frm)
+{
+	struct a2mp_info_req *h = frm->ptr;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Get AMP Assoc req: id %d\n", h->id);
+}
+
+static inline void a2mp_assoc_dump(int level, uint8_t *assoc, uint16_t len)
+{
+	int i;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	p_indent(level, 0);
+	printf("Assoc data:");
+	for (i = 0; i < len; i++) {
+		if (!(i%16)) {
+			printf("\n");
+			p_indent(level+1, 0);
+		}
+		printf("%2.2x ",*assoc++);
+	}
+	printf("\n");
+}
+
+static inline void a2mp_assoc_rsp(int level, struct frame *frm, uint16_t len)
+{
+	struct a2mp_assoc_rsp *h = frm->ptr;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Get AMP Assoc rsp: id %d status (%d) %s \n",
+		   h->id, h->status, a2mpstatus2str(h->status));
+	a2mp_assoc_dump(level + 1, (uint8_t *) &h->assoc_data, len - 2);
+}
+
+static inline void a2mp_create_req(int level, struct frame *frm, uint16_t len)
+{
+	struct a2mp_create_req *h = frm->ptr;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Create Physical Link req: local id %d remote id %d\n",
+		   h->local_id, h->remote_id);
+	a2mp_assoc_dump(level + 1, (uint8_t *) &h->assoc_data, len - 2);
+}
+
+static inline void a2mp_create_rsp(int level, struct frame *frm)
+{
+	struct a2mp_create_rsp *h = frm->ptr;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Create Physical Link rsp: local id %d remote id %d status %d\n",
+		   h->local_id, h->remote_id, h->status);
+	p_indent(level+1, 0);
+	printf("%s\n", a2mpcplstatus2str(h->status));
+}
+
+static inline void a2mp_disconn_req(int level, struct frame *frm)
+{
+	struct a2mp_disconn_req *h = frm->ptr;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Disconnect Physical Link req: local id %d remote id %d\n",
+		   h->local_id, h->remote_id);
+}
+
+static inline void a2mp_disconn_rsp(int level, struct frame *frm)
+{
+	struct a2mp_create_rsp *h = frm->ptr;
+
+	if (p_filter(FILT_A2MP))
+		return;
+
+	printf("Disconnect Physical Link rsp: local id %d remote id %d status %d\n",
+		   h->local_id, h->remote_id, h->status);
+	p_indent(level+1, 0);
+	printf("%s\n", a2mpdplstatus2str(h->status));
+}
+
 static void l2cap_parse(int level, struct frame *frm)
 {
 	l2cap_hdr *hdr = (void *)frm->ptr;
@@ -1061,6 +1389,76 @@ static void l2cap_parse(int level, struct frame *frm)
 		p_indent(level, frm);
 		printf("L2CAP(c): len %d psm %d\n", dlen, psm);
 		raw_dump(level, frm);
+	} else if ((cid == 0x3) && (frm->len > 4)) {
+
+		/* Adjust for extra ERTM control bytes */
+		frm->ptr += 2;
+		frm->len -= 2;
+
+		while (frm->len >= A2MP_HDR_SIZE) {
+			struct a2mp_hdr *hdr = frm->ptr;
+
+			frm->ptr += A2MP_HDR_SIZE;
+			frm->len -= A2MP_HDR_SIZE;
+
+			if (!p_filter(FILT_A2MP)) {
+				p_indent(level, frm);
+				printf("A2MP: ");
+			}
+			switch (hdr->code) {
+			case A2MP_COMMAND_REJ:
+				a2mp_command_rej(level, frm);
+				break;
+			case A2MP_DISCOVER_REQ:
+				a2mp_discover_req(level, frm, hdr->len);
+				break;
+			case A2MP_DISCOVER_RSP:
+				a2mp_discover_rsp(level, frm, hdr->len);
+				break;
+			case A2MP_CHANGE_NOTIFY:
+				a2mp_change_notify(level, frm, hdr->len);
+				break;
+			case A2MP_CHANGE_RSP:
+				a2mp_change_rsp(level, frm);
+				break;
+			case A2MP_INFO_REQ:
+				a2mp_info_req(level, frm);
+				break;
+			case A2MP_INFO_RSP:
+				a2mp_info_rsp(level, frm);
+				break;
+			case A2MP_ASSOC_REQ:
+				a2mp_assoc_req(level, frm);
+				break;
+			case A2MP_ASSOC_RSP:
+				a2mp_assoc_rsp(level, frm, hdr->len);
+				break;
+			case A2MP_CREATE_REQ:
+				a2mp_create_req(level, frm, hdr->len);
+				break;
+			case A2MP_CREATE_RSP:
+				a2mp_create_rsp(level, frm);
+				break;
+			case A2MP_DISCONN_REQ:
+				a2mp_disconn_req(level, frm);
+				break;
+			case A2MP_DISCONN_RSP:
+				a2mp_disconn_rsp(level, frm);
+				break;
+			default:
+				if (p_filter(FILT_A2MP))
+					break;
+				printf("code 0x%2.2x ident %d len %d\n",
+					   hdr->code, hdr->ident, btohs(hdr->len));
+				raw_dump(level, frm);
+			}
+
+			if (frm->len > btohs(hdr->len)) {
+				frm->len -= btohs(hdr->len);
+				frm->ptr += btohs(hdr->len);
+			} else
+				frm->len = 0;
+		}
 	} else if (cid == 0x04) {
 		if (!p_filter(FILT_ATT))
 			att_dump(level, frm);
diff --git a/parser/parser.h b/parser/parser.h
index e975808..22d18c3 100644
--- a/parser/parser.h
+++ b/parser/parser.h
@@ -80,6 +80,7 @@ struct frame {
 #define FILT_AVCTP	0x0800
 #define FILT_ATT 	0x1000
 #define FILT_SMP	0x2000
+#define FILT_A2MP	0x4000
 
 #define FILT_OBEX	0x00010000
 #define FILT_CAPI	0x00020000
diff --git a/src/hcidump.c b/src/hcidump.c
index 0c13360..2513c7c 100644
--- a/src/hcidump.c
+++ b/src/hcidump.c
@@ -802,6 +802,7 @@ static struct {
 	{ "hci",	FILT_HCI	},
 	{ "sco",	FILT_SCO	},
 	{ "l2cap",	FILT_L2CAP	},
+	{ "a2mp",	FILT_A2MP	},
 	{ "rfcomm",	FILT_RFCOMM	},
 	{ "sdp",	FILT_SDP	},
 	{ "bnep",	FILT_BNEP	},
-- 
1.7.7

--
Peter Krystad
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 hcidump 5/5] Minor cleanup of indentation in output
  2011-11-03  0:56 [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Peter Krystad
                   ` (3 preceding siblings ...)
  2011-11-03  0:56 ` [PATCH v2 hcidump 4/5] Add parsing of A2MP signals Peter Krystad
@ 2011-11-03  0:56 ` Peter Krystad
  2011-11-11 14:28 ` [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Andrei Emeltchenko
  2011-12-08  8:38 ` Andrei Emeltchenko
  6 siblings, 0 replies; 9+ messages in thread
From: Peter Krystad @ 2011-11-03  0:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Peter Krystad

Minor indentation cleanup and fix display of physical link key
---
 parser/hci.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/parser/hci.c b/parser/hci.c
index a0e3034..e459e9e 100644
--- a/parser/hci.c
+++ b/parser/hci.c
@@ -1124,12 +1124,11 @@ static inline void create_physical_link_dump(int level, struct frame *frm)
 	int i;
 
 	p_indent(level, frm);
-
 	printf("handle %d key length %d key type %d\n",
 		cp->handle, cp->key_length, cp->key_type);
+	p_indent(level, frm);
 	printf("key ");
-
-	for (i = 0; i < cp->key_length && cp->key_length < 32; i++)
+	for (i = 0; i < cp->key_length && cp->key_length <= 32; i++)
 		printf("%2.2x", cp->key[i]);
 	printf("\n");
 }
@@ -1140,12 +1139,16 @@ static inline void create_logical_link_dump(int level, struct frame *frm)
 	int i;
 
 	p_indent(level, frm);
-
 	printf("handle %d\n", cp->handle);
+
+	p_indent(level, frm);
 	printf("tx_flow ");
 	for (i = 0; i < 16; i++)
 		printf("%2.2x", cp->tx_flow[i]);
-	printf("\nrx_flow ");
+	printf("\n");
+
+	p_indent(level, frm);
+	printf("rx_flow ");
 	for (i = 0; i < 16; i++)
 		printf("%2.2x", cp->rx_flow[i]);
 	printf("\n");
@@ -2605,6 +2608,8 @@ static inline void read_local_amp_assoc_dump(int level, struct frame *frm)
 		p_indent(level, frm);
 		printf("Error: %s\n", status2str(rp->status));
 	} else {
+		p_indent(level, frm);
+		printf("assoc data");
 		for (i = 0; i < len; i++) {
 			if (!(i % 16)) {
 				printf("\n");
-- 
1.7.7

--
Peter Krystad
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 hcidump 4/5] Add parsing of A2MP signals
  2011-11-03  0:56 ` [PATCH v2 hcidump 4/5] Add parsing of A2MP signals Peter Krystad
@ 2011-11-11 14:24   ` Andrei Emeltchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2011-11-11 14:24 UTC (permalink / raw)
  To: Peter Krystad; +Cc: linux-bluetooth

Hi Peter,

On Wed, Nov 02, 2011 at 05:56:56PM -0700, Peter Krystad wrote:
> ---
>  parser/l2cap.c  |  398 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  parser/parser.h |    1 +
>  src/hcidump.c   |    1 +
>  3 files changed, 400 insertions(+), 0 deletions(-)
> 
> diff --git a/parser/l2cap.c b/parser/l2cap.c
> index 1a4c288..ebe693d 100644
> --- a/parser/l2cap.c
> +++ b/parser/l2cap.c
> @@ -37,6 +37,7 @@
>  #include "parser/sdp.h"
>  #include "lib/hci.h"
>  #include "lib/l2cap.h"
> +#include "lib/a2mp.h"
>  
>  typedef struct {
>  	uint16_t handle;
> @@ -269,6 +270,16 @@ static char *reason2str(uint16_t reason)
>  	}
>  }
>  
> +static char *a2mpreason2str(uint16_t reason)
> +{
> +	switch (reason) {
> +	case A2MP_COMMAND_NOT_RECOGNIZED:
> +		return "Command not recognized";
> +	default:
> +		return "Reserved";
> +	}
> +}
> +
>  static char *connresult2str(uint16_t result)
>  {
>  	switch (result) {
> @@ -409,6 +420,88 @@ static char *supervisory2str(uint8_t supervisory)
>  	}
>  }
>  
> +static char *ampctrltype2str(uint8_t type)
> +{
> +	switch (type) {
> +	case AMP_CTRL_BR_EDR:
> +		return "BR-EDR";
> +	case AMP_CTRL_802_11:
> +		return "802.11 AMP";
> +	default:
> +		return "Reserved";
> +	}
> +}
> +
> +static char *ampctrlstatus2str(uint8_t status)
> +{
> +	switch (status) {
> +	case AMP_CTRL_POWERED_DOWN:
> +		return "Powered down";
> +	case AMP_CTRL_BLUETOOTH_ONLY:
> +		return "Bluetooth only";
> +	case AMP_CTRL_NO_CAPACITY:
> +		return "No capacity";
> +	case AMP_CTRL_LOW_CAPACITY:
> +		return "Low capacity";
> +	case AMP_CTRL_MEDIUM_CAPACITY:
> +		return "Medium capacity";
> +	case AMP_CTRL_HIGH_CAPACITY:
> +		return "High capacity";
> +	case AMP_CTRL_FULL_CAPACITY:
> +		return "Full capacity";
> +	default:
> +		return "Reserved";
> +
> +	}
> +}
> +
> +static char *a2mpstatus2str(uint8_t status)
> +{
> +	switch (status) {
> +	case A2MP_STATUS_SUCCESS:
> +		return "Success";
> +	case A2MP_STATUS_INVALID_CTRL_ID:
> +		return "Invalid Controller ID";
> +	default:
> +		return "Reserved";
> +	}
> +}
> +
> +static char *a2mpcplstatus2str(uint8_t status)
> +{
> +	switch (status) {
> +	case A2MP_STATUS_SUCCESS:
> +		return "Success";
> +	case A2MP_STATUS_INVALID_CTRL_ID:
> +		return "Invalid Controller ID";
> +	case A2MP_STATUS_UNABLE_START_LINK_CREATION:
> +		return "Failed - Unable to start link creation";
> +	case A2MP_STATUS_COLLISION_OCCURED:
> +		return "Failed - Collision occured";
> +	case A2MP_STATUS_DISCONN_REQ_RECVD:
> +		return "Failed - Disconnect physical link received";
> +	case A2MP_STATUS_PHYS_LINK_EXISTS:
> +		return "Failed - Physical link already exists";
> +	case A2MP_STATUS_SECURITY_VIOLATION:
> +		return "Failed - Security violation";
> +	default:
> +		return "Reserved";
> +	}
> +}
> +
> +static char *a2mpdplstatus2str(uint8_t status)
> +{
> +	switch (status) {
> +	case A2MP_STATUS_SUCCESS:
> +		return "Success";
> +	case A2MP_STATUS_INVALID_CTRL_ID:
> +		return "Invalid Controller ID";
> +	case A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS:
> +		return "Failed - No Physical Link exists";
> +	default:
> +		return "Reserved";
> +	}
> +}
>  
>  static inline void command_rej(int level, struct frame *frm)
>  {
> @@ -941,6 +1034,241 @@ static inline void move_cfm_rsp(int level, l2cap_cmd_hdr *cmd, struct frame *frm
>  	printf("Move cfm rsp: icid 0x%4.4x\n", icid);
>  }
>  
> +static inline void a2mp_command_rej(int level, struct frame *frm)
> +{
> +	struct a2mp_command_rej *h = frm->ptr;
> +	uint16_t reason = btohs(h->reason);
> +
> +	if (p_filter(FILT_A2MP))
> +		return;

You seems to filter for each a2mp command, maybe it is better to put
filter before switch?

> +
> +	printf("Command Reject: reason %d\n", reason);
> +	p_indent(level + 1, frm);
> +	printf("%s\n", a2mpreason2str(reason));
> +}
> +
> +static inline void a2mp_discover_req(int level, struct frame *frm, uint16_t len)
> +{
> +	struct a2mp_discover_req *h = frm->ptr;
> +	uint16_t mtu = btohs(h->mtu);
> +	uint8_t	 *octet = (uint8_t *)&(h->mask);
> +	uint16_t mask;
> +	uint8_t  extension;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Discover req: mtu/mps %d ", mtu);
> +	len -= 2;
> +
> +	printf("mask:");
> +
> +	do {
> +		len -= 2;
> +		mask = btohs(*(uint16_t *)(&octet[0]));
> +		printf(" 0x%4.4x", mask);
> +
> +		extension = octet[1] & 0x80;
> +		octet += 2;
> +	} while ((extension != 0) && (len >= 2));
> +
> +	printf("\n");
> +}
> +
> +static inline void a2mp_ctrl_list_dump(int level, struct a2mp_ctrl *list, uint16_t len)
> +{
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	p_indent(level, 0);
> +	printf("Controller list:\n");
> +
> +	while (len >= 3) {
> +		p_indent(level + 1, 0);
> +		printf("id %d type %d (%s) status 0x%2.2x (%s)\n",
> +			   list->id, list->type, ampctrltype2str(list->type), list->status, ampctrlstatus2str(list->status));
> +		list++;
> +		len -= 3;
> +	}
> +
> +}
> +
> +static inline void a2mp_discover_rsp(int level, struct frame *frm, uint16_t len)
> +{
> +	struct a2mp_discover_rsp *h = frm->ptr;
> +	uint16_t mtu = btohs(h->mtu);
> +	uint8_t	 *octet = (uint8_t *)&(h->mask);
> +	uint16_t mask;
> +	uint8_t  extension;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Discover rsp: mtu/mps %d ", mtu);
> +	len -= 2;
> +
> +	printf("mask:");
> +
> +	do {
> +		len -= 2;
> +		mask = btohs(*(uint16_t *)(&octet[0]));
> +		printf(" 0x%4.4x", mask);
> +
> +		extension = octet[1] & 0x80;
> +		octet += 2;
> +	} while ((extension != 0) && (len >= 2));
> +
> +	printf("\n");
> +
> +	if (len >= 3) {
> +		a2mp_ctrl_list_dump(level + 1, (struct a2mp_ctrl *) octet, len);
> +	}
> +}
> +
> +static inline void a2mp_change_notify(int level, struct frame *frm, uint16_t len)
> +{
> +	struct a2mp_ctrl *list = frm->ptr;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Change Notify\n");
> +
> +	if (len >= 3) {
> +		a2mp_ctrl_list_dump(level + 1, list, len);
> +	}
> +}
> +
> +static inline void a2mp_change_rsp(int level, struct frame *frm)
> +{
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Change Response\n");
> +}
> +
> +static inline void a2mp_info_req(int level, struct frame *frm)
> +{
> +	struct a2mp_info_req *h = frm->ptr;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Get Info req: id %d\n", h->id);
> +}
> +
> +static inline void a2mp_info_rsp(int level, struct frame *frm)
> +{
> +	struct a2mp_info_rsp *h = frm->ptr;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Get Info rsp: id %d status %d (%s)\n",
> +		   h->id, h->status, a2mpstatus2str(h->status));
> +
> +	p_indent(level + 1, frm);
> +	printf("Total bandwidth %d\n", btohl(h->total_bw));
> +	p_indent(level + 1, frm);
> +	printf("Max guaranteed bandwidth %d\n", btohl(h->max_bw));
> +	p_indent(level + 1, frm);
> +	printf("Min latency %d\n", btohl(h->min_latency));
> +	p_indent(level + 1, frm);
> +	printf("Pal capabilities 0x%4.4x\n", btohs(h->pal_caps));
> +	p_indent(level + 1, frm);
> +	printf("Assoc size %d\n", btohs(h->assoc_size));
> +}
> +
> +static inline void a2mp_assoc_req(int level, struct frame *frm)
> +{
> +	struct a2mp_info_req *h = frm->ptr;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Get AMP Assoc req: id %d\n", h->id);
> +}
> +
> +static inline void a2mp_assoc_dump(int level, uint8_t *assoc, uint16_t len)
> +{
> +	int i;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	p_indent(level, 0);
> +	printf("Assoc data:");
> +	for (i = 0; i < len; i++) {
> +		if (!(i%16)) {
> +			printf("\n");
> +			p_indent(level+1, 0);
> +		}
> +		printf("%2.2x ",*assoc++);
> +	}
> +	printf("\n");
> +}
> +
> +static inline void a2mp_assoc_rsp(int level, struct frame *frm, uint16_t len)
> +{
> +	struct a2mp_assoc_rsp *h = frm->ptr;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Get AMP Assoc rsp: id %d status (%d) %s \n",
> +		   h->id, h->status, a2mpstatus2str(h->status));
> +	a2mp_assoc_dump(level + 1, (uint8_t *) &h->assoc_data, len - 2);
> +}
> +
> +static inline void a2mp_create_req(int level, struct frame *frm, uint16_t len)
> +{
> +	struct a2mp_create_req *h = frm->ptr;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Create Physical Link req: local id %d remote id %d\n",
> +		   h->local_id, h->remote_id);
> +	a2mp_assoc_dump(level + 1, (uint8_t *) &h->assoc_data, len - 2);
> +}
> +
> +static inline void a2mp_create_rsp(int level, struct frame *frm)
> +{
> +	struct a2mp_create_rsp *h = frm->ptr;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Create Physical Link rsp: local id %d remote id %d status %d\n",
> +		   h->local_id, h->remote_id, h->status);
> +	p_indent(level+1, 0);
> +	printf("%s\n", a2mpcplstatus2str(h->status));
> +}
> +
> +static inline void a2mp_disconn_req(int level, struct frame *frm)
> +{
> +	struct a2mp_disconn_req *h = frm->ptr;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Disconnect Physical Link req: local id %d remote id %d\n",
> +		   h->local_id, h->remote_id);
> +}
> +
> +static inline void a2mp_disconn_rsp(int level, struct frame *frm)
> +{
> +	struct a2mp_create_rsp *h = frm->ptr;
> +
> +	if (p_filter(FILT_A2MP))
> +		return;
> +
> +	printf("Disconnect Physical Link rsp: local id %d remote id %d status %d\n",
> +		   h->local_id, h->remote_id, h->status);
> +	p_indent(level+1, 0);
> +	printf("%s\n", a2mpdplstatus2str(h->status));
> +}
> +
>  static void l2cap_parse(int level, struct frame *frm)
>  {
>  	l2cap_hdr *hdr = (void *)frm->ptr;
> @@ -1061,6 +1389,76 @@ static void l2cap_parse(int level, struct frame *frm)
>  		p_indent(level, frm);
>  		printf("L2CAP(c): len %d psm %d\n", dlen, psm);
>  		raw_dump(level, frm);
> +	} else if ((cid == 0x3) && (frm->len > 4)) {
> +
> +		/* Adjust for extra ERTM control bytes */
> +		frm->ptr += 2;
> +		frm->len -= 2;
> +
> +		while (frm->len >= A2MP_HDR_SIZE) {
> +			struct a2mp_hdr *hdr = frm->ptr;
> +
> +			frm->ptr += A2MP_HDR_SIZE;
> +			frm->len -= A2MP_HDR_SIZE;
> +
> +			if (!p_filter(FILT_A2MP)) {
> +				p_indent(level, frm);
> +				printf("A2MP: ");
> +			}

skip switch when filtering?

Best regards 
Andrei Emeltchenko 

> +			switch (hdr->code) {
> +			case A2MP_COMMAND_REJ:
> +				a2mp_command_rej(level, frm);
> +				break;
> +			case A2MP_DISCOVER_REQ:
> +				a2mp_discover_req(level, frm, hdr->len);
> +				break;
> +			case A2MP_DISCOVER_RSP:
> +				a2mp_discover_rsp(level, frm, hdr->len);
> +				break;
> +			case A2MP_CHANGE_NOTIFY:
> +				a2mp_change_notify(level, frm, hdr->len);
> +				break;
> +			case A2MP_CHANGE_RSP:
> +				a2mp_change_rsp(level, frm);
> +				break;
> +			case A2MP_INFO_REQ:
> +				a2mp_info_req(level, frm);
> +				break;
> +			case A2MP_INFO_RSP:
> +				a2mp_info_rsp(level, frm);
> +				break;
> +			case A2MP_ASSOC_REQ:
> +				a2mp_assoc_req(level, frm);
> +				break;
> +			case A2MP_ASSOC_RSP:
> +				a2mp_assoc_rsp(level, frm, hdr->len);
> +				break;
> +			case A2MP_CREATE_REQ:
> +				a2mp_create_req(level, frm, hdr->len);
> +				break;
> +			case A2MP_CREATE_RSP:
> +				a2mp_create_rsp(level, frm);
> +				break;
> +			case A2MP_DISCONN_REQ:
> +				a2mp_disconn_req(level, frm);
> +				break;
> +			case A2MP_DISCONN_RSP:
> +				a2mp_disconn_rsp(level, frm);
> +				break;
> +			default:
> +				if (p_filter(FILT_A2MP))
> +					break;
> +				printf("code 0x%2.2x ident %d len %d\n",
> +					   hdr->code, hdr->ident, btohs(hdr->len));
> +				raw_dump(level, frm);
> +			}
> +
> +			if (frm->len > btohs(hdr->len)) {
> +				frm->len -= btohs(hdr->len);
> +				frm->ptr += btohs(hdr->len);
> +			} else
> +				frm->len = 0;
> +		}
>  	} else if (cid == 0x04) {
>  		if (!p_filter(FILT_ATT))
>  			att_dump(level, frm);
> diff --git a/parser/parser.h b/parser/parser.h
> index e975808..22d18c3 100644
> --- a/parser/parser.h
> +++ b/parser/parser.h
> @@ -80,6 +80,7 @@ struct frame {
>  #define FILT_AVCTP	0x0800
>  #define FILT_ATT 	0x1000
>  #define FILT_SMP	0x2000
> +#define FILT_A2MP	0x4000
>  
>  #define FILT_OBEX	0x00010000
>  #define FILT_CAPI	0x00020000
> diff --git a/src/hcidump.c b/src/hcidump.c
> index 0c13360..2513c7c 100644
> --- a/src/hcidump.c
> +++ b/src/hcidump.c
> @@ -802,6 +802,7 @@ static struct {
>  	{ "hci",	FILT_HCI	},
>  	{ "sco",	FILT_SCO	},
>  	{ "l2cap",	FILT_L2CAP	},
> +	{ "a2mp",	FILT_A2MP	},
>  	{ "rfcomm",	FILT_RFCOMM	},
>  	{ "sdp",	FILT_SDP	},
>  	{ "bnep",	FILT_BNEP	},
> -- 
> 1.7.7
> 
> --
> Peter Krystad
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing
  2011-11-03  0:56 [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Peter Krystad
                   ` (4 preceding siblings ...)
  2011-11-03  0:56 ` [PATCH v2 hcidump 5/5] Minor cleanup of indentation in output Peter Krystad
@ 2011-11-11 14:28 ` Andrei Emeltchenko
  2011-12-08  8:38 ` Andrei Emeltchenko
  6 siblings, 0 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2011-11-11 14:28 UTC (permalink / raw)
  To: Peter Krystad; +Cc: linux-bluetooth

On Wed, Nov 02, 2011 at 05:56:52PM -0700, Peter Krystad wrote:
> This patch adds parsing and display of BT 3.0+HS signaling
> 
> v2 - updates to match revised a2mp.h from bluez

Those patches looks OK except my comments for parsing "A2MP signals"
patch.

ack

Best regards 
Andrei Emeltchenko 
> 
> Peter Krystad (5):
>   Add L2CAP Create/Move channel definitions
>   Add A2MP definitions
>   Add parsing of L2CAP Create/Move Channel signals
>   Add parsing of A2MP signals
>   Minor cleanup of indentation in output
> 
>  lib/a2mp.h      |  137 +++++++++++++++
>  lib/l2cap.h     |   44 +++++
>  parser/hci.c    |   15 +-
>  parser/l2cap.c  |  495 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  parser/parser.h |    1 +
>  src/hcidump.c   |    1 +
>  6 files changed, 688 insertions(+), 5 deletions(-)
>  create mode 100644 lib/a2mp.h
> 
> -- 
> 1.7.7
> 
> --
> Peter Krystad
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing
  2011-11-03  0:56 [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Peter Krystad
                   ` (5 preceding siblings ...)
  2011-11-11 14:28 ` [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Andrei Emeltchenko
@ 2011-12-08  8:38 ` Andrei Emeltchenko
  6 siblings, 0 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2011-12-08  8:38 UTC (permalink / raw)
  To: Peter Krystad; +Cc: linux-bluetooth

Hi all,

On Wed, Nov 02, 2011 at 05:56:52PM -0700, Peter Krystad wrote:
> This patch adds parsing and display of BT 3.0+HS signaling
> 
> v2 - updates to match revised a2mp.h from bluez

What is the status with these patches? Do I understand it correctly that
the license for one patch with definitions (GPL v2 only) prevents it to be
applied?

Peter could you change license so that all user-space code have the same
license? Otherwise we could use hardcoded values of course ....

Best regards 
Andrei Emeltchenko 

> 
> Peter Krystad (5):
>   Add L2CAP Create/Move channel definitions
>   Add A2MP definitions
>   Add parsing of L2CAP Create/Move Channel signals
>   Add parsing of A2MP signals
>   Minor cleanup of indentation in output
> 
>  lib/a2mp.h      |  137 +++++++++++++++
>  lib/l2cap.h     |   44 +++++
>  parser/hci.c    |   15 +-
>  parser/l2cap.c  |  495 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  parser/parser.h |    1 +
>  src/hcidump.c   |    1 +
>  6 files changed, 688 insertions(+), 5 deletions(-)
>  create mode 100644 lib/a2mp.h
> 
> -- 
> 1.7.7
> 
> --
> Peter Krystad
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-12-08  8:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-03  0:56 [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Peter Krystad
2011-11-03  0:56 ` [PATCH v2 hcidump 1/5] Add L2CAP Create/Move channel definitions Peter Krystad
2011-11-03  0:56 ` [PATCH v2 hcidump 2/5] Add A2MP definitions Peter Krystad
2011-11-03  0:56 ` [PATCH v2 hcidump 3/5] Add parsing of L2CAP Create/Move Channel signals Peter Krystad
2011-11-03  0:56 ` [PATCH v2 hcidump 4/5] Add parsing of A2MP signals Peter Krystad
2011-11-11 14:24   ` Andrei Emeltchenko
2011-11-03  0:56 ` [PATCH v2 hcidump 5/5] Minor cleanup of indentation in output Peter Krystad
2011-11-11 14:28 ` [PATCH v2 hcidump 0/5] Add BT 3.0+HS parsing Andrei Emeltchenko
2011-12-08  8:38 ` Andrei Emeltchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).