linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions
@ 2012-06-05  9:09 Andrei Emeltchenko
  2012-06-05  9:09 ` [PATCHv2 hcidump 2/4] Fix number of triplet calculation Andrei Emeltchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Andrei Emeltchenko @ 2012-06-05  9:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 lib/a2mp.h |   38 -------------
 lib/amp.h  |  174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 174 insertions(+), 38 deletions(-)
 create mode 100644 lib/amp.h

diff --git a/lib/a2mp.h b/lib/a2mp.h
index 61f1c1e..da937d1 100644
--- a/lib/a2mp.h
+++ b/lib/a2mp.h
@@ -142,44 +142,6 @@ struct a2mp_disconn_rsp {
 #define A2MP_STATUS_PHYS_LINK_EXISTS			0x05
 #define A2MP_STATUS_SECURITY_VIOLATION			0x06
 
-#define A2MP_MAC_ADDR_TYPE		1
-#define A2MP_PREF_CHANLIST_TYPE		2
-#define A2MP_CONNECTED_CHAN		3
-#define A2MP_PAL_CAP_TYPE		4
-#define A2MP_PAL_VER_INFO		5
-
-struct a2mp_tlv {
-	uint8_t type;
-	uint16_t len;
-	uint8_t val[0];
-} __attribute__ ((packed));
-
-struct a2mp_pal_ver {
-	uint8_t ver;
-	uint16_t company_id;
-	uint16_t sub_ver;
-} __attribute__ ((packed));
-
-struct a2mp_country_triplet {
-	union {
-		struct {
-			uint8_t first_channel;
-			uint8_t num_channels;
-			int8_t max_power;
-		} __attribute__ ((packed)) chans;
-		struct {
-			uint8_t reg_extension_id;
-			uint8_t reg_class;
-			uint8_t coverage_class;
-		} __attribute__ ((packed)) ext;
-	};
-} __attribute__ ((packed));
-
-struct a2mp_chan_list {
-	uint8_t country_code[3];
-	struct a2mp_country_triplet triplets[0];
-} __attribute__ ((packed));
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/amp.h b/lib/amp.h
new file mode 100644
index 0000000..f364f85
--- /dev/null
+++ b/lib/amp.h
@@ -0,0 +1,174 @@
+/*
+ *
+ *	BlueZ - Bluetooth protocol stack for Linux
+ *
+ *	Copyright (C) 2010-2011 Code Aurora Forum.  All rights reserved.
+ *	Copyright (C) 2012 Intel Corp.
+ *
+ *	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 __AMP_H
+#define __AMP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AMP_MGR_CID 0x03
+
+/* AMP manager codes */
+#define AMP_COMMAND_REJ		0x01
+#define AMP_DISCOVER_REQ	0x02
+#define AMP_DISCOVER_RSP	0x03
+#define AMP_CHANGE_NOTIFY	0x04
+#define AMP_CHANGE_RSP		0x05
+#define AMP_INFO_REQ		0x06
+#define AMP_INFO_RSP		0x07
+#define AMP_ASSOC_REQ		0x08
+#define AMP_ASSOC_RSP		0x09
+#define AMP_LINK_REQ		0x0a
+#define AMP_LINK_RSP		0x0b
+#define AMP_DISCONN_REQ		0x0c
+#define AMP_DISCONN_RSP		0x0d
+
+typedef struct {
+	uint8_t		code;
+	uint8_t		ident;
+	uint16_t	len;
+} __attribute__ ((packed)) amp_mgr_hdr;
+#define AMP_MGR_HDR_SIZE 4
+
+/* AMP ASSOC structure */
+typedef struct {
+	uint8_t		type_id;
+	uint16_t	len;
+	uint8_t		data[0];
+} __attribute__ ((packed)) amp_assoc_tlv;
+
+typedef struct {
+	uint16_t	reason;
+} __attribute__ ((packed)) amp_cmd_rej_parms;
+
+typedef struct {
+	uint16_t	mtu;
+	uint16_t	mask;
+} __attribute__ ((packed)) amp_discover_req_parms;
+
+typedef struct {
+	uint16_t	mtu;
+	uint16_t	mask;
+	uint8_t		controller_list[0];
+} __attribute__ ((packed)) amp_discover_rsp_parms;
+
+typedef struct {
+	uint8_t		id;
+} __attribute__ ((packed)) amp_info_req_parms;
+
+typedef struct {
+	uint8_t		id;
+	uint8_t		status;
+	uint32_t	total_bandwidth;
+	uint32_t	max_bandwidth;
+	uint32_t	min_latency;
+	uint16_t	pal_caps;
+	uint16_t	assoc_size;
+} __attribute__ ((packed)) amp_info_rsp_parms;
+
+typedef struct {
+	uint8_t		id;
+	uint8_t		status;
+	amp_assoc_tlv	assoc;
+} __attribute__ ((packed)) amp_assoc_rsp_parms;
+
+typedef struct {
+	uint8_t		local_id;
+	uint8_t		remote_id;
+	amp_assoc_tlv	assoc;
+} __attribute__ ((packed)) amp_link_req_parms;
+
+typedef struct {
+	uint8_t		local_id;
+	uint8_t		remote_id;
+	uint8_t		status;
+} __attribute__ ((packed)) amp_link_rsp_parms;
+
+typedef struct {
+	uint8_t		local_id;
+	uint8_t		remote_id;
+} __attribute__ ((packed)) amp_disconn_req_parms;
+
+#define A2MP_MAC_ADDR_TYPE		1
+#define A2MP_PREF_CHANLIST_TYPE		2
+#define A2MP_CONNECTED_CHAN		3
+#define A2MP_PAL_CAP_TYPE		4
+#define A2MP_PAL_VER_INFO		5
+
+struct amp_tlv {
+	uint8_t type;
+	uint16_t len;
+	uint8_t val[0];
+} __attribute__ ((packed));
+
+struct amp_pal_ver {
+	uint8_t ver;
+	uint16_t company_id;
+	uint16_t sub_ver;
+} __attribute__ ((packed));
+
+struct amp_country_triplet {
+	union {
+		struct {
+			uint8_t first_channel;
+			uint8_t num_channels;
+			int8_t max_power;
+		} __attribute__ ((packed)) chans;
+		struct {
+			uint8_t reg_extension_id;
+			uint8_t reg_class;
+			uint8_t coverage_class;
+		} __attribute__ ((packed)) ext;
+	};
+} __attribute__ ((packed));
+
+struct amp_chan_list {
+	uint8_t country_code[3];
+	struct amp_country_triplet triplets[0];
+} __attribute__ ((packed));
+
+#define AMP_COMMAND_NOT_RECOGNIZED 0x0000
+
+/* AMP controller status */
+#define AMP_CT_POWERED_DOWN		0x00
+#define AMP_CT_BLUETOOTH_ONLY		0x01
+#define AMP_CT_NO_CAPACITY		0x02
+#define AMP_CT_LOW_CAPACITY		0x03
+#define AMP_CT_MEDIUM_CAPACITY		0x04
+#define AMP_CT_HIGH_CAPACITY		0x05
+#define AMP_CT_FULL_CAPACITY		0x06
+
+/* AMP response status */
+#define AMP_STATUS_SUCCESS				0x00
+#define AMP_STATUS_INVALID_CTRL_ID			0x01
+#define AMP_STATUS_UNABLE_START_LINK_CREATION		0x02
+#define AMP_STATUS_NO_PHYSICAL_LINK_EXISTS		0x02
+#define AMP_STATUS_COLLISION_OCCURED			0x03
+#define AMP_STATUS_DISCONN_REQ_RECVD			0x04
+#define AMP_STATUS_PHYS_LINK_EXISTS			0x05
+#define AMP_STATUS_SECURITY_VIOLATION			0x06
+
+void amp_assoc_dump(int level, uint8_t *assoc, uint16_t len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AMP_H */
-- 
1.7.9.5


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

* [PATCHv2 hcidump 2/4] Fix number of triplet calculation
  2012-06-05  9:09 [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions Andrei Emeltchenko
@ 2012-06-05  9:09 ` Andrei Emeltchenko
  2012-06-05  9:09 ` [PATCHv2 hcidump 3/4] Make assoc dump function available for HCI parser Andrei Emeltchenko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Andrei Emeltchenko @ 2012-06-05  9:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Country code is also included in the TLV size.
---
 parser/l2cap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parser/l2cap.c b/parser/l2cap.c
index 056e2a6..f6ed91d 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -1168,7 +1168,7 @@ static void a2mp_dump_chanlist(int level, struct a2mp_tlv *tlv, char *prefix)
 	struct a2mp_country_triplet *triplet;
 	int i, num;
 
-	num = tlv->len / sizeof(*triplet);
+	num = (tlv->len - sizeof(*chan_list)) / sizeof(*triplet);
 
 	printf("%s number of triplets %d\n", prefix, num);
 
-- 
1.7.9.5


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

* [PATCHv2 hcidump 3/4] Make assoc dump function available for HCI parser
  2012-06-05  9:09 [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions Andrei Emeltchenko
  2012-06-05  9:09 ` [PATCHv2 hcidump 2/4] Fix number of triplet calculation Andrei Emeltchenko
@ 2012-06-05  9:09 ` Andrei Emeltchenko
  2012-06-05  9:09 ` [PATCHv2 hcidump 4/4] Add decoding AMP Assoc data in " Andrei Emeltchenko
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Andrei Emeltchenko @ 2012-06-05  9:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

AMP Assoc dump will be used for HCI dump functions
---
 Makefile.am    |    3 +-
 parser/amp.c   |  127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 parser/l2cap.c |  104 ++--------------------------------------------
 3 files changed, 132 insertions(+), 102 deletions(-)
 create mode 100644 parser/amp.c

diff --git a/Makefile.am b/Makefile.am
index 80d04e8..64927d1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,7 +26,8 @@ parser_sources =  parser/parser.h parser/parser.c \
 					parser/tcpip.c \
 					parser/ericsson.c \
 					parser/csr.c \
-					parser/bpa.c
+					parser/bpa.c \
+					parser/amp.c
 
 
 sbin_PROGRAMS = src/hcidump
diff --git a/parser/amp.c b/parser/amp.c
new file mode 100644
index 0000000..9e0f7f3
--- /dev/null
+++ b/parser/amp.c
@@ -0,0 +1,127 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2012  Intel Corp.
+ *
+ *  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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "parser/parser.h"
+#include "lib/amp.h"
+
+void amp_dump_chanlist(int level, struct amp_tlv *tlv, char *prefix)
+{
+	struct amp_chan_list *chan_list = (void *) tlv->val;
+	struct amp_country_triplet *triplet;
+	int i, num;
+
+	num = (tlv->len - sizeof(*chan_list)) / sizeof(*triplet);
+
+	printf("%s (number of triplets %d)\n", prefix, num);
+
+	p_indent(level+2, 0);
+
+	printf("Country code: %c%c%c\n", chan_list->country_code[0],
+		chan_list->country_code[1], chan_list->country_code[2]);
+
+	for (i = 0; i < num; i++) {
+		triplet = &chan_list->triplets[i];
+
+		p_indent(level+2, 0);
+
+		if (triplet->chans.first_channel >= 201) {
+			printf("Reg ext id %d reg class %d coverage class %d\n",
+						triplet->ext.reg_extension_id,
+						triplet->ext.reg_class,
+						triplet->ext.coverage_class);
+		} else {
+			if (triplet->chans.num_channels == 1)
+				printf("Channel %d max power %d\n",
+						triplet->chans.first_channel,
+						triplet->chans.max_power);
+			else
+				printf("Channels %d - %d max power %d\n",
+						triplet->chans.first_channel,
+						triplet->chans.first_channel +
+						triplet->chans.num_channels,
+						triplet->chans.max_power);
+		}
+	}
+}
+
+void amp_assoc_dump(int level, uint8_t *assoc, uint16_t len)
+{
+	struct amp_tlv *tlv = (void *) assoc;
+
+	p_indent(level, 0);
+	printf("Assoc data [len %d]:\n", len);
+
+	while (len > sizeof(*tlv)) {
+		uint16_t tlvlen = btohs(tlv->len);
+		struct amp_pal_ver *ver;
+
+		p_indent(level+1, 0);
+
+		switch (tlv->type) {
+		case A2MP_MAC_ADDR_TYPE:
+			if (tlvlen != 6)
+				break;
+			printf("MAC: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+					tlv->val[0], tlv->val[1], tlv->val[2],
+					tlv->val[3], tlv->val[4], tlv->val[5]);
+			break;
+
+		case A2MP_PREF_CHANLIST_TYPE:
+			amp_dump_chanlist(level, tlv, "Preferred Chan List");
+			break;
+
+		case A2MP_CONNECTED_CHAN:
+			amp_dump_chanlist(level, tlv, "Connected Chan List");
+			break;
+
+		case A2MP_PAL_CAP_TYPE:
+			if (tlvlen != 4)
+				break;
+			printf("PAL CAP: %2.2x %2.2x %2.2x %2.2x\n",
+					tlv->val[0], tlv->val[1], tlv->val[2],
+					tlv->val[3]);
+			break;
+
+		case A2MP_PAL_VER_INFO:
+			if (tlvlen != 5)
+				break;
+			ver = (struct amp_pal_ver *) tlv->val;
+			printf("PAL VER: %2.2x Comp ID: %4.4x SubVer: %4.4x\n",
+					ver->ver, btohs(ver->company_id),
+					btohs(ver->sub_ver));
+			break;
+
+		default:
+			printf("Unrecognized type %d\n", tlv->type);
+			break;
+		}
+
+		len -= tlvlen + sizeof(*tlv);
+		assoc += tlvlen + sizeof(*tlv);
+		tlv = (struct amp_tlv *) assoc;
+	}
+}
+
diff --git a/parser/l2cap.c b/parser/l2cap.c
index f6ed91d..cfe8834 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -38,6 +38,7 @@
 #include "lib/hci.h"
 #include "lib/l2cap.h"
 #include "lib/a2mp.h"
+#include "lib/amp.h"
 
 typedef struct {
 	uint16_t handle;
@@ -1162,112 +1163,13 @@ static inline void a2mp_assoc_req(int level, struct frame *frm)
 	printf("Get AMP Assoc req: id %d\n", h->id);
 }
 
-static void a2mp_dump_chanlist(int level, struct a2mp_tlv *tlv, char *prefix)
-{
-	struct a2mp_chan_list *chan_list = (struct a2mp_chan_list *) tlv->val;
-	struct a2mp_country_triplet *triplet;
-	int i, num;
-
-	num = (tlv->len - sizeof(*chan_list)) / sizeof(*triplet);
-
-	printf("%s number of triplets %d\n", prefix, num);
-
-	p_indent(level+2, 0);
-
-	printf("Country code: %c%c%c\n", chan_list->country_code[0],
-		chan_list->country_code[1], chan_list->country_code[2]);
-
-	for (i = 0; i < num; i++) {
-		triplet = &chan_list->triplets[i];
-
-		p_indent(level+2, 0);
-
-		if (triplet->chans.first_channel >= 201) {
-			printf("Reg ext id %d reg class %d coverage class %d\n",
-						triplet->ext.reg_extension_id,
-						triplet->ext.reg_class,
-						triplet->ext.coverage_class);
-		} else {
-			if (triplet->chans.num_channels == 1)
-				printf("Channel %d max power %d\n",
-						triplet->chans.first_channel,
-						triplet->chans.max_power);
-			else
-				printf("Channels %d - %d max power %d\n",
-						triplet->chans.first_channel,
-						triplet->chans.first_channel +
-						triplet->chans.num_channels,
-						triplet->chans.max_power);
-		}
-	}
-}
-
-static inline void a2mp_assoc_dump(int level, uint8_t *assoc, uint16_t len)
-{
-	struct a2mp_tlv *tlv;
-
-	p_indent(level, 0);
-	printf("Assoc data [len %d]:\n", len);
-
-	tlv = (struct a2mp_tlv *) assoc;
-	while (len > sizeof(*tlv)) {
-		uint16_t tlvlen = btohs(tlv->len);
-		struct a2mp_pal_ver *ver;
-
-		p_indent(level+1, 0);
-
-		switch (tlv->type) {
-		case A2MP_MAC_ADDR_TYPE:
-			if (tlvlen != 6)
-				break;
-			printf("MAC: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
-					tlv->val[0], tlv->val[1], tlv->val[2],
-					tlv->val[3], tlv->val[4], tlv->val[5]);
-			break;
-
-		case A2MP_PREF_CHANLIST_TYPE:
-			a2mp_dump_chanlist(level, tlv, "Preferred Chan List");
-			break;
-
-		case A2MP_CONNECTED_CHAN:
-			a2mp_dump_chanlist(level, tlv, "Connected Chan List");
-			break;
-
-		case A2MP_PAL_CAP_TYPE:
-			if (tlvlen != 4)
-				break;
-			printf("PAL CAP: %2.2x %2.2x %2.2x %2.2x\n",
-					tlv->val[0], tlv->val[1], tlv->val[2],
-					tlv->val[3]);
-			break;
-
-		case A2MP_PAL_VER_INFO:
-			if (tlvlen != 5)
-				break;
-			ver = (struct a2mp_pal_ver *) tlv->val;
-			printf("PAL VER: %2.2x Comp ID: %4.4x SubVer: %4.4x\n",
-					ver->ver, btohs(ver->company_id),
-					btohs(ver->sub_ver));
-			break;
-
-		default:
-			printf("Unrecognized type %d\n", tlv->type);
-			break;
-		}
-
-		len -= tlvlen + sizeof(*tlv);
-		assoc += tlvlen + sizeof(*tlv);
-		tlv = (struct a2mp_tlv *) assoc;
-	}
-}
-
 static inline void a2mp_assoc_rsp(int level, struct frame *frm, uint16_t len)
 {
 	struct a2mp_assoc_rsp *h = frm->ptr;
 
 	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);
+	amp_assoc_dump(level + 1, h->assoc_data, len - sizeof(*h));
 }
 
 static inline void a2mp_create_req(int level, struct frame *frm, uint16_t len)
@@ -1276,7 +1178,7 @@ static inline void a2mp_create_req(int level, struct frame *frm, uint16_t len)
 
 	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);
+	amp_assoc_dump(level + 1, h->assoc_data, len - sizeof(*h));
 }
 
 static inline void a2mp_create_rsp(int level, struct frame *frm)
-- 
1.7.9.5


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

* [PATCHv2 hcidump 4/4] Add decoding AMP Assoc data in HCI parser
  2012-06-05  9:09 [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions Andrei Emeltchenko
  2012-06-05  9:09 ` [PATCHv2 hcidump 2/4] Fix number of triplet calculation Andrei Emeltchenko
  2012-06-05  9:09 ` [PATCHv2 hcidump 3/4] Make assoc dump function available for HCI parser Andrei Emeltchenko
@ 2012-06-05  9:09 ` Andrei Emeltchenko
  2012-06-14  7:25 ` [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions Andrei Emeltchenko
  2012-06-28 13:09 ` [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data Andrei Emeltchenko
  4 siblings, 0 replies; 11+ messages in thread
From: Andrei Emeltchenko @ 2012-06-05  9:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 parser/hci.c |   13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/parser/hci.c b/parser/hci.c
index 984b554..5b837e9 100644
--- a/parser/hci.c
+++ b/parser/hci.c
@@ -36,6 +36,7 @@
 #include "parser/parser.h"
 #include "lib/hci.h"
 #include "lib/hci_lib.h"
+#include "lib/amp.h"
 
 static uint16_t manufacturer = DEFAULT_COMPID;
 
@@ -2599,7 +2600,6 @@ static inline void read_local_amp_assoc_dump(int level, struct frame *frm)
 {
 	read_local_amp_assoc_rp *rp = frm->ptr;
 	uint16_t len = btohs(rp->length);
-	int i;
 
 	p_indent(level, frm);
 	printf("status 0x%2.2x handle 0x%2.2x remaining len %d\n",
@@ -2608,16 +2608,7 @@ 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");
-				p_indent(level, frm);
-			}
-			printf("%2.2x ", rp->fragment[i]);
-		}
-		printf("\n");
+		amp_assoc_dump(level + 1, rp->fragment, len);
 	}
 }
 
-- 
1.7.9.5


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

* Re: [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions
  2012-06-05  9:09 [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions Andrei Emeltchenko
                   ` (2 preceding siblings ...)
  2012-06-05  9:09 ` [PATCHv2 hcidump 4/4] Add decoding AMP Assoc data in " Andrei Emeltchenko
@ 2012-06-14  7:25 ` Andrei Emeltchenko
  2012-06-26 12:02   ` Andrei Emeltchenko
  2012-06-28 13:09 ` [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data Andrei Emeltchenko
  4 siblings, 1 reply; 11+ messages in thread
From: Andrei Emeltchenko @ 2012-06-14  7:25 UTC (permalink / raw)
  To: linux-bluetooth

On Tue, Jun 05, 2012 at 12:09:18PM +0300, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

ping

> 
> ---
>  lib/a2mp.h |   38 -------------
>  lib/amp.h  |  174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 174 insertions(+), 38 deletions(-)
>  create mode 100644 lib/amp.h
> 
> diff --git a/lib/a2mp.h b/lib/a2mp.h
> index 61f1c1e..da937d1 100644
> --- a/lib/a2mp.h
> +++ b/lib/a2mp.h
> @@ -142,44 +142,6 @@ struct a2mp_disconn_rsp {
>  #define A2MP_STATUS_PHYS_LINK_EXISTS			0x05
>  #define A2MP_STATUS_SECURITY_VIOLATION			0x06
>  
> -#define A2MP_MAC_ADDR_TYPE		1
> -#define A2MP_PREF_CHANLIST_TYPE		2
> -#define A2MP_CONNECTED_CHAN		3
> -#define A2MP_PAL_CAP_TYPE		4
> -#define A2MP_PAL_VER_INFO		5
> -
> -struct a2mp_tlv {
> -	uint8_t type;
> -	uint16_t len;
> -	uint8_t val[0];
> -} __attribute__ ((packed));
> -
> -struct a2mp_pal_ver {
> -	uint8_t ver;
> -	uint16_t company_id;
> -	uint16_t sub_ver;
> -} __attribute__ ((packed));
> -
> -struct a2mp_country_triplet {
> -	union {
> -		struct {
> -			uint8_t first_channel;
> -			uint8_t num_channels;
> -			int8_t max_power;
> -		} __attribute__ ((packed)) chans;
> -		struct {
> -			uint8_t reg_extension_id;
> -			uint8_t reg_class;
> -			uint8_t coverage_class;
> -		} __attribute__ ((packed)) ext;
> -	};
> -} __attribute__ ((packed));
> -
> -struct a2mp_chan_list {
> -	uint8_t country_code[3];
> -	struct a2mp_country_triplet triplets[0];
> -} __attribute__ ((packed));
> -
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/amp.h b/lib/amp.h
> new file mode 100644
> index 0000000..f364f85
> --- /dev/null
> +++ b/lib/amp.h
> @@ -0,0 +1,174 @@
> +/*
> + *
> + *	BlueZ - Bluetooth protocol stack for Linux
> + *
> + *	Copyright (C) 2010-2011 Code Aurora Forum.  All rights reserved.
> + *	Copyright (C) 2012 Intel Corp.
> + *
> + *	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 __AMP_H
> +#define __AMP_H
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#define AMP_MGR_CID 0x03
> +
> +/* AMP manager codes */
> +#define AMP_COMMAND_REJ		0x01
> +#define AMP_DISCOVER_REQ	0x02
> +#define AMP_DISCOVER_RSP	0x03
> +#define AMP_CHANGE_NOTIFY	0x04
> +#define AMP_CHANGE_RSP		0x05
> +#define AMP_INFO_REQ		0x06
> +#define AMP_INFO_RSP		0x07
> +#define AMP_ASSOC_REQ		0x08
> +#define AMP_ASSOC_RSP		0x09
> +#define AMP_LINK_REQ		0x0a
> +#define AMP_LINK_RSP		0x0b
> +#define AMP_DISCONN_REQ		0x0c
> +#define AMP_DISCONN_RSP		0x0d
> +
> +typedef struct {
> +	uint8_t		code;
> +	uint8_t		ident;
> +	uint16_t	len;
> +} __attribute__ ((packed)) amp_mgr_hdr;
> +#define AMP_MGR_HDR_SIZE 4
> +
> +/* AMP ASSOC structure */
> +typedef struct {
> +	uint8_t		type_id;
> +	uint16_t	len;
> +	uint8_t		data[0];
> +} __attribute__ ((packed)) amp_assoc_tlv;
> +
> +typedef struct {
> +	uint16_t	reason;
> +} __attribute__ ((packed)) amp_cmd_rej_parms;
> +
> +typedef struct {
> +	uint16_t	mtu;
> +	uint16_t	mask;
> +} __attribute__ ((packed)) amp_discover_req_parms;
> +
> +typedef struct {
> +	uint16_t	mtu;
> +	uint16_t	mask;
> +	uint8_t		controller_list[0];
> +} __attribute__ ((packed)) amp_discover_rsp_parms;
> +
> +typedef struct {
> +	uint8_t		id;
> +} __attribute__ ((packed)) amp_info_req_parms;
> +
> +typedef struct {
> +	uint8_t		id;
> +	uint8_t		status;
> +	uint32_t	total_bandwidth;
> +	uint32_t	max_bandwidth;
> +	uint32_t	min_latency;
> +	uint16_t	pal_caps;
> +	uint16_t	assoc_size;
> +} __attribute__ ((packed)) amp_info_rsp_parms;
> +
> +typedef struct {
> +	uint8_t		id;
> +	uint8_t		status;
> +	amp_assoc_tlv	assoc;
> +} __attribute__ ((packed)) amp_assoc_rsp_parms;
> +
> +typedef struct {
> +	uint8_t		local_id;
> +	uint8_t		remote_id;
> +	amp_assoc_tlv	assoc;
> +} __attribute__ ((packed)) amp_link_req_parms;
> +
> +typedef struct {
> +	uint8_t		local_id;
> +	uint8_t		remote_id;
> +	uint8_t		status;
> +} __attribute__ ((packed)) amp_link_rsp_parms;
> +
> +typedef struct {
> +	uint8_t		local_id;
> +	uint8_t		remote_id;
> +} __attribute__ ((packed)) amp_disconn_req_parms;
> +
> +#define A2MP_MAC_ADDR_TYPE		1
> +#define A2MP_PREF_CHANLIST_TYPE		2
> +#define A2MP_CONNECTED_CHAN		3
> +#define A2MP_PAL_CAP_TYPE		4
> +#define A2MP_PAL_VER_INFO		5
> +
> +struct amp_tlv {
> +	uint8_t type;
> +	uint16_t len;
> +	uint8_t val[0];
> +} __attribute__ ((packed));
> +
> +struct amp_pal_ver {
> +	uint8_t ver;
> +	uint16_t company_id;
> +	uint16_t sub_ver;
> +} __attribute__ ((packed));
> +
> +struct amp_country_triplet {
> +	union {
> +		struct {
> +			uint8_t first_channel;
> +			uint8_t num_channels;
> +			int8_t max_power;
> +		} __attribute__ ((packed)) chans;
> +		struct {
> +			uint8_t reg_extension_id;
> +			uint8_t reg_class;
> +			uint8_t coverage_class;
> +		} __attribute__ ((packed)) ext;
> +	};
> +} __attribute__ ((packed));
> +
> +struct amp_chan_list {
> +	uint8_t country_code[3];
> +	struct amp_country_triplet triplets[0];
> +} __attribute__ ((packed));
> +
> +#define AMP_COMMAND_NOT_RECOGNIZED 0x0000
> +
> +/* AMP controller status */
> +#define AMP_CT_POWERED_DOWN		0x00
> +#define AMP_CT_BLUETOOTH_ONLY		0x01
> +#define AMP_CT_NO_CAPACITY		0x02
> +#define AMP_CT_LOW_CAPACITY		0x03
> +#define AMP_CT_MEDIUM_CAPACITY		0x04
> +#define AMP_CT_HIGH_CAPACITY		0x05
> +#define AMP_CT_FULL_CAPACITY		0x06
> +
> +/* AMP response status */
> +#define AMP_STATUS_SUCCESS				0x00
> +#define AMP_STATUS_INVALID_CTRL_ID			0x01
> +#define AMP_STATUS_UNABLE_START_LINK_CREATION		0x02
> +#define AMP_STATUS_NO_PHYSICAL_LINK_EXISTS		0x02
> +#define AMP_STATUS_COLLISION_OCCURED			0x03
> +#define AMP_STATUS_DISCONN_REQ_RECVD			0x04
> +#define AMP_STATUS_PHYS_LINK_EXISTS			0x05
> +#define AMP_STATUS_SECURITY_VIOLATION			0x06
> +
> +void amp_assoc_dump(int level, uint8_t *assoc, uint16_t len);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* __AMP_H */
> -- 
> 1.7.9.5
> 
> --
> 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] 11+ messages in thread

* Re: [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions
  2012-06-14  7:25 ` [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions Andrei Emeltchenko
@ 2012-06-26 12:02   ` Andrei Emeltchenko
  0 siblings, 0 replies; 11+ messages in thread
From: Andrei Emeltchenko @ 2012-06-26 12:02 UTC (permalink / raw)
  To: linux-bluetooth

On Thu, Jun 14, 2012 at 10:25:14AM +0300, Andrei Emeltchenko wrote:
> On Tue, Jun 05, 2012 at 12:09:18PM +0300, Andrei Emeltchenko wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> ping

ping

> 
> > 
> > ---
> >  lib/a2mp.h |   38 -------------
> >  lib/amp.h  |  174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 174 insertions(+), 38 deletions(-)
> >  create mode 100644 lib/amp.h
> > 
> > diff --git a/lib/a2mp.h b/lib/a2mp.h
> > index 61f1c1e..da937d1 100644
> > --- a/lib/a2mp.h
> > +++ b/lib/a2mp.h
> > @@ -142,44 +142,6 @@ struct a2mp_disconn_rsp {
> >  #define A2MP_STATUS_PHYS_LINK_EXISTS			0x05
> >  #define A2MP_STATUS_SECURITY_VIOLATION			0x06
> >  
> > -#define A2MP_MAC_ADDR_TYPE		1
> > -#define A2MP_PREF_CHANLIST_TYPE		2
> > -#define A2MP_CONNECTED_CHAN		3
> > -#define A2MP_PAL_CAP_TYPE		4
> > -#define A2MP_PAL_VER_INFO		5
> > -
> > -struct a2mp_tlv {
> > -	uint8_t type;
> > -	uint16_t len;
> > -	uint8_t val[0];
> > -} __attribute__ ((packed));
> > -
> > -struct a2mp_pal_ver {
> > -	uint8_t ver;
> > -	uint16_t company_id;
> > -	uint16_t sub_ver;
> > -} __attribute__ ((packed));
> > -
> > -struct a2mp_country_triplet {
> > -	union {
> > -		struct {
> > -			uint8_t first_channel;
> > -			uint8_t num_channels;
> > -			int8_t max_power;
> > -		} __attribute__ ((packed)) chans;
> > -		struct {
> > -			uint8_t reg_extension_id;
> > -			uint8_t reg_class;
> > -			uint8_t coverage_class;
> > -		} __attribute__ ((packed)) ext;
> > -	};
> > -} __attribute__ ((packed));
> > -
> > -struct a2mp_chan_list {
> > -	uint8_t country_code[3];
> > -	struct a2mp_country_triplet triplets[0];
> > -} __attribute__ ((packed));
> > -
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > diff --git a/lib/amp.h b/lib/amp.h
> > new file mode 100644
> > index 0000000..f364f85
> > --- /dev/null
> > +++ b/lib/amp.h
> > @@ -0,0 +1,174 @@
> > +/*
> > + *
> > + *	BlueZ - Bluetooth protocol stack for Linux
> > + *
> > + *	Copyright (C) 2010-2011 Code Aurora Forum.  All rights reserved.
> > + *	Copyright (C) 2012 Intel Corp.
> > + *
> > + *	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 __AMP_H
> > +#define __AMP_H
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +#define AMP_MGR_CID 0x03
> > +
> > +/* AMP manager codes */
> > +#define AMP_COMMAND_REJ		0x01
> > +#define AMP_DISCOVER_REQ	0x02
> > +#define AMP_DISCOVER_RSP	0x03
> > +#define AMP_CHANGE_NOTIFY	0x04
> > +#define AMP_CHANGE_RSP		0x05
> > +#define AMP_INFO_REQ		0x06
> > +#define AMP_INFO_RSP		0x07
> > +#define AMP_ASSOC_REQ		0x08
> > +#define AMP_ASSOC_RSP		0x09
> > +#define AMP_LINK_REQ		0x0a
> > +#define AMP_LINK_RSP		0x0b
> > +#define AMP_DISCONN_REQ		0x0c
> > +#define AMP_DISCONN_RSP		0x0d
> > +
> > +typedef struct {
> > +	uint8_t		code;
> > +	uint8_t		ident;
> > +	uint16_t	len;
> > +} __attribute__ ((packed)) amp_mgr_hdr;
> > +#define AMP_MGR_HDR_SIZE 4
> > +
> > +/* AMP ASSOC structure */
> > +typedef struct {
> > +	uint8_t		type_id;
> > +	uint16_t	len;
> > +	uint8_t		data[0];
> > +} __attribute__ ((packed)) amp_assoc_tlv;
> > +
> > +typedef struct {
> > +	uint16_t	reason;
> > +} __attribute__ ((packed)) amp_cmd_rej_parms;
> > +
> > +typedef struct {
> > +	uint16_t	mtu;
> > +	uint16_t	mask;
> > +} __attribute__ ((packed)) amp_discover_req_parms;
> > +
> > +typedef struct {
> > +	uint16_t	mtu;
> > +	uint16_t	mask;
> > +	uint8_t		controller_list[0];
> > +} __attribute__ ((packed)) amp_discover_rsp_parms;
> > +
> > +typedef struct {
> > +	uint8_t		id;
> > +} __attribute__ ((packed)) amp_info_req_parms;
> > +
> > +typedef struct {
> > +	uint8_t		id;
> > +	uint8_t		status;
> > +	uint32_t	total_bandwidth;
> > +	uint32_t	max_bandwidth;
> > +	uint32_t	min_latency;
> > +	uint16_t	pal_caps;
> > +	uint16_t	assoc_size;
> > +} __attribute__ ((packed)) amp_info_rsp_parms;
> > +
> > +typedef struct {
> > +	uint8_t		id;
> > +	uint8_t		status;
> > +	amp_assoc_tlv	assoc;
> > +} __attribute__ ((packed)) amp_assoc_rsp_parms;
> > +
> > +typedef struct {
> > +	uint8_t		local_id;
> > +	uint8_t		remote_id;
> > +	amp_assoc_tlv	assoc;
> > +} __attribute__ ((packed)) amp_link_req_parms;
> > +
> > +typedef struct {
> > +	uint8_t		local_id;
> > +	uint8_t		remote_id;
> > +	uint8_t		status;
> > +} __attribute__ ((packed)) amp_link_rsp_parms;
> > +
> > +typedef struct {
> > +	uint8_t		local_id;
> > +	uint8_t		remote_id;
> > +} __attribute__ ((packed)) amp_disconn_req_parms;
> > +
> > +#define A2MP_MAC_ADDR_TYPE		1
> > +#define A2MP_PREF_CHANLIST_TYPE		2
> > +#define A2MP_CONNECTED_CHAN		3
> > +#define A2MP_PAL_CAP_TYPE		4
> > +#define A2MP_PAL_VER_INFO		5
> > +
> > +struct amp_tlv {
> > +	uint8_t type;
> > +	uint16_t len;
> > +	uint8_t val[0];
> > +} __attribute__ ((packed));
> > +
> > +struct amp_pal_ver {
> > +	uint8_t ver;
> > +	uint16_t company_id;
> > +	uint16_t sub_ver;
> > +} __attribute__ ((packed));
> > +
> > +struct amp_country_triplet {
> > +	union {
> > +		struct {
> > +			uint8_t first_channel;
> > +			uint8_t num_channels;
> > +			int8_t max_power;
> > +		} __attribute__ ((packed)) chans;
> > +		struct {
> > +			uint8_t reg_extension_id;
> > +			uint8_t reg_class;
> > +			uint8_t coverage_class;
> > +		} __attribute__ ((packed)) ext;
> > +	};
> > +} __attribute__ ((packed));
> > +
> > +struct amp_chan_list {
> > +	uint8_t country_code[3];
> > +	struct amp_country_triplet triplets[0];
> > +} __attribute__ ((packed));
> > +
> > +#define AMP_COMMAND_NOT_RECOGNIZED 0x0000
> > +
> > +/* AMP controller status */
> > +#define AMP_CT_POWERED_DOWN		0x00
> > +#define AMP_CT_BLUETOOTH_ONLY		0x01
> > +#define AMP_CT_NO_CAPACITY		0x02
> > +#define AMP_CT_LOW_CAPACITY		0x03
> > +#define AMP_CT_MEDIUM_CAPACITY		0x04
> > +#define AMP_CT_HIGH_CAPACITY		0x05
> > +#define AMP_CT_FULL_CAPACITY		0x06
> > +
> > +/* AMP response status */
> > +#define AMP_STATUS_SUCCESS				0x00
> > +#define AMP_STATUS_INVALID_CTRL_ID			0x01
> > +#define AMP_STATUS_UNABLE_START_LINK_CREATION		0x02
> > +#define AMP_STATUS_NO_PHYSICAL_LINK_EXISTS		0x02
> > +#define AMP_STATUS_COLLISION_OCCURED			0x03
> > +#define AMP_STATUS_DISCONN_REQ_RECVD			0x04
> > +#define AMP_STATUS_PHYS_LINK_EXISTS			0x05
> > +#define AMP_STATUS_SECURITY_VIOLATION			0x06
> > +
> > +void amp_assoc_dump(int level, uint8_t *assoc, uint16_t len);
> > +
> > +#ifdef __cplusplus
> > +}
> > +#endif
> > +
> > +#endif /* __AMP_H */
> > -- 
> > 1.7.9.5
> > 
> > --
> > 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
> --
> 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] 11+ messages in thread

* [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data
  2012-06-05  9:09 [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions Andrei Emeltchenko
                   ` (3 preceding siblings ...)
  2012-06-14  7:25 ` [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions Andrei Emeltchenko
@ 2012-06-28 13:09 ` Andrei Emeltchenko
  2012-06-28 13:09   ` [PATCHv3 hcidump 2/4] a2mp: Fix number of triplet calculation Andrei Emeltchenko
                     ` (3 more replies)
  4 siblings, 4 replies; 11+ messages in thread
From: Andrei Emeltchenko @ 2012-06-28 13:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 lib/a2mp.h |   38 --------------
 lib/amp.h  |  172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 172 insertions(+), 38 deletions(-)
 create mode 100644 lib/amp.h

diff --git a/lib/a2mp.h b/lib/a2mp.h
index 61f1c1e..da937d1 100644
--- a/lib/a2mp.h
+++ b/lib/a2mp.h
@@ -142,44 +142,6 @@ struct a2mp_disconn_rsp {
 #define A2MP_STATUS_PHYS_LINK_EXISTS			0x05
 #define A2MP_STATUS_SECURITY_VIOLATION			0x06
 
-#define A2MP_MAC_ADDR_TYPE		1
-#define A2MP_PREF_CHANLIST_TYPE		2
-#define A2MP_CONNECTED_CHAN		3
-#define A2MP_PAL_CAP_TYPE		4
-#define A2MP_PAL_VER_INFO		5
-
-struct a2mp_tlv {
-	uint8_t type;
-	uint16_t len;
-	uint8_t val[0];
-} __attribute__ ((packed));
-
-struct a2mp_pal_ver {
-	uint8_t ver;
-	uint16_t company_id;
-	uint16_t sub_ver;
-} __attribute__ ((packed));
-
-struct a2mp_country_triplet {
-	union {
-		struct {
-			uint8_t first_channel;
-			uint8_t num_channels;
-			int8_t max_power;
-		} __attribute__ ((packed)) chans;
-		struct {
-			uint8_t reg_extension_id;
-			uint8_t reg_class;
-			uint8_t coverage_class;
-		} __attribute__ ((packed)) ext;
-	};
-} __attribute__ ((packed));
-
-struct a2mp_chan_list {
-	uint8_t country_code[3];
-	struct a2mp_country_triplet triplets[0];
-} __attribute__ ((packed));
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/amp.h b/lib/amp.h
new file mode 100644
index 0000000..27aab1d
--- /dev/null
+++ b/lib/amp.h
@@ -0,0 +1,172 @@
+/*
+ *
+ *	BlueZ - Bluetooth protocol stack for Linux
+ *
+ *	Copyright (C) 2010-2011 Code Aurora Forum.  All rights reserved.
+ *	Copyright (C) 2012 Intel Corporation.
+ *
+ *	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 __AMP_H
+#define __AMP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AMP_MGR_CID 0x03
+
+/* AMP manager codes */
+#define AMP_COMMAND_REJ		0x01
+#define AMP_DISCOVER_REQ	0x02
+#define AMP_DISCOVER_RSP	0x03
+#define AMP_CHANGE_NOTIFY	0x04
+#define AMP_CHANGE_RSP		0x05
+#define AMP_INFO_REQ		0x06
+#define AMP_INFO_RSP		0x07
+#define AMP_ASSOC_REQ		0x08
+#define AMP_ASSOC_RSP		0x09
+#define AMP_LINK_REQ		0x0a
+#define AMP_LINK_RSP		0x0b
+#define AMP_DISCONN_REQ		0x0c
+#define AMP_DISCONN_RSP		0x0d
+
+typedef struct {
+	uint8_t		code;
+	uint8_t		ident;
+	uint16_t	len;
+} __attribute__ ((packed)) amp_mgr_hdr;
+#define AMP_MGR_HDR_SIZE 4
+
+/* AMP ASSOC structure */
+typedef struct {
+	uint8_t		type_id;
+	uint16_t	len;
+	uint8_t		data[0];
+} __attribute__ ((packed)) amp_assoc_tlv;
+
+typedef struct {
+	uint16_t	reason;
+} __attribute__ ((packed)) amp_cmd_rej_parms;
+
+typedef struct {
+	uint16_t	mtu;
+	uint16_t	mask;
+} __attribute__ ((packed)) amp_discover_req_parms;
+
+typedef struct {
+	uint16_t	mtu;
+	uint16_t	mask;
+	uint8_t		controller_list[0];
+} __attribute__ ((packed)) amp_discover_rsp_parms;
+
+typedef struct {
+	uint8_t		id;
+} __attribute__ ((packed)) amp_info_req_parms;
+
+typedef struct {
+	uint8_t		id;
+	uint8_t		status;
+	uint32_t	total_bandwidth;
+	uint32_t	max_bandwidth;
+	uint32_t	min_latency;
+	uint16_t	pal_caps;
+	uint16_t	assoc_size;
+} __attribute__ ((packed)) amp_info_rsp_parms;
+
+typedef struct {
+	uint8_t		id;
+	uint8_t		status;
+	amp_assoc_tlv	assoc;
+} __attribute__ ((packed)) amp_assoc_rsp_parms;
+
+typedef struct {
+	uint8_t		local_id;
+	uint8_t		remote_id;
+	amp_assoc_tlv	assoc;
+} __attribute__ ((packed)) amp_link_req_parms;
+
+typedef struct {
+	uint8_t		local_id;
+	uint8_t		remote_id;
+	uint8_t		status;
+} __attribute__ ((packed)) amp_link_rsp_parms;
+
+typedef struct {
+	uint8_t		local_id;
+	uint8_t		remote_id;
+} __attribute__ ((packed)) amp_disconn_req_parms;
+
+#define A2MP_MAC_ADDR_TYPE		1
+#define A2MP_PREF_CHANLIST_TYPE		2
+#define A2MP_CONNECTED_CHAN		3
+#define A2MP_PAL_CAP_TYPE		4
+#define A2MP_PAL_VER_INFO		5
+
+struct amp_tlv {
+	uint8_t type;
+	uint16_t len;
+	uint8_t val[0];
+} __attribute__ ((packed));
+
+struct amp_pal_ver {
+	uint8_t ver;
+	uint16_t company_id;
+	uint16_t sub_ver;
+} __attribute__ ((packed));
+
+struct amp_country_triplet {
+	union {
+		struct {
+			uint8_t first_channel;
+			uint8_t num_channels;
+			int8_t max_power;
+		} __attribute__ ((packed)) chans;
+		struct {
+			uint8_t reg_extension_id;
+			uint8_t reg_class;
+			uint8_t coverage_class;
+		} __attribute__ ((packed)) ext;
+	};
+} __attribute__ ((packed));
+
+struct amp_chan_list {
+	uint8_t country_code[3];
+	struct amp_country_triplet triplets[0];
+} __attribute__ ((packed));
+
+#define AMP_COMMAND_NOT_RECOGNIZED 0x0000
+
+/* AMP controller status */
+#define AMP_CT_POWERED_DOWN		0x00
+#define AMP_CT_BLUETOOTH_ONLY		0x01
+#define AMP_CT_NO_CAPACITY		0x02
+#define AMP_CT_LOW_CAPACITY		0x03
+#define AMP_CT_MEDIUM_CAPACITY		0x04
+#define AMP_CT_HIGH_CAPACITY		0x05
+#define AMP_CT_FULL_CAPACITY		0x06
+
+/* AMP response status */
+#define AMP_STATUS_SUCCESS				0x00
+#define AMP_STATUS_INVALID_CTRL_ID			0x01
+#define AMP_STATUS_UNABLE_START_LINK_CREATION		0x02
+#define AMP_STATUS_NO_PHYSICAL_LINK_EXISTS		0x02
+#define AMP_STATUS_COLLISION_OCCURED			0x03
+#define AMP_STATUS_DISCONN_REQ_RECVD			0x04
+#define AMP_STATUS_PHYS_LINK_EXISTS			0x05
+#define AMP_STATUS_SECURITY_VIOLATION			0x06
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AMP_H */
-- 
1.7.9.5


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

* [PATCHv3 hcidump 2/4] a2mp: Fix number of triplet calculation
  2012-06-28 13:09 ` [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data Andrei Emeltchenko
@ 2012-06-28 13:09   ` Andrei Emeltchenko
  2012-06-28 13:09   ` [PATCHv3 hcidump 3/4] a2mp: Make assoc dump function available for HCI parser Andrei Emeltchenko
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Andrei Emeltchenko @ 2012-06-28 13:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Country code is also included in the TLV size.
---
 parser/l2cap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parser/l2cap.c b/parser/l2cap.c
index 056e2a6..f6ed91d 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -1168,7 +1168,7 @@ static void a2mp_dump_chanlist(int level, struct a2mp_tlv *tlv, char *prefix)
 	struct a2mp_country_triplet *triplet;
 	int i, num;
 
-	num = tlv->len / sizeof(*triplet);
+	num = (tlv->len - sizeof(*chan_list)) / sizeof(*triplet);
 
 	printf("%s number of triplets %d\n", prefix, num);
 
-- 
1.7.9.5


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

* [PATCHv3 hcidump 3/4] a2mp: Make assoc dump function available for HCI parser
  2012-06-28 13:09 ` [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data Andrei Emeltchenko
  2012-06-28 13:09   ` [PATCHv3 hcidump 2/4] a2mp: Fix number of triplet calculation Andrei Emeltchenko
@ 2012-06-28 13:09   ` Andrei Emeltchenko
  2012-06-28 13:09   ` [PATCHv3 hcidump 4/4] amp: Add decoding AMP Assoc data in " Andrei Emeltchenko
  2012-06-28 13:19   ` [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data Johan Hedberg
  3 siblings, 0 replies; 11+ messages in thread
From: Andrei Emeltchenko @ 2012-06-28 13:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

AMP Assoc dump will be used also for HCI dump functions
---
 Makefile.am    |    3 +-
 lib/amp.h      |    2 +
 parser/amp.c   |  126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 parser/l2cap.c |  106 ++---------------------------------------------
 4 files changed, 134 insertions(+), 103 deletions(-)
 create mode 100644 parser/amp.c

diff --git a/Makefile.am b/Makefile.am
index 80d04e8..64927d1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,7 +26,8 @@ parser_sources =  parser/parser.h parser/parser.c \
 					parser/tcpip.c \
 					parser/ericsson.c \
 					parser/csr.c \
-					parser/bpa.c
+					parser/bpa.c \
+					parser/amp.c
 
 
 sbin_PROGRAMS = src/hcidump
diff --git a/lib/amp.h b/lib/amp.h
index 27aab1d..711987a 100644
--- a/lib/amp.h
+++ b/lib/amp.h
@@ -165,6 +165,8 @@ struct amp_chan_list {
 #define AMP_STATUS_PHYS_LINK_EXISTS			0x05
 #define AMP_STATUS_SECURITY_VIOLATION			0x06
 
+void amp_assoc_dump(int level, uint8_t *assoc, uint16_t len);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/parser/amp.c b/parser/amp.c
new file mode 100644
index 0000000..deca924
--- /dev/null
+++ b/parser/amp.c
@@ -0,0 +1,126 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2012  Intel Corporation.
+ *
+ *  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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "parser/parser.h"
+#include "lib/amp.h"
+
+static void amp_dump_chanlist(int level, struct amp_tlv *tlv, char *prefix)
+{
+	struct amp_chan_list *chan_list = (void *) tlv->val;
+	struct amp_country_triplet *triplet;
+	int i, num;
+
+	num = (tlv->len - sizeof(*chan_list)) / sizeof(*triplet);
+
+	printf("%s (number of triplets %d)\n", prefix, num);
+
+	p_indent(level+2, 0);
+
+	printf("Country code: %c%c%c\n", chan_list->country_code[0],
+		chan_list->country_code[1], chan_list->country_code[2]);
+
+	for (i = 0; i < num; i++) {
+		triplet = &chan_list->triplets[i];
+
+		p_indent(level+2, 0);
+
+		if (triplet->chans.first_channel >= 201) {
+			printf("Reg ext id %d reg class %d coverage class %d\n",
+						triplet->ext.reg_extension_id,
+						triplet->ext.reg_class,
+						triplet->ext.coverage_class);
+		} else {
+			if (triplet->chans.num_channels == 1)
+				printf("Channel %d max power %d\n",
+						triplet->chans.first_channel,
+						triplet->chans.max_power);
+			else
+				printf("Channels %d - %d max power %d\n",
+						triplet->chans.first_channel,
+						triplet->chans.first_channel +
+						triplet->chans.num_channels,
+						triplet->chans.max_power);
+		}
+	}
+}
+
+void amp_assoc_dump(int level, uint8_t *assoc, uint16_t len)
+{
+	struct amp_tlv *tlv = (void *) assoc;
+
+	p_indent(level, 0);
+	printf("Assoc data [len %d]:\n", len);
+
+	while (len > sizeof(*tlv)) {
+		uint16_t tlvlen = btohs(tlv->len);
+		struct amp_pal_ver *ver;
+
+		p_indent(level+1, 0);
+
+		switch (tlv->type) {
+		case A2MP_MAC_ADDR_TYPE:
+			if (tlvlen != 6)
+				break;
+			printf("MAC: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+					tlv->val[0], tlv->val[1], tlv->val[2],
+					tlv->val[3], tlv->val[4], tlv->val[5]);
+			break;
+
+		case A2MP_PREF_CHANLIST_TYPE:
+			amp_dump_chanlist(level, tlv, "Preferred Chan List");
+			break;
+
+		case A2MP_CONNECTED_CHAN:
+			amp_dump_chanlist(level, tlv, "Connected Chan List");
+			break;
+
+		case A2MP_PAL_CAP_TYPE:
+			if (tlvlen != 4)
+				break;
+			printf("PAL CAP: %2.2x %2.2x %2.2x %2.2x\n",
+					tlv->val[0], tlv->val[1], tlv->val[2],
+					tlv->val[3]);
+			break;
+
+		case A2MP_PAL_VER_INFO:
+			if (tlvlen != 5)
+				break;
+			ver = (struct amp_pal_ver *) tlv->val;
+			printf("PAL VER: %2.2x Comp ID: %4.4x SubVer: %4.4x\n",
+					ver->ver, btohs(ver->company_id),
+					btohs(ver->sub_ver));
+			break;
+
+		default:
+			printf("Unrecognized type %d\n", tlv->type);
+			break;
+		}
+
+		len -= tlvlen + sizeof(*tlv);
+		assoc += tlvlen + sizeof(*tlv);
+		tlv = (struct amp_tlv *) assoc;
+	}
+}
diff --git a/parser/l2cap.c b/parser/l2cap.c
index f6ed91d..8dc825b 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -38,6 +38,7 @@
 #include "lib/hci.h"
 #include "lib/l2cap.h"
 #include "lib/a2mp.h"
+#include "lib/amp.h"
 
 typedef struct {
 	uint16_t handle;
@@ -1162,112 +1163,13 @@ static inline void a2mp_assoc_req(int level, struct frame *frm)
 	printf("Get AMP Assoc req: id %d\n", h->id);
 }
 
-static void a2mp_dump_chanlist(int level, struct a2mp_tlv *tlv, char *prefix)
-{
-	struct a2mp_chan_list *chan_list = (struct a2mp_chan_list *) tlv->val;
-	struct a2mp_country_triplet *triplet;
-	int i, num;
-
-	num = (tlv->len - sizeof(*chan_list)) / sizeof(*triplet);
-
-	printf("%s number of triplets %d\n", prefix, num);
-
-	p_indent(level+2, 0);
-
-	printf("Country code: %c%c%c\n", chan_list->country_code[0],
-		chan_list->country_code[1], chan_list->country_code[2]);
-
-	for (i = 0; i < num; i++) {
-		triplet = &chan_list->triplets[i];
-
-		p_indent(level+2, 0);
-
-		if (triplet->chans.first_channel >= 201) {
-			printf("Reg ext id %d reg class %d coverage class %d\n",
-						triplet->ext.reg_extension_id,
-						triplet->ext.reg_class,
-						triplet->ext.coverage_class);
-		} else {
-			if (triplet->chans.num_channels == 1)
-				printf("Channel %d max power %d\n",
-						triplet->chans.first_channel,
-						triplet->chans.max_power);
-			else
-				printf("Channels %d - %d max power %d\n",
-						triplet->chans.first_channel,
-						triplet->chans.first_channel +
-						triplet->chans.num_channels,
-						triplet->chans.max_power);
-		}
-	}
-}
-
-static inline void a2mp_assoc_dump(int level, uint8_t *assoc, uint16_t len)
-{
-	struct a2mp_tlv *tlv;
-
-	p_indent(level, 0);
-	printf("Assoc data [len %d]:\n", len);
-
-	tlv = (struct a2mp_tlv *) assoc;
-	while (len > sizeof(*tlv)) {
-		uint16_t tlvlen = btohs(tlv->len);
-		struct a2mp_pal_ver *ver;
-
-		p_indent(level+1, 0);
-
-		switch (tlv->type) {
-		case A2MP_MAC_ADDR_TYPE:
-			if (tlvlen != 6)
-				break;
-			printf("MAC: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
-					tlv->val[0], tlv->val[1], tlv->val[2],
-					tlv->val[3], tlv->val[4], tlv->val[5]);
-			break;
-
-		case A2MP_PREF_CHANLIST_TYPE:
-			a2mp_dump_chanlist(level, tlv, "Preferred Chan List");
-			break;
-
-		case A2MP_CONNECTED_CHAN:
-			a2mp_dump_chanlist(level, tlv, "Connected Chan List");
-			break;
-
-		case A2MP_PAL_CAP_TYPE:
-			if (tlvlen != 4)
-				break;
-			printf("PAL CAP: %2.2x %2.2x %2.2x %2.2x\n",
-					tlv->val[0], tlv->val[1], tlv->val[2],
-					tlv->val[3]);
-			break;
-
-		case A2MP_PAL_VER_INFO:
-			if (tlvlen != 5)
-				break;
-			ver = (struct a2mp_pal_ver *) tlv->val;
-			printf("PAL VER: %2.2x Comp ID: %4.4x SubVer: %4.4x\n",
-					ver->ver, btohs(ver->company_id),
-					btohs(ver->sub_ver));
-			break;
-
-		default:
-			printf("Unrecognized type %d\n", tlv->type);
-			break;
-		}
-
-		len -= tlvlen + sizeof(*tlv);
-		assoc += tlvlen + sizeof(*tlv);
-		tlv = (struct a2mp_tlv *) assoc;
-	}
-}
-
 static inline void a2mp_assoc_rsp(int level, struct frame *frm, uint16_t len)
 {
 	struct a2mp_assoc_rsp *h = frm->ptr;
 
-	printf("Get AMP Assoc rsp: id %d status (%d) %s \n",
+	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);
+	amp_assoc_dump(level + 1, h->assoc_data, len - sizeof(*h));
 }
 
 static inline void a2mp_create_req(int level, struct frame *frm, uint16_t len)
@@ -1276,7 +1178,7 @@ static inline void a2mp_create_req(int level, struct frame *frm, uint16_t len)
 
 	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);
+	amp_assoc_dump(level + 1, h->assoc_data, len - sizeof(*h));
 }
 
 static inline void a2mp_create_rsp(int level, struct frame *frm)
-- 
1.7.9.5


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

* [PATCHv3 hcidump 4/4] amp: Add decoding AMP Assoc data in HCI parser
  2012-06-28 13:09 ` [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data Andrei Emeltchenko
  2012-06-28 13:09   ` [PATCHv3 hcidump 2/4] a2mp: Fix number of triplet calculation Andrei Emeltchenko
  2012-06-28 13:09   ` [PATCHv3 hcidump 3/4] a2mp: Make assoc dump function available for HCI parser Andrei Emeltchenko
@ 2012-06-28 13:09   ` Andrei Emeltchenko
  2012-06-28 13:19   ` [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data Johan Hedberg
  3 siblings, 0 replies; 11+ messages in thread
From: Andrei Emeltchenko @ 2012-06-28 13:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 parser/hci.c |   13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/parser/hci.c b/parser/hci.c
index 984b554..5b837e9 100644
--- a/parser/hci.c
+++ b/parser/hci.c
@@ -36,6 +36,7 @@
 #include "parser/parser.h"
 #include "lib/hci.h"
 #include "lib/hci_lib.h"
+#include "lib/amp.h"
 
 static uint16_t manufacturer = DEFAULT_COMPID;
 
@@ -2599,7 +2600,6 @@ static inline void read_local_amp_assoc_dump(int level, struct frame *frm)
 {
 	read_local_amp_assoc_rp *rp = frm->ptr;
 	uint16_t len = btohs(rp->length);
-	int i;
 
 	p_indent(level, frm);
 	printf("status 0x%2.2x handle 0x%2.2x remaining len %d\n",
@@ -2608,16 +2608,7 @@ 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");
-				p_indent(level, frm);
-			}
-			printf("%2.2x ", rp->fragment[i]);
-		}
-		printf("\n");
+		amp_assoc_dump(level + 1, rp->fragment, len);
 	}
 }
 
-- 
1.7.9.5


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

* Re: [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data
  2012-06-28 13:09 ` [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data Andrei Emeltchenko
                     ` (2 preceding siblings ...)
  2012-06-28 13:09   ` [PATCHv3 hcidump 4/4] amp: Add decoding AMP Assoc data in " Andrei Emeltchenko
@ 2012-06-28 13:19   ` Johan Hedberg
  3 siblings, 0 replies; 11+ messages in thread
From: Johan Hedberg @ 2012-06-28 13:19 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

On Thu, Jun 28, 2012, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> ---
>  lib/a2mp.h |   38 --------------
>  lib/amp.h  |  172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 172 insertions(+), 38 deletions(-)
>  create mode 100644 lib/amp.h

All patches in this set have been applied (and the lib one went to
bluez.git too).

Johan

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

end of thread, other threads:[~2012-06-28 13:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-05  9:09 [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions Andrei Emeltchenko
2012-06-05  9:09 ` [PATCHv2 hcidump 2/4] Fix number of triplet calculation Andrei Emeltchenko
2012-06-05  9:09 ` [PATCHv2 hcidump 3/4] Make assoc dump function available for HCI parser Andrei Emeltchenko
2012-06-05  9:09 ` [PATCHv2 hcidump 4/4] Add decoding AMP Assoc data in " Andrei Emeltchenko
2012-06-14  7:25 ` [PATCHv2 hcidump 1/4] Headers for AMP ASSOC dump functions Andrei Emeltchenko
2012-06-26 12:02   ` Andrei Emeltchenko
2012-06-28 13:09 ` [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data Andrei Emeltchenko
2012-06-28 13:09   ` [PATCHv3 hcidump 2/4] a2mp: Fix number of triplet calculation Andrei Emeltchenko
2012-06-28 13:09   ` [PATCHv3 hcidump 3/4] a2mp: Make assoc dump function available for HCI parser Andrei Emeltchenko
2012-06-28 13:09   ` [PATCHv3 hcidump 4/4] amp: Add decoding AMP Assoc data in " Andrei Emeltchenko
2012-06-28 13:19   ` [PATCHv3 hcidump 1/4] lib: Add headers for AMP ASSOC data Johan Hedberg

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).