* [PATCH hcidump 2/2] decode fixed channel list info rsp
2011-10-06 13:38 [PATCH hcidump 1/2] make struct features available for others Emeltchenko Andrei
@ 2011-10-06 13:38 ` Emeltchenko Andrei
0 siblings, 0 replies; 4+ messages in thread
From: Emeltchenko Andrei @ 2011-10-06 13:38 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Decode fixed channels in information response
< ACL data: handle 1 flags 0x00 dlen 10
L2CAP(s): Info req: type 3
> ACL data: handle 1 flags 0x02 dlen 20
L2CAP(s): Info rsp: type 3 result 0
Fixed channel list 0x000a
L2CAP Signalling Channel
AMP Manager Protocol
---
lib/bluetooth.h | 4 ++++
lib/l2cap.h | 5 +++++
parser/l2cap.c | 22 +++++++++++++++++++---
3 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index 738e07a..b0680e2 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -93,13 +93,17 @@ enum {
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define htobs(d) (d)
#define htobl(d) (d)
+#define htobll(d) (d)
#define btohs(d) (d)
#define btohl(d) (d)
+#define btohll(d) (d)
#elif __BYTE_ORDER == __BIG_ENDIAN
#define htobs(d) bswap_16(d)
#define htobl(d) bswap_32(d)
+#define htobll(d) bswap_64(d)
#define btohs(d) bswap_16(d)
#define btohl(d) bswap_32(d)
+#define btohll(d) bswap_64(d)
#else
#error "Unknown byte order"
#endif
diff --git a/lib/l2cap.h b/lib/l2cap.h
index 47b3dc3..3880551 100644
--- a/lib/l2cap.h
+++ b/lib/l2cap.h
@@ -139,6 +139,11 @@ struct l2cap_conninfo {
#define L2CAP_SDULEN_SIZE 2
+/* L2CAP fixed channels */
+#define L2CAP_FC_L2CAP 0x02
+#define L2CAP_FC_CONNLESS 0x04
+#define L2CAP_FC_A2MP 0x08
+
/* L2CAP structures */
typedef struct {
uint16_t len;
diff --git a/parser/l2cap.c b/parser/l2cap.c
index c975374..8933f8f 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -80,6 +80,13 @@ static struct features l2cap_features[] = {
{ 0 }
};
+static struct features l2cap_fix_chan[] = {
+ { "L2CAP Signalling Channel", L2CAP_FC_L2CAP },
+ { "L2CAP Connless", L2CAP_FC_CONNLESS },
+ { "AMP Manager Protocol", L2CAP_FC_A2MP },
+ { 0 }
+};
+
static struct frame *add_handle(uint16_t handle)
{
register handle_info *t = handle_table;
@@ -243,6 +250,8 @@ static uint32_t get_val(uint8_t *ptr, uint8_t len)
return btohs(bt_get_unaligned((uint16_t *) ptr));
case 4:
return btohl(bt_get_unaligned((uint32_t *) ptr));
+ case 8:
+ return btohll(bt_get_unaligned((uint64_t *) ptr));
}
return 0;
}
@@ -729,7 +738,7 @@ static inline void echo_rsp(int level, l2cap_cmd_hdr *cmd, struct frame *frm)
static void info_opt(int level, int type, void *ptr, int len)
{
- uint32_t mask;
+ uint64_t mask;
int i;
p_indent(level, 0);
@@ -740,7 +749,7 @@ static void info_opt(int level, int type, void *ptr, int len)
break;
case 0x0002:
mask = get_val(ptr, len);
- printf("Extended feature mask 0x%4.4x\n", mask);
+ printf("Extended feature mask 0x%4.4x\n", (uint32_t) mask);
if (parser.flags & DUMP_VERBOSE)
for (i=0; l2cap_features[i].name; i++)
if (mask & l2cap_features[i].flag) {
@@ -749,7 +758,14 @@ static void info_opt(int level, int type, void *ptr, int len)
}
break;
case 0x0003:
- printf("Fixed channel list\n");
+ mask = get_val(ptr, len);
+ printf("Fixed channel list 0x%4.4llx\n", mask);
+ if (parser.flags & DUMP_VERBOSE)
+ for (i=0; l2cap_fix_chan[i].name; i++)
+ if (mask & l2cap_fix_chan[i].flag) {
+ p_indent(level + 1, 0);
+ printf("%s\n", l2cap_fix_chan[i].name);
+ }
break;
default:
printf("Unknown (len %d)\n", len);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH hcidump 1/2] add get_le/get_be helpers
@ 2011-10-24 9:22 Emeltchenko Andrei
2011-10-24 9:22 ` [PATCH hcidump 2/2] decode fixed channel list info rsp Emeltchenko Andrei
0 siblings, 1 reply; 4+ messages in thread
From: Emeltchenko Andrei @ 2011-10-24 9:22 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Helpers to access LE / BE values. In bluetooth there is a mixture
of LE / BE network byte order.
---
lib/bluetooth.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index b0680e2..5bd4f03 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -125,6 +125,70 @@ do { \
__p->__v = (val); \
} while(0)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+static inline uint64_t bt_get_le64(void *ptr)
+{
+ return bt_get_unaligned((uint64_t *) ptr);
+}
+
+static inline uint64_t bt_get_be64(void *ptr)
+{
+ return bswap_64(bt_get_unaligned((uint64_t *) ptr));
+}
+
+static inline uint32_t bt_get_le32(void *ptr)
+{
+ return bt_get_unaligned((uint32_t *) ptr);
+}
+
+static inline uint32_t bt_get_be32(void *ptr)
+{
+ return bswap_32(bt_get_unaligned((uint32_t *) ptr));
+}
+
+static inline uint16_t bt_get_le16(void *ptr)
+{
+ return bt_get_unaligned((uint16_t *) ptr);
+}
+
+static inline uint16_t bt_get_be16(void *ptr)
+{
+ return bswap_16(bt_get_unaligned((uint16_t *) ptr));
+}
+#elif __BYTE_ORDER == __BIG_ENDIAN
+static inline uint64_t bt_get_le64(void *ptr)
+{
+ return bswap_64(bt_get_unaligned((uint64_t *) ptr));
+}
+
+static inline uint64_t bt_get_be64(void *ptr)
+{
+ return bt_get_unaligned((uint64_t *) ptr);
+}
+
+static inline uint32_t bt_get_le32(void *ptr)
+{
+ return bswap_32(bt_get_unaligned((uint32_t *) ptr));
+}
+
+static inline uint32_t bt_get_be32(void *ptr)
+{
+ return bt_get_unaligned((uint32_t *) ptr);
+}
+
+static inline uint16_t bt_get_le16(void *ptr)
+{
+ return bswap_16(bt_get_unaligned((uint16_t *) ptr));
+}
+
+static inline uint16_t bt_get_be16(void *ptr)
+{
+ return bt_get_unaligned((uint16_t *) ptr);
+}
+#else
+#error "Unknown byte order"
+#endif
+
/* BD Address */
typedef struct {
uint8_t b[6];
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH hcidump 2/2] decode fixed channel list info rsp
2011-10-24 9:22 [PATCH hcidump 1/2] add get_le/get_be helpers Emeltchenko Andrei
@ 2011-10-24 9:22 ` Emeltchenko Andrei
2011-10-25 9:21 ` Johan Hedberg
0 siblings, 1 reply; 4+ messages in thread
From: Emeltchenko Andrei @ 2011-10-24 9:22 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Decode fixed channels in information response
< ACL data: handle 1 flags 0x00 dlen 10
L2CAP(s): Info req: type 3
> ACL data: handle 1 flags 0x02 dlen 20
L2CAP(s): Info rsp: type 3 result 0
Fixed channel list 0x0000000a
L2CAP Signalling Channel
AMP Manager Protocol
---
parser/l2cap.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/parser/l2cap.c b/parser/l2cap.c
index 6a5a4b2..3eea172 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -61,10 +61,12 @@ static cid_info cid_table[2][CID_TABLE_SIZE];
#define DCID cid_table[1]
/* Can we move this to l2cap.h? */
-static struct {
+struct features {
char *name;
int flag;
-} l2cap_features[] = {
+};
+
+static struct features l2cap_features[] = {
{ "Flow control mode", L2CAP_FEAT_FLOWCTL },
{ "Retransmission mode", L2CAP_FEAT_RETRANS },
{ "Bi-directional QoS", L2CAP_FEAT_BIDIR_QOS },
@@ -78,6 +80,13 @@ static struct {
{ 0 }
};
+static struct features l2cap_fix_chan[] = {
+ { "L2CAP Signalling Channel", L2CAP_FC_L2CAP },
+ { "L2CAP Connless", L2CAP_FC_CONNLESS },
+ { "AMP Manager Protocol", L2CAP_FC_A2MP },
+ { 0 }
+};
+
static struct frame *add_handle(uint16_t handle)
{
register handle_info *t = handle_table;
@@ -728,6 +737,7 @@ static inline void echo_rsp(int level, l2cap_cmd_hdr *cmd, struct frame *frm)
static void info_opt(int level, int type, void *ptr, int len)
{
uint32_t mask;
+ uint64_t fc_mask;
int i;
p_indent(level, 0);
@@ -747,7 +757,14 @@ static void info_opt(int level, int type, void *ptr, int len)
}
break;
case 0x0003:
- printf("Fixed channel list\n");
+ fc_mask = bt_get_le64(ptr);
+ printf("Fixed channel list 0x%8.8llx\n", fc_mask);
+ if (parser.flags & DUMP_VERBOSE)
+ for (i=0; l2cap_fix_chan[i].name; i++)
+ if (fc_mask & l2cap_fix_chan[i].flag) {
+ p_indent(level + 1, 0);
+ printf("%s\n", l2cap_fix_chan[i].name);
+ }
break;
default:
printf("Unknown (len %d)\n", len);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH hcidump 2/2] decode fixed channel list info rsp
2011-10-24 9:22 ` [PATCH hcidump 2/2] decode fixed channel list info rsp Emeltchenko Andrei
@ 2011-10-25 9:21 ` Johan Hedberg
0 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2011-10-25 9:21 UTC (permalink / raw)
To: Emeltchenko Andrei; +Cc: linux-bluetooth
Hi Andrei,
On Mon, Oct 24, 2011, Emeltchenko Andrei wrote:
> Decode fixed channels in information response
>
> < ACL data: handle 1 flags 0x00 dlen 10
> L2CAP(s): Info req: type 3
> > ACL data: handle 1 flags 0x02 dlen 20
> L2CAP(s): Info rsp: type 3 result 0
> Fixed channel list 0x0000000a
> L2CAP Signalling Channel
> AMP Manager Protocol
> ---
> parser/l2cap.c | 23 ++++++++++++++++++++---
> 1 files changed, 20 insertions(+), 3 deletions(-)
Both patches have been applied, but I had to fix the following to use
PRIx64 instead of %llx to compile both on 32 and 64 bit architectures.
> + printf("Fixed channel list 0x%8.8llx\n", fc_mask);
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-10-25 9:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-24 9:22 [PATCH hcidump 1/2] add get_le/get_be helpers Emeltchenko Andrei
2011-10-24 9:22 ` [PATCH hcidump 2/2] decode fixed channel list info rsp Emeltchenko Andrei
2011-10-25 9:21 ` Johan Hedberg
-- strict thread matches above, loose matches on Subject: below --
2011-10-06 13:38 [PATCH hcidump 1/2] make struct features available for others Emeltchenko Andrei
2011-10-06 13:38 ` [PATCH hcidump 2/2] decode fixed channel list info rsp Emeltchenko Andrei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox