Linux bluetooth development
 help / color / mirror / Atom feed
* [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 1/2] make struct features available for others
@ 2011-10-06 13:38 Emeltchenko Andrei
  2011-10-06 13:38 ` [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-06 13:38 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 parser/l2cap.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/parser/l2cap.c b/parser/l2cap.c
index c2ac10e..c975374 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	},
-- 
1.7.4.1


^ permalink raw reply related	[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