Statistics
| Branch: | Revision:

root / hw / bt.h @ 5afb9869

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