Statistics
| Branch: | Revision:

root / hw / bt.h @ 4efbe58f

History | View | Annotate | Download (58.6 kB)

1 1ae26a18 balrog
/*
2 1ae26a18 balrog
 * QEMU Bluetooth HCI helpers.
3 1ae26a18 balrog
 *
4 1ae26a18 balrog
 * Copyright (C) 2007 OpenMoko, Inc.
5 1ae26a18 balrog
 * Written by Andrzej Zaborowski <andrew@openedhand.com>
6 1ae26a18 balrog
 *
7 4e38eb54 balrog
 * Useful definitions taken from BlueZ project's headers.
8 4e38eb54 balrog
 * Copyright (C) 2000-2001  Qualcomm Incorporated
9 4e38eb54 balrog
 * Copyright (C) 2002-2003  Maxim Krasnyansky <maxk@qualcomm.com>
10 4e38eb54 balrog
 * Copyright (C) 2002-2006  Marcel Holtmann <marcel@holtmann.org>
11 4e38eb54 balrog
 *
12 1ae26a18 balrog
 * This program is free software; you can redistribute it and/or
13 1ae26a18 balrog
 * modify it under the terms of the GNU General Public License as
14 1ae26a18 balrog
 * published by the Free Software Foundation; either version 2 of
15 1ae26a18 balrog
 * the License, or (at your option) any later version.
16 1ae26a18 balrog
 *
17 1ae26a18 balrog
 * This program is distributed in the hope that it will be useful,
18 1ae26a18 balrog
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 1ae26a18 balrog
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 1ae26a18 balrog
 * GNU General Public License for more details.
21 1ae26a18 balrog
 *
22 1ae26a18 balrog
 * You should have received a copy of the GNU General Public License
23 1ae26a18 balrog
 * along with this program; if not, write to the Free Software
24 1ae26a18 balrog
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
25 1ae26a18 balrog
 * MA  02110-1301  USA
26 1ae26a18 balrog
 */
27 1ae26a18 balrog
28 1ae26a18 balrog
/* BD Address */
29 1ae26a18 balrog
typedef struct {
30 1ae26a18 balrog
    uint8_t b[6];
31 1ae26a18 balrog
} __attribute__((packed)) bdaddr_t;
32 1ae26a18 balrog
33 1ae26a18 balrog
#define BDADDR_ANY        (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
34 1ae26a18 balrog
#define BDADDR_ALL        (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
35 1ae26a18 balrog
#define BDADDR_LOCAL        (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
36 1ae26a18 balrog
37 1ae26a18 balrog
/* Copy, swap, convert BD Address */
38 1ae26a18 balrog
static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
39 1ae26a18 balrog
{
40 1ae26a18 balrog
    return memcmp(ba1, ba2, sizeof(bdaddr_t));
41 1ae26a18 balrog
}
42 1ae26a18 balrog
static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
43 1ae26a18 balrog
{
44 1ae26a18 balrog
    memcpy(dst, src, sizeof(bdaddr_t));
45 1ae26a18 balrog
}
46 1ae26a18 balrog
47 1ae26a18 balrog
#define BAINIT(orig)        { .b = {                \
48 1ae26a18 balrog
    (orig)->b[0], (orig)->b[1], (orig)->b[2],        \
49 1ae26a18 balrog
    (orig)->b[3], (orig)->b[4], (orig)->b[5],        \
50 1ae26a18 balrog
}, }
51 1ae26a18 balrog
52 1ae26a18 balrog
/* The twisted structures of a bluetooth environment */
53 1ae26a18 balrog
struct bt_device_s;
54 1ae26a18 balrog
struct bt_scatternet_s;
55 1ae26a18 balrog
struct bt_piconet_s;
56 1ae26a18 balrog
struct bt_link_s;
57 1ae26a18 balrog
58 1ae26a18 balrog
struct bt_scatternet_s {
59 1ae26a18 balrog
    struct bt_device_s *slave;
60 1ae26a18 balrog
};
61 1ae26a18 balrog
62 1ae26a18 balrog
struct bt_link_s {
63 1ae26a18 balrog
    struct bt_device_s *slave, *host;
64 1ae26a18 balrog
    uint16_t handle;                /* Master (host) side handle */
65 1ae26a18 balrog
    uint16_t acl_interval;
66 1ae26a18 balrog
    enum {
67 1ae26a18 balrog
        acl_active,
68 1ae26a18 balrog
        acl_hold,
69 1ae26a18 balrog
        acl_sniff,
70 1ae26a18 balrog
        acl_parked,
71 1ae26a18 balrog
    } acl_mode;
72 1ae26a18 balrog
};
73 1ae26a18 balrog
74 1ae26a18 balrog
struct bt_device_s {
75 1ae26a18 balrog
    int lt_addr;
76 1ae26a18 balrog
    bdaddr_t bd_addr;
77 1ae26a18 balrog
    int mtu;
78 1ae26a18 balrog
    int setup;
79 1ae26a18 balrog
    struct bt_scatternet_s *net;
80 1ae26a18 balrog
81 1ae26a18 balrog
    uint8_t key[16];
82 1ae26a18 balrog
    int key_present;
83 1ae26a18 balrog
    uint8_t class[3];
84 1ae26a18 balrog
85 1ae26a18 balrog
    uint8_t reject_reason;
86 1ae26a18 balrog
87 1ae26a18 balrog
    uint64_t lmp_caps;
88 1ae26a18 balrog
    const char *lmp_name;
89 1ae26a18 balrog
    void (*lmp_connection_request)(struct bt_link_s *link);
90 1ae26a18 balrog
    void (*lmp_connection_complete)(struct bt_link_s *link);
91 1ae26a18 balrog
    void (*lmp_disconnect_master)(struct bt_link_s *link);
92 1ae26a18 balrog
    void (*lmp_disconnect_slave)(struct bt_link_s *link);
93 1ae26a18 balrog
    void (*lmp_acl_data)(struct bt_link_s *link, const uint8_t *data,
94 1ae26a18 balrog
                    int start, int len);
95 1ae26a18 balrog
    void (*lmp_acl_resp)(struct bt_link_s *link, const uint8_t *data,
96 1ae26a18 balrog
                    int start, int len);
97 1ae26a18 balrog
    void (*lmp_mode_change)(struct bt_link_s *link);
98 1ae26a18 balrog
99 1ae26a18 balrog
    void (*handle_destroy)(struct bt_device_s *device);
100 1ae26a18 balrog
    struct bt_device_s *next;        /* Next in the piconet/scatternet */
101 1ae26a18 balrog
102 1ae26a18 balrog
    int inquiry_scan;
103 1ae26a18 balrog
    int page_scan;
104 1ae26a18 balrog
105 1ae26a18 balrog
    uint16_t clkoff;        /* Note: Always little-endian */
106 1ae26a18 balrog
};
107 1ae26a18 balrog
108 1ae26a18 balrog
/* bt.c */
109 1ae26a18 balrog
void bt_device_init(struct bt_device_s *dev, struct bt_scatternet_s *net);
110 1ae26a18 balrog
void bt_device_done(struct bt_device_s *dev);
111 58a26b47 balrog
112 4e38eb54 balrog
/* bt-hci.c */
113 4e38eb54 balrog
struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net);
114 4e38eb54 balrog
115 4e38eb54 balrog
/* bt-host.c */
116 4e38eb54 balrog
struct HCIInfo *bt_host_hci(const char *id);
117 4e38eb54 balrog
118 ab2b6f50 balrog
/* bt-vhci.c */
119 ab2b6f50 balrog
void bt_vhci_init(struct HCIInfo *info);
120 ab2b6f50 balrog
121 58a26b47 balrog
/* bt-hci-csr.c */
122 58a26b47 balrog
enum {
123 58a26b47 balrog
    csrhci_pin_reset,
124 58a26b47 balrog
    csrhci_pin_wakeup,
125 58a26b47 balrog
    __csrhci_pins,
126 58a26b47 balrog
};
127 58a26b47 balrog
qemu_irq *csrhci_pins_get(CharDriverState *chr);
128 58a26b47 balrog
CharDriverState *uart_hci_init(qemu_irq wakeup);
129 58a26b47 balrog
130 4d2d181c balrog
/* bt-l2cap.c */
131 4d2d181c balrog
struct bt_l2cap_device_s;
132 4d2d181c balrog
struct bt_l2cap_conn_params_s;
133 4d2d181c balrog
struct bt_l2cap_psm_s;
134 4d2d181c balrog
void bt_l2cap_device_init(struct bt_l2cap_device_s *dev,
135 4d2d181c balrog
                struct bt_scatternet_s *net);
136 4d2d181c balrog
void bt_l2cap_device_done(struct bt_l2cap_device_s *dev);
137 4d2d181c balrog
void bt_l2cap_psm_register(struct bt_l2cap_device_s *dev, int psm,
138 4d2d181c balrog
                int min_mtu, int (*new_channel)(struct bt_l2cap_device_s *dev,
139 4d2d181c balrog
                        struct bt_l2cap_conn_params_s *params));
140 4d2d181c balrog
141 4d2d181c balrog
struct bt_l2cap_device_s {
142 4d2d181c balrog
    struct bt_device_s device;
143 4d2d181c balrog
    struct bt_l2cap_psm_s *first_psm;
144 4d2d181c balrog
};
145 4d2d181c balrog
146 4d2d181c balrog
struct bt_l2cap_conn_params_s {
147 4d2d181c balrog
    /* Input */
148 4d2d181c balrog
    uint8_t *(*sdu_out)(struct bt_l2cap_conn_params_s *chan, int len);
149 4d2d181c balrog
    void (*sdu_submit)(struct bt_l2cap_conn_params_s *chan);
150 4d2d181c balrog
    int remote_mtu;
151 4d2d181c balrog
    /* Output */
152 4d2d181c balrog
    void *opaque;
153 4d2d181c balrog
    void (*sdu_in)(void *opaque, const uint8_t *data, int len);
154 4d2d181c balrog
    void (*close)(void *opaque);
155 4d2d181c balrog
};
156 4d2d181c balrog
157 4d2d181c balrog
enum bt_l2cap_psm_predef {
158 4d2d181c balrog
    BT_PSM_SDP                = 0x0001,
159 4d2d181c balrog
    BT_PSM_RFCOMM        = 0x0003,
160 4d2d181c balrog
    BT_PSM_TELEPHONY        = 0x0005,
161 4d2d181c balrog
    BT_PSM_TCS                = 0x0007,
162 4d2d181c balrog
    BT_PSM_BNEP                = 0x000f,
163 4d2d181c balrog
    BT_PSM_HID_CTRL        = 0x0011,
164 4d2d181c balrog
    BT_PSM_HID_INTR        = 0x0013,
165 4d2d181c balrog
    BT_PSM_UPNP                = 0x0015,
166 4d2d181c balrog
    BT_PSM_AVCTP        = 0x0017,
167 4d2d181c balrog
    BT_PSM_AVDTP        = 0x0019,
168 4d2d181c balrog
};
169 4d2d181c balrog
170 4d2d181c balrog
/* bt-sdp.c */
171 4d2d181c balrog
void bt_l2cap_sdp_init(struct bt_l2cap_device_s *dev);
172 4d2d181c balrog
173 ab2b6f50 balrog
/* bt-hid.c */
174 ab2b6f50 balrog
struct bt_device_s *bt_mouse_init(struct bt_scatternet_s *net);
175 ab2b6f50 balrog
struct bt_device_s *bt_tablet_init(struct bt_scatternet_s *net);
176 ab2b6f50 balrog
struct bt_device_s *bt_keyboard_init(struct bt_scatternet_s *net);
177 ab2b6f50 balrog
178 58a26b47 balrog
/* Link Management Protocol layer defines */
179 58a26b47 balrog
180 58a26b47 balrog
#define LLID_ACLU_CONT                0x1
181 58a26b47 balrog
#define LLID_ACLU_START                0x2
182 58a26b47 balrog
#define LLID_ACLC                0x3
183 58a26b47 balrog
184 58a26b47 balrog
enum lmp_pdu_type {
185 58a26b47 balrog
    LMP_NAME_REQ                = 0x0001,
186 58a26b47 balrog
    LMP_NAME_RES                = 0x0002,
187 58a26b47 balrog
    LMP_ACCEPTED                = 0x0003,
188 58a26b47 balrog
    LMP_NOT_ACCEPTED                = 0x0004,
189 58a26b47 balrog
    LMP_CLKOFFSET_REQ                = 0x0005,
190 58a26b47 balrog
    LMP_CLKOFFSET_RES                = 0x0006,
191 58a26b47 balrog
    LMP_DETACH                        = 0x0007,
192 58a26b47 balrog
    LMP_IN_RAND                        = 0x0008,
193 58a26b47 balrog
    LMP_COMB_KEY                = 0x0009,
194 58a26b47 balrog
    LMP_UNIT_KEY                = 0x000a,
195 58a26b47 balrog
    LMP_AU_RAND                        = 0x000b,
196 58a26b47 balrog
    LMP_SRES                        = 0x000c,
197 58a26b47 balrog
    LMP_TEMP_RAND                = 0x000d,
198 58a26b47 balrog
    LMP_TEMP_KEY                = 0x000e,
199 58a26b47 balrog
    LMP_CRYPT_MODE_REQ                = 0x000f,
200 58a26b47 balrog
    LMP_CRYPT_KEY_SIZE_REQ        = 0x0010,
201 58a26b47 balrog
    LMP_START_ENCRYPT_REQ        = 0x0011,
202 58a26b47 balrog
    LMP_STOP_ENCRYPT_REQ        = 0x0012,
203 58a26b47 balrog
    LMP_SWITCH_REQ                = 0x0013,
204 58a26b47 balrog
    LMP_HOLD                        = 0x0014,
205 58a26b47 balrog
    LMP_HOLD_REQ                = 0x0015,
206 58a26b47 balrog
    LMP_SNIFF_REQ                = 0x0017,
207 58a26b47 balrog
    LMP_UNSNIFF_REQ                = 0x0018,
208 58a26b47 balrog
    LMP_LMP_PARK_REQ                = 0x0019,
209 58a26b47 balrog
    LMP_SET_BCAST_SCAN_WND        = 0x001b,
210 58a26b47 balrog
    LMP_MODIFY_BEACON                = 0x001c,
211 58a26b47 balrog
    LMP_UNPARK_BD_ADDR_REQ        = 0x001d,
212 58a26b47 balrog
    LMP_UNPARK_PM_ADDR_REQ        = 0x001e,
213 58a26b47 balrog
    LMP_INCR_POWER_REQ                = 0x001f,
214 58a26b47 balrog
    LMP_DECR_POWER_REQ                = 0x0020,
215 58a26b47 balrog
    LMP_MAX_POWER                = 0x0021,
216 58a26b47 balrog
    LMP_MIN_POWER                = 0x0022,
217 58a26b47 balrog
    LMP_AUTO_RATE                = 0x0023,
218 58a26b47 balrog
    LMP_PREFERRED_RATE                = 0x0024,
219 58a26b47 balrog
    LMP_VERSION_REQ                = 0x0025,
220 58a26b47 balrog
    LMP_VERSION_RES                = 0x0026,
221 58a26b47 balrog
    LMP_FEATURES_REQ                = 0x0027,
222 58a26b47 balrog
    LMP_FEATURES_RES                = 0x0028,
223 58a26b47 balrog
    LMP_QUALITY_OF_SERVICE        = 0x0029,
224 58a26b47 balrog
    LMP_QOS_REQ                        = 0x002a,
225 58a26b47 balrog
    LMP_RM_SCO_LINK_REQ                = 0x002b,
226 58a26b47 balrog
    LMP_SCO_LINK_REQ                = 0x002c,
227 58a26b47 balrog
    LMP_MAX_SLOT                = 0x002d,
228 58a26b47 balrog
    LMP_MAX_SLOT_REQ                = 0x002e,
229 58a26b47 balrog
    LMP_TIMING_ACCURACY_REQ        = 0x002f,
230 58a26b47 balrog
    LMP_TIMING_ACCURACY_RES        = 0x0030,
231 58a26b47 balrog
    LMP_SETUP_COMPLETE                = 0x0031,
232 58a26b47 balrog
    LMP_USE_SEMIPERM_KEY        = 0x0032,
233 58a26b47 balrog
    LMP_HOST_CONNECTION_REQ        = 0x0033,
234 58a26b47 balrog
    LMP_SLOT_OFFSET                = 0x0034,
235 58a26b47 balrog
    LMP_PAGE_MODE_REQ                = 0x0035,
236 58a26b47 balrog
    LMP_PAGE_SCAN_MODE_REQ        = 0x0036,
237 58a26b47 balrog
    LMP_SUPERVISION_TIMEOUT        = 0x0037,
238 58a26b47 balrog
    LMP_TEST_ACTIVATE                = 0x0038,
239 58a26b47 balrog
    LMP_TEST_CONTROL                = 0x0039,
240 58a26b47 balrog
    LMP_CRYPT_KEY_MASK_REQ        = 0x003a,
241 58a26b47 balrog
    LMP_CRYPT_KEY_MASK_RES        = 0x003b,
242 58a26b47 balrog
    LMP_SET_AFH                        = 0x003c,
243 58a26b47 balrog
    LMP_ACCEPTED_EXT                = 0x7f01,
244 58a26b47 balrog
    LMP_NOT_ACCEPTED_EXT        = 0x7f02,
245 58a26b47 balrog
    LMP_FEATURES_REQ_EXT        = 0x7f03,
246 58a26b47 balrog
    LMP_FEATURES_RES_EXT        = 0x7f04,
247 58a26b47 balrog
    LMP_PACKET_TYPE_TBL_REQ        = 0x7f0b,
248 58a26b47 balrog
    LMP_ESCO_LINK_REQ                = 0x7f0c,
249 58a26b47 balrog
    LMP_RM_ESCO_LINK_REQ        = 0x7f0d,
250 58a26b47 balrog
    LMP_CHANNEL_CLASS_REQ        = 0x7f10,
251 58a26b47 balrog
    LMP_CHANNEL_CLASS                = 0x7f11,
252 58a26b47 balrog
};
253 58a26b47 balrog
254 58a26b47 balrog
/* Host Controller Interface layer defines */
255 58a26b47 balrog
256 58a26b47 balrog
enum hci_packet_type {
257 58a26b47 balrog
    HCI_COMMAND_PKT                = 0x01,
258 58a26b47 balrog
    HCI_ACLDATA_PKT                = 0x02,
259 58a26b47 balrog
    HCI_SCODATA_PKT                = 0x03,
260 58a26b47 balrog
    HCI_EVENT_PKT                = 0x04,
261 58a26b47 balrog
    HCI_VENDOR_PKT                = 0xff,
262 58a26b47 balrog
};
263 58a26b47 balrog
264 58a26b47 balrog
enum bt_packet_type {
265 58a26b47 balrog
    HCI_2DH1        = 1 << 1,
266 58a26b47 balrog
    HCI_3DH1        = 1 << 2,
267 58a26b47 balrog
    HCI_DM1        = 1 << 3,
268 58a26b47 balrog
    HCI_DH1        = 1 << 4,
269 58a26b47 balrog
    HCI_2DH3        = 1 << 8,
270 58a26b47 balrog
    HCI_3DH3        = 1 << 9,
271 58a26b47 balrog
    HCI_DM3        = 1 << 10,
272 58a26b47 balrog
    HCI_DH3        = 1 << 11,
273 58a26b47 balrog
    HCI_2DH5        = 1 << 12,
274 58a26b47 balrog
    HCI_3DH5        = 1 << 13,
275 58a26b47 balrog
    HCI_DM5        = 1 << 14,
276 58a26b47 balrog
    HCI_DH5        = 1 << 15,
277 58a26b47 balrog
};
278 58a26b47 balrog
279 58a26b47 balrog
enum sco_packet_type {
280 58a26b47 balrog
    HCI_HV1        = 1 << 5,
281 58a26b47 balrog
    HCI_HV2        = 1 << 6,
282 58a26b47 balrog
    HCI_HV3        = 1 << 7,
283 58a26b47 balrog
};
284 58a26b47 balrog
285 58a26b47 balrog
enum ev_packet_type {
286 58a26b47 balrog
    HCI_EV3        = 1 << 3,
287 58a26b47 balrog
    HCI_EV4        = 1 << 4,
288 58a26b47 balrog
    HCI_EV5        = 1 << 5,
289 58a26b47 balrog
    HCI_2EV3        = 1 << 6,
290 58a26b47 balrog
    HCI_3EV3        = 1 << 7,
291 58a26b47 balrog
    HCI_2EV5        = 1 << 8,
292 58a26b47 balrog
    HCI_3EV5        = 1 << 9,
293 58a26b47 balrog
};
294 58a26b47 balrog
295 58a26b47 balrog
enum hci_error_code {
296 58a26b47 balrog
    HCI_SUCCESS                                = 0x00,
297 58a26b47 balrog
    HCI_UNKNOWN_COMMAND                        = 0x01,
298 58a26b47 balrog
    HCI_NO_CONNECTION                        = 0x02,
299 58a26b47 balrog
    HCI_HARDWARE_FAILURE                = 0x03,
300 58a26b47 balrog
    HCI_PAGE_TIMEOUT                        = 0x04,
301 58a26b47 balrog
    HCI_AUTHENTICATION_FAILURE                = 0x05,
302 58a26b47 balrog
    HCI_PIN_OR_KEY_MISSING                = 0x06,
303 58a26b47 balrog
    HCI_MEMORY_FULL                        = 0x07,
304 58a26b47 balrog
    HCI_CONNECTION_TIMEOUT                = 0x08,
305 58a26b47 balrog
    HCI_MAX_NUMBER_OF_CONNECTIONS        = 0x09,
306 58a26b47 balrog
    HCI_MAX_NUMBER_OF_SCO_CONNECTIONS        = 0x0a,
307 58a26b47 balrog
    HCI_ACL_CONNECTION_EXISTS                = 0x0b,
308 58a26b47 balrog
    HCI_COMMAND_DISALLOWED                = 0x0c,
309 58a26b47 balrog
    HCI_REJECTED_LIMITED_RESOURCES        = 0x0d,
310 58a26b47 balrog
    HCI_REJECTED_SECURITY                = 0x0e,
311 58a26b47 balrog
    HCI_REJECTED_PERSONAL                = 0x0f,
312 58a26b47 balrog
    HCI_HOST_TIMEOUT                        = 0x10,
313 58a26b47 balrog
    HCI_UNSUPPORTED_FEATURE                = 0x11,
314 58a26b47 balrog
    HCI_INVALID_PARAMETERS                = 0x12,
315 58a26b47 balrog
    HCI_OE_USER_ENDED_CONNECTION        = 0x13,
316 58a26b47 balrog
    HCI_OE_LOW_RESOURCES                = 0x14,
317 58a26b47 balrog
    HCI_OE_POWER_OFF                        = 0x15,
318 58a26b47 balrog
    HCI_CONNECTION_TERMINATED                = 0x16,
319 58a26b47 balrog
    HCI_REPEATED_ATTEMPTS                = 0x17,
320 58a26b47 balrog
    HCI_PAIRING_NOT_ALLOWED                = 0x18,
321 58a26b47 balrog
    HCI_UNKNOWN_LMP_PDU                        = 0x19,
322 58a26b47 balrog
    HCI_UNSUPPORTED_REMOTE_FEATURE        = 0x1a,
323 58a26b47 balrog
    HCI_SCO_OFFSET_REJECTED                = 0x1b,
324 58a26b47 balrog
    HCI_SCO_INTERVAL_REJECTED                = 0x1c,
325 58a26b47 balrog
    HCI_AIR_MODE_REJECTED                = 0x1d,
326 58a26b47 balrog
    HCI_INVALID_LMP_PARAMETERS                = 0x1e,
327 58a26b47 balrog
    HCI_UNSPECIFIED_ERROR                = 0x1f,
328 58a26b47 balrog
    HCI_UNSUPPORTED_LMP_PARAMETER_VALUE        = 0x20,
329 58a26b47 balrog
    HCI_ROLE_CHANGE_NOT_ALLOWED                = 0x21,
330 58a26b47 balrog
    HCI_LMP_RESPONSE_TIMEOUT                = 0x22,
331 58a26b47 balrog
    HCI_LMP_ERROR_TRANSACTION_COLLISION        = 0x23,
332 58a26b47 balrog
    HCI_LMP_PDU_NOT_ALLOWED                = 0x24,
333 58a26b47 balrog
    HCI_ENCRYPTION_MODE_NOT_ACCEPTED        = 0x25,
334 58a26b47 balrog
    HCI_UNIT_LINK_KEY_USED                = 0x26,
335 58a26b47 balrog
    HCI_QOS_NOT_SUPPORTED                = 0x27,
336 58a26b47 balrog
    HCI_INSTANT_PASSED                        = 0x28,
337 58a26b47 balrog
    HCI_PAIRING_NOT_SUPPORTED                = 0x29,
338 58a26b47 balrog
    HCI_TRANSACTION_COLLISION                = 0x2a,
339 58a26b47 balrog
    HCI_QOS_UNACCEPTABLE_PARAMETER        = 0x2c,
340 58a26b47 balrog
    HCI_QOS_REJECTED                        = 0x2d,
341 58a26b47 balrog
    HCI_CLASSIFICATION_NOT_SUPPORTED        = 0x2e,
342 58a26b47 balrog
    HCI_INSUFFICIENT_SECURITY                = 0x2f,
343 58a26b47 balrog
    HCI_PARAMETER_OUT_OF_RANGE                = 0x30,
344 58a26b47 balrog
    HCI_ROLE_SWITCH_PENDING                = 0x32,
345 58a26b47 balrog
    HCI_SLOT_VIOLATION                        = 0x34,
346 58a26b47 balrog
    HCI_ROLE_SWITCH_FAILED                = 0x35,
347 58a26b47 balrog
};
348 58a26b47 balrog
349 58a26b47 balrog
enum acl_flag_bits {
350 58a26b47 balrog
    ACL_CONT                = 1 << 0,
351 58a26b47 balrog
    ACL_START                = 1 << 1,
352 58a26b47 balrog
    ACL_ACTIVE_BCAST        = 1 << 2,
353 58a26b47 balrog
    ACL_PICO_BCAST        = 1 << 3,
354 58a26b47 balrog
};
355 58a26b47 balrog
356 58a26b47 balrog
enum baseband_link_type {
357 58a26b47 balrog
    SCO_LINK                = 0x00,
358 58a26b47 balrog
    ACL_LINK                = 0x01,
359 58a26b47 balrog
};
360 58a26b47 balrog
361 58a26b47 balrog
enum lmp_feature_bits0 {
362 58a26b47 balrog
    LMP_3SLOT                = 1 << 0,
363 58a26b47 balrog
    LMP_5SLOT                = 1 << 1,
364 58a26b47 balrog
    LMP_ENCRYPT                = 1 << 2,
365 58a26b47 balrog
    LMP_SOFFSET                = 1 << 3,
366 58a26b47 balrog
    LMP_TACCURACY        = 1 << 4,
367 58a26b47 balrog
    LMP_RSWITCH                = 1 << 5,
368 58a26b47 balrog
    LMP_HOLD_MODE        = 1 << 6,
369 58a26b47 balrog
    LMP_SNIFF_MODE        = 1 << 7,
370 58a26b47 balrog
};
371 58a26b47 balrog
372 58a26b47 balrog
enum lmp_feature_bits1 {
373 58a26b47 balrog
    LMP_PARK                = 1 << 0,
374 58a26b47 balrog
    LMP_RSSI                = 1 << 1,
375 58a26b47 balrog
    LMP_QUALITY                = 1 << 2,
376 58a26b47 balrog
    LMP_SCO                = 1 << 3,
377 58a26b47 balrog
    LMP_HV2                = 1 << 4,
378 58a26b47 balrog
    LMP_HV3                = 1 << 5,
379 58a26b47 balrog
    LMP_ULAW                = 1 << 6,
380 58a26b47 balrog
    LMP_ALAW                = 1 << 7,
381 58a26b47 balrog
};
382 58a26b47 balrog
383 58a26b47 balrog
enum lmp_feature_bits2 {
384 58a26b47 balrog
    LMP_CVSD                = 1 << 0,
385 58a26b47 balrog
    LMP_PSCHEME                = 1 << 1,
386 58a26b47 balrog
    LMP_PCONTROL        = 1 << 2,
387 58a26b47 balrog
    LMP_TRSP_SCO        = 1 << 3,
388 58a26b47 balrog
    LMP_BCAST_ENC        = 1 << 7,
389 58a26b47 balrog
};
390 58a26b47 balrog
391 58a26b47 balrog
enum lmp_feature_bits3 {
392 58a26b47 balrog
    LMP_EDR_ACL_2M        = 1 << 1,
393 58a26b47 balrog
    LMP_EDR_ACL_3M        = 1 << 2,
394 58a26b47 balrog
    LMP_ENH_ISCAN        = 1 << 3,
395 58a26b47 balrog
    LMP_ILACE_ISCAN        = 1 << 4,
396 58a26b47 balrog
    LMP_ILACE_PSCAN        = 1 << 5,
397 58a26b47 balrog
    LMP_RSSI_INQ        = 1 << 6,
398 58a26b47 balrog
    LMP_ESCO                = 1 << 7,
399 58a26b47 balrog
};
400 58a26b47 balrog
401 58a26b47 balrog
enum lmp_feature_bits4 {
402 58a26b47 balrog
    LMP_EV4                = 1 << 0,
403 58a26b47 balrog
    LMP_EV5                = 1 << 1,
404 58a26b47 balrog
    LMP_AFH_CAP_SLV        = 1 << 3,
405 58a26b47 balrog
    LMP_AFH_CLS_SLV        = 1 << 4,
406 58a26b47 balrog
    LMP_EDR_3SLOT        = 1 << 7,
407 58a26b47 balrog
};
408 58a26b47 balrog
409 58a26b47 balrog
enum lmp_feature_bits5 {
410 58a26b47 balrog
    LMP_EDR_5SLOT        = 1 << 0,
411 58a26b47 balrog
    LMP_SNIFF_SUBR        = 1 << 1,
412 58a26b47 balrog
    LMP_AFH_CAP_MST        = 1 << 3,
413 58a26b47 balrog
    LMP_AFH_CLS_MST        = 1 << 4,
414 58a26b47 balrog
    LMP_EDR_ESCO_2M        = 1 << 5,
415 58a26b47 balrog
    LMP_EDR_ESCO_3M        = 1 << 6,
416 58a26b47 balrog
    LMP_EDR_3S_ESCO        = 1 << 7,
417 58a26b47 balrog
};
418 58a26b47 balrog
419 58a26b47 balrog
enum lmp_feature_bits6 {
420 58a26b47 balrog
    LMP_EXT_INQ                = 1 << 0,
421 58a26b47 balrog
};
422 58a26b47 balrog
423 58a26b47 balrog
enum lmp_feature_bits7 {
424 58a26b47 balrog
    LMP_EXT_FEAT        = 1 << 7,
425 58a26b47 balrog
};
426 58a26b47 balrog
427 58a26b47 balrog
enum hci_link_policy {
428 58a26b47 balrog
    HCI_LP_RSWITCH        = 1 << 0,
429 58a26b47 balrog
    HCI_LP_HOLD                = 1 << 1,
430 58a26b47 balrog
    HCI_LP_SNIFF        = 1 << 2,
431 58a26b47 balrog
    HCI_LP_PARK                = 1 << 3,
432 58a26b47 balrog
};
433 58a26b47 balrog
434 58a26b47 balrog
enum hci_link_mode {
435 58a26b47 balrog
    HCI_LM_ACCEPT        = 1 << 15,
436 58a26b47 balrog
    HCI_LM_MASTER        = 1 << 0,
437 58a26b47 balrog
    HCI_LM_AUTH                = 1 << 1,
438 58a26b47 balrog
    HCI_LM_ENCRYPT        = 1 << 2,
439 58a26b47 balrog
    HCI_LM_TRUSTED        = 1 << 3,
440 58a26b47 balrog
    HCI_LM_RELIABLE        = 1 << 4,
441 58a26b47 balrog
    HCI_LM_SECURE        = 1 << 5,
442 58a26b47 balrog
};
443 58a26b47 balrog
444 58a26b47 balrog
/* HCI Commands */
445 58a26b47 balrog
446 58a26b47 balrog
/* Link Control */
447 58a26b47 balrog
#define OGF_LINK_CTL                0x01
448 58a26b47 balrog
449 58a26b47 balrog
#define OCF_INQUIRY                        0x0001
450 58a26b47 balrog
typedef struct {
451 58a26b47 balrog
    uint8_t        lap[3];
452 58a26b47 balrog
    uint8_t        length;                /* 1.28s units */
453 58a26b47 balrog
    uint8_t        num_rsp;
454 58a26b47 balrog
} __attribute__ ((packed)) inquiry_cp;
455 58a26b47 balrog
#define INQUIRY_CP_SIZE 5
456 58a26b47 balrog
457 58a26b47 balrog
typedef struct {
458 58a26b47 balrog
    uint8_t                status;
459 58a26b47 balrog
    bdaddr_t        bdaddr;
460 58a26b47 balrog
} __attribute__ ((packed)) status_bdaddr_rp;
461 58a26b47 balrog
#define STATUS_BDADDR_RP_SIZE 7
462 58a26b47 balrog
463 58a26b47 balrog
#define OCF_INQUIRY_CANCEL                0x0002
464 58a26b47 balrog
465 58a26b47 balrog
#define OCF_PERIODIC_INQUIRY                0x0003
466 58a26b47 balrog
typedef struct {
467 58a26b47 balrog
    uint16_t        max_period;        /* 1.28s units */
468 58a26b47 balrog
    uint16_t        min_period;        /* 1.28s units */
469 58a26b47 balrog
    uint8_t        lap[3];
470 58a26b47 balrog
    uint8_t        length;                /* 1.28s units */
471 58a26b47 balrog
    uint8_t        num_rsp;
472 58a26b47 balrog
} __attribute__ ((packed)) periodic_inquiry_cp;
473 58a26b47 balrog
#define PERIODIC_INQUIRY_CP_SIZE 9
474 58a26b47 balrog
475 58a26b47 balrog
#define OCF_EXIT_PERIODIC_INQUIRY        0x0004
476 58a26b47 balrog
477 58a26b47 balrog
#define OCF_CREATE_CONN                        0x0005
478 58a26b47 balrog
typedef struct {
479 58a26b47 balrog
    bdaddr_t        bdaddr;
480 58a26b47 balrog
    uint16_t        pkt_type;
481 58a26b47 balrog
    uint8_t        pscan_rep_mode;
482 58a26b47 balrog
    uint8_t        pscan_mode;
483 58a26b47 balrog
    uint16_t        clock_offset;
484 58a26b47 balrog
    uint8_t        role_switch;
485 58a26b47 balrog
} __attribute__ ((packed)) create_conn_cp;
486 58a26b47 balrog
#define CREATE_CONN_CP_SIZE 13
487 58a26b47 balrog
488 58a26b47 balrog
#define OCF_DISCONNECT                        0x0006
489 58a26b47 balrog
typedef struct {
490 58a26b47 balrog
    uint16_t        handle;
491 58a26b47 balrog
    uint8_t        reason;
492 58a26b47 balrog
} __attribute__ ((packed)) disconnect_cp;
493 58a26b47 balrog
#define DISCONNECT_CP_SIZE 3
494 58a26b47 balrog
495 58a26b47 balrog
#define OCF_ADD_SCO                        0x0007
496 58a26b47 balrog
typedef struct {
497 58a26b47 balrog
    uint16_t        handle;
498 58a26b47 balrog
    uint16_t        pkt_type;
499 58a26b47 balrog
} __attribute__ ((packed)) add_sco_cp;
500 58a26b47 balrog
#define ADD_SCO_CP_SIZE 4
501 58a26b47 balrog
502 58a26b47 balrog
#define OCF_CREATE_CONN_CANCEL                0x0008
503 58a26b47 balrog
typedef struct {
504 58a26b47 balrog
    uint8_t        status;
505 58a26b47 balrog
    bdaddr_t        bdaddr;
506 58a26b47 balrog
} __attribute__ ((packed)) create_conn_cancel_cp;
507 58a26b47 balrog
#define CREATE_CONN_CANCEL_CP_SIZE 6
508 58a26b47 balrog
509 58a26b47 balrog
typedef struct {
510 58a26b47 balrog
    uint8_t        status;
511 58a26b47 balrog
    bdaddr_t        bdaddr;
512 58a26b47 balrog
} __attribute__ ((packed)) create_conn_cancel_rp;
513 58a26b47 balrog
#define CREATE_CONN_CANCEL_RP_SIZE 7
514 58a26b47 balrog
515 58a26b47 balrog
#define OCF_ACCEPT_CONN_REQ                0x0009
516 58a26b47 balrog
typedef struct {
517 58a26b47 balrog
    bdaddr_t        bdaddr;
518 58a26b47 balrog
    uint8_t        role;
519 58a26b47 balrog
} __attribute__ ((packed)) accept_conn_req_cp;
520 58a26b47 balrog
#define ACCEPT_CONN_REQ_CP_SIZE        7
521 58a26b47 balrog
522 58a26b47 balrog
#define OCF_REJECT_CONN_REQ                0x000A
523 58a26b47 balrog
typedef struct {
524 58a26b47 balrog
    bdaddr_t        bdaddr;
525 58a26b47 balrog
    uint8_t        reason;
526 58a26b47 balrog
} __attribute__ ((packed)) reject_conn_req_cp;
527 58a26b47 balrog
#define REJECT_CONN_REQ_CP_SIZE        7
528 58a26b47 balrog
529 58a26b47 balrog
#define OCF_LINK_KEY_REPLY                0x000B
530 58a26b47 balrog
typedef struct {
531 58a26b47 balrog
    bdaddr_t        bdaddr;
532 58a26b47 balrog
    uint8_t        link_key[16];
533 58a26b47 balrog
} __attribute__ ((packed)) link_key_reply_cp;
534 58a26b47 balrog
#define LINK_KEY_REPLY_CP_SIZE 22
535 58a26b47 balrog
536 58a26b47 balrog
#define OCF_LINK_KEY_NEG_REPLY                0x000C
537 58a26b47 balrog
538 58a26b47 balrog
#define OCF_PIN_CODE_REPLY                0x000D
539 58a26b47 balrog
typedef struct {
540 58a26b47 balrog
    bdaddr_t        bdaddr;
541 58a26b47 balrog
    uint8_t        pin_len;
542 58a26b47 balrog
    uint8_t        pin_code[16];
543 58a26b47 balrog
} __attribute__ ((packed)) pin_code_reply_cp;
544 58a26b47 balrog
#define PIN_CODE_REPLY_CP_SIZE 23
545 58a26b47 balrog
546 58a26b47 balrog
#define OCF_PIN_CODE_NEG_REPLY                0x000E
547 58a26b47 balrog
548 58a26b47 balrog
#define OCF_SET_CONN_PTYPE                0x000F
549 58a26b47 balrog
typedef struct {
550 58a26b47 balrog
    uint16_t         handle;
551 58a26b47 balrog
    uint16_t         pkt_type;
552 58a26b47 balrog
} __attribute__ ((packed)) set_conn_ptype_cp;
553 58a26b47 balrog
#define SET_CONN_PTYPE_CP_SIZE 4
554 58a26b47 balrog
555 58a26b47 balrog
#define OCF_AUTH_REQUESTED                0x0011
556 58a26b47 balrog
typedef struct {
557 58a26b47 balrog
    uint16_t         handle;
558 58a26b47 balrog
} __attribute__ ((packed)) auth_requested_cp;
559 58a26b47 balrog
#define AUTH_REQUESTED_CP_SIZE 2
560 58a26b47 balrog
561 58a26b47 balrog
#define OCF_SET_CONN_ENCRYPT                0x0013
562 58a26b47 balrog
typedef struct {
563 58a26b47 balrog
    uint16_t        handle;
564 58a26b47 balrog
    uint8_t        encrypt;
565 58a26b47 balrog
} __attribute__ ((packed)) set_conn_encrypt_cp;
566 58a26b47 balrog
#define SET_CONN_ENCRYPT_CP_SIZE 3
567 58a26b47 balrog
568 58a26b47 balrog
#define OCF_CHANGE_CONN_LINK_KEY        0x0015
569 58a26b47 balrog
typedef struct {
570 58a26b47 balrog
    uint16_t        handle;
571 58a26b47 balrog
} __attribute__ ((packed)) change_conn_link_key_cp;
572 58a26b47 balrog
#define CHANGE_CONN_LINK_KEY_CP_SIZE 2
573 58a26b47 balrog
574 58a26b47 balrog
#define OCF_MASTER_LINK_KEY                0x0017
575 58a26b47 balrog
typedef struct {
576 58a26b47 balrog
    uint8_t        key_flag;
577 58a26b47 balrog
} __attribute__ ((packed)) master_link_key_cp;
578 58a26b47 balrog
#define MASTER_LINK_KEY_CP_SIZE 1
579 58a26b47 balrog
580 58a26b47 balrog
#define OCF_REMOTE_NAME_REQ                0x0019
581 58a26b47 balrog
typedef struct {
582 58a26b47 balrog
    bdaddr_t        bdaddr;
583 58a26b47 balrog
    uint8_t        pscan_rep_mode;
584 58a26b47 balrog
    uint8_t        pscan_mode;
585 58a26b47 balrog
    uint16_t        clock_offset;
586 58a26b47 balrog
} __attribute__ ((packed)) remote_name_req_cp;
587 58a26b47 balrog
#define REMOTE_NAME_REQ_CP_SIZE 10
588 58a26b47 balrog
589 58a26b47 balrog
#define OCF_REMOTE_NAME_REQ_CANCEL        0x001A
590 58a26b47 balrog
typedef struct {
591 58a26b47 balrog
    bdaddr_t        bdaddr;
592 58a26b47 balrog
} __attribute__ ((packed)) remote_name_req_cancel_cp;
593 58a26b47 balrog
#define REMOTE_NAME_REQ_CANCEL_CP_SIZE 6
594 58a26b47 balrog
595 58a26b47 balrog
typedef struct {
596 58a26b47 balrog
    uint8_t                status;
597 58a26b47 balrog
    bdaddr_t        bdaddr;
598 58a26b47 balrog
} __attribute__ ((packed)) remote_name_req_cancel_rp;
599 58a26b47 balrog
#define REMOTE_NAME_REQ_CANCEL_RP_SIZE 7
600 58a26b47 balrog
601 58a26b47 balrog
#define OCF_READ_REMOTE_FEATURES        0x001B
602 58a26b47 balrog
typedef struct {
603 58a26b47 balrog
    uint16_t        handle;
604 58a26b47 balrog
} __attribute__ ((packed)) read_remote_features_cp;
605 58a26b47 balrog
#define READ_REMOTE_FEATURES_CP_SIZE 2
606 58a26b47 balrog
607 58a26b47 balrog
#define OCF_READ_REMOTE_EXT_FEATURES        0x001C
608 58a26b47 balrog
typedef struct {
609 58a26b47 balrog
    uint16_t        handle;
610 58a26b47 balrog
    uint8_t        page_num;
611 58a26b47 balrog
} __attribute__ ((packed)) read_remote_ext_features_cp;
612 58a26b47 balrog
#define READ_REMOTE_EXT_FEATURES_CP_SIZE 3
613 58a26b47 balrog
614 58a26b47 balrog
#define OCF_READ_REMOTE_VERSION                0x001D
615 58a26b47 balrog
typedef struct {
616 58a26b47 balrog
    uint16_t        handle;
617 58a26b47 balrog
} __attribute__ ((packed)) read_remote_version_cp;
618 58a26b47 balrog
#define READ_REMOTE_VERSION_CP_SIZE 2
619 58a26b47 balrog
620 58a26b47 balrog
#define OCF_READ_CLOCK_OFFSET                0x001F
621 58a26b47 balrog
typedef struct {
622 58a26b47 balrog
    uint16_t        handle;
623 58a26b47 balrog
} __attribute__ ((packed)) read_clock_offset_cp;
624 58a26b47 balrog
#define READ_CLOCK_OFFSET_CP_SIZE 2
625 58a26b47 balrog
626 58a26b47 balrog
#define OCF_READ_LMP_HANDLE                0x0020
627 58a26b47 balrog
typedef struct {
628 58a26b47 balrog
    uint16_t        handle;
629 58a26b47 balrog
} __attribute__ ((packed)) read_lmp_handle_cp;
630 58a26b47 balrog
#define READ_LMP_HANDLE_CP_SIZE 2
631 58a26b47 balrog
632 58a26b47 balrog
typedef struct {
633 58a26b47 balrog
    uint8_t        status;
634 58a26b47 balrog
    uint16_t        handle;
635 58a26b47 balrog
    uint8_t        lmp_handle;
636 58a26b47 balrog
    uint32_t        reserved;
637 58a26b47 balrog
} __attribute__ ((packed)) read_lmp_handle_rp;
638 58a26b47 balrog
#define READ_LMP_HANDLE_RP_SIZE 8
639 58a26b47 balrog
640 58a26b47 balrog
#define OCF_SETUP_SYNC_CONN                0x0028
641 58a26b47 balrog
typedef struct {
642 58a26b47 balrog
    uint16_t        handle;
643 58a26b47 balrog
    uint32_t        tx_bandwith;
644 58a26b47 balrog
    uint32_t        rx_bandwith;
645 58a26b47 balrog
    uint16_t        max_latency;
646 58a26b47 balrog
    uint16_t        voice_setting;
647 58a26b47 balrog
    uint8_t        retrans_effort;
648 58a26b47 balrog
    uint16_t        pkt_type;
649 58a26b47 balrog
} __attribute__ ((packed)) setup_sync_conn_cp;
650 58a26b47 balrog
#define SETUP_SYNC_CONN_CP_SIZE 17
651 58a26b47 balrog
652 58a26b47 balrog
#define OCF_ACCEPT_SYNC_CONN_REQ        0x0029
653 58a26b47 balrog
typedef struct {
654 58a26b47 balrog
    bdaddr_t        bdaddr;
655 58a26b47 balrog
    uint32_t        tx_bandwith;
656 58a26b47 balrog
    uint32_t        rx_bandwith;
657 58a26b47 balrog
    uint16_t        max_latency;
658 58a26b47 balrog
    uint16_t        voice_setting;
659 58a26b47 balrog
    uint8_t        retrans_effort;
660 58a26b47 balrog
    uint16_t        pkt_type;
661 58a26b47 balrog
} __attribute__ ((packed)) accept_sync_conn_req_cp;
662 58a26b47 balrog
#define ACCEPT_SYNC_CONN_REQ_CP_SIZE 21
663 58a26b47 balrog
664 58a26b47 balrog
#define OCF_REJECT_SYNC_CONN_REQ        0x002A
665 58a26b47 balrog
typedef struct {
666 58a26b47 balrog
    bdaddr_t        bdaddr;
667 58a26b47 balrog
    uint8_t        reason;
668 58a26b47 balrog
} __attribute__ ((packed)) reject_sync_conn_req_cp;
669 58a26b47 balrog
#define REJECT_SYNC_CONN_REQ_CP_SIZE 7
670 58a26b47 balrog
671 58a26b47 balrog
/* Link Policy */
672 58a26b47 balrog
#define OGF_LINK_POLICY                0x02
673 58a26b47 balrog
674 58a26b47 balrog
#define OCF_HOLD_MODE                        0x0001
675 58a26b47 balrog
typedef struct {
676 58a26b47 balrog
    uint16_t        handle;
677 58a26b47 balrog
    uint16_t        max_interval;
678 58a26b47 balrog
    uint16_t        min_interval;
679 58a26b47 balrog
} __attribute__ ((packed)) hold_mode_cp;
680 58a26b47 balrog
#define HOLD_MODE_CP_SIZE 6
681 58a26b47 balrog
682 58a26b47 balrog
#define OCF_SNIFF_MODE                        0x0003
683 58a26b47 balrog
typedef struct {
684 58a26b47 balrog
    uint16_t        handle;
685 58a26b47 balrog
    uint16_t        max_interval;
686 58a26b47 balrog
    uint16_t        min_interval;
687 58a26b47 balrog
    uint16_t        attempt;
688 58a26b47 balrog
    uint16_t        timeout;
689 58a26b47 balrog
} __attribute__ ((packed)) sniff_mode_cp;
690 58a26b47 balrog
#define SNIFF_MODE_CP_SIZE 10
691 58a26b47 balrog
692 58a26b47 balrog
#define OCF_EXIT_SNIFF_MODE                0x0004
693 58a26b47 balrog
typedef struct {
694 58a26b47 balrog
    uint16_t        handle;
695 58a26b47 balrog
} __attribute__ ((packed)) exit_sniff_mode_cp;
696 58a26b47 balrog
#define EXIT_SNIFF_MODE_CP_SIZE 2
697 58a26b47 balrog
698 58a26b47 balrog
#define OCF_PARK_MODE                        0x0005
699 58a26b47 balrog
typedef struct {
700 58a26b47 balrog
    uint16_t        handle;
701 58a26b47 balrog
    uint16_t        max_interval;
702 58a26b47 balrog
    uint16_t        min_interval;
703 58a26b47 balrog
} __attribute__ ((packed)) park_mode_cp;
704 58a26b47 balrog
#define PARK_MODE_CP_SIZE 6
705 58a26b47 balrog
706 58a26b47 balrog
#define OCF_EXIT_PARK_MODE                0x0006
707 58a26b47 balrog
typedef struct {
708 58a26b47 balrog
    uint16_t        handle;
709 58a26b47 balrog
} __attribute__ ((packed)) exit_park_mode_cp;
710 58a26b47 balrog
#define EXIT_PARK_MODE_CP_SIZE 2
711 58a26b47 balrog
712 58a26b47 balrog
#define OCF_QOS_SETUP                        0x0007
713 58a26b47 balrog
typedef struct {
714 58a26b47 balrog
    uint8_t        service_type;                /* 1 = best effort */
715 58a26b47 balrog
    uint32_t        token_rate;                /* Byte per seconds */
716 58a26b47 balrog
    uint32_t        peak_bandwidth;                /* Byte per seconds */
717 58a26b47 balrog
    uint32_t        latency;                /* Microseconds */
718 58a26b47 balrog
    uint32_t        delay_variation;        /* Microseconds */
719 58a26b47 balrog
} __attribute__ ((packed)) hci_qos;
720 58a26b47 balrog
#define HCI_QOS_CP_SIZE 17
721 58a26b47 balrog
typedef struct {
722 58a26b47 balrog
    uint16_t         handle;
723 58a26b47 balrog
    uint8_t         flags;                        /* Reserved */
724 58a26b47 balrog
    hci_qos         qos;
725 58a26b47 balrog
} __attribute__ ((packed)) qos_setup_cp;
726 58a26b47 balrog
#define QOS_SETUP_CP_SIZE (3 + HCI_QOS_CP_SIZE)
727 58a26b47 balrog
728 58a26b47 balrog
#define OCF_ROLE_DISCOVERY                0x0009
729 58a26b47 balrog
typedef struct {
730 58a26b47 balrog
    uint16_t        handle;
731 58a26b47 balrog
} __attribute__ ((packed)) role_discovery_cp;
732 58a26b47 balrog
#define ROLE_DISCOVERY_CP_SIZE 2
733 58a26b47 balrog
typedef struct {
734 58a26b47 balrog
    uint8_t        status;
735 58a26b47 balrog
    uint16_t        handle;
736 58a26b47 balrog
    uint8_t        role;
737 58a26b47 balrog
} __attribute__ ((packed)) role_discovery_rp;
738 58a26b47 balrog
#define ROLE_DISCOVERY_RP_SIZE 4
739 58a26b47 balrog
740 58a26b47 balrog
#define OCF_SWITCH_ROLE                        0x000B
741 58a26b47 balrog
typedef struct {
742 58a26b47 balrog
    bdaddr_t        bdaddr;
743 58a26b47 balrog
    uint8_t        role;
744 58a26b47 balrog
} __attribute__ ((packed)) switch_role_cp;
745 58a26b47 balrog
#define SWITCH_ROLE_CP_SIZE 7
746 58a26b47 balrog
747 58a26b47 balrog
#define OCF_READ_LINK_POLICY                0x000C
748 58a26b47 balrog
typedef struct {
749 58a26b47 balrog
    uint16_t        handle;
750 58a26b47 balrog
} __attribute__ ((packed)) read_link_policy_cp;
751 58a26b47 balrog
#define READ_LINK_POLICY_CP_SIZE 2
752 58a26b47 balrog
typedef struct {
753 58a26b47 balrog
    uint8_t         status;
754 58a26b47 balrog
    uint16_t        handle;
755 58a26b47 balrog
    uint16_t        policy;
756 58a26b47 balrog
} __attribute__ ((packed)) read_link_policy_rp;
757 58a26b47 balrog
#define READ_LINK_POLICY_RP_SIZE 5
758 58a26b47 balrog
759 58a26b47 balrog
#define OCF_WRITE_LINK_POLICY                0x000D
760 58a26b47 balrog
typedef struct {
761 58a26b47 balrog
    uint16_t        handle;
762 58a26b47 balrog
    uint16_t        policy;
763 58a26b47 balrog
} __attribute__ ((packed)) write_link_policy_cp;
764 58a26b47 balrog
#define WRITE_LINK_POLICY_CP_SIZE 4
765 58a26b47 balrog
typedef struct {
766 58a26b47 balrog
    uint8_t         status;
767 58a26b47 balrog
    uint16_t        handle;
768 58a26b47 balrog
} __attribute__ ((packed)) write_link_policy_rp;
769 58a26b47 balrog
#define WRITE_LINK_POLICY_RP_SIZE 3
770 58a26b47 balrog
771 58a26b47 balrog
#define OCF_READ_DEFAULT_LINK_POLICY        0x000E
772 58a26b47 balrog
773 58a26b47 balrog
#define OCF_WRITE_DEFAULT_LINK_POLICY        0x000F
774 58a26b47 balrog
775 58a26b47 balrog
#define OCF_FLOW_SPECIFICATION                0x0010
776 58a26b47 balrog
777 58a26b47 balrog
#define OCF_SNIFF_SUBRATE                0x0011
778 58a26b47 balrog
typedef struct {
779 58a26b47 balrog
    uint16_t        handle;
780 58a26b47 balrog
    uint16_t        max_remote_latency;
781 58a26b47 balrog
    uint16_t        max_local_latency;
782 58a26b47 balrog
    uint16_t        min_remote_timeout;
783 58a26b47 balrog
    uint16_t        min_local_timeout;
784 58a26b47 balrog
} __attribute__ ((packed)) sniff_subrate_cp;
785 58a26b47 balrog
#define SNIFF_SUBRATE_CP_SIZE 10
786 58a26b47 balrog
787 58a26b47 balrog
/* Host Controller and Baseband */
788 58a26b47 balrog
#define OGF_HOST_CTL                0x03
789 58a26b47 balrog
790 58a26b47 balrog
#define OCF_SET_EVENT_MASK                0x0001
791 58a26b47 balrog
typedef struct {
792 58a26b47 balrog
    uint8_t        mask[8];
793 58a26b47 balrog
} __attribute__ ((packed)) set_event_mask_cp;
794 58a26b47 balrog
#define SET_EVENT_MASK_CP_SIZE 8
795 58a26b47 balrog
796 58a26b47 balrog
#define OCF_RESET                        0x0003
797 58a26b47 balrog
798 58a26b47 balrog
#define OCF_SET_EVENT_FLT                0x0005
799 58a26b47 balrog
typedef struct {
800 58a26b47 balrog
    uint8_t        flt_type;
801 58a26b47 balrog
    uint8_t        cond_type;
802 58a26b47 balrog
    uint8_t        condition[0];
803 58a26b47 balrog
} __attribute__ ((packed)) set_event_flt_cp;
804 58a26b47 balrog
#define SET_EVENT_FLT_CP_SIZE 2
805 58a26b47 balrog
806 58a26b47 balrog
enum bt_filter_type {
807 58a26b47 balrog
    FLT_CLEAR_ALL                = 0x00,
808 58a26b47 balrog
    FLT_INQ_RESULT                = 0x01,
809 58a26b47 balrog
    FLT_CONN_SETUP                = 0x02,
810 58a26b47 balrog
};
811 58a26b47 balrog
enum inq_result_cond_type {
812 58a26b47 balrog
    INQ_RESULT_RETURN_ALL        = 0x00,
813 58a26b47 balrog
    INQ_RESULT_RETURN_CLASS        = 0x01,
814 58a26b47 balrog
    INQ_RESULT_RETURN_BDADDR        = 0x02,
815 58a26b47 balrog
};
816 58a26b47 balrog
enum conn_setup_cond_type {
817 58a26b47 balrog
    CONN_SETUP_ALLOW_ALL        = 0x00,
818 58a26b47 balrog
    CONN_SETUP_ALLOW_CLASS        = 0x01,
819 58a26b47 balrog
    CONN_SETUP_ALLOW_BDADDR        = 0x02,
820 58a26b47 balrog
};
821 58a26b47 balrog
enum conn_setup_cond {
822 58a26b47 balrog
    CONN_SETUP_AUTO_OFF                = 0x01,
823 58a26b47 balrog
    CONN_SETUP_AUTO_ON                = 0x02,
824 58a26b47 balrog
};
825 58a26b47 balrog
826 58a26b47 balrog
#define OCF_FLUSH                        0x0008
827 58a26b47 balrog
typedef struct {
828 58a26b47 balrog
    uint16_t        handle;
829 58a26b47 balrog
} __attribute__ ((packed)) flush_cp;
830 58a26b47 balrog
#define FLUSH_CP_SIZE 2
831 58a26b47 balrog
832 58a26b47 balrog
typedef struct {
833 58a26b47 balrog
    uint8_t        status;
834 58a26b47 balrog
    uint16_t        handle;
835 58a26b47 balrog
} __attribute__ ((packed)) flush_rp;
836 58a26b47 balrog
#define FLUSH_RP_SIZE 3
837 58a26b47 balrog
838 58a26b47 balrog
#define OCF_READ_PIN_TYPE                0x0009
839 58a26b47 balrog
typedef struct {
840 58a26b47 balrog
    uint8_t        status;
841 58a26b47 balrog
    uint8_t        pin_type;
842 58a26b47 balrog
} __attribute__ ((packed)) read_pin_type_rp;
843 58a26b47 balrog
#define READ_PIN_TYPE_RP_SIZE 2
844 58a26b47 balrog
845 58a26b47 balrog
#define OCF_WRITE_PIN_TYPE                0x000A
846 58a26b47 balrog
typedef struct {
847 58a26b47 balrog
    uint8_t        pin_type;
848 58a26b47 balrog
} __attribute__ ((packed)) write_pin_type_cp;
849 58a26b47 balrog
#define WRITE_PIN_TYPE_CP_SIZE 1
850 58a26b47 balrog
851 58a26b47 balrog
#define OCF_CREATE_NEW_UNIT_KEY                0x000B
852 58a26b47 balrog
853 58a26b47 balrog
#define OCF_READ_STORED_LINK_KEY        0x000D
854 58a26b47 balrog
typedef struct {
855 58a26b47 balrog
    bdaddr_t        bdaddr;
856 58a26b47 balrog
    uint8_t        read_all;
857 58a26b47 balrog
} __attribute__ ((packed)) read_stored_link_key_cp;
858 58a26b47 balrog
#define READ_STORED_LINK_KEY_CP_SIZE 7
859 58a26b47 balrog
typedef struct {
860 58a26b47 balrog
    uint8_t        status;
861 58a26b47 balrog
    uint16_t        max_keys;
862 58a26b47 balrog
    uint16_t        num_keys;
863 58a26b47 balrog
} __attribute__ ((packed)) read_stored_link_key_rp;
864 58a26b47 balrog
#define READ_STORED_LINK_KEY_RP_SIZE 5
865 58a26b47 balrog
866 58a26b47 balrog
#define OCF_WRITE_STORED_LINK_KEY        0x0011
867 58a26b47 balrog
typedef struct {
868 58a26b47 balrog
    uint8_t        num_keys;
869 58a26b47 balrog
    /* variable length part */
870 58a26b47 balrog
} __attribute__ ((packed)) write_stored_link_key_cp;
871 58a26b47 balrog
#define WRITE_STORED_LINK_KEY_CP_SIZE 1
872 58a26b47 balrog
typedef struct {
873 58a26b47 balrog
    uint8_t        status;
874 58a26b47 balrog
    uint8_t        num_keys;
875 58a26b47 balrog
} __attribute__ ((packed)) write_stored_link_key_rp;
876 58a26b47 balrog
#define READ_WRITE_LINK_KEY_RP_SIZE 2
877 58a26b47 balrog
878 58a26b47 balrog
#define OCF_DELETE_STORED_LINK_KEY        0x0012
879 58a26b47 balrog
typedef struct {
880 58a26b47 balrog
    bdaddr_t        bdaddr;
881 58a26b47 balrog
    uint8_t        delete_all;
882 58a26b47 balrog
} __attribute__ ((packed)) delete_stored_link_key_cp;
883 58a26b47 balrog
#define DELETE_STORED_LINK_KEY_CP_SIZE 7
884 58a26b47 balrog
typedef struct {
885 58a26b47 balrog
    uint8_t        status;
886 58a26b47 balrog
    uint16_t        num_keys;
887 58a26b47 balrog
} __attribute__ ((packed)) delete_stored_link_key_rp;
888 58a26b47 balrog
#define DELETE_STORED_LINK_KEY_RP_SIZE 3
889 58a26b47 balrog
890 58a26b47 balrog
#define OCF_CHANGE_LOCAL_NAME                0x0013
891 58a26b47 balrog
typedef struct {
892 58a26b47 balrog
    char        name[248];
893 58a26b47 balrog
} __attribute__ ((packed)) change_local_name_cp;
894 58a26b47 balrog
#define CHANGE_LOCAL_NAME_CP_SIZE 248 
895 58a26b47 balrog
896 58a26b47 balrog
#define OCF_READ_LOCAL_NAME                0x0014
897 58a26b47 balrog
typedef struct {
898 58a26b47 balrog
    uint8_t        status;
899 58a26b47 balrog
    char        name[248];
900 58a26b47 balrog
} __attribute__ ((packed)) read_local_name_rp;
901 58a26b47 balrog
#define READ_LOCAL_NAME_RP_SIZE 249 
902 58a26b47 balrog
903 58a26b47 balrog
#define OCF_READ_CONN_ACCEPT_TIMEOUT        0x0015
904 58a26b47 balrog
typedef struct {
905 58a26b47 balrog
    uint8_t        status;
906 58a26b47 balrog
    uint16_t        timeout;
907 58a26b47 balrog
} __attribute__ ((packed)) read_conn_accept_timeout_rp;
908 58a26b47 balrog
#define READ_CONN_ACCEPT_TIMEOUT_RP_SIZE 3
909 58a26b47 balrog
910 58a26b47 balrog
#define OCF_WRITE_CONN_ACCEPT_TIMEOUT        0x0016
911 58a26b47 balrog
typedef struct {
912 58a26b47 balrog
    uint16_t        timeout;
913 58a26b47 balrog
} __attribute__ ((packed)) write_conn_accept_timeout_cp;
914 58a26b47 balrog
#define WRITE_CONN_ACCEPT_TIMEOUT_CP_SIZE 2
915 58a26b47 balrog
916 58a26b47 balrog
#define OCF_READ_PAGE_TIMEOUT                0x0017
917 58a26b47 balrog
typedef struct {
918 58a26b47 balrog
    uint8_t        status;
919 58a26b47 balrog
    uint16_t        timeout;
920 58a26b47 balrog
} __attribute__ ((packed)) read_page_timeout_rp;
921 58a26b47 balrog
#define READ_PAGE_TIMEOUT_RP_SIZE 3
922 58a26b47 balrog
923 58a26b47 balrog
#define OCF_WRITE_PAGE_TIMEOUT                0x0018
924 58a26b47 balrog
typedef struct {
925 58a26b47 balrog
    uint16_t        timeout;
926 58a26b47 balrog
} __attribute__ ((packed)) write_page_timeout_cp;
927 58a26b47 balrog
#define WRITE_PAGE_TIMEOUT_CP_SIZE 2
928 58a26b47 balrog
929 58a26b47 balrog
#define OCF_READ_SCAN_ENABLE                0x0019
930 58a26b47 balrog
typedef struct {
931 58a26b47 balrog
    uint8_t        status;
932 58a26b47 balrog
    uint8_t        enable;
933 58a26b47 balrog
} __attribute__ ((packed)) read_scan_enable_rp;
934 58a26b47 balrog
#define READ_SCAN_ENABLE_RP_SIZE 2
935 58a26b47 balrog
936 58a26b47 balrog
#define OCF_WRITE_SCAN_ENABLE                0x001A
937 58a26b47 balrog
typedef struct {
938 58a26b47 balrog
    uint8_t        scan_enable;
939 58a26b47 balrog
} __attribute__ ((packed)) write_scan_enable_cp;
940 58a26b47 balrog
#define WRITE_SCAN_ENABLE_CP_SIZE 1
941 58a26b47 balrog
942 58a26b47 balrog
enum scan_enable_bits {
943 58a26b47 balrog
    SCAN_DISABLED                = 0,
944 58a26b47 balrog
    SCAN_INQUIRY                = 1 << 0,
945 58a26b47 balrog
    SCAN_PAGE                        = 1 << 1,
946 58a26b47 balrog
};
947 58a26b47 balrog
948 58a26b47 balrog
#define OCF_READ_PAGE_ACTIVITY                0x001B
949 58a26b47 balrog
typedef struct {
950 58a26b47 balrog
    uint8_t        status;
951 58a26b47 balrog
    uint16_t        interval;
952 58a26b47 balrog
    uint16_t        window;
953 58a26b47 balrog
} __attribute__ ((packed)) read_page_activity_rp;
954 58a26b47 balrog
#define READ_PAGE_ACTIVITY_RP_SIZE 5
955 58a26b47 balrog
956 58a26b47 balrog
#define OCF_WRITE_PAGE_ACTIVITY                0x001C
957 58a26b47 balrog
typedef struct {
958 58a26b47 balrog
    uint16_t        interval;
959 58a26b47 balrog
    uint16_t        window;
960 58a26b47 balrog
} __attribute__ ((packed)) write_page_activity_cp;
961 58a26b47 balrog
#define WRITE_PAGE_ACTIVITY_CP_SIZE 4
962 58a26b47 balrog
963 58a26b47 balrog
#define OCF_READ_INQ_ACTIVITY                0x001D
964 58a26b47 balrog
typedef struct {
965 58a26b47 balrog
    uint8_t        status;
966 58a26b47 balrog
    uint16_t        interval;
967 58a26b47 balrog
    uint16_t        window;
968 58a26b47 balrog
} __attribute__ ((packed)) read_inq_activity_rp;
969 58a26b47 balrog
#define READ_INQ_ACTIVITY_RP_SIZE 5
970 58a26b47 balrog
971 58a26b47 balrog
#define OCF_WRITE_INQ_ACTIVITY                0x001E
972 58a26b47 balrog
typedef struct {
973 58a26b47 balrog
    uint16_t        interval;
974 58a26b47 balrog
    uint16_t        window;
975 58a26b47 balrog
} __attribute__ ((packed)) write_inq_activity_cp;
976 58a26b47 balrog
#define WRITE_INQ_ACTIVITY_CP_SIZE 4
977 58a26b47 balrog
978 58a26b47 balrog
#define OCF_READ_AUTH_ENABLE                0x001F
979 58a26b47 balrog
980 58a26b47 balrog
#define OCF_WRITE_AUTH_ENABLE                0x0020
981 58a26b47 balrog
982 58a26b47 balrog
#define AUTH_DISABLED                0x00
983 58a26b47 balrog
#define AUTH_ENABLED                0x01
984 58a26b47 balrog
985 58a26b47 balrog
#define OCF_READ_ENCRYPT_MODE                0x0021
986 58a26b47 balrog
987 58a26b47 balrog
#define OCF_WRITE_ENCRYPT_MODE                0x0022
988 58a26b47 balrog
989 58a26b47 balrog
#define ENCRYPT_DISABLED        0x00
990 58a26b47 balrog
#define ENCRYPT_P2P                0x01
991 58a26b47 balrog
#define ENCRYPT_BOTH                0x02
992 58a26b47 balrog
993 58a26b47 balrog
#define OCF_READ_CLASS_OF_DEV                0x0023
994 58a26b47 balrog
typedef struct {
995 58a26b47 balrog
    uint8_t        status;
996 58a26b47 balrog
    uint8_t        dev_class[3];
997 58a26b47 balrog
} __attribute__ ((packed)) read_class_of_dev_rp;
998 58a26b47 balrog
#define READ_CLASS_OF_DEV_RP_SIZE 4 
999 58a26b47 balrog
1000 58a26b47 balrog
#define OCF_WRITE_CLASS_OF_DEV                0x0024
1001 58a26b47 balrog
typedef struct {
1002 58a26b47 balrog
    uint8_t        dev_class[3];
1003 58a26b47 balrog
} __attribute__ ((packed)) write_class_of_dev_cp;
1004 58a26b47 balrog
#define WRITE_CLASS_OF_DEV_CP_SIZE 3
1005 58a26b47 balrog
1006 58a26b47 balrog
#define OCF_READ_VOICE_SETTING                0x0025
1007 58a26b47 balrog
typedef struct {
1008 58a26b47 balrog
    uint8_t        status;
1009 58a26b47 balrog
    uint16_t        voice_setting;
1010 58a26b47 balrog
} __attribute__ ((packed)) read_voice_setting_rp;
1011 58a26b47 balrog
#define READ_VOICE_SETTING_RP_SIZE 3
1012 58a26b47 balrog
1013 58a26b47 balrog
#define OCF_WRITE_VOICE_SETTING                0x0026
1014 58a26b47 balrog
typedef struct {
1015 58a26b47 balrog
    uint16_t        voice_setting;
1016 58a26b47 balrog
} __attribute__ ((packed)) write_voice_setting_cp;
1017 58a26b47 balrog
#define WRITE_VOICE_SETTING_CP_SIZE 2
1018 58a26b47 balrog
1019 58a26b47 balrog
#define OCF_READ_AUTOMATIC_FLUSH_TIMEOUT        0x0027
1020 58a26b47 balrog
1021 58a26b47 balrog
#define OCF_WRITE_AUTOMATIC_FLUSH_TIMEOUT        0x0028
1022 58a26b47 balrog
1023 58a26b47 balrog
#define OCF_READ_NUM_BROADCAST_RETRANS        0x0029
1024 58a26b47 balrog
1025 58a26b47 balrog
#define OCF_WRITE_NUM_BROADCAST_RETRANS        0x002A
1026 58a26b47 balrog
1027 58a26b47 balrog
#define OCF_READ_HOLD_MODE_ACTIVITY        0x002B
1028 58a26b47 balrog
1029 58a26b47 balrog
#define OCF_WRITE_HOLD_MODE_ACTIVITY        0x002C
1030 58a26b47 balrog
1031 58a26b47 balrog
#define OCF_READ_TRANSMIT_POWER_LEVEL        0x002D
1032 58a26b47 balrog
typedef struct {
1033 58a26b47 balrog
    uint16_t        handle;
1034 58a26b47 balrog
    uint8_t        type;
1035 58a26b47 balrog
} __attribute__ ((packed)) read_transmit_power_level_cp;
1036 58a26b47 balrog
#define READ_TRANSMIT_POWER_LEVEL_CP_SIZE 3
1037 58a26b47 balrog
typedef struct {
1038 58a26b47 balrog
    uint8_t        status;
1039 58a26b47 balrog
    uint16_t        handle;
1040 58a26b47 balrog
    int8_t        level;
1041 58a26b47 balrog
} __attribute__ ((packed)) read_transmit_power_level_rp;
1042 58a26b47 balrog
#define READ_TRANSMIT_POWER_LEVEL_RP_SIZE 4
1043 58a26b47 balrog
1044 58a26b47 balrog
#define OCF_HOST_BUFFER_SIZE                0x0033
1045 58a26b47 balrog
typedef struct {
1046 58a26b47 balrog
    uint16_t        acl_mtu;
1047 58a26b47 balrog
    uint8_t        sco_mtu;
1048 58a26b47 balrog
    uint16_t        acl_max_pkt;
1049 58a26b47 balrog
    uint16_t        sco_max_pkt;
1050 58a26b47 balrog
} __attribute__ ((packed)) host_buffer_size_cp;
1051 58a26b47 balrog
#define HOST_BUFFER_SIZE_CP_SIZE 7
1052 58a26b47 balrog
1053 58a26b47 balrog
#define OCF_HOST_NUMBER_OF_COMPLETED_PACKETS        0x0035
1054 58a26b47 balrog
1055 58a26b47 balrog
#define OCF_READ_LINK_SUPERVISION_TIMEOUT        0x0036
1056 58a26b47 balrog
typedef struct {
1057 58a26b47 balrog
    uint8_t        status;
1058 58a26b47 balrog
    uint16_t        handle;
1059 58a26b47 balrog
    uint16_t        link_sup_to;
1060 58a26b47 balrog
} __attribute__ ((packed)) read_link_supervision_timeout_rp;
1061 58a26b47 balrog
#define READ_LINK_SUPERVISION_TIMEOUT_RP_SIZE 5
1062 58a26b47 balrog
1063 58a26b47 balrog
#define OCF_WRITE_LINK_SUPERVISION_TIMEOUT        0x0037
1064 58a26b47 balrog
typedef struct {
1065 58a26b47 balrog
    uint16_t        handle;
1066 58a26b47 balrog
    uint16_t        link_sup_to;
1067 58a26b47 balrog
} __attribute__ ((packed)) write_link_supervision_timeout_cp;
1068 58a26b47 balrog
#define WRITE_LINK_SUPERVISION_TIMEOUT_CP_SIZE 4
1069 58a26b47 balrog
typedef struct {
1070 58a26b47 balrog
    uint8_t        status;
1071 58a26b47 balrog
    uint16_t        handle;
1072 58a26b47 balrog
} __attribute__ ((packed)) write_link_supervision_timeout_rp;
1073 58a26b47 balrog
#define WRITE_LINK_SUPERVISION_TIMEOUT_RP_SIZE 3
1074 58a26b47 balrog
1075 58a26b47 balrog
#define OCF_READ_NUM_SUPPORTED_IAC        0x0038
1076 58a26b47 balrog
1077 58a26b47 balrog
#define MAX_IAC_LAP 0x40
1078 58a26b47 balrog
#define OCF_READ_CURRENT_IAC_LAP        0x0039
1079 58a26b47 balrog
typedef struct {
1080 58a26b47 balrog
    uint8_t        status;
1081 58a26b47 balrog
    uint8_t        num_current_iac;
1082 58a26b47 balrog
    uint8_t        lap[MAX_IAC_LAP][3];
1083 58a26b47 balrog
} __attribute__ ((packed)) read_current_iac_lap_rp;
1084 58a26b47 balrog
#define READ_CURRENT_IAC_LAP_RP_SIZE 2+3*MAX_IAC_LAP
1085 58a26b47 balrog
1086 58a26b47 balrog
#define OCF_WRITE_CURRENT_IAC_LAP        0x003A
1087 58a26b47 balrog
typedef struct {
1088 58a26b47 balrog
    uint8_t        num_current_iac;
1089 58a26b47 balrog
    uint8_t        lap[MAX_IAC_LAP][3];
1090 58a26b47 balrog
} __attribute__ ((packed)) write_current_iac_lap_cp;
1091 58a26b47 balrog
#define WRITE_CURRENT_IAC_LAP_CP_SIZE 1+3*MAX_IAC_LAP
1092 58a26b47 balrog
1093 58a26b47 balrog
#define OCF_READ_PAGE_SCAN_PERIOD_MODE        0x003B
1094 58a26b47 balrog
1095 58a26b47 balrog
#define OCF_WRITE_PAGE_SCAN_PERIOD_MODE        0x003C
1096 58a26b47 balrog
1097 58a26b47 balrog
#define OCF_READ_PAGE_SCAN_MODE                0x003D
1098 58a26b47 balrog
1099 58a26b47 balrog
#define OCF_WRITE_PAGE_SCAN_MODE        0x003E
1100 58a26b47 balrog
1101 58a26b47 balrog
#define OCF_SET_AFH_CLASSIFICATION        0x003F
1102 58a26b47 balrog
typedef struct {
1103 58a26b47 balrog
    uint8_t        map[10];
1104 58a26b47 balrog
} __attribute__ ((packed)) set_afh_classification_cp;
1105 58a26b47 balrog
#define SET_AFH_CLASSIFICATION_CP_SIZE 10
1106 58a26b47 balrog
typedef struct {
1107 58a26b47 balrog
    uint8_t        status;
1108 58a26b47 balrog
} __attribute__ ((packed)) set_afh_classification_rp;
1109 58a26b47 balrog
#define SET_AFH_CLASSIFICATION_RP_SIZE 1
1110 58a26b47 balrog
1111 58a26b47 balrog
#define OCF_READ_INQUIRY_SCAN_TYPE        0x0042
1112 58a26b47 balrog
typedef struct {
1113 58a26b47 balrog
    uint8_t        status;
1114 58a26b47 balrog
    uint8_t        type;
1115 58a26b47 balrog
} __attribute__ ((packed)) read_inquiry_scan_type_rp;
1116 58a26b47 balrog
#define READ_INQUIRY_SCAN_TYPE_RP_SIZE 2
1117 58a26b47 balrog
1118 58a26b47 balrog
#define OCF_WRITE_INQUIRY_SCAN_TYPE        0x0043
1119 58a26b47 balrog
typedef struct {
1120 58a26b47 balrog
    uint8_t        type;
1121 58a26b47 balrog
} __attribute__ ((packed)) write_inquiry_scan_type_cp;
1122 58a26b47 balrog
#define WRITE_INQUIRY_SCAN_TYPE_CP_SIZE 1
1123 58a26b47 balrog
typedef struct {
1124 58a26b47 balrog
    uint8_t        status;
1125 58a26b47 balrog
} __attribute__ ((packed)) write_inquiry_scan_type_rp;
1126 58a26b47 balrog
#define WRITE_INQUIRY_SCAN_TYPE_RP_SIZE 1
1127 58a26b47 balrog
1128 58a26b47 balrog
#define OCF_READ_INQUIRY_MODE                0x0044
1129 58a26b47 balrog
typedef struct {
1130 58a26b47 balrog
    uint8_t        status;
1131 58a26b47 balrog
    uint8_t        mode;
1132 58a26b47 balrog
} __attribute__ ((packed)) read_inquiry_mode_rp;
1133 58a26b47 balrog
#define READ_INQUIRY_MODE_RP_SIZE 2
1134 58a26b47 balrog
1135 58a26b47 balrog
#define OCF_WRITE_INQUIRY_MODE                0x0045
1136 58a26b47 balrog
typedef struct {
1137 58a26b47 balrog
    uint8_t        mode;
1138 58a26b47 balrog
} __attribute__ ((packed)) write_inquiry_mode_cp;
1139 58a26b47 balrog
#define WRITE_INQUIRY_MODE_CP_SIZE 1
1140 58a26b47 balrog
typedef struct {
1141 58a26b47 balrog
    uint8_t        status;
1142 58a26b47 balrog
} __attribute__ ((packed)) write_inquiry_mode_rp;
1143 58a26b47 balrog
#define WRITE_INQUIRY_MODE_RP_SIZE 1
1144 58a26b47 balrog
1145 58a26b47 balrog
#define OCF_READ_PAGE_SCAN_TYPE                0x0046
1146 58a26b47 balrog
1147 58a26b47 balrog
#define OCF_WRITE_PAGE_SCAN_TYPE        0x0047
1148 58a26b47 balrog
1149 58a26b47 balrog
#define OCF_READ_AFH_MODE                0x0048
1150 58a26b47 balrog
typedef struct {
1151 58a26b47 balrog
    uint8_t        status;
1152 58a26b47 balrog
    uint8_t        mode;
1153 58a26b47 balrog
} __attribute__ ((packed)) read_afh_mode_rp;
1154 58a26b47 balrog
#define READ_AFH_MODE_RP_SIZE 2
1155 58a26b47 balrog
1156 58a26b47 balrog
#define OCF_WRITE_AFH_MODE                0x0049
1157 58a26b47 balrog
typedef struct {
1158 58a26b47 balrog
    uint8_t        mode;
1159 58a26b47 balrog
} __attribute__ ((packed)) write_afh_mode_cp;
1160 58a26b47 balrog
#define WRITE_AFH_MODE_CP_SIZE 1
1161 58a26b47 balrog
typedef struct {
1162 58a26b47 balrog
    uint8_t        status;
1163 58a26b47 balrog
} __attribute__ ((packed)) write_afh_mode_rp;
1164 58a26b47 balrog
#define WRITE_AFH_MODE_RP_SIZE 1
1165 58a26b47 balrog
1166 58a26b47 balrog
#define OCF_READ_EXT_INQUIRY_RESPONSE        0x0051
1167 58a26b47 balrog
typedef struct {
1168 58a26b47 balrog
    uint8_t        status;
1169 58a26b47 balrog
    uint8_t        fec;
1170 58a26b47 balrog
    uint8_t        data[240];
1171 58a26b47 balrog
} __attribute__ ((packed)) read_ext_inquiry_response_rp;
1172 58a26b47 balrog
#define READ_EXT_INQUIRY_RESPONSE_RP_SIZE 242
1173 58a26b47 balrog
1174 58a26b47 balrog
#define OCF_WRITE_EXT_INQUIRY_RESPONSE        0x0052
1175 58a26b47 balrog
typedef struct {
1176 58a26b47 balrog
    uint8_t        fec;
1177 58a26b47 balrog
    uint8_t        data[240];
1178 58a26b47 balrog
} __attribute__ ((packed)) write_ext_inquiry_response_cp;
1179 58a26b47 balrog
#define WRITE_EXT_INQUIRY_RESPONSE_CP_SIZE 241
1180 58a26b47 balrog
typedef struct {
1181 58a26b47 balrog
    uint8_t        status;
1182 58a26b47 balrog
} __attribute__ ((packed)) write_ext_inquiry_response_rp;
1183 58a26b47 balrog
#define WRITE_EXT_INQUIRY_RESPONSE_RP_SIZE 1
1184 58a26b47 balrog
1185 58a26b47 balrog
/* Informational Parameters */
1186 58a26b47 balrog
#define OGF_INFO_PARAM                0x04
1187 58a26b47 balrog
1188 58a26b47 balrog
#define OCF_READ_LOCAL_VERSION                0x0001
1189 58a26b47 balrog
typedef struct {
1190 58a26b47 balrog
    uint8_t        status;
1191 58a26b47 balrog
    uint8_t        hci_ver;
1192 58a26b47 balrog
    uint16_t        hci_rev;
1193 58a26b47 balrog
    uint8_t        lmp_ver;
1194 58a26b47 balrog
    uint16_t        manufacturer;
1195 58a26b47 balrog
    uint16_t        lmp_subver;
1196 58a26b47 balrog
} __attribute__ ((packed)) read_local_version_rp;
1197 58a26b47 balrog
#define READ_LOCAL_VERSION_RP_SIZE 9
1198 58a26b47 balrog
1199 58a26b47 balrog
#define OCF_READ_LOCAL_COMMANDS                0x0002
1200 58a26b47 balrog
typedef struct {
1201 58a26b47 balrog
    uint8_t        status;
1202 58a26b47 balrog
    uint8_t        commands[64];
1203 58a26b47 balrog
} __attribute__ ((packed)) read_local_commands_rp;
1204 58a26b47 balrog
#define READ_LOCAL_COMMANDS_RP_SIZE 65
1205 58a26b47 balrog
1206 58a26b47 balrog
#define OCF_READ_LOCAL_FEATURES                0x0003
1207 58a26b47 balrog
typedef struct {
1208 58a26b47 balrog
    uint8_t        status;
1209 58a26b47 balrog
    uint8_t        features[8];
1210 58a26b47 balrog
} __attribute__ ((packed)) read_local_features_rp;
1211 58a26b47 balrog
#define READ_LOCAL_FEATURES_RP_SIZE 9
1212 58a26b47 balrog
1213 58a26b47 balrog
#define OCF_READ_LOCAL_EXT_FEATURES        0x0004
1214 58a26b47 balrog
typedef struct {
1215 58a26b47 balrog
    uint8_t        page_num;
1216 58a26b47 balrog
} __attribute__ ((packed)) read_local_ext_features_cp;
1217 58a26b47 balrog
#define READ_LOCAL_EXT_FEATURES_CP_SIZE 1
1218 58a26b47 balrog
typedef struct {
1219 58a26b47 balrog
    uint8_t        status;
1220 58a26b47 balrog
    uint8_t        page_num;
1221 58a26b47 balrog
    uint8_t        max_page_num;
1222 58a26b47 balrog
    uint8_t        features[8];
1223 58a26b47 balrog
} __attribute__ ((packed)) read_local_ext_features_rp;
1224 58a26b47 balrog
#define READ_LOCAL_EXT_FEATURES_RP_SIZE 11
1225 58a26b47 balrog
1226 58a26b47 balrog
#define OCF_READ_BUFFER_SIZE                0x0005
1227 58a26b47 balrog
typedef struct {
1228 58a26b47 balrog
    uint8_t        status;
1229 58a26b47 balrog
    uint16_t        acl_mtu;
1230 58a26b47 balrog
    uint8_t        sco_mtu;
1231 58a26b47 balrog
    uint16_t        acl_max_pkt;
1232 58a26b47 balrog
    uint16_t        sco_max_pkt;
1233 58a26b47 balrog
} __attribute__ ((packed)) read_buffer_size_rp;
1234 58a26b47 balrog
#define READ_BUFFER_SIZE_RP_SIZE 8
1235 58a26b47 balrog
1236 58a26b47 balrog
#define OCF_READ_COUNTRY_CODE                0x0007
1237 58a26b47 balrog
typedef struct {
1238 58a26b47 balrog
    uint8_t        status;
1239 58a26b47 balrog
    uint8_t        country_code;
1240 58a26b47 balrog
} __attribute__ ((packed)) read_country_code_rp;
1241 58a26b47 balrog
#define READ_COUNTRY_CODE_RP_SIZE 2
1242 58a26b47 balrog
1243 58a26b47 balrog
#define OCF_READ_BD_ADDR                0x0009
1244 58a26b47 balrog
typedef struct {
1245 58a26b47 balrog
    uint8_t        status;
1246 58a26b47 balrog
    bdaddr_t        bdaddr;
1247 58a26b47 balrog
} __attribute__ ((packed)) read_bd_addr_rp;
1248 58a26b47 balrog
#define READ_BD_ADDR_RP_SIZE 7
1249 58a26b47 balrog
1250 58a26b47 balrog
/* Status params */
1251 58a26b47 balrog
#define OGF_STATUS_PARAM        0x05
1252 58a26b47 balrog
1253 58a26b47 balrog
#define OCF_READ_FAILED_CONTACT_COUNTER                0x0001
1254 58a26b47 balrog
typedef struct {
1255 58a26b47 balrog
    uint8_t        status;
1256 58a26b47 balrog
    uint16_t        handle;
1257 58a26b47 balrog
    uint8_t        counter;
1258 58a26b47 balrog
} __attribute__ ((packed)) read_failed_contact_counter_rp;
1259 58a26b47 balrog
#define READ_FAILED_CONTACT_COUNTER_RP_SIZE 4
1260 58a26b47 balrog
1261 58a26b47 balrog
#define OCF_RESET_FAILED_CONTACT_COUNTER        0x0002
1262 58a26b47 balrog
typedef struct {
1263 58a26b47 balrog
    uint8_t        status;
1264 58a26b47 balrog
    uint16_t        handle;
1265 58a26b47 balrog
} __attribute__ ((packed)) reset_failed_contact_counter_rp;
1266 58a26b47 balrog
#define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 4
1267 58a26b47 balrog
1268 58a26b47 balrog
#define OCF_READ_LINK_QUALITY                0x0003
1269 58a26b47 balrog
typedef struct {
1270 58a26b47 balrog
    uint16_t        handle;
1271 58a26b47 balrog
} __attribute__ ((packed)) read_link_quality_cp;
1272 58a26b47 balrog
#define READ_LINK_QUALITY_CP_SIZE 4
1273 58a26b47 balrog
1274 58a26b47 balrog
typedef struct {
1275 58a26b47 balrog
    uint8_t        status;
1276 58a26b47 balrog
    uint16_t        handle;
1277 58a26b47 balrog
    uint8_t        link_quality;
1278 58a26b47 balrog
} __attribute__ ((packed)) read_link_quality_rp;
1279 58a26b47 balrog
#define READ_LINK_QUALITY_RP_SIZE 4
1280 58a26b47 balrog
1281 58a26b47 balrog
#define OCF_READ_RSSI                        0x0005
1282 58a26b47 balrog
typedef struct {
1283 58a26b47 balrog
    uint8_t        status;
1284 58a26b47 balrog
    uint16_t        handle;
1285 58a26b47 balrog
    int8_t        rssi;
1286 58a26b47 balrog
} __attribute__ ((packed)) read_rssi_rp;
1287 58a26b47 balrog
#define READ_RSSI_RP_SIZE 4
1288 58a26b47 balrog
1289 58a26b47 balrog
#define OCF_READ_AFH_MAP                0x0006
1290 58a26b47 balrog
typedef struct {
1291 58a26b47 balrog
    uint8_t        status;
1292 58a26b47 balrog
    uint16_t        handle;
1293 58a26b47 balrog
    uint8_t        mode;
1294 58a26b47 balrog
    uint8_t        map[10];
1295 58a26b47 balrog
} __attribute__ ((packed)) read_afh_map_rp;
1296 58a26b47 balrog
#define READ_AFH_MAP_RP_SIZE 14
1297 58a26b47 balrog
1298 58a26b47 balrog
#define OCF_READ_CLOCK                        0x0007
1299 58a26b47 balrog
typedef struct {
1300 58a26b47 balrog
    uint16_t        handle;
1301 58a26b47 balrog
    uint8_t        which_clock;
1302 58a26b47 balrog
} __attribute__ ((packed)) read_clock_cp;
1303 58a26b47 balrog
#define READ_CLOCK_CP_SIZE 3
1304 58a26b47 balrog
typedef struct {
1305 58a26b47 balrog
    uint8_t        status;
1306 58a26b47 balrog
    uint16_t        handle;
1307 58a26b47 balrog
    uint32_t        clock;
1308 58a26b47 balrog
    uint16_t        accuracy;
1309 58a26b47 balrog
} __attribute__ ((packed)) read_clock_rp;
1310 58a26b47 balrog
#define READ_CLOCK_RP_SIZE 9
1311 58a26b47 balrog
1312 58a26b47 balrog
/* Testing commands */
1313 58a26b47 balrog
#define OGF_TESTING_CMD                0x3e
1314 58a26b47 balrog
1315 58a26b47 balrog
/* Vendor specific commands */
1316 58a26b47 balrog
#define OGF_VENDOR_CMD                0x3f
1317 58a26b47 balrog
1318 58a26b47 balrog
/* HCI Events */
1319 58a26b47 balrog
1320 58a26b47 balrog
#define EVT_INQUIRY_COMPLETE                0x01
1321 58a26b47 balrog
1322 58a26b47 balrog
#define EVT_INQUIRY_RESULT                0x02
1323 58a26b47 balrog
typedef struct {
1324 58a26b47 balrog
    uint8_t        num_responses;
1325 58a26b47 balrog
    bdaddr_t        bdaddr;
1326 58a26b47 balrog
    uint8_t        pscan_rep_mode;
1327 58a26b47 balrog
    uint8_t        pscan_period_mode;
1328 58a26b47 balrog
    uint8_t        pscan_mode;
1329 58a26b47 balrog
    uint8_t        dev_class[3];
1330 58a26b47 balrog
    uint16_t        clock_offset;
1331 58a26b47 balrog
} __attribute__ ((packed)) inquiry_info;
1332 58a26b47 balrog
#define INQUIRY_INFO_SIZE 14
1333 58a26b47 balrog
1334 58a26b47 balrog
#define EVT_CONN_COMPLETE                0x03
1335 58a26b47 balrog
typedef struct {
1336 58a26b47 balrog
    uint8_t        status;
1337 58a26b47 balrog
    uint16_t        handle;
1338 58a26b47 balrog
    bdaddr_t        bdaddr;
1339 58a26b47 balrog
    uint8_t        link_type;
1340 58a26b47 balrog
    uint8_t        encr_mode;
1341 58a26b47 balrog
} __attribute__ ((packed)) evt_conn_complete;
1342 58a26b47 balrog
#define EVT_CONN_COMPLETE_SIZE 11
1343 58a26b47 balrog
1344 58a26b47 balrog
#define EVT_CONN_REQUEST                0x04
1345 58a26b47 balrog
typedef struct {
1346 58a26b47 balrog
    bdaddr_t        bdaddr;
1347 58a26b47 balrog
    uint8_t        dev_class[3];
1348 58a26b47 balrog
    uint8_t        link_type;
1349 58a26b47 balrog
} __attribute__ ((packed)) evt_conn_request;
1350 58a26b47 balrog
#define EVT_CONN_REQUEST_SIZE 10
1351 58a26b47 balrog
1352 58a26b47 balrog
#define EVT_DISCONN_COMPLETE                0x05
1353 58a26b47 balrog
typedef struct {
1354 58a26b47 balrog
    uint8_t        status;
1355 58a26b47 balrog
    uint16_t        handle;
1356 58a26b47 balrog
    uint8_t        reason;
1357 58a26b47 balrog
} __attribute__ ((packed)) evt_disconn_complete;
1358 58a26b47 balrog
#define EVT_DISCONN_COMPLETE_SIZE 4
1359 58a26b47 balrog
1360 58a26b47 balrog
#define EVT_AUTH_COMPLETE                0x06
1361 58a26b47 balrog
typedef struct {
1362 58a26b47 balrog
    uint8_t        status;
1363 58a26b47 balrog
    uint16_t        handle;
1364 58a26b47 balrog
} __attribute__ ((packed)) evt_auth_complete;
1365 58a26b47 balrog
#define EVT_AUTH_COMPLETE_SIZE 3
1366 58a26b47 balrog
1367 58a26b47 balrog
#define EVT_REMOTE_NAME_REQ_COMPLETE        0x07
1368 58a26b47 balrog
typedef struct {
1369 58a26b47 balrog
    uint8_t        status;
1370 58a26b47 balrog
    bdaddr_t        bdaddr;
1371 58a26b47 balrog
    char        name[248];
1372 58a26b47 balrog
} __attribute__ ((packed)) evt_remote_name_req_complete;
1373 58a26b47 balrog
#define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255
1374 58a26b47 balrog
1375 58a26b47 balrog
#define EVT_ENCRYPT_CHANGE                0x08
1376 58a26b47 balrog
typedef struct {
1377 58a26b47 balrog
    uint8_t        status;
1378 58a26b47 balrog
    uint16_t        handle;
1379 58a26b47 balrog
    uint8_t        encrypt;
1380 58a26b47 balrog
} __attribute__ ((packed)) evt_encrypt_change;
1381 58a26b47 balrog
#define EVT_ENCRYPT_CHANGE_SIZE 5
1382 58a26b47 balrog
1383 58a26b47 balrog
#define EVT_CHANGE_CONN_LINK_KEY_COMPLETE        0x09
1384 58a26b47 balrog
typedef struct {
1385 58a26b47 balrog
    uint8_t        status;
1386 58a26b47 balrog
    uint16_t        handle;
1387 58a26b47 balrog
}  __attribute__ ((packed)) evt_change_conn_link_key_complete;
1388 58a26b47 balrog
#define EVT_CHANGE_CONN_LINK_KEY_COMPLETE_SIZE 3
1389 58a26b47 balrog
1390 58a26b47 balrog
#define EVT_MASTER_LINK_KEY_COMPLETE                0x0A
1391 58a26b47 balrog
typedef struct {
1392 58a26b47 balrog
    uint8_t        status;
1393 58a26b47 balrog
    uint16_t        handle;
1394 58a26b47 balrog
    uint8_t        key_flag;
1395 58a26b47 balrog
} __attribute__ ((packed)) evt_master_link_key_complete;
1396 58a26b47 balrog
#define EVT_MASTER_LINK_KEY_COMPLETE_SIZE 4
1397 58a26b47 balrog
1398 58a26b47 balrog
#define EVT_READ_REMOTE_FEATURES_COMPLETE        0x0B
1399 58a26b47 balrog
typedef struct {
1400 58a26b47 balrog
    uint8_t        status;
1401 58a26b47 balrog
    uint16_t        handle;
1402 58a26b47 balrog
    uint8_t        features[8];
1403 58a26b47 balrog
} __attribute__ ((packed)) evt_read_remote_features_complete;
1404 58a26b47 balrog
#define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
1405 58a26b47 balrog
1406 58a26b47 balrog
#define EVT_READ_REMOTE_VERSION_COMPLETE        0x0C
1407 58a26b47 balrog
typedef struct {
1408 58a26b47 balrog
    uint8_t        status;
1409 58a26b47 balrog
    uint16_t        handle;
1410 58a26b47 balrog
    uint8_t        lmp_ver;
1411 58a26b47 balrog
    uint16_t        manufacturer;
1412 58a26b47 balrog
    uint16_t        lmp_subver;
1413 58a26b47 balrog
} __attribute__ ((packed)) evt_read_remote_version_complete;
1414 58a26b47 balrog
#define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
1415 58a26b47 balrog
1416 58a26b47 balrog
#define EVT_QOS_SETUP_COMPLETE                0x0D
1417 58a26b47 balrog
typedef struct {
1418 58a26b47 balrog
    uint8_t        status;
1419 58a26b47 balrog
    uint16_t        handle;
1420 58a26b47 balrog
    uint8_t        flags;                        /* Reserved */
1421 58a26b47 balrog
    hci_qos        qos;
1422 58a26b47 balrog
} __attribute__ ((packed)) evt_qos_setup_complete;
1423 58a26b47 balrog
#define EVT_QOS_SETUP_COMPLETE_SIZE (4 + HCI_QOS_CP_SIZE)
1424 58a26b47 balrog
1425 58a26b47 balrog
#define EVT_CMD_COMPLETE                 0x0E
1426 58a26b47 balrog
typedef struct {
1427 58a26b47 balrog
    uint8_t        ncmd;
1428 58a26b47 balrog
    uint16_t        opcode;
1429 58a26b47 balrog
} __attribute__ ((packed)) evt_cmd_complete;
1430 58a26b47 balrog
#define EVT_CMD_COMPLETE_SIZE 3
1431 58a26b47 balrog
1432 58a26b47 balrog
#define EVT_CMD_STATUS                         0x0F
1433 58a26b47 balrog
typedef struct {
1434 58a26b47 balrog
    uint8_t        status;
1435 58a26b47 balrog
    uint8_t        ncmd;
1436 58a26b47 balrog
    uint16_t        opcode;
1437 58a26b47 balrog
} __attribute__ ((packed)) evt_cmd_status;
1438 58a26b47 balrog
#define EVT_CMD_STATUS_SIZE 4
1439 58a26b47 balrog
1440 58a26b47 balrog
#define EVT_HARDWARE_ERROR                0x10
1441 58a26b47 balrog
typedef struct {
1442 58a26b47 balrog
    uint8_t        code;
1443 58a26b47 balrog
} __attribute__ ((packed)) evt_hardware_error;
1444 58a26b47 balrog
#define EVT_HARDWARE_ERROR_SIZE 1
1445 58a26b47 balrog
1446 58a26b47 balrog
#define EVT_FLUSH_OCCURRED                0x11
1447 58a26b47 balrog
typedef struct {
1448 58a26b47 balrog
    uint16_t        handle;
1449 58a26b47 balrog
} __attribute__ ((packed)) evt_flush_occured;
1450 58a26b47 balrog
#define EVT_FLUSH_OCCURRED_SIZE 2
1451 58a26b47 balrog
1452 58a26b47 balrog
#define EVT_ROLE_CHANGE                        0x12
1453 58a26b47 balrog
typedef struct {
1454 58a26b47 balrog
    uint8_t        status;
1455 58a26b47 balrog
    bdaddr_t        bdaddr;
1456 58a26b47 balrog
    uint8_t        role;
1457 58a26b47 balrog
} __attribute__ ((packed)) evt_role_change;
1458 58a26b47 balrog
#define EVT_ROLE_CHANGE_SIZE 8
1459 58a26b47 balrog
1460 58a26b47 balrog
#define EVT_NUM_COMP_PKTS                0x13
1461 58a26b47 balrog
typedef struct {
1462 58a26b47 balrog
    uint8_t        num_hndl;
1463 58a26b47 balrog
    struct {
1464 58a26b47 balrog
        uint16_t handle;
1465 58a26b47 balrog
        uint16_t num_packets;
1466 58a26b47 balrog
    } connection[0];
1467 58a26b47 balrog
} __attribute__ ((packed)) evt_num_comp_pkts;
1468 58a26b47 balrog
#define EVT_NUM_COMP_PKTS_SIZE(num_hndl) (1 + 4 * (num_hndl))
1469 58a26b47 balrog
1470 58a26b47 balrog
#define EVT_MODE_CHANGE                        0x14
1471 58a26b47 balrog
typedef struct {
1472 58a26b47 balrog
    uint8_t        status;
1473 58a26b47 balrog
    uint16_t        handle;
1474 58a26b47 balrog
    uint8_t        mode;
1475 58a26b47 balrog
    uint16_t        interval;
1476 58a26b47 balrog
} __attribute__ ((packed)) evt_mode_change;
1477 58a26b47 balrog
#define EVT_MODE_CHANGE_SIZE 6
1478 58a26b47 balrog
1479 58a26b47 balrog
#define EVT_RETURN_LINK_KEYS                0x15
1480 58a26b47 balrog
typedef struct {
1481 58a26b47 balrog
    uint8_t        num_keys;
1482 58a26b47 balrog
    /* variable length part */
1483 58a26b47 balrog
} __attribute__ ((packed)) evt_return_link_keys;
1484 58a26b47 balrog
#define EVT_RETURN_LINK_KEYS_SIZE 1
1485 58a26b47 balrog
1486 58a26b47 balrog
#define EVT_PIN_CODE_REQ                0x16
1487 58a26b47 balrog
typedef struct {
1488 58a26b47 balrog
    bdaddr_t        bdaddr;
1489 58a26b47 balrog
} __attribute__ ((packed)) evt_pin_code_req;
1490 58a26b47 balrog
#define EVT_PIN_CODE_REQ_SIZE 6
1491 58a26b47 balrog
1492 58a26b47 balrog
#define EVT_LINK_KEY_REQ                0x17
1493 58a26b47 balrog
typedef struct {
1494 58a26b47 balrog
    bdaddr_t        bdaddr;
1495 58a26b47 balrog
} __attribute__ ((packed)) evt_link_key_req;
1496 58a26b47 balrog
#define EVT_LINK_KEY_REQ_SIZE 6
1497 58a26b47 balrog
1498 58a26b47 balrog
#define EVT_LINK_KEY_NOTIFY                0x18
1499 58a26b47 balrog
typedef struct {
1500 58a26b47 balrog
    bdaddr_t        bdaddr;
1501 58a26b47 balrog
    uint8_t        link_key[16];
1502 58a26b47 balrog
    uint8_t        key_type;
1503 58a26b47 balrog
} __attribute__ ((packed)) evt_link_key_notify;
1504 58a26b47 balrog
#define EVT_LINK_KEY_NOTIFY_SIZE 23
1505 58a26b47 balrog
1506 58a26b47 balrog
#define EVT_LOOPBACK_COMMAND                0x19
1507 58a26b47 balrog
1508 58a26b47 balrog
#define EVT_DATA_BUFFER_OVERFLOW        0x1A
1509 58a26b47 balrog
typedef struct {
1510 58a26b47 balrog
    uint8_t        link_type;
1511 58a26b47 balrog
} __attribute__ ((packed)) evt_data_buffer_overflow;
1512 58a26b47 balrog
#define EVT_DATA_BUFFER_OVERFLOW_SIZE 1
1513 58a26b47 balrog
1514 58a26b47 balrog
#define EVT_MAX_SLOTS_CHANGE                0x1B
1515 58a26b47 balrog
typedef struct {
1516 58a26b47 balrog
    uint16_t        handle;
1517 58a26b47 balrog
    uint8_t        max_slots;
1518 58a26b47 balrog
} __attribute__ ((packed)) evt_max_slots_change;
1519 58a26b47 balrog
#define EVT_MAX_SLOTS_CHANGE_SIZE 3
1520 58a26b47 balrog
1521 58a26b47 balrog
#define EVT_READ_CLOCK_OFFSET_COMPLETE        0x1C
1522 58a26b47 balrog
typedef struct {
1523 58a26b47 balrog
    uint8_t        status;
1524 58a26b47 balrog
    uint16_t        handle;
1525 58a26b47 balrog
    uint16_t        clock_offset;
1526 58a26b47 balrog
} __attribute__ ((packed)) evt_read_clock_offset_complete;
1527 58a26b47 balrog
#define EVT_READ_CLOCK_OFFSET_COMPLETE_SIZE 5
1528 58a26b47 balrog
1529 58a26b47 balrog
#define EVT_CONN_PTYPE_CHANGED                0x1D
1530 58a26b47 balrog
typedef struct {
1531 58a26b47 balrog
    uint8_t        status;
1532 58a26b47 balrog
    uint16_t        handle;
1533 58a26b47 balrog
    uint16_t        ptype;
1534 58a26b47 balrog
} __attribute__ ((packed)) evt_conn_ptype_changed;
1535 58a26b47 balrog
#define EVT_CONN_PTYPE_CHANGED_SIZE 5
1536 58a26b47 balrog
1537 58a26b47 balrog
#define EVT_QOS_VIOLATION                0x1E
1538 58a26b47 balrog
typedef struct {
1539 58a26b47 balrog
    uint16_t        handle;
1540 58a26b47 balrog
} __attribute__ ((packed)) evt_qos_violation;
1541 58a26b47 balrog
#define EVT_QOS_VIOLATION_SIZE 2
1542 58a26b47 balrog
1543 58a26b47 balrog
#define EVT_PSCAN_REP_MODE_CHANGE        0x20
1544 58a26b47 balrog
typedef struct {
1545 58a26b47 balrog
    bdaddr_t        bdaddr;
1546 58a26b47 balrog
    uint8_t        pscan_rep_mode;
1547 58a26b47 balrog
} __attribute__ ((packed)) evt_pscan_rep_mode_change;
1548 58a26b47 balrog
#define EVT_PSCAN_REP_MODE_CHANGE_SIZE 7
1549 58a26b47 balrog
1550 58a26b47 balrog
#define EVT_FLOW_SPEC_COMPLETE                0x21
1551 58a26b47 balrog
typedef struct {
1552 58a26b47 balrog
    uint8_t        status;
1553 58a26b47 balrog
    uint16_t        handle;
1554 58a26b47 balrog
    uint8_t        flags;
1555 58a26b47 balrog
    uint8_t        direction;
1556 58a26b47 balrog
    hci_qos        qos;
1557 58a26b47 balrog
} __attribute__ ((packed)) evt_flow_spec_complete;
1558 58a26b47 balrog
#define EVT_FLOW_SPEC_COMPLETE_SIZE (5 + HCI_QOS_CP_SIZE)
1559 58a26b47 balrog
1560 58a26b47 balrog
#define EVT_INQUIRY_RESULT_WITH_RSSI        0x22
1561 58a26b47 balrog
typedef struct {
1562 58a26b47 balrog
    uint8_t        num_responses;
1563 58a26b47 balrog
    bdaddr_t        bdaddr;
1564 58a26b47 balrog
    uint8_t        pscan_rep_mode;
1565 58a26b47 balrog
    uint8_t        pscan_period_mode;
1566 58a26b47 balrog
    uint8_t        dev_class[3];
1567 58a26b47 balrog
    uint16_t        clock_offset;
1568 58a26b47 balrog
    int8_t        rssi;
1569 58a26b47 balrog
} __attribute__ ((packed)) inquiry_info_with_rssi;
1570 58a26b47 balrog
#define INQUIRY_INFO_WITH_RSSI_SIZE 15
1571 58a26b47 balrog
typedef struct {
1572 58a26b47 balrog
    uint8_t        num_responses;
1573 58a26b47 balrog
    bdaddr_t        bdaddr;
1574 58a26b47 balrog
    uint8_t        pscan_rep_mode;
1575 58a26b47 balrog
    uint8_t        pscan_period_mode;
1576 58a26b47 balrog
    uint8_t        pscan_mode;
1577 58a26b47 balrog
    uint8_t        dev_class[3];
1578 58a26b47 balrog
    uint16_t        clock_offset;
1579 58a26b47 balrog
    int8_t        rssi;
1580 58a26b47 balrog
} __attribute__ ((packed)) inquiry_info_with_rssi_and_pscan_mode;
1581 58a26b47 balrog
#define INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE 16
1582 58a26b47 balrog
1583 58a26b47 balrog
#define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE        0x23
1584 58a26b47 balrog
typedef struct {
1585 58a26b47 balrog
    uint8_t        status;
1586 58a26b47 balrog
    uint16_t        handle;
1587 58a26b47 balrog
    uint8_t        page_num;
1588 58a26b47 balrog
    uint8_t        max_page_num;
1589 58a26b47 balrog
    uint8_t        features[8];
1590 58a26b47 balrog
} __attribute__ ((packed)) evt_read_remote_ext_features_complete;
1591 58a26b47 balrog
#define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE_SIZE 13
1592 58a26b47 balrog
1593 58a26b47 balrog
#define EVT_SYNC_CONN_COMPLETE                0x2C
1594 58a26b47 balrog
typedef struct {
1595 58a26b47 balrog
    uint8_t        status;
1596 58a26b47 balrog
    uint16_t        handle;
1597 58a26b47 balrog
    bdaddr_t        bdaddr;
1598 58a26b47 balrog
    uint8_t        link_type;
1599 58a26b47 balrog
    uint8_t        trans_interval;
1600 58a26b47 balrog
    uint8_t        retrans_window;
1601 58a26b47 balrog
    uint16_t        rx_pkt_len;
1602 58a26b47 balrog
    uint16_t        tx_pkt_len;
1603 58a26b47 balrog
    uint8_t        air_mode;
1604 58a26b47 balrog
} __attribute__ ((packed)) evt_sync_conn_complete;
1605 58a26b47 balrog
#define EVT_SYNC_CONN_COMPLETE_SIZE 17
1606 58a26b47 balrog
1607 58a26b47 balrog
#define EVT_SYNC_CONN_CHANGED                0x2D
1608 58a26b47 balrog
typedef struct {
1609 58a26b47 balrog
    uint8_t        status;
1610 58a26b47 balrog
    uint16_t        handle;
1611 58a26b47 balrog
    uint8_t        trans_interval;
1612 58a26b47 balrog
    uint8_t        retrans_window;
1613 58a26b47 balrog
    uint16_t        rx_pkt_len;
1614 58a26b47 balrog
    uint16_t        tx_pkt_len;
1615 58a26b47 balrog
} __attribute__ ((packed)) evt_sync_conn_changed;
1616 58a26b47 balrog
#define EVT_SYNC_CONN_CHANGED_SIZE 9
1617 58a26b47 balrog
1618 58a26b47 balrog
#define EVT_SNIFF_SUBRATE                0x2E
1619 58a26b47 balrog
typedef struct {
1620 58a26b47 balrog
    uint8_t        status;
1621 58a26b47 balrog
    uint16_t        handle;
1622 58a26b47 balrog
    uint16_t        max_remote_latency;
1623 58a26b47 balrog
    uint16_t        max_local_latency;
1624 58a26b47 balrog
    uint16_t        min_remote_timeout;
1625 58a26b47 balrog
    uint16_t        min_local_timeout;
1626 58a26b47 balrog
} __attribute__ ((packed)) evt_sniff_subrate;
1627 58a26b47 balrog
#define EVT_SNIFF_SUBRATE_SIZE 11
1628 58a26b47 balrog
1629 58a26b47 balrog
#define EVT_EXTENDED_INQUIRY_RESULT        0x2F
1630 58a26b47 balrog
typedef struct {
1631 58a26b47 balrog
    bdaddr_t        bdaddr;
1632 58a26b47 balrog
    uint8_t        pscan_rep_mode;
1633 58a26b47 balrog
    uint8_t        pscan_period_mode;
1634 58a26b47 balrog
    uint8_t        dev_class[3];
1635 58a26b47 balrog
    uint16_t        clock_offset;
1636 58a26b47 balrog
    int8_t        rssi;
1637 58a26b47 balrog
    uint8_t        data[240];
1638 58a26b47 balrog
} __attribute__ ((packed)) extended_inquiry_info;
1639 58a26b47 balrog
#define EXTENDED_INQUIRY_INFO_SIZE 254
1640 58a26b47 balrog
1641 58a26b47 balrog
#define EVT_TESTING                        0xFE
1642 58a26b47 balrog
1643 58a26b47 balrog
#define EVT_VENDOR                        0xFF
1644 58a26b47 balrog
1645 58a26b47 balrog
/* Command opcode pack/unpack */
1646 58a26b47 balrog
#define cmd_opcode_pack(ogf, ocf)        (uint16_t)((ocf & 0x03ff)|(ogf << 10))
1647 58a26b47 balrog
#define cmd_opcode_ogf(op)                (op >> 10)
1648 58a26b47 balrog
#define cmd_opcode_ocf(op)                (op & 0x03ff)
1649 58a26b47 balrog
1650 58a26b47 balrog
/* ACL handle and flags pack/unpack */
1651 58a26b47 balrog
#define acl_handle_pack(h, f)        (uint16_t)(((h) & 0x0fff)|((f) << 12))
1652 58a26b47 balrog
#define acl_handle(h)                ((h) & 0x0fff)
1653 58a26b47 balrog
#define acl_flags(h)                ((h) >> 12)
1654 58a26b47 balrog
1655 58a26b47 balrog
/* HCI Packet structures */
1656 58a26b47 balrog
#define HCI_COMMAND_HDR_SIZE        3
1657 58a26b47 balrog
#define HCI_EVENT_HDR_SIZE        2
1658 58a26b47 balrog
#define HCI_ACL_HDR_SIZE        4
1659 58a26b47 balrog
#define HCI_SCO_HDR_SIZE        3
1660 58a26b47 balrog
1661 58a26b47 balrog
struct hci_command_hdr {
1662 58a26b47 balrog
    uint16_t         opcode;                /* OCF & OGF */
1663 58a26b47 balrog
    uint8_t        plen;
1664 58a26b47 balrog
} __attribute__ ((packed));
1665 58a26b47 balrog
1666 58a26b47 balrog
struct hci_event_hdr {
1667 58a26b47 balrog
    uint8_t        evt;
1668 58a26b47 balrog
    uint8_t        plen;
1669 58a26b47 balrog
} __attribute__ ((packed));
1670 58a26b47 balrog
1671 58a26b47 balrog
struct hci_acl_hdr {
1672 58a26b47 balrog
    uint16_t        handle;                /* Handle & Flags(PB, BC) */
1673 58a26b47 balrog
    uint16_t        dlen;
1674 58a26b47 balrog
} __attribute__ ((packed));
1675 58a26b47 balrog
1676 58a26b47 balrog
struct hci_sco_hdr {
1677 58a26b47 balrog
    uint16_t        handle;
1678 58a26b47 balrog
    uint8_t        dlen;
1679 58a26b47 balrog
} __attribute__ ((packed));
1680 4d2d181c balrog
1681 4d2d181c balrog
/* L2CAP layer defines */
1682 4d2d181c balrog
1683 4d2d181c balrog
enum bt_l2cap_lm_bits {
1684 4d2d181c balrog
    L2CAP_LM_MASTER        = 1 << 0,
1685 4d2d181c balrog
    L2CAP_LM_AUTH        = 1 << 1,
1686 4d2d181c balrog
    L2CAP_LM_ENCRYPT        = 1 << 2,
1687 4d2d181c balrog
    L2CAP_LM_TRUSTED        = 1 << 3,
1688 4d2d181c balrog
    L2CAP_LM_RELIABLE        = 1 << 4,
1689 4d2d181c balrog
    L2CAP_LM_SECURE        = 1 << 5,
1690 4d2d181c balrog
};
1691 4d2d181c balrog
1692 4d2d181c balrog
enum bt_l2cap_cid_predef {
1693 4d2d181c balrog
    L2CAP_CID_INVALID        = 0x0000,
1694 4d2d181c balrog
    L2CAP_CID_SIGNALLING= 0x0001,
1695 4d2d181c balrog
    L2CAP_CID_GROUP        = 0x0002,
1696 4d2d181c balrog
    L2CAP_CID_ALLOC        = 0x0040,
1697 4d2d181c balrog
};
1698 4d2d181c balrog
1699 4d2d181c balrog
/* L2CAP command codes */
1700 4d2d181c balrog
enum bt_l2cap_cmd {
1701 4d2d181c balrog
    L2CAP_COMMAND_REJ        = 1,
1702 4d2d181c balrog
    L2CAP_CONN_REQ,
1703 4d2d181c balrog
    L2CAP_CONN_RSP,
1704 4d2d181c balrog
    L2CAP_CONF_REQ,
1705 4d2d181c balrog
    L2CAP_CONF_RSP,
1706 4d2d181c balrog
    L2CAP_DISCONN_REQ,
1707 4d2d181c balrog
    L2CAP_DISCONN_RSP,
1708 4d2d181c balrog
    L2CAP_ECHO_REQ,
1709 4d2d181c balrog
    L2CAP_ECHO_RSP,
1710 4d2d181c balrog
    L2CAP_INFO_REQ,
1711 4d2d181c balrog
    L2CAP_INFO_RSP,
1712 4d2d181c balrog
};
1713 4d2d181c balrog
1714 4d2d181c balrog
enum bt_l2cap_sar_bits {
1715 4d2d181c balrog
    L2CAP_SAR_NO_SEG        = 0,
1716 4d2d181c balrog
    L2CAP_SAR_START,
1717 4d2d181c balrog
    L2CAP_SAR_END,
1718 4d2d181c balrog
    L2CAP_SAR_CONT,
1719 4d2d181c balrog
};
1720 4d2d181c balrog
1721 4d2d181c balrog
/* L2CAP structures */
1722 4d2d181c balrog
typedef struct {
1723 4d2d181c balrog
    uint16_t        len;
1724 4d2d181c balrog
    uint16_t        cid;
1725 4d2d181c balrog
    uint8_t        data[0];
1726 4d2d181c balrog
} __attribute__ ((packed)) l2cap_hdr;
1727 4d2d181c balrog
#define L2CAP_HDR_SIZE 4
1728 4d2d181c balrog
1729 4d2d181c balrog
typedef struct {
1730 4d2d181c balrog
    uint8_t        code;
1731 4d2d181c balrog
    uint8_t        ident;
1732 4d2d181c balrog
    uint16_t        len;
1733 4d2d181c balrog
} __attribute__ ((packed)) l2cap_cmd_hdr;
1734 4d2d181c balrog
#define L2CAP_CMD_HDR_SIZE 4
1735 4d2d181c balrog
1736 4d2d181c balrog
typedef struct {
1737 4d2d181c balrog
    uint16_t        reason;
1738 4d2d181c balrog
} __attribute__ ((packed)) l2cap_cmd_rej;
1739 4d2d181c balrog
#define L2CAP_CMD_REJ_SIZE 2
1740 4d2d181c balrog
1741 4d2d181c balrog
typedef struct {
1742 4d2d181c balrog
    uint16_t        dcid;
1743 4d2d181c balrog
    uint16_t        scid;
1744 4d2d181c balrog
} __attribute__ ((packed)) l2cap_cmd_rej_cid;
1745 4d2d181c balrog
#define L2CAP_CMD_REJ_CID_SIZE 4
1746 4d2d181c balrog
1747 4d2d181c balrog
/* reject reason */
1748 4d2d181c balrog
enum bt_l2cap_rej_reason {
1749 4d2d181c balrog
    L2CAP_REJ_CMD_NOT_UNDERSTOOD = 0,
1750 4d2d181c balrog
    L2CAP_REJ_SIG_TOOBIG,
1751 4d2d181c balrog
    L2CAP_REJ_CID_INVAL,
1752 4d2d181c balrog
};
1753 4d2d181c balrog
1754 4d2d181c balrog
typedef struct {
1755 4d2d181c balrog
    uint16_t        psm;
1756 4d2d181c balrog
    uint16_t        scid;
1757 4d2d181c balrog
} __attribute__ ((packed)) l2cap_conn_req;
1758 4d2d181c balrog
#define L2CAP_CONN_REQ_SIZE 4
1759 4d2d181c balrog
1760 4d2d181c balrog
typedef struct {
1761 4d2d181c balrog
    uint16_t        dcid;
1762 4d2d181c balrog
    uint16_t        scid;
1763 4d2d181c balrog
    uint16_t        result;
1764 4d2d181c balrog
    uint16_t        status;
1765 4d2d181c balrog
} __attribute__ ((packed)) l2cap_conn_rsp;
1766 4d2d181c balrog
#define L2CAP_CONN_RSP_SIZE 8
1767 4d2d181c balrog
1768 4d2d181c balrog
/* connect result */
1769 4d2d181c balrog
enum bt_l2cap_conn_res {
1770 4d2d181c balrog
    L2CAP_CR_SUCCESS        = 0,
1771 4d2d181c balrog
    L2CAP_CR_PEND,
1772 4d2d181c balrog
    L2CAP_CR_BAD_PSM,
1773 4d2d181c balrog
    L2CAP_CR_SEC_BLOCK,
1774 4d2d181c balrog
    L2CAP_CR_NO_MEM,
1775 4d2d181c balrog
};
1776 4d2d181c balrog
1777 4d2d181c balrog
/* connect status */
1778 4d2d181c balrog
enum bt_l2cap_conn_stat {
1779 4d2d181c balrog
    L2CAP_CS_NO_INFO        = 0,
1780 4d2d181c balrog
    L2CAP_CS_AUTHEN_PEND,
1781 4d2d181c balrog
    L2CAP_CS_AUTHOR_PEND,
1782 4d2d181c balrog
};
1783 4d2d181c balrog
1784 4d2d181c balrog
typedef struct {
1785 4d2d181c balrog
    uint16_t        dcid;
1786 4d2d181c balrog
    uint16_t        flags;
1787 4d2d181c balrog
    uint8_t        data[0];
1788 4d2d181c balrog
} __attribute__ ((packed)) l2cap_conf_req;
1789 4d2d181c balrog
#define L2CAP_CONF_REQ_SIZE(datalen) (4 + (datalen))
1790 4d2d181c balrog
1791 4d2d181c balrog
typedef struct {
1792 4d2d181c balrog
    uint16_t        scid;
1793 4d2d181c balrog
    uint16_t        flags;
1794 4d2d181c balrog
    uint16_t        result;
1795 4d2d181c balrog
    uint8_t        data[0];
1796 4d2d181c balrog
} __attribute__ ((packed)) l2cap_conf_rsp;
1797 4d2d181c balrog
#define L2CAP_CONF_RSP_SIZE(datalen) (6 + datalen)
1798 4d2d181c balrog
1799 4d2d181c balrog
enum bt_l2cap_conf_res {
1800 4d2d181c balrog
    L2CAP_CONF_SUCCESS        = 0,
1801 4d2d181c balrog
    L2CAP_CONF_UNACCEPT,
1802 4d2d181c balrog
    L2CAP_CONF_REJECT,
1803 4d2d181c balrog
    L2CAP_CONF_UNKNOWN,
1804 4d2d181c balrog
};
1805 4d2d181c balrog
1806 4d2d181c balrog
typedef struct {
1807 4d2d181c balrog
    uint8_t        type;
1808 4d2d181c balrog
    uint8_t        len;
1809 4d2d181c balrog
    uint8_t        val[0];
1810 4d2d181c balrog
} __attribute__ ((packed)) l2cap_conf_opt;
1811 4d2d181c balrog
#define L2CAP_CONF_OPT_SIZE 2
1812 4d2d181c balrog
1813 4d2d181c balrog
enum bt_l2cap_conf_val {
1814 4d2d181c balrog
    L2CAP_CONF_MTU        = 1,
1815 4d2d181c balrog
    L2CAP_CONF_FLUSH_TO,
1816 4d2d181c balrog
    L2CAP_CONF_QOS,
1817 4d2d181c balrog
    L2CAP_CONF_RFC,
1818 4d2d181c balrog
    L2CAP_CONF_RFC_MODE        = L2CAP_CONF_RFC,
1819 4d2d181c balrog
};
1820 4d2d181c balrog
1821 4d2d181c balrog
typedef struct {
1822 4d2d181c balrog
    uint8_t        flags;
1823 4d2d181c balrog
    uint8_t        service_type;
1824 4d2d181c balrog
    uint32_t        token_rate;
1825 4d2d181c balrog
    uint32_t        token_bucket_size;
1826 4d2d181c balrog
    uint32_t        peak_bandwidth;
1827 4d2d181c balrog
    uint32_t        latency;
1828 4d2d181c balrog
    uint32_t        delay_variation;
1829 4d2d181c balrog
} __attribute__ ((packed)) l2cap_conf_opt_qos;
1830 4d2d181c balrog
#define L2CAP_CONF_OPT_QOS_SIZE 22
1831 4d2d181c balrog
1832 4d2d181c balrog
enum bt_l2cap_conf_opt_qos_st {
1833 4d2d181c balrog
    L2CAP_CONF_QOS_NO_TRAFFIC = 0x00,
1834 4d2d181c balrog
    L2CAP_CONF_QOS_BEST_EFFORT,
1835 4d2d181c balrog
    L2CAP_CONF_QOS_GUARANTEED,
1836 4d2d181c balrog
};
1837 4d2d181c balrog
1838 4d2d181c balrog
#define L2CAP_CONF_QOS_WILDCARD        0xffffffff
1839 4d2d181c balrog
1840 4d2d181c balrog
enum bt_l2cap_mode {
1841 4d2d181c balrog
    L2CAP_MODE_BASIC        = 0,
1842 4d2d181c balrog
    L2CAP_MODE_RETRANS        = 1,
1843 4d2d181c balrog
    L2CAP_MODE_FLOWCTL        = 2,
1844 4d2d181c balrog
};
1845 4d2d181c balrog
1846 4d2d181c balrog
typedef struct {
1847 4d2d181c balrog
    uint16_t        dcid;
1848 4d2d181c balrog
    uint16_t        scid;
1849 4d2d181c balrog
} __attribute__ ((packed)) l2cap_disconn_req;
1850 4d2d181c balrog
#define L2CAP_DISCONN_REQ_SIZE 4
1851 4d2d181c balrog
1852 4d2d181c balrog
typedef struct {
1853 4d2d181c balrog
    uint16_t        dcid;
1854 4d2d181c balrog
    uint16_t        scid;
1855 4d2d181c balrog
} __attribute__ ((packed)) l2cap_disconn_rsp;
1856 4d2d181c balrog
#define L2CAP_DISCONN_RSP_SIZE 4
1857 4d2d181c balrog
1858 4d2d181c balrog
typedef struct {
1859 4d2d181c balrog
    uint16_t        type;
1860 4d2d181c balrog
} __attribute__ ((packed)) l2cap_info_req;
1861 4d2d181c balrog
#define L2CAP_INFO_REQ_SIZE 2
1862 4d2d181c balrog
1863 4d2d181c balrog
typedef struct {
1864 4d2d181c balrog
    uint16_t        type;
1865 4d2d181c balrog
    uint16_t        result;
1866 4d2d181c balrog
    uint8_t        data[0];
1867 4d2d181c balrog
} __attribute__ ((packed)) l2cap_info_rsp;
1868 4d2d181c balrog
#define L2CAP_INFO_RSP_SIZE 4
1869 4d2d181c balrog
1870 4d2d181c balrog
/* info type */
1871 4d2d181c balrog
enum bt_l2cap_info_type {
1872 4d2d181c balrog
    L2CAP_IT_CL_MTU        = 1,
1873 4d2d181c balrog
    L2CAP_IT_FEAT_MASK,
1874 4d2d181c balrog
};
1875 4d2d181c balrog
1876 4d2d181c balrog
/* info result */
1877 4d2d181c balrog
enum bt_l2cap_info_result {
1878 4d2d181c balrog
    L2CAP_IR_SUCCESS        = 0,
1879 4d2d181c balrog
    L2CAP_IR_NOTSUPP,
1880 4d2d181c balrog
};
1881 4d2d181c balrog
1882 4d2d181c balrog
/* Service Discovery Protocol defines */
1883 4d2d181c balrog
/* Note that all multibyte values in lower layer protocols (above in this file)
1884 4d2d181c balrog
 * are little-endian while SDP is big-endian.  */
1885 4d2d181c balrog
1886 4d2d181c balrog
/* Protocol UUIDs */
1887 4d2d181c balrog
enum sdp_proto_uuid {
1888 4d2d181c balrog
    SDP_UUID                = 0x0001,
1889 4d2d181c balrog
    UDP_UUID                = 0x0002,
1890 4d2d181c balrog
    RFCOMM_UUID                = 0x0003,
1891 4d2d181c balrog
    TCP_UUID                = 0x0004,
1892 4d2d181c balrog
    TCS_BIN_UUID        = 0x0005,
1893 4d2d181c balrog
    TCS_AT_UUID                = 0x0006,
1894 4d2d181c balrog
    OBEX_UUID                = 0x0008,
1895 4d2d181c balrog
    IP_UUID                = 0x0009,
1896 4d2d181c balrog
    FTP_UUID                = 0x000a,
1897 4d2d181c balrog
    HTTP_UUID                = 0x000c,
1898 4d2d181c balrog
    WSP_UUID                = 0x000e,
1899 4d2d181c balrog
    BNEP_UUID                = 0x000f,
1900 4d2d181c balrog
    UPNP_UUID                = 0x0010,
1901 4d2d181c balrog
    HIDP_UUID                = 0x0011,
1902 4d2d181c balrog
    HCRP_CTRL_UUID        = 0x0012,
1903 4d2d181c balrog
    HCRP_DATA_UUID        = 0x0014,
1904 4d2d181c balrog
    HCRP_NOTE_UUID        = 0x0016,
1905 4d2d181c balrog
    AVCTP_UUID                = 0x0017,
1906 4d2d181c balrog
    AVDTP_UUID                = 0x0019,
1907 4d2d181c balrog
    CMTP_UUID                = 0x001b,
1908 4d2d181c balrog
    UDI_UUID                = 0x001d,
1909 4d2d181c balrog
    MCAP_CTRL_UUID        = 0x001e,
1910 4d2d181c balrog
    MCAP_DATA_UUID        = 0x001f,
1911 4d2d181c balrog
    L2CAP_UUID                = 0x0100,
1912 4d2d181c balrog
};
1913 4d2d181c balrog
1914 4d2d181c balrog
/*
1915 4d2d181c balrog
 * Service class identifiers of standard services and service groups
1916 4d2d181c balrog
 */
1917 4d2d181c balrog
enum service_class_id {
1918 4d2d181c balrog
    SDP_SERVER_SVCLASS_ID                = 0x1000,
1919 4d2d181c balrog
    BROWSE_GRP_DESC_SVCLASS_ID                = 0x1001,
1920 4d2d181c balrog
    PUBLIC_BROWSE_GROUP                        = 0x1002,
1921 4d2d181c balrog
    SERIAL_PORT_SVCLASS_ID                = 0x1101,
1922 4d2d181c balrog
    LAN_ACCESS_SVCLASS_ID                = 0x1102,
1923 4d2d181c balrog
    DIALUP_NET_SVCLASS_ID                = 0x1103,
1924 4d2d181c balrog
    IRMC_SYNC_SVCLASS_ID                = 0x1104,
1925 4d2d181c balrog
    OBEX_OBJPUSH_SVCLASS_ID                = 0x1105,
1926 4d2d181c balrog
    OBEX_FILETRANS_SVCLASS_ID                = 0x1106,
1927 4d2d181c balrog
    IRMC_SYNC_CMD_SVCLASS_ID                = 0x1107,
1928 4d2d181c balrog
    HEADSET_SVCLASS_ID                        = 0x1108,
1929 4d2d181c balrog
    CORDLESS_TELEPHONY_SVCLASS_ID        = 0x1109,
1930 4d2d181c balrog
    AUDIO_SOURCE_SVCLASS_ID                = 0x110a,
1931 4d2d181c balrog
    AUDIO_SINK_SVCLASS_ID                = 0x110b,
1932 4d2d181c balrog
    AV_REMOTE_TARGET_SVCLASS_ID                = 0x110c,
1933 4d2d181c balrog
    ADVANCED_AUDIO_SVCLASS_ID                = 0x110d,
1934 4d2d181c balrog
    AV_REMOTE_SVCLASS_ID                = 0x110e,
1935 4d2d181c balrog
    VIDEO_CONF_SVCLASS_ID                = 0x110f,
1936 4d2d181c balrog
    INTERCOM_SVCLASS_ID                        = 0x1110,
1937 4d2d181c balrog
    FAX_SVCLASS_ID                        = 0x1111,
1938 4d2d181c balrog
    HEADSET_AGW_SVCLASS_ID                = 0x1112,
1939 4d2d181c balrog
    WAP_SVCLASS_ID                        = 0x1113,
1940 4d2d181c balrog
    WAP_CLIENT_SVCLASS_ID                = 0x1114,
1941 4d2d181c balrog
    PANU_SVCLASS_ID                        = 0x1115,
1942 4d2d181c balrog
    NAP_SVCLASS_ID                        = 0x1116,
1943 4d2d181c balrog
    GN_SVCLASS_ID                        = 0x1117,
1944 4d2d181c balrog
    DIRECT_PRINTING_SVCLASS_ID                = 0x1118,
1945 4d2d181c balrog
    REFERENCE_PRINTING_SVCLASS_ID        = 0x1119,
1946 4d2d181c balrog
    IMAGING_SVCLASS_ID                        = 0x111a,
1947 4d2d181c balrog
    IMAGING_RESPONDER_SVCLASS_ID        = 0x111b,
1948 4d2d181c balrog
    IMAGING_ARCHIVE_SVCLASS_ID                = 0x111c,
1949 4d2d181c balrog
    IMAGING_REFOBJS_SVCLASS_ID                = 0x111d,
1950 4d2d181c balrog
    HANDSFREE_SVCLASS_ID                = 0x111e,
1951 4d2d181c balrog
    HANDSFREE_AGW_SVCLASS_ID                = 0x111f,
1952 4d2d181c balrog
    DIRECT_PRT_REFOBJS_SVCLASS_ID        = 0x1120,
1953 4d2d181c balrog
    REFLECTED_UI_SVCLASS_ID                = 0x1121,
1954 4d2d181c balrog
    BASIC_PRINTING_SVCLASS_ID                = 0x1122,
1955 4d2d181c balrog
    PRINTING_STATUS_SVCLASS_ID                = 0x1123,
1956 4d2d181c balrog
    HID_SVCLASS_ID                        = 0x1124,
1957 4d2d181c balrog
    HCR_SVCLASS_ID                        = 0x1125,
1958 4d2d181c balrog
    HCR_PRINT_SVCLASS_ID                = 0x1126,
1959 4d2d181c balrog
    HCR_SCAN_SVCLASS_ID                        = 0x1127,
1960 4d2d181c balrog
    CIP_SVCLASS_ID                        = 0x1128,
1961 4d2d181c balrog
    VIDEO_CONF_GW_SVCLASS_ID                = 0x1129,
1962 4d2d181c balrog
    UDI_MT_SVCLASS_ID                        = 0x112a,
1963 4d2d181c balrog
    UDI_TA_SVCLASS_ID                        = 0x112b,
1964 4d2d181c balrog
    AV_SVCLASS_ID                        = 0x112c,
1965 4d2d181c balrog
    SAP_SVCLASS_ID                        = 0x112d,
1966 4d2d181c balrog
    PBAP_PCE_SVCLASS_ID                        = 0x112e,
1967 4d2d181c balrog
    PBAP_PSE_SVCLASS_ID                        = 0x112f,
1968 4d2d181c balrog
    PBAP_SVCLASS_ID                        = 0x1130,
1969 4d2d181c balrog
    PNP_INFO_SVCLASS_ID                        = 0x1200,
1970 4d2d181c balrog
    GENERIC_NETWORKING_SVCLASS_ID        = 0x1201,
1971 4d2d181c balrog
    GENERIC_FILETRANS_SVCLASS_ID        = 0x1202,
1972 4d2d181c balrog
    GENERIC_AUDIO_SVCLASS_ID                = 0x1203,
1973 4d2d181c balrog
    GENERIC_TELEPHONY_SVCLASS_ID        = 0x1204,
1974 4d2d181c balrog
    UPNP_SVCLASS_ID                        = 0x1205,
1975 4d2d181c balrog
    UPNP_IP_SVCLASS_ID                        = 0x1206,
1976 4d2d181c balrog
    UPNP_PAN_SVCLASS_ID                        = 0x1300,
1977 4d2d181c balrog
    UPNP_LAP_SVCLASS_ID                        = 0x1301,
1978 4d2d181c balrog
    UPNP_L2CAP_SVCLASS_ID                = 0x1302,
1979 4d2d181c balrog
    VIDEO_SOURCE_SVCLASS_ID                = 0x1303,
1980 4d2d181c balrog
    VIDEO_SINK_SVCLASS_ID                = 0x1304,
1981 4d2d181c balrog
    VIDEO_DISTRIBUTION_SVCLASS_ID        = 0x1305,
1982 4d2d181c balrog
    MDP_SVCLASS_ID                        = 0x1400,
1983 4d2d181c balrog
    MDP_SOURCE_SVCLASS_ID                = 0x1401,
1984 4d2d181c balrog
    MDP_SINK_SVCLASS_ID                        = 0x1402,
1985 4d2d181c balrog
    APPLE_AGENT_SVCLASS_ID                = 0x2112,
1986 4d2d181c balrog
};
1987 4d2d181c balrog
1988 4d2d181c balrog
/*
1989 4d2d181c balrog
 * Standard profile descriptor identifiers; note these
1990 4d2d181c balrog
 * may be identical to some of the service classes defined above
1991 4d2d181c balrog
 */
1992 4d2d181c balrog
#define SDP_SERVER_PROFILE_ID                SDP_SERVER_SVCLASS_ID
1993 4d2d181c balrog
#define BROWSE_GRP_DESC_PROFILE_ID        BROWSE_GRP_DESC_SVCLASS_ID
1994 4d2d181c balrog
#define SERIAL_PORT_PROFILE_ID                SERIAL_PORT_SVCLASS_ID
1995 4d2d181c balrog
#define LAN_ACCESS_PROFILE_ID                LAN_ACCESS_SVCLASS_ID
1996 4d2d181c balrog
#define DIALUP_NET_PROFILE_ID                DIALUP_NET_SVCLASS_ID
1997 4d2d181c balrog
#define IRMC_SYNC_PROFILE_ID                IRMC_SYNC_SVCLASS_ID
1998 4d2d181c balrog
#define OBEX_OBJPUSH_PROFILE_ID                OBEX_OBJPUSH_SVCLASS_ID
1999 4d2d181c balrog
#define OBEX_FILETRANS_PROFILE_ID        OBEX_FILETRANS_SVCLASS_ID
2000 4d2d181c balrog
#define IRMC_SYNC_CMD_PROFILE_ID        IRMC_SYNC_CMD_SVCLASS_ID
2001 4d2d181c balrog
#define HEADSET_PROFILE_ID                HEADSET_SVCLASS_ID
2002 4d2d181c balrog
#define CORDLESS_TELEPHONY_PROFILE_ID        CORDLESS_TELEPHONY_SVCLASS_ID
2003 4d2d181c balrog
#define AUDIO_SOURCE_PROFILE_ID                AUDIO_SOURCE_SVCLASS_ID
2004 4d2d181c balrog
#define AUDIO_SINK_PROFILE_ID                AUDIO_SINK_SVCLASS_ID
2005 4d2d181c balrog
#define AV_REMOTE_TARGET_PROFILE_ID        AV_REMOTE_TARGET_SVCLASS_ID
2006 4d2d181c balrog
#define ADVANCED_AUDIO_PROFILE_ID        ADVANCED_AUDIO_SVCLASS_ID
2007 4d2d181c balrog
#define AV_REMOTE_PROFILE_ID                AV_REMOTE_SVCLASS_ID
2008 4d2d181c balrog
#define VIDEO_CONF_PROFILE_ID                VIDEO_CONF_SVCLASS_ID
2009 4d2d181c balrog
#define INTERCOM_PROFILE_ID                INTERCOM_SVCLASS_ID
2010 4d2d181c balrog
#define FAX_PROFILE_ID                        FAX_SVCLASS_ID
2011 4d2d181c balrog
#define HEADSET_AGW_PROFILE_ID                HEADSET_AGW_SVCLASS_ID
2012 4d2d181c balrog
#define WAP_PROFILE_ID                        WAP_SVCLASS_ID
2013 4d2d181c balrog
#define WAP_CLIENT_PROFILE_ID                WAP_CLIENT_SVCLASS_ID
2014 4d2d181c balrog
#define PANU_PROFILE_ID                        PANU_SVCLASS_ID
2015 4d2d181c balrog
#define NAP_PROFILE_ID                        NAP_SVCLASS_ID
2016 4d2d181c balrog
#define GN_PROFILE_ID                        GN_SVCLASS_ID
2017 4d2d181c balrog
#define DIRECT_PRINTING_PROFILE_ID        DIRECT_PRINTING_SVCLASS_ID
2018 4d2d181c balrog
#define REFERENCE_PRINTING_PROFILE_ID        REFERENCE_PRINTING_SVCLASS_ID
2019 4d2d181c balrog
#define IMAGING_PROFILE_ID                IMAGING_SVCLASS_ID
2020 4d2d181c balrog
#define IMAGING_RESPONDER_PROFILE_ID        IMAGING_RESPONDER_SVCLASS_ID
2021 4d2d181c balrog
#define IMAGING_ARCHIVE_PROFILE_ID        IMAGING_ARCHIVE_SVCLASS_ID
2022 4d2d181c balrog
#define IMAGING_REFOBJS_PROFILE_ID        IMAGING_REFOBJS_SVCLASS_ID
2023 4d2d181c balrog
#define HANDSFREE_PROFILE_ID                HANDSFREE_SVCLASS_ID
2024 4d2d181c balrog
#define HANDSFREE_AGW_PROFILE_ID        HANDSFREE_AGW_SVCLASS_ID
2025 4d2d181c balrog
#define DIRECT_PRT_REFOBJS_PROFILE_ID        DIRECT_PRT_REFOBJS_SVCLASS_ID
2026 4d2d181c balrog
#define REFLECTED_UI_PROFILE_ID                REFLECTED_UI_SVCLASS_ID
2027 4d2d181c balrog
#define BASIC_PRINTING_PROFILE_ID        BASIC_PRINTING_SVCLASS_ID
2028 4d2d181c balrog
#define PRINTING_STATUS_PROFILE_ID        PRINTING_STATUS_SVCLASS_ID
2029 4d2d181c balrog
#define HID_PROFILE_ID                        HID_SVCLASS_ID
2030 4d2d181c balrog
#define HCR_PROFILE_ID                        HCR_SCAN_SVCLASS_ID
2031 4d2d181c balrog
#define HCR_PRINT_PROFILE_ID                HCR_PRINT_SVCLASS_ID
2032 4d2d181c balrog
#define HCR_SCAN_PROFILE_ID                HCR_SCAN_SVCLASS_ID
2033 4d2d181c balrog
#define CIP_PROFILE_ID                        CIP_SVCLASS_ID
2034 4d2d181c balrog
#define VIDEO_CONF_GW_PROFILE_ID        VIDEO_CONF_GW_SVCLASS_ID
2035 4d2d181c balrog
#define UDI_MT_PROFILE_ID                UDI_MT_SVCLASS_ID
2036 4d2d181c balrog
#define UDI_TA_PROFILE_ID                UDI_TA_SVCLASS_ID
2037 4d2d181c balrog
#define AV_PROFILE_ID                        AV_SVCLASS_ID
2038 4d2d181c balrog
#define SAP_PROFILE_ID                        SAP_SVCLASS_ID
2039 4d2d181c balrog
#define PBAP_PCE_PROFILE_ID                PBAP_PCE_SVCLASS_ID
2040 4d2d181c balrog
#define PBAP_PSE_PROFILE_ID                PBAP_PSE_SVCLASS_ID
2041 4d2d181c balrog
#define PBAP_PROFILE_ID                        PBAP_SVCLASS_ID
2042 4d2d181c balrog
#define PNP_INFO_PROFILE_ID                PNP_INFO_SVCLASS_ID
2043 4d2d181c balrog
#define GENERIC_NETWORKING_PROFILE_ID        GENERIC_NETWORKING_SVCLASS_ID
2044 4d2d181c balrog
#define GENERIC_FILETRANS_PROFILE_ID        GENERIC_FILETRANS_SVCLASS_ID
2045 4d2d181c balrog
#define GENERIC_AUDIO_PROFILE_ID        GENERIC_AUDIO_SVCLASS_ID
2046 4d2d181c balrog
#define GENERIC_TELEPHONY_PROFILE_ID        GENERIC_TELEPHONY_SVCLASS_ID
2047 4d2d181c balrog
#define UPNP_PROFILE_ID                        UPNP_SVCLASS_ID
2048 4d2d181c balrog
#define UPNP_IP_PROFILE_ID                UPNP_IP_SVCLASS_ID
2049 4d2d181c balrog
#define UPNP_PAN_PROFILE_ID                UPNP_PAN_SVCLASS_ID
2050 4d2d181c balrog
#define UPNP_LAP_PROFILE_ID                UPNP_LAP_SVCLASS_ID
2051 4d2d181c balrog
#define UPNP_L2CAP_PROFILE_ID                UPNP_L2CAP_SVCLASS_ID
2052 4d2d181c balrog
#define VIDEO_SOURCE_PROFILE_ID                VIDEO_SOURCE_SVCLASS_ID
2053 4d2d181c balrog
#define VIDEO_SINK_PROFILE_ID                VIDEO_SINK_SVCLASS_ID
2054 4d2d181c balrog
#define VIDEO_DISTRIBUTION_PROFILE_ID        VIDEO_DISTRIBUTION_SVCLASS_ID
2055 4d2d181c balrog
#define MDP_PROFILE_ID                        MDP_SVCLASS_ID
2056 4d2d181c balrog
#define MDP_SOURCE_PROFILE_ID                MDP_SROUCE_SVCLASS_ID
2057 4d2d181c balrog
#define MDP_SINK_PROFILE_ID                MDP_SINK_SVCLASS_ID
2058 4d2d181c balrog
#define APPLE_AGENT_PROFILE_ID                APPLE_AGENT_SVCLASS_ID
2059 4d2d181c balrog
2060 4d2d181c balrog
/* Data Representation */
2061 4d2d181c balrog
enum bt_sdp_data_type {
2062 4d2d181c balrog
    SDP_DTYPE_NIL        = 0 << 3,
2063 4d2d181c balrog
    SDP_DTYPE_UINT        = 1 << 3,
2064 4d2d181c balrog
    SDP_DTYPE_SINT        = 2 << 3,
2065 4d2d181c balrog
    SDP_DTYPE_UUID        = 3 << 3,
2066 4d2d181c balrog
    SDP_DTYPE_STRING        = 4 << 3,
2067 4d2d181c balrog
    SDP_DTYPE_BOOL        = 5 << 3,
2068 4d2d181c balrog
    SDP_DTYPE_SEQ        = 6 << 3,
2069 4d2d181c balrog
    SDP_DTYPE_ALT        = 7 << 3,
2070 4d2d181c balrog
    SDP_DTYPE_URL        = 8 << 3,
2071 4d2d181c balrog
};
2072 4d2d181c balrog
2073 4d2d181c balrog
enum bt_sdp_data_size {
2074 4d2d181c balrog
    SDP_DSIZE_1                = 0,
2075 4d2d181c balrog
    SDP_DSIZE_2,
2076 4d2d181c balrog
    SDP_DSIZE_4,
2077 4d2d181c balrog
    SDP_DSIZE_8,
2078 4d2d181c balrog
    SDP_DSIZE_16,
2079 4d2d181c balrog
    SDP_DSIZE_NEXT1,
2080 4d2d181c balrog
    SDP_DSIZE_NEXT2,
2081 4d2d181c balrog
    SDP_DSIZE_NEXT4,
2082 4d2d181c balrog
    SDP_DSIZE_MASK = SDP_DSIZE_NEXT4,
2083 4d2d181c balrog
};
2084 4d2d181c balrog
2085 4d2d181c balrog
enum bt_sdp_cmd {
2086 4d2d181c balrog
    SDP_ERROR_RSP                = 0x01,
2087 4d2d181c balrog
    SDP_SVC_SEARCH_REQ                = 0x02,
2088 4d2d181c balrog
    SDP_SVC_SEARCH_RSP                = 0x03,
2089 4d2d181c balrog
    SDP_SVC_ATTR_REQ                = 0x04,
2090 4d2d181c balrog
    SDP_SVC_ATTR_RSP                = 0x05,
2091 4d2d181c balrog
    SDP_SVC_SEARCH_ATTR_REQ        = 0x06,
2092 4d2d181c balrog
    SDP_SVC_SEARCH_ATTR_RSP        = 0x07,
2093 4d2d181c balrog
};
2094 4d2d181c balrog
2095 4d2d181c balrog
enum bt_sdp_errorcode {
2096 4d2d181c balrog
    SDP_INVALID_VERSION                = 0x0001,
2097 4d2d181c balrog
    SDP_INVALID_RECORD_HANDLE        = 0x0002,
2098 4d2d181c balrog
    SDP_INVALID_SYNTAX                = 0x0003,
2099 4d2d181c balrog
    SDP_INVALID_PDU_SIZE        = 0x0004,
2100 4d2d181c balrog
    SDP_INVALID_CSTATE                = 0x0005,
2101 4d2d181c balrog
};
2102 4d2d181c balrog
2103 4d2d181c balrog
/*
2104 4d2d181c balrog
 * String identifiers are based on the SDP spec stating that
2105 4d2d181c balrog
 * "base attribute id of the primary (universal) language must be 0x0100"
2106 4d2d181c balrog
 *
2107 4d2d181c balrog
 * Other languages should have their own offset; e.g.:
2108 4d2d181c balrog
 * #define XXXLangBase yyyy
2109 4d2d181c balrog
 * #define AttrServiceName_XXX        0x0000+XXXLangBase
2110 4d2d181c balrog
 */
2111 4d2d181c balrog
#define SDP_PRIMARY_LANG_BASE                 0x0100
2112 4d2d181c balrog
2113 4d2d181c balrog
enum bt_sdp_attribute_id {
2114 4d2d181c balrog
    SDP_ATTR_RECORD_HANDLE                        = 0x0000,
2115 4d2d181c balrog
    SDP_ATTR_SVCLASS_ID_LIST                        = 0x0001,
2116 4d2d181c balrog
    SDP_ATTR_RECORD_STATE                        = 0x0002,
2117 4d2d181c balrog
    SDP_ATTR_SERVICE_ID                                = 0x0003,
2118 4d2d181c balrog
    SDP_ATTR_PROTO_DESC_LIST                        = 0x0004,
2119 4d2d181c balrog
    SDP_ATTR_BROWSE_GRP_LIST                        = 0x0005,
2120 4d2d181c balrog
    SDP_ATTR_LANG_BASE_ATTR_ID_LIST                = 0x0006,
2121 4d2d181c balrog
    SDP_ATTR_SVCINFO_TTL                        = 0x0007,
2122 4d2d181c balrog
    SDP_ATTR_SERVICE_AVAILABILITY                = 0x0008,
2123 4d2d181c balrog
    SDP_ATTR_PFILE_DESC_LIST                        = 0x0009,
2124 4d2d181c balrog
    SDP_ATTR_DOC_URL                                = 0x000a,
2125 4d2d181c balrog
    SDP_ATTR_CLNT_EXEC_URL                        = 0x000b,
2126 4d2d181c balrog
    SDP_ATTR_ICON_URL                                = 0x000c,
2127 4d2d181c balrog
    SDP_ATTR_ADD_PROTO_DESC_LIST                = 0x000d,
2128 4d2d181c balrog
2129 4d2d181c balrog
    SDP_ATTR_SVCNAME_PRIMARY                        = SDP_PRIMARY_LANG_BASE + 0,
2130 4d2d181c balrog
    SDP_ATTR_SVCDESC_PRIMARY                        = SDP_PRIMARY_LANG_BASE + 1,
2131 4d2d181c balrog
    SDP_ATTR_SVCPROV_PRIMARY                        = SDP_PRIMARY_LANG_BASE + 2,
2132 4d2d181c balrog
2133 4d2d181c balrog
    SDP_ATTR_GROUP_ID                                = 0x0200,
2134 4d2d181c balrog
    SDP_ATTR_IP_SUBNET                                = 0x0200,
2135 4d2d181c balrog
2136 4d2d181c balrog
    /* SDP */
2137 4d2d181c balrog
    SDP_ATTR_VERSION_NUM_LIST                        = 0x0200,
2138 4d2d181c balrog
    SDP_ATTR_SVCDB_STATE                        = 0x0201,
2139 4d2d181c balrog
2140 4d2d181c balrog
    SDP_ATTR_SERVICE_VERSION                        = 0x0300,
2141 4d2d181c balrog
    SDP_ATTR_EXTERNAL_NETWORK                        = 0x0301,
2142 4d2d181c balrog
    SDP_ATTR_SUPPORTED_DATA_STORES_LIST                = 0x0301,
2143 4d2d181c balrog
    SDP_ATTR_FAX_CLASS1_SUPPORT                        = 0x0302,
2144 4d2d181c balrog
    SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL        = 0x0302,
2145 4d2d181c balrog
    SDP_ATTR_FAX_CLASS20_SUPPORT                = 0x0303,
2146 4d2d181c balrog
    SDP_ATTR_SUPPORTED_FORMATS_LIST                = 0x0303,
2147 4d2d181c balrog
    SDP_ATTR_FAX_CLASS2_SUPPORT                        = 0x0304,
2148 4d2d181c balrog
    SDP_ATTR_AUDIO_FEEDBACK_SUPPORT                = 0x0305,
2149 4d2d181c balrog
    SDP_ATTR_NETWORK_ADDRESS                        = 0x0306,
2150 4d2d181c balrog
    SDP_ATTR_WAP_GATEWAY                        = 0x0307,
2151 4d2d181c balrog
    SDP_ATTR_HOMEPAGE_URL                        = 0x0308,
2152 4d2d181c balrog
    SDP_ATTR_WAP_STACK_TYPE                        = 0x0309,
2153 4d2d181c balrog
    SDP_ATTR_SECURITY_DESC                        = 0x030a,
2154 4d2d181c balrog
    SDP_ATTR_NET_ACCESS_TYPE                        = 0x030b,
2155 4d2d181c balrog
    SDP_ATTR_MAX_NET_ACCESSRATE                        = 0x030c,
2156 4d2d181c balrog
    SDP_ATTR_IP4_SUBNET                                = 0x030d,
2157 4d2d181c balrog
    SDP_ATTR_IP6_SUBNET                                = 0x030e,
2158 4d2d181c balrog
    SDP_ATTR_SUPPORTED_CAPABILITIES                = 0x0310,
2159 4d2d181c balrog
    SDP_ATTR_SUPPORTED_FEATURES                        = 0x0311,
2160 4d2d181c balrog
    SDP_ATTR_SUPPORTED_FUNCTIONS                = 0x0312,
2161 4d2d181c balrog
    SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY        = 0x0313,
2162 4d2d181c balrog
    SDP_ATTR_SUPPORTED_REPOSITORIES                = 0x0314,
2163 4d2d181c balrog
2164 4d2d181c balrog
    /* PnP Information */
2165 4d2d181c balrog
    SDP_ATTR_SPECIFICATION_ID                        = 0x0200,
2166 4d2d181c balrog
    SDP_ATTR_VENDOR_ID                                = 0x0201,
2167 4d2d181c balrog
    SDP_ATTR_PRODUCT_ID                                = 0x0202,
2168 4d2d181c balrog
    SDP_ATTR_VERSION                                = 0x0203,
2169 4d2d181c balrog
    SDP_ATTR_PRIMARY_RECORD                        = 0x0204,
2170 4d2d181c balrog
    SDP_ATTR_VENDOR_ID_SOURCE                        = 0x0205,
2171 4d2d181c balrog
2172 4d2d181c balrog
    /* BT HID */
2173 4d2d181c balrog
    SDP_ATTR_DEVICE_RELEASE_NUMBER                = 0x0200,
2174 4d2d181c balrog
    SDP_ATTR_PARSER_VERSION                        = 0x0201,
2175 4d2d181c balrog
    SDP_ATTR_DEVICE_SUBCLASS                        = 0x0202,
2176 4d2d181c balrog
    SDP_ATTR_COUNTRY_CODE                        = 0x0203,
2177 4d2d181c balrog
    SDP_ATTR_VIRTUAL_CABLE                        = 0x0204,
2178 4d2d181c balrog
    SDP_ATTR_RECONNECT_INITIATE                        = 0x0205,
2179 4d2d181c balrog
    SDP_ATTR_DESCRIPTOR_LIST                        = 0x0206,
2180 4d2d181c balrog
    SDP_ATTR_LANG_ID_BASE_LIST                        = 0x0207,
2181 4d2d181c balrog
    SDP_ATTR_SDP_DISABLE                        = 0x0208,
2182 4d2d181c balrog
    SDP_ATTR_BATTERY_POWER                        = 0x0209,
2183 4d2d181c balrog
    SDP_ATTR_REMOTE_WAKEUP                        = 0x020a,
2184 4d2d181c balrog
    SDP_ATTR_PROFILE_VERSION                        = 0x020b,
2185 4d2d181c balrog
    SDP_ATTR_SUPERVISION_TIMEOUT                = 0x020c,
2186 4d2d181c balrog
    SDP_ATTR_NORMALLY_CONNECTABLE                = 0x020d,
2187 4d2d181c balrog
    SDP_ATTR_BOOT_DEVICE                        = 0x020e,
2188 4d2d181c balrog
};