Statistics
| Branch: | Revision:

root / hw / bt.h @ 074f2fff

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