3
* BlueZ - Bluetooth protocol stack for Linux
5
* Copyright (C) 2000-2001 Qualcomm Incorporated
6
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
7
* Copyright (C) 2002-2009 Marcel Holtmann <marcel@holtmann.org>
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
40
#define AF_BLUETOOTH 31
41
#define PF_BLUETOOTH AF_BLUETOOTH
44
#define BTPROTO_L2CAP 0
47
#define BTPROTO_RFCOMM 3
48
#define BTPROTO_BNEP 4
49
#define BTPROTO_CMTP 5
50
#define BTPROTO_HIDP 6
51
#define BTPROTO_AVDTP 7
59
#define SOL_BLUETOOTH 274
66
#define BT_SECURITY_SDP 0
67
#define BT_SECURITY_LOW 1
68
#define BT_SECURITY_MEDIUM 2
69
#define BT_SECURITY_HIGH 3
71
#define BT_DEFER_SETUP 7
73
/* Connection and socket states */
75
BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
86
/* Byte order conversions */
87
#if __BYTE_ORDER == __LITTLE_ENDIAN
92
#elif __BYTE_ORDER == __BIG_ENDIAN
93
#define htobs(d) bswap_16(d)
94
#define htobl(d) bswap_32(d)
95
#define btohs(d) bswap_16(d)
96
#define btohl(d) bswap_32(d)
98
#error "Unknown byte order"
101
/* Bluetooth unaligned access */
102
#define bt_get_unaligned(ptr) \
104
struct __attribute__((packed)) { \
105
typeof(*(ptr)) __v; \
106
} *__p = (void *) (ptr); \
110
#define bt_put_unaligned(val, ptr) \
112
struct __attribute__((packed)) { \
113
typeof(*(ptr)) __v; \
114
} *__p = (void *) (ptr); \
121
} __attribute__((packed)) bdaddr_t;
123
#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
124
#define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
125
#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
127
/* Copy, swap, convert BD Address */
128
static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
130
return memcmp(ba1, ba2, sizeof(bdaddr_t));
132
static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
134
memcpy(dst, src, sizeof(bdaddr_t));
137
void baswap(bdaddr_t *dst, const bdaddr_t *src);
138
bdaddr_t *strtoba(const char *str);
139
char *batostr(const bdaddr_t *ba);
140
int ba2str(const bdaddr_t *ba, char *str);
141
int str2ba(const char *str, bdaddr_t *ba);
142
int ba2oui(const bdaddr_t *ba, char *oui);
143
int bachk(const char *str);
145
int baprintf(const char *format, ...);
146
int bafprintf(FILE *stream, const char *format, ...);
147
int basprintf(char *str, const char *format, ...);
148
int basnprintf(char *str, size_t size, const char *format, ...);
150
void *bt_malloc(size_t size);
151
void bt_free(void *ptr);
153
int bt_error(uint16_t code);
154
char *bt_compidtostr(int id);
160
#endif /* __BLUETOOTH_H */