25 #include <netinet/in.h> 28 #define AF_BLUETOOTH 31 29 #define PF_BLUETOOTH AF_BLUETOOTH 32 #define BTPROTO_L2CAP 0 35 #define BTPROTO_RFCOMM 3 36 #define BTPROTO_BNEP 4 37 #define BTPROTO_CMTP 5 38 #define BTPROTO_HIDP 6 39 #define BTPROTO_AVDTP 7 47 #define SOL_BLUETOOTH 274 55 #define BT_SECURITY_SDP 0 56 #define BT_SECURITY_LOW 1 57 #define BT_SECURITY_MEDIUM 2 58 #define BT_SECURITY_HIGH 3 59 #define BT_SECURITY_FIPS 4 61 #define BT_DEFER_SETUP 7 63 #define BT_FLUSHABLE 8 65 #define BT_FLUSHABLE_OFF 0 66 #define BT_FLUSHABLE_ON 1 72 #define BT_POWER_FORCE_ACTIVE_OFF 0 73 #define BT_POWER_FORCE_ACTIVE_ON 1 75 #define BT_CHANNEL_POLICY 10 82 #define BT_CHANNEL_POLICY_BREDR_ONLY 0 89 #define BT_CHANNEL_POLICY_BREDR_PREFERRED 1 100 #define BT_CHANNEL_POLICY_AMP_PREFERRED 2 110 #define BT_VOICE_TRANSPARENT 0x0003 111 #define BT_VOICE_CVSD_16BIT 0x0060 115 #define BT_PHY_BR_1M_1SLOT 0x00000001 116 #define BT_PHY_BR_1M_3SLOT 0x00000002 117 #define BT_PHY_BR_1M_5SLOT 0x00000004 118 #define BT_PHY_EDR_2M_1SLOT 0x00000008 119 #define BT_PHY_EDR_2M_3SLOT 0x00000010 120 #define BT_PHY_EDR_2M_5SLOT 0x00000020 121 #define BT_PHY_EDR_3M_1SLOT 0x00000040 122 #define BT_PHY_EDR_3M_3SLOT 0x00000080 123 #define BT_PHY_EDR_3M_5SLOT 0x00000100 124 #define BT_PHY_LE_1M_TX 0x00000200 125 #define BT_PHY_LE_1M_RX 0x00000400 126 #define BT_PHY_LE_2M_TX 0x00000800 127 #define BT_PHY_LE_2M_RX 0x00001000 128 #define BT_PHY_LE_CODED_TX 0x00002000 129 #define BT_PHY_LE_CODED_RX 0x00004000 133 #define BT_MODE_BASIC 0x00 134 #define BT_MODE_ERTM 0x01 135 #define BT_MODE_STREAMING 0x02 136 #define BT_MODE_LE_FLOWCTL 0x03 137 #define BT_MODE_EXT_FLOWCTL 0x04 139 #define BT_PKT_STATUS 16 141 #define BT_SCM_PKT_STATUS 0x03 148 uint8_t data_path_id;
175 #if __BYTE_ORDER == __LITTLE_ENDIAN 178 #define htobll(d) (d) 181 #define btohll(d) (d) 182 #elif __BYTE_ORDER == __BIG_ENDIAN 183 #define htobs(d) bswap_16(d) 184 #define htobl(d) bswap_32(d) 185 #define htobll(d) bswap_64(d) 186 #define btohs(d) bswap_16(d) 187 #define btohl(d) bswap_32(d) 188 #define btohll(d) bswap_64(d) 190 #error "Unknown byte order" 194 #define bt_get_unaligned(ptr) \ 196 struct __attribute__((packed)) { \ 197 __typeof__(*(ptr)) __v; \ 198 } *__p = (__typeof__(__p)) (ptr); \ 202 #define bt_put_unaligned(val, ptr) \ 204 struct __attribute__((packed)) { \ 205 __typeof__(*(ptr)) __v; \ 206 } *__p = (__typeof__(__p)) (ptr); \ 210 #if __BYTE_ORDER == __LITTLE_ENDIAN 211 static inline uint64_t bt_get_le64(
const void *ptr)
213 return bt_get_unaligned((
const uint64_t *) ptr);
216 static inline uint64_t bt_get_be64(
const void *ptr)
218 return bswap_64(bt_get_unaligned((
const uint64_t *) ptr));
221 static inline uint32_t bt_get_le32(
const void *ptr)
223 return bt_get_unaligned((
const uint32_t *) ptr);
226 static inline uint32_t bt_get_be32(
const void *ptr)
228 return bswap_32(bt_get_unaligned((
const uint32_t *) ptr));
231 static inline uint16_t bt_get_le16(
const void *ptr)
233 return bt_get_unaligned((
const uint16_t *) ptr);
236 static inline uint16_t bt_get_be16(
const void *ptr)
238 return bswap_16(bt_get_unaligned((
const uint16_t *) ptr));
241 static inline void bt_put_le64(uint64_t val,
const void *ptr)
243 bt_put_unaligned(val, (uint64_t *) ptr);
246 static inline void bt_put_be64(uint64_t val,
const void *ptr)
248 bt_put_unaligned(bswap_64(val), (uint64_t *) ptr);
251 static inline void bt_put_le32(uint32_t val,
const void *ptr)
253 bt_put_unaligned(val, (uint32_t *) ptr);
256 static inline void bt_put_be32(uint32_t val,
const void *ptr)
258 bt_put_unaligned(bswap_32(val), (uint32_t *) ptr);
261 static inline void bt_put_le16(uint16_t val,
const void *ptr)
263 bt_put_unaligned(val, (uint16_t *) ptr);
266 static inline void bt_put_be16(uint16_t val,
const void *ptr)
268 bt_put_unaligned(bswap_16(val), (uint16_t *) ptr);
271 #elif __BYTE_ORDER == __BIG_ENDIAN 272 static inline uint64_t bt_get_le64(
const void *ptr)
274 return bswap_64(bt_get_unaligned((
const uint64_t *) ptr));
277 static inline uint64_t bt_get_be64(
const void *ptr)
279 return bt_get_unaligned((
const uint64_t *) ptr);
282 static inline uint32_t bt_get_le32(
const void *ptr)
284 return bswap_32(bt_get_unaligned((
const uint32_t *) ptr));
287 static inline uint32_t bt_get_be32(
const void *ptr)
289 return bt_get_unaligned((
const uint32_t *) ptr);
292 static inline uint16_t bt_get_le16(
const void *ptr)
294 return bswap_16(bt_get_unaligned((
const uint16_t *) ptr));
297 static inline uint16_t bt_get_be16(
const void *ptr)
299 return bt_get_unaligned((
const uint16_t *) ptr);
302 static inline void bt_put_le64(uint64_t val,
const void *ptr)
304 bt_put_unaligned(bswap_64(val), (uint64_t *) ptr);
307 static inline void bt_put_be64(uint64_t val,
const void *ptr)
309 bt_put_unaligned(val, (uint64_t *) ptr);
312 static inline void bt_put_le32(uint32_t val,
const void *ptr)
314 bt_put_unaligned(bswap_32(val), (uint32_t *) ptr);
317 static inline void bt_put_be32(uint32_t val,
const void *ptr)
319 bt_put_unaligned(val, (uint32_t *) ptr);
322 static inline void bt_put_le16(uint16_t val,
const void *ptr)
324 bt_put_unaligned(bswap_16(val), (uint16_t *) ptr);
327 static inline void bt_put_be16(uint16_t val,
const void *ptr)
329 bt_put_unaligned(val, (uint16_t *) ptr);
332 #error "Unknown byte order" 338 } __attribute__((packed)) bdaddr_t;
341 #define BDADDR_BREDR 0x00 342 #define BDADDR_LE_PUBLIC 0x01 343 #define BDADDR_LE_RANDOM 0x02 345 #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) 346 #define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}) 347 #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) 350 static inline int bacmp(
const bdaddr_t *ba1,
const bdaddr_t *ba2)
352 return memcmp(ba1, ba2,
sizeof(bdaddr_t));
354 static inline void bacpy(bdaddr_t *dst,
const bdaddr_t *src)
356 memcpy(dst, src,
sizeof(bdaddr_t));
359 void baswap(bdaddr_t *dst,
const bdaddr_t *src);
360 bdaddr_t *strtoba(
const char *str);
361 char *batostr(
const bdaddr_t *ba);
362 int ba2str(
const bdaddr_t *ba,
char *str);
363 int ba2strlc(
const bdaddr_t *ba,
char *str);
364 int str2ba(
const char *str, bdaddr_t *ba);
365 int ba2oui(
const bdaddr_t *ba,
char *oui);
366 int bachk(
const char *str);
368 int baprintf(
const char *format, ...);
369 int bafprintf(FILE *stream,
const char *format, ...);
370 int basprintf(
char *str,
const char *format, ...);
371 int basnprintf(
char *str,
size_t size,
const char *format, ...);
373 void *bt_malloc(
size_t size);
374 void *bt_malloc0(
size_t size);
375 void bt_free(
void *ptr);
377 int bt_error(uint16_t code);
378 const char *bt_compidtostr(
int id);
384 static inline void bswap_128(
const void *src,
void *dst)
386 const uint8_t *s = (
const uint8_t *) src;
387 uint8_t *d = (uint8_t *) dst;
390 for (i = 0; i < 16; i++)
394 #if __BYTE_ORDER == __BIG_ENDIAN 396 #define ntoh64(x) (x) 410 static inline uint64_t ntoh64(uint64_t n)
413 uint64_t tmp = ntohl(n & 0x00000000ffffffff);
433 #define hton64(x) ntoh64(x) 434 #define hton128(x, y) ntoh128(x, y) 435 #define htob128(x, y) btoh128(x, y) Definition: bluetooth.h:103
Definition: bluetooth.h:156
Definition: bluetooth.h:69
Definition: bluetooth.h:51
Definition: bluetooth.h:144
Definition: bluetooth.h:150
Definition: bluetooth.h:380