Vendor import of netgraph from FreeBSD-current 20080626
[dragonfly.git] / sys / netgraph7 / bluetooth / include / ng_hci.h
1 /*
2  * ng_hci.h
3  */
4
5 /*-
6  * Copyright (c) 2001 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $Id: ng_hci.h,v 1.2 2003/03/18 00:09:37 max Exp $
31  * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.7 2006/05/17 00:13:06 emax Exp $
32  */
33
34 /*
35  * This file contains everything that application needs to know about
36  * Host Controller Interface (HCI). All information was obtained from
37  * Bluetooth Specification Book v1.1.
38  *
39  * This file can be included by both kernel and userland applications.
40  *
41  * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth
42  *       specification refers to both devices and units. They are the
43  *       same thing (i think), so to be consistent word "unit" will be
44  *       used.
45  */
46
47 #ifndef _NETGRAPH_HCI_H_
48 #define _NETGRAPH_HCI_H_
49
50 /**************************************************************************
51  **************************************************************************
52  **     Netgraph node hook name, type name and type cookie and commands
53  **************************************************************************
54  **************************************************************************/
55
56 /* Node type name and type cookie */
57 #define NG_HCI_NODE_TYPE                        "hci"
58 #define NGM_HCI_COOKIE                          1000774184
59
60 /* Netgraph node hook names */
61 #define NG_HCI_HOOK_DRV                         "drv" /* Driver <-> HCI */
62 #define NG_HCI_HOOK_ACL                         "acl" /* HCI <-> Upper */
63 #define NG_HCI_HOOK_SCO                         "sco" /* HCI <-> Upper */ 
64 #define NG_HCI_HOOK_RAW                         "raw" /* HCI <-> Upper */ 
65
66 /**************************************************************************
67  **************************************************************************
68  **                   Common defines and types (HCI)
69  **************************************************************************
70  **************************************************************************/
71
72 /* All sizes are in bytes */
73 #define NG_HCI_BDADDR_SIZE                      6   /* unit address */
74 #define NG_HCI_LAP_SIZE                         3   /* unit LAP */
75 #define NG_HCI_KEY_SIZE                         16  /* link key */
76 #define NG_HCI_PIN_SIZE                         16  /* link PIN */
77 #define NG_HCI_EVENT_MASK_SIZE                  8   /* event mask */
78 #define NG_HCI_CLASS_SIZE                       3   /* unit class */
79 #define NG_HCI_FEATURES_SIZE                    8   /* LMP features */
80 #define NG_HCI_UNIT_NAME_SIZE                   248 /* unit name size */
81
82 /* HCI specification */
83 #define NG_HCI_SPEC_V10                         0x00 /* v1.0 */
84 #define NG_HCI_SPEC_V11                         0x01 /* v1.1 */
85 /* 0x02 - 0xFF - reserved for future use */
86
87 /* LMP features */
88 /* ------------------- byte 0 --------------------*/
89 #define NG_HCI_LMP_3SLOT                        0x01
90 #define NG_HCI_LMP_5SLOT                        0x02
91 #define NG_HCI_LMP_ENCRYPTION                   0x04
92 #define NG_HCI_LMP_SLOT_OFFSET                  0x08
93 #define NG_HCI_LMP_TIMING_ACCURACY              0x10
94 #define NG_HCI_LMP_SWITCH                       0x20
95 #define NG_HCI_LMP_HOLD_MODE                    0x40
96 #define NG_HCI_LMP_SNIFF_MODE                   0x80
97 /* ------------------- byte 1 --------------------*/
98 #define NG_HCI_LMP_PARK_MODE                    0x01
99 #define NG_HCI_LMP_RSSI                         0x02
100 #define NG_HCI_LMP_CHANNEL_QUALITY              0x04
101 #define NG_HCI_LMP_SCO_LINK                     0x08
102 #define NG_HCI_LMP_HV2_PKT                      0x10
103 #define NG_HCI_LMP_HV3_PKT                      0x20
104 #define NG_HCI_LMP_ULAW_LOG                     0x40
105 #define NG_HCI_LMP_ALAW_LOG                     0x80
106 /* ------------------- byte 2 --------------------*/
107 #define NG_HCI_LMP_CVSD                         0x01
108 #define NG_HCI_LMP_PAGING_SCHEME                0x02
109 #define NG_HCI_LMP_POWER_CONTROL                0x04
110 #define NG_HCI_LMP_TRANSPARENT_SCO              0x08
111 #define NG_HCI_LMP_FLOW_CONTROL_LAG0            0x10
112 #define NG_HCI_LMP_FLOW_CONTROL_LAG1            0x20
113 #define NG_HCI_LMP_FLOW_CONTROL_LAG2            0x40
114
115 /* Link types */
116 #define NG_HCI_LINK_SCO                         0x00 /* Voice */
117 #define NG_HCI_LINK_ACL                         0x01 /* Data */
118 /* 0x02 - 0xFF - reserved for future use */
119
120 /* Packet types */
121                                 /* 0x0001 - 0x0004 - reserved for future use */
122 #define NG_HCI_PKT_DM1                          0x0008 /* ACL link */
123 #define NG_HCI_PKT_DH1                          0x0010 /* ACL link */
124 #define NG_HCI_PKT_HV1                          0x0020 /* SCO link */
125 #define NG_HCI_PKT_HV2                          0x0040 /* SCO link */
126 #define NG_HCI_PKT_HV3                          0x0080 /* SCO link */
127                                 /* 0x0100 - 0x0200 - reserved for future use */
128 #define NG_HCI_PKT_DM3                          0x0400 /* ACL link */
129 #define NG_HCI_PKT_DH3                          0x0800 /* ACL link */
130                                 /* 0x1000 - 0x2000 - reserved for future use */
131 #define NG_HCI_PKT_DM5                          0x4000 /* ACL link */
132 #define NG_HCI_PKT_DH5                          0x8000 /* ACL link */
133
134 /* 
135  * Connection modes/Unit modes
136  *
137  * This is confusing. It means that one of the units change its mode
138  * for the specific connection. For example one connection was put on 
139  * hold (but i could be wrong :) 
140  */
141
142 #define NG_HCI_UNIT_MODE_ACTIVE                 0x00
143 #define NG_HCI_UNIT_MODE_HOLD                   0x01
144 #define NG_HCI_UNIT_MODE_SNIFF                  0x02
145 #define NG_HCI_UNIT_MODE_PARK                   0x03
146 /* 0x04 - 0xFF - reserved for future use */
147
148 /* Page scan modes */
149 #define NG_HCI_MANDATORY_PAGE_SCAN_MODE         0x00
150 #define NG_HCI_OPTIONAL_PAGE_SCAN_MODE1         0x01
151 #define NG_HCI_OPTIONAL_PAGE_SCAN_MODE2         0x02
152 #define NG_HCI_OPTIONAL_PAGE_SCAN_MODE3         0x03
153 /* 0x04 - 0xFF - reserved for future use */
154
155 /* Page scan repetition modes */
156 #define NG_HCI_SCAN_REP_MODE0                   0x00
157 #define NG_HCI_SCAN_REP_MODE1                   0x01
158 #define NG_HCI_SCAN_REP_MODE2                   0x02
159 /* 0x03 - 0xFF - reserved for future use */
160
161 /* Page scan period modes */
162 #define NG_HCI_PAGE_SCAN_PERIOD_MODE0           0x00
163 #define NG_HCI_PAGE_SCAN_PERIOD_MODE1           0x01
164 #define NG_HCI_PAGE_SCAN_PERIOD_MODE2           0x02
165 /* 0x03 - 0xFF - reserved for future use */
166
167 /* Scan enable */
168 #define NG_HCI_NO_SCAN_ENABLE                   0x00
169 #define NG_HCI_INQUIRY_ENABLE_PAGE_DISABLE      0x01
170 #define NG_HCI_INQUIRY_DISABLE_PAGE_ENABLE      0x02
171 #define NG_HCI_INQUIRY_ENABLE_PAGE_ENABLE       0x03
172 /* 0x04 - 0xFF - reserved for future use */
173
174 /* Hold mode activities */
175 #define NG_HCI_HOLD_MODE_NO_CHANGE              0x00
176 #define NG_HCI_HOLD_MODE_SUSPEND_PAGE_SCAN      0x01
177 #define NG_HCI_HOLD_MODE_SUSPEND_INQUIRY_SCAN   0x02
178 #define NG_HCI_HOLD_MODE_SUSPEND_PERIOD_INQUIRY 0x04
179 /* 0x08 - 0x80 - reserved for future use */
180
181 /* Connection roles */
182 #define NG_HCI_ROLE_MASTER                      0x00
183 #define NG_HCI_ROLE_SLAVE                       0x01
184 /* 0x02 - 0xFF - reserved for future use */
185
186 /* Key flags */
187 #define NG_HCI_USE_SEMI_PERMANENT_LINK_KEYS     0x00
188 #define NG_HCI_USE_TEMPORARY_LINK_KEY           0x01
189 /* 0x02 - 0xFF - reserved for future use */
190
191 /* Pin types */
192 #define NG_HCI_PIN_TYPE_VARIABLE                0x00
193 #define NG_HCI_PIN_TYPE_FIXED                   0x01
194
195 /* Link key types */
196 #define NG_HCI_LINK_KEY_TYPE_COMBINATION_KEY    0x00
197 #define NG_HCI_LINK_KEY_TYPE_LOCAL_UNIT_KEY     0x01
198 #define NG_HCI_LINK_KEY_TYPE_REMOTE_UNIT_KEY    0x02
199 /* 0x03 - 0xFF - reserved for future use */
200
201 /* Encryption modes */
202 #define NG_HCI_ENCRYPTION_MODE_NONE             0x00
203 #define NG_HCI_ENCRYPTION_MODE_P2P              0x01
204 #define NG_HCI_ENCRYPTION_MODE_ALL              0x02
205 /* 0x03 - 0xFF - reserved for future use */
206
207 /* Quality of service types */
208 #define NG_HCI_SERVICE_TYPE_NO_TRAFFIC          0x00
209 #define NG_HCI_SERVICE_TYPE_BEST_EFFORT         0x01
210 #define NG_HCI_SERVICE_TYPE_GUARANTEED          0x02
211 /* 0x03 - 0xFF - reserved for future use */
212
213 /* Link policy settings */
214 #define NG_HCI_LINK_POLICY_DISABLE_ALL_LM_MODES 0x0000
215 #define NG_HCI_LINK_POLICY_ENABLE_ROLE_SWITCH   0x0001 /* Master/Slave switch */
216 #define NG_HCI_LINK_POLICY_ENABLE_HOLD_MODE     0x0002
217 #define NG_HCI_LINK_POLICY_ENABLE_SNIFF_MODE    0x0004
218 #define NG_HCI_LINK_POLICY_ENABLE_PARK_MODE     0x0008
219 /* 0x0010 - 0x8000 - reserved for future use */
220
221 /* Event masks */
222 #define NG_HCI_EVMSK_ALL                        0x00000000ffffffff
223 #define NG_HCI_EVMSK_NONE                       0x0000000000000000
224 #define NG_HCI_EVMSK_INQUIRY_COMPL              0x0000000000000001
225 #define NG_HCI_EVMSK_INQUIRY_RESULT             0x0000000000000002
226 #define NG_HCI_EVMSK_CON_COMPL                  0x0000000000000004
227 #define NG_HCI_EVMSK_CON_REQ                    0x0000000000000008
228 #define NG_HCI_EVMSK_DISCON_COMPL               0x0000000000000010
229 #define NG_HCI_EVMSK_AUTH_COMPL                 0x0000000000000020
230 #define NG_HCI_EVMSK_REMOTE_NAME_REQ_COMPL      0x0000000000000040
231 #define NG_HCI_EVMSK_ENCRYPTION_CHANGE          0x0000000000000080
232 #define NG_HCI_EVMSK_CHANGE_CON_LINK_KEY_COMPL  0x0000000000000100
233 #define NG_HCI_EVMSK_MASTER_LINK_KEY_COMPL      0x0000000000000200
234 #define NG_HCI_EVMSK_READ_REMOTE_FEATURES_COMPL 0x0000000000000400
235 #define NG_HCI_EVMSK_READ_REMOTE_VER_INFO_COMPL 0x0000000000000800
236 #define NG_HCI_EVMSK_QOS_SETUP_COMPL            0x0000000000001000
237 #define NG_HCI_EVMSK_COMMAND_COMPL              0x0000000000002000
238 #define NG_HCI_EVMSK_COMMAND_STATUS             0x0000000000004000
239 #define NG_HCI_EVMSK_HARDWARE_ERROR             0x0000000000008000
240 #define NG_HCI_EVMSK_FLUSH_OCCUR                0x0000000000010000
241 #define NG_HCI_EVMSK_ROLE_CHANGE                0x0000000000020000
242 #define NG_HCI_EVMSK_NUM_COMPL_PKTS             0x0000000000040000
243 #define NG_HCI_EVMSK_MODE_CHANGE                0x0000000000080000
244 #define NG_HCI_EVMSK_RETURN_LINK_KEYS           0x0000000000100000
245 #define NG_HCI_EVMSK_PIN_CODE_REQ               0x0000000000200000
246 #define NG_HCI_EVMSK_LINK_KEY_REQ               0x0000000000400000
247 #define NG_HCI_EVMSK_LINK_KEY_NOTIFICATION      0x0000000000800000
248 #define NG_HCI_EVMSK_LOOPBACK_COMMAND           0x0000000001000000
249 #define NG_HCI_EVMSK_DATA_BUFFER_OVERFLOW       0x0000000002000000
250 #define NG_HCI_EVMSK_MAX_SLOT_CHANGE            0x0000000004000000
251 #define NG_HCI_EVMSK_READ_CLOCK_OFFSET_COMLETE  0x0000000008000000
252 #define NG_HCI_EVMSK_CON_PKT_TYPE_CHANGED       0x0000000010000000
253 #define NG_HCI_EVMSK_QOS_VIOLATION              0x0000000020000000
254 #define NG_HCI_EVMSK_PAGE_SCAN_MODE_CHANGE      0x0000000040000000
255 #define NG_HCI_EVMSK_PAGE_SCAN_REP_MODE_CHANGE  0x0000000080000000
256 /* 0x0000000100000000 - 0x8000000000000000 - reserved for future use */
257
258 /* Filter types */
259 #define NG_HCI_FILTER_TYPE_NONE                 0x00
260 #define NG_HCI_FILTER_TYPE_INQUIRY_RESULT       0x01
261 #define NG_HCI_FILTER_TYPE_CON_SETUP            0x02
262 /* 0x03 - 0xFF - reserved for future use */
263
264 /* Filter condition types for NG_HCI_FILTER_TYPE_INQUIRY_RESULT */
265 #define NG_HCI_FILTER_COND_INQUIRY_NEW_UNIT     0x00
266 #define NG_HCI_FILTER_COND_INQUIRY_UNIT_CLASS   0x01
267 #define NG_HCI_FILTER_COND_INQUIRY_BDADDR       0x02
268 /* 0x03 - 0xFF - reserved for future use */
269
270 /* Filter condition types for NG_HCI_FILTER_TYPE_CON_SETUP */
271 #define NG_HCI_FILTER_COND_CON_ANY_UNIT         0x00
272 #define NG_HCI_FILTER_COND_CON_UNIT_CLASS       0x01
273 #define NG_HCI_FILTER_COND_CON_BDADDR           0x02
274 /* 0x03 - 0xFF - reserved for future use */
275
276 /* Xmit level types */
277 #define NG_HCI_XMIT_LEVEL_CURRENT               0x00
278 #define NG_HCI_XMIT_LEVEL_MAXIMUM               0x01
279 /* 0x02 - 0xFF - reserved for future use */
280
281 /* Host to Host Controller flow control */
282 #define NG_HCI_H2HC_FLOW_CONTROL_NONE           0x00
283 #define NG_HCI_H2HC_FLOW_CONTROL_ACL            0x01
284 #define NG_HCI_H2HC_FLOW_CONTROL_SCO            0x02
285 #define NG_HCI_H2HC_FLOW_CONTROL_BOTH           0x03    /* ACL and SCO */
286 /* 0x04 - 0xFF - reserved future use */
287
288 /* Country codes */
289 #define NG_HCI_COUNTRY_CODE_NAM_EUR_JP          0x00
290 #define NG_HCI_COUNTRY_CODE_FRANCE              0x01
291 /* 0x02 - 0xFF - reserved future use */
292
293 /* Loopback modes */
294 #define NG_HCI_LOOPBACK_NONE                    0x00
295 #define NG_HCI_LOOPBACK_LOCAL                   0x01
296 #define NG_HCI_LOOPBACK_REMOTE                  0x02
297 /* 0x03 - 0xFF - reserved future use */
298
299 /**************************************************************************
300  **************************************************************************
301  **                 Link level defines, headers and types
302  **************************************************************************
303  **************************************************************************/
304
305 /* 
306  * Macro(s) to combine OpCode and extract OGF (OpCode Group Field) 
307  * and OCF (OpCode Command Field) from OpCode.
308  */
309
310 #define NG_HCI_OPCODE(gf,cf)            ((((gf) & 0x3f) << 10) | ((cf) & 0x3ff))
311 #define NG_HCI_OCF(op)                  ((op) & 0x3ff)
312 #define NG_HCI_OGF(op)                  (((op) >> 10) & 0x3f)
313
314 /* 
315  * Marco(s) to extract/combine connection handle, BC (Broadcast) and 
316  * PB (Packet boundary) flags.
317  */
318
319 #define NG_HCI_CON_HANDLE(h)            ((h) & 0x0fff)
320 #define NG_HCI_PB_FLAG(h)               (((h) & 0x3000) >> 12)
321 #define NG_HCI_BC_FLAG(h)               (((h) & 0xc000) >> 14)
322 #define NG_HCI_MK_CON_HANDLE(h, pb, bc) \
323         (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14))
324
325 /* PB flag values */
326                                         /* 00 - reserved for future use */
327 #define NG_HCI_PACKET_FRAGMENT          0x1 
328 #define NG_HCI_PACKET_START             0x2
329                                         /* 11 - reserved for future use */
330
331 /* BC flag values */
332 #define NG_HCI_POINT2POINT              0x0 /* only Host controller to Host */
333 #define NG_HCI_BROADCAST_ACTIVE         0x1 /* both directions */
334 #define NG_HCI_BROADCAST_PICONET        0x2 /* both directions */
335                                         /* 11 - reserved for future use */
336
337 /* HCI command packet header */
338 #define NG_HCI_CMD_PKT                  0x01
339 #define NG_HCI_CMD_PKT_SIZE             0xff /* without header */
340 typedef struct {
341         u_int8_t        type;   /* MUST be 0x1 */
342         u_int16_t       opcode; /* OpCode */
343         u_int8_t        length; /* parameter(s) length in bytes */
344 } __attribute__ ((packed)) ng_hci_cmd_pkt_t;
345
346 /* ACL data packet header */
347 #define NG_HCI_ACL_DATA_PKT             0x02
348 #define NG_HCI_ACL_PKT_SIZE             0xffff /* without header */
349 typedef struct {
350         u_int8_t        type;        /* MUST be 0x2 */
351         u_int16_t       con_handle;  /* connection handle + PB + BC flags */
352         u_int16_t       length;      /* payload length in bytes */
353 } __attribute__ ((packed)) ng_hci_acldata_pkt_t;
354
355 /* SCO data packet header */
356 #define NG_HCI_SCO_DATA_PKT             0x03
357 #define NG_HCI_SCO_PKT_SIZE             0xff /* without header */
358 typedef struct {
359         u_int8_t        type;       /* MUST be 0x3 */
360         u_int16_t       con_handle; /* connection handle + reserved bits */
361         u_int8_t        length;     /* payload length in bytes */
362 } __attribute__ ((packed)) ng_hci_scodata_pkt_t;
363
364 /* HCI event packet header */
365 #define NG_HCI_EVENT_PKT                0x04
366 #define NG_HCI_EVENT_PKT_SIZE           0xff /* without header */
367 typedef struct {
368         u_int8_t        type;   /* MUST be 0x4 */
369         u_int8_t        event;  /* event */
370         u_int8_t        length; /* parameter(s) length in bytes */
371 } __attribute__ ((packed)) ng_hci_event_pkt_t;
372
373 /* Bluetooth unit address */
374 typedef struct {
375         u_int8_t        b[NG_HCI_BDADDR_SIZE];
376 } __attribute__ ((packed)) bdaddr_t;
377 typedef bdaddr_t *      bdaddr_p;
378
379 /* Any BD_ADDR. Note: This is actually 7 bytes (count '\0' terminator) */
380 #define NG_HCI_BDADDR_ANY       ((bdaddr_p) "\000\000\000\000\000\000")
381
382 /* HCI status return parameter */
383 typedef struct {
384         u_int8_t        status; /* 0x00 - success */
385 } __attribute__ ((packed)) ng_hci_status_rp;
386
387 /**************************************************************************
388  **************************************************************************
389  **        Upper layer protocol interface. LP_xxx event parameters
390  **************************************************************************
391  **************************************************************************/
392
393 /* Connection Request Event */
394 #define NGM_HCI_LP_CON_REQ                      1  /* Upper -> HCI */
395 typedef struct {
396         u_int16_t       link_type; /* type of connection */
397         bdaddr_t        bdaddr;    /* remote unit address */
398 } ng_hci_lp_con_req_ep;
399
400 /*
401  * XXX XXX XXX
402  *
403  * NOTE: This request is not defined by Bluetooth specification, 
404  * but i find it useful :)
405  */
406 #define NGM_HCI_LP_DISCON_REQ                   2 /* Upper -> HCI */
407 typedef struct {
408         u_int16_t       con_handle; /* connection handle */
409         u_int16_t       reason;     /* reason to disconnect (only low byte) */
410 } ng_hci_lp_discon_req_ep;
411
412 /* Connection Confirmation Event */
413 #define NGM_HCI_LP_CON_CFM                      3  /* HCI -> Upper */
414 typedef struct {
415         u_int8_t        status;     /* 0x00 - success */
416         u_int8_t        link_type;  /* link type */
417         u_int16_t       con_handle; /* con_handle */
418         bdaddr_t        bdaddr;     /* remote unit address */
419 } ng_hci_lp_con_cfm_ep;
420
421 /* Connection Indication Event */
422 #define NGM_HCI_LP_CON_IND                      4  /* HCI -> Upper */
423 typedef struct {
424         u_int8_t        link_type;                 /* link type */
425         u_int8_t        uclass[NG_HCI_CLASS_SIZE]; /* unit class */
426         bdaddr_t        bdaddr;                    /* remote unit address */
427 } ng_hci_lp_con_ind_ep;
428
429 /* Connection Response Event */
430 #define NGM_HCI_LP_CON_RSP                      5  /* Upper -> HCI */
431 typedef struct {
432         u_int8_t        status;    /* 0x00 - accept connection */
433         u_int8_t        link_type; /* link type */
434         bdaddr_t        bdaddr;    /* remote unit address */
435 } ng_hci_lp_con_rsp_ep;
436
437 /* Disconnection Indication Event */
438 #define NGM_HCI_LP_DISCON_IND                   6  /* HCI -> Upper */
439 typedef struct {
440         u_int8_t        reason;     /* reason to disconnect (only low byte) */
441         u_int8_t        link_type;  /* link type */
442         u_int16_t       con_handle; /* connection handle */
443 } ng_hci_lp_discon_ind_ep;
444
445 /* QoS Setup Request Event */
446 #define NGM_HCI_LP_QOS_REQ                      7  /* Upper -> HCI */
447 typedef struct {
448         u_int16_t       con_handle;      /* connection handle */
449         u_int8_t        flags;           /* reserved */
450         u_int8_t        service_type;    /* service type */
451         u_int32_t       token_rate;      /* bytes/sec */
452         u_int32_t       peak_bandwidth;  /* bytes/sec */
453         u_int32_t       latency;         /* msec */
454         u_int32_t       delay_variation; /* msec */
455 } ng_hci_lp_qos_req_ep;
456
457 /* QoS Conformition Event */
458 #define NGM_HCI_LP_QOS_CFM                      8  /* HCI -> Upper */
459 typedef struct {
460         u_int16_t       status;          /* 0x00 - success  (only low byte) */
461         u_int16_t       con_handle;      /* connection handle */
462 } ng_hci_lp_qos_cfm_ep;
463
464 /* QoS Violation Indication Event */
465 #define NGM_HCI_LP_QOS_IND                      9  /* HCI -> Upper */
466 typedef struct {
467         u_int16_t       con_handle; /* connection handle */
468 } ng_hci_lp_qos_ind_ep;
469
470 /**************************************************************************
471  **************************************************************************
472  **                    HCI node command/event parameters
473  **************************************************************************
474  **************************************************************************/
475
476 /* Debug levels */
477 #define NG_HCI_ALERT_LEVEL              1
478 #define NG_HCI_ERR_LEVEL                2
479 #define NG_HCI_WARN_LEVEL               3
480 #define NG_HCI_INFO_LEVEL               4
481
482 /* Unit states */
483 #define NG_HCI_UNIT_CONNECTED           (1 << 0)
484 #define NG_HCI_UNIT_INITED              (1 << 1)
485 #define NG_HCI_UNIT_READY       (NG_HCI_UNIT_CONNECTED|NG_HCI_UNIT_INITED)
486 #define NG_HCI_UNIT_COMMAND_PENDING     (1 << 2)
487
488 /* Connection state */
489 #define NG_HCI_CON_CLOSED               0 /* connection closed */
490 #define NG_HCI_CON_W4_LP_CON_RSP        1 /* wait for LP_ConnectRsp */
491 #define NG_HCI_CON_W4_CONN_COMPLETE     2 /* wait for Connection_Complete evt */
492 #define NG_HCI_CON_OPEN                 3 /* connection open */
493
494 /* Get HCI node (unit) state (see states above) */
495 #define NGM_HCI_NODE_GET_STATE                  100  /* HCI -> User */
496 typedef u_int16_t       ng_hci_node_state_ep;
497
498 /* Turn on "inited" bit */
499 #define NGM_HCI_NODE_INIT                       101 /* User -> HCI */
500 /* No parameters */
501
502 /* Get/Set node debug level (see debug levels above) */
503 #define NGM_HCI_NODE_GET_DEBUG                  102 /* HCI -> User */
504 #define NGM_HCI_NODE_SET_DEBUG                  103 /* User -> HCI */
505 typedef u_int16_t       ng_hci_node_debug_ep;
506
507 /* Get node buffer info */
508 #define NGM_HCI_NODE_GET_BUFFER                 104 /* HCI -> User */
509 typedef struct {
510         u_int8_t        cmd_free; /* number of free command packets */
511         u_int8_t        sco_size; /* max. size of SCO packet */
512         u_int16_t       sco_pkts; /* number of SCO packets */
513         u_int16_t       sco_free; /* number of free SCO packets */
514         u_int16_t       acl_size; /* max. size of ACL packet */
515         u_int16_t       acl_pkts; /* number of ACL packets */
516         u_int16_t       acl_free; /* number of free ACL packets */
517 } ng_hci_node_buffer_ep;
518
519 /* Get BDADDR */
520 #define NGM_HCI_NODE_GET_BDADDR                 105 /* HCI -> User */
521 /* bdaddr_t -- BDADDR */
522
523 /* Get features */
524 #define NGM_HCI_NODE_GET_FEATURES               106 /* HCI -> User */
525 /* features[NG_HCI_FEATURES_SIZE] -- features */
526
527 #define NGM_HCI_NODE_GET_STAT                   107 /* HCI -> User */
528 typedef struct {
529         u_int32_t       cmd_sent;   /* number of HCI commands sent */
530         u_int32_t       evnt_recv;  /* number of HCI events received */
531         u_int32_t       acl_recv;   /* number of ACL packets received */
532         u_int32_t       acl_sent;   /* number of ACL packets sent */
533         u_int32_t       sco_recv;   /* number of SCO packets received */
534         u_int32_t       sco_sent;   /* number of SCO packets sent */
535         u_int32_t       bytes_recv; /* total number of bytes received */
536         u_int32_t       bytes_sent; /* total number of bytes sent */
537 } ng_hci_node_stat_ep;
538
539 #define NGM_HCI_NODE_RESET_STAT                 108 /* User -> HCI */
540 /* No parameters */
541
542 #define NGM_HCI_NODE_FLUSH_NEIGHBOR_CACHE       109 /* User -> HCI */
543
544 #define NGM_HCI_NODE_GET_NEIGHBOR_CACHE         110 /* HCI -> User */
545 typedef struct {
546         u_int32_t       num_entries;    /* number of entries */
547 } ng_hci_node_get_neighbor_cache_ep;
548
549 typedef struct {
550         u_int16_t       page_scan_rep_mode;             /* page rep scan mode */
551         u_int16_t       page_scan_mode;                 /* page scan mode */
552         u_int16_t       clock_offset;                   /* clock offset */
553         bdaddr_t        bdaddr;                         /* bdaddr */
554         u_int8_t        features[NG_HCI_FEATURES_SIZE]; /* features */
555 } ng_hci_node_neighbor_cache_entry_ep;
556
557 #define NG_HCI_MAX_NEIGHBOR_NUM \
558         ((0xffff - sizeof(ng_hci_node_get_neighbor_cache_ep))/sizeof(ng_hci_node_neighbor_cache_entry_ep))
559
560 #define NGM_HCI_NODE_GET_CON_LIST               111 /* HCI -> User */
561 typedef struct {
562         u_int32_t       num_connections; /* number of connections */
563 } ng_hci_node_con_list_ep;
564
565 typedef struct {
566         u_int8_t        link_type;       /* ACL or SCO */
567         u_int8_t        encryption_mode; /* none, p2p, ... */
568         u_int8_t        mode;            /* ACTIVE, HOLD ... */
569         u_int8_t        role;            /* MASTER/SLAVE */
570         u_int16_t       state;           /* connection state */
571         u_int16_t       reserved;        /* place holder */
572         u_int16_t       pending;         /* number of pending packets */
573         u_int16_t       queue_len;       /* number of packets in queue */
574         u_int16_t       con_handle;      /* connection handle */
575         bdaddr_t        bdaddr;          /* remote bdaddr */
576 } ng_hci_node_con_ep;
577
578 #define NG_HCI_MAX_CON_NUM \
579         ((0xffff - sizeof(ng_hci_node_con_list_ep))/sizeof(ng_hci_node_con_ep))
580
581 #define NGM_HCI_NODE_UP                         112 /* HCI -> Upper */
582 typedef struct {
583         u_int16_t       pkt_size; /* max. ACL/SCO packet size (w/out header) */
584         u_int16_t       num_pkts; /* ACL/SCO packet queue size */
585         u_int16_t       reserved; /* place holder */
586         bdaddr_t        bdaddr;   /* bdaddr */
587 } ng_hci_node_up_ep;
588
589 #define NGM_HCI_SYNC_CON_QUEUE                  113 /* HCI -> Upper */
590 typedef struct {
591         u_int16_t       con_handle; /* connection handle */
592         u_int16_t       completed;  /* number of completed packets */
593 } ng_hci_sync_con_queue_ep;
594
595 #define NGM_HCI_NODE_GET_LINK_POLICY_SETTINGS_MASK      114 /* HCI -> User */
596 #define NGM_HCI_NODE_SET_LINK_POLICY_SETTINGS_MASK      115 /* User -> HCI */
597 typedef u_int16_t       ng_hci_node_link_policy_mask_ep;
598
599 #define NGM_HCI_NODE_GET_PACKET_MASK            116 /* HCI -> User */
600 #define NGM_HCI_NODE_SET_PACKET_MASK            117 /* User -> HCI */
601 typedef u_int16_t       ng_hci_node_packet_mask_ep;
602
603 #define NGM_HCI_NODE_GET_ROLE_SWITCH            118 /* HCI -> User */
604 #define NGM_HCI_NODE_SET_ROLE_SWITCH            119 /* User -> HCI */
605 typedef u_int16_t       ng_hci_node_role_switch_ep;
606
607 #define NGM_HCI_NODE_LIST_NAMES                 200 /* HCI -> User */
608
609 /**************************************************************************
610  **************************************************************************
611  **             Link control commands and return parameters
612  **************************************************************************
613  **************************************************************************/
614
615 #define NG_HCI_OGF_LINK_CONTROL                 0x01 /* OpCode Group Field */
616
617 #define NG_HCI_OCF_INQUIRY                      0x0001
618 typedef struct {
619         u_int8_t        lap[NG_HCI_LAP_SIZE]; /* LAP */
620         u_int8_t        inquiry_length; /* (N x 1.28) sec */
621         u_int8_t        num_responses;  /* Max. # of responses before halted */
622 } __attribute__ ((packed)) ng_hci_inquiry_cp;
623 /* No return parameter(s) */
624
625 #define NG_HCI_OCF_INQUIRY_CANCEL               0x0002
626 /* No command parameter(s) */
627 typedef ng_hci_status_rp        ng_hci_inquiry_cancel_rp;
628
629 #define NG_HCI_OCF_PERIODIC_INQUIRY             0x0003
630 typedef struct {
631         u_int16_t       max_period_length; /* Max. and min. amount of time */
632         u_int16_t       min_period_length; /* between consecutive inquiries */
633         u_int8_t        lap[NG_HCI_LAP_SIZE]; /* LAP */
634         u_int8_t        inquiry_length;    /* (inquiry_length * 1.28) sec */
635         u_int8_t        num_responses;     /* Max. # of responses */
636 } __attribute__ ((packed)) ng_hci_periodic_inquiry_cp;
637
638 typedef ng_hci_status_rp        ng_hci_periodic_inquiry_rp;
639         
640 #define NG_HCI_OCF_EXIT_PERIODIC_INQUIRY        0x0004
641 /* No command parameter(s) */
642 typedef ng_hci_status_rp        ng_hci_exit_periodic_inquiry_rp;
643
644 #define NG_HCI_OCF_CREATE_CON                   0x0005
645 typedef struct {
646         bdaddr_t        bdaddr;             /* destination address */
647         u_int16_t       pkt_type;           /* packet type */
648         u_int8_t        page_scan_rep_mode; /* page scan repetition mode */
649         u_int8_t        page_scan_mode;     /* page scan mode */
650         u_int16_t       clock_offset;       /* clock offset */
651         u_int8_t        accept_role_switch; /* accept role switch? 0x00 - no */
652 } __attribute__ ((packed)) ng_hci_create_con_cp;
653 /* No return parameter(s) */
654
655 #define NG_HCI_OCF_DISCON                       0x0006
656 typedef struct {
657         u_int16_t       con_handle; /* connection handle */
658         u_int8_t        reason;     /* reason to disconnect */
659 } __attribute__ ((packed)) ng_hci_discon_cp;
660 /* No return parameter(s) */
661
662 #define NG_HCI_OCF_ADD_SCO_CON                  0x0007
663 typedef struct {
664         u_int16_t       con_handle; /* connection handle */
665         u_int16_t       pkt_type;   /* packet type */
666 } __attribute__ ((packed)) ng_hci_add_sco_con_cp;
667 /* No return parameter(s) */
668
669 #define NG_HCI_OCF_ACCEPT_CON                   0x0009
670 typedef struct {
671         bdaddr_t        bdaddr; /* address of unit to be connected */
672         u_int8_t        role;   /* connection role */
673 } __attribute__ ((packed)) ng_hci_accept_con_cp;
674 /* No return parameter(s) */
675
676 #define NG_HCI_OCF_REJECT_CON                   0x000a
677 typedef struct {
678         bdaddr_t        bdaddr; /* remote address */
679         u_int8_t        reason; /* reason to reject */
680 } __attribute__ ((packed)) ng_hci_reject_con_cp;
681 /* No return parameter(s) */
682
683 #define NG_HCI_OCF_LINK_KEY_REP                 0x000b
684 typedef struct {
685         bdaddr_t        bdaddr;               /* remote address */
686         u_int8_t        key[NG_HCI_KEY_SIZE]; /* key */
687 } __attribute__ ((packed)) ng_hci_link_key_rep_cp;
688
689 typedef struct {
690         u_int8_t        status; /* 0x00 - success */
691         bdaddr_t        bdaddr; /* unit address */
692 } __attribute__ ((packed)) ng_hci_link_key_rep_rp;
693
694 #define NG_HCI_OCF_LINK_KEY_NEG_REP             0x000c
695 typedef struct {
696         bdaddr_t        bdaddr; /* remote address */
697 } __attribute__ ((packed)) ng_hci_link_key_neg_rep_cp;
698
699 typedef struct {
700         u_int8_t        status; /* 0x00 - success */
701         bdaddr_t        bdaddr; /* unit address */
702 } __attribute__ ((packed)) ng_hci_link_key_neg_rep_rp;
703
704 #define NG_HCI_OCF_PIN_CODE_REP                 0x000d
705 typedef struct {
706         bdaddr_t        bdaddr;               /* remote address */
707         u_int8_t        pin_size;             /* pin code length (in bytes) */
708         u_int8_t        pin[NG_HCI_PIN_SIZE]; /* pin code */
709 } __attribute__ ((packed)) ng_hci_pin_code_rep_cp;
710
711 typedef struct {
712         u_int8_t        status; /* 0x00 - success */
713         bdaddr_t        bdaddr; /* unit address */
714 } __attribute__ ((packed)) ng_hci_pin_code_rep_rp;
715
716 #define NG_HCI_OCF_PIN_CODE_NEG_REP             0x000e
717 typedef struct {
718         bdaddr_t        bdaddr;  /* remote address */
719 } __attribute__ ((packed)) ng_hci_pin_code_neg_rep_cp;
720
721 typedef struct {
722         u_int8_t        status; /* 0x00 - success */
723         bdaddr_t        bdaddr; /* unit address */
724 } __attribute__ ((packed)) ng_hci_pin_code_neg_rep_rp;
725
726 #define NG_HCI_OCF_CHANGE_CON_PKT_TYPE          0x000f
727 typedef struct {
728         u_int16_t       con_handle; /* connection handle */
729         u_int16_t       pkt_type;   /* packet type */
730 } __attribute__ ((packed)) ng_hci_change_con_pkt_type_cp;
731 /* No return parameter(s) */
732
733 #define NG_HCI_OCF_AUTH_REQ                     0x0011
734 typedef struct {
735         u_int16_t       con_handle; /* connection handle */
736 } __attribute__ ((packed)) ng_hci_auth_req_cp;
737 /* No return parameter(s) */
738
739 #define NG_HCI_OCF_SET_CON_ENCRYPTION           0x0013
740 typedef struct {
741         u_int16_t       con_handle;        /* connection handle */
742         u_int8_t        encryption_enable; /* 0x00 - disable, 0x01 - enable */
743 } __attribute__ ((packed)) ng_hci_set_con_encryption_cp;
744 /* No return parameter(s) */
745
746 #define NG_HCI_OCF_CHANGE_CON_LINK_KEY          0x0015
747 typedef struct {
748         u_int16_t       con_handle; /* connection handle */
749 } __attribute__ ((packed)) ng_hci_change_con_link_key_cp;
750 /* No return parameter(s) */
751
752 #define NG_HCI_OCF_MASTER_LINK_KEY              0x0017
753 typedef struct {
754         u_int8_t        key_flag; /* key flag */
755 } __attribute__ ((packed)) ng_hci_master_link_key_cp;
756 /* No return parameter(s) */
757
758 #define NG_HCI_OCF_REMOTE_NAME_REQ              0x0019
759 typedef struct {
760         bdaddr_t        bdaddr;             /* remote address */
761         u_int8_t        page_scan_rep_mode; /* page scan repetition mode */
762         u_int8_t        page_scan_mode;     /* page scan mode */
763         u_int16_t       clock_offset;       /* clock offset */
764 } __attribute__ ((packed)) ng_hci_remote_name_req_cp;
765 /* No return parameter(s) */
766
767 #define NG_HCI_OCF_READ_REMOTE_FEATURES         0x001b
768 typedef struct {
769         u_int16_t       con_handle; /* connection handle */
770 } __attribute__ ((packed)) ng_hci_read_remote_features_cp;
771 /* No return parameter(s) */
772
773 #define NG_HCI_OCF_READ_REMOTE_VER_INFO         0x001d
774 typedef struct {
775         u_int16_t       con_handle; /* connection handle */
776 } __attribute__ ((packed)) ng_hci_read_remote_ver_info_cp;
777 /* No return parameter(s) */
778
779 #define NG_HCI_OCF_READ_CLOCK_OFFSET             0x001f
780 typedef struct {
781         u_int16_t       con_handle; /* connection handle */
782 } __attribute__ ((packed)) ng_hci_read_clock_offset_cp;
783 /* No return parameter(s) */
784
785 /**************************************************************************
786  **************************************************************************
787  **        Link policy commands and return parameters
788  **************************************************************************
789  **************************************************************************/
790
791 #define NG_HCI_OGF_LINK_POLICY                  0x02 /* OpCode Group Field */
792
793 #define NG_HCI_OCF_HOLD_MODE                    0x0001
794 typedef struct {
795         u_int16_t       con_handle;   /* connection handle */
796         u_int16_t       max_interval; /* (max_interval * 0.625) msec */
797         u_int16_t       min_interval; /* (max_interval * 0.625) msec */
798 } __attribute__ ((packed)) ng_hci_hold_mode_cp;
799 /* No return parameter(s) */
800
801 #define NG_HCI_OCF_SNIFF_MODE                   0x0003
802 typedef struct {
803         u_int16_t       con_handle;   /* connection handle */
804         u_int16_t       max_interval; /* (max_interval * 0.625) msec */
805         u_int16_t       min_interval; /* (max_interval * 0.625) msec */
806         u_int16_t       attempt;      /* (2 * attempt - 1) * 0.625 msec */
807         u_int16_t       timeout;      /* (2 * attempt - 1) * 0.625 msec */
808 } __attribute__ ((packed)) ng_hci_sniff_mode_cp;
809 /* No return parameter(s) */
810
811 #define NG_HCI_OCF_EXIT_SNIFF_MODE              0x0004
812 typedef struct {
813         u_int16_t       con_handle; /* connection handle */
814 } __attribute__ ((packed)) ng_hci_exit_sniff_mode_cp;
815 /* No return parameter(s) */
816
817 #define NG_HCI_OCF_PARK_MODE                    0x0005
818 typedef struct {
819         u_int16_t       con_handle;   /* connection handle */
820         u_int16_t       max_interval; /* (max_interval * 0.625) msec */
821         u_int16_t       min_interval; /* (max_interval * 0.625) msec */
822 } __attribute__ ((packed)) ng_hci_park_mode_cp;
823 /* No return parameter(s) */
824
825 #define NG_HCI_OCF_EXIT_PARK_MODE               0x0006
826 typedef struct {
827         u_int16_t       con_handle; /* connection handle */
828 } __attribute__ ((packed)) ng_hci_exit_park_mode_cp;
829 /* No return parameter(s) */
830
831 #define NG_HCI_OCF_QOS_SETUP                    0x0007
832 typedef struct {
833         u_int16_t       con_handle;      /* connection handle */
834         u_int8_t        flags;           /* reserved for future use */
835         u_int8_t        service_type;    /* service type */
836         u_int32_t       token_rate;      /* bytes per second */
837         u_int32_t       peak_bandwidth;  /* bytes per second */
838         u_int32_t       latency;         /* microseconds */
839         u_int32_t       delay_variation; /* microseconds */
840 } __attribute__ ((packed)) ng_hci_qos_setup_cp;
841 /* No return parameter(s) */
842
843 #define NG_HCI_OCF_ROLE_DISCOVERY               0x0009
844 typedef struct {
845         u_int16_t       con_handle; /* connection handle */
846 } __attribute__ ((packed)) ng_hci_role_discovery_cp;
847
848 typedef struct {
849         u_int8_t        status;     /* 0x00 - success */
850         u_int16_t       con_handle; /* connection handle */
851         u_int8_t        role;       /* role for the connection handle */
852 } __attribute__ ((packed)) ng_hci_role_discovery_rp;
853
854 #define NG_HCI_OCF_SWITCH_ROLE                  0x000b
855 typedef struct {
856         bdaddr_t        bdaddr; /* remote address */
857         u_int8_t        role;   /* new local role */
858 } __attribute__ ((packed)) ng_hci_switch_role_cp;
859 /* No return parameter(s) */
860
861 #define NG_HCI_OCF_READ_LINK_POLICY_SETTINGS    0x000c
862 typedef struct {
863         u_int16_t       con_handle; /* connection handle */
864 } __attribute__ ((packed)) ng_hci_read_link_policy_settings_cp;
865         
866 typedef struct {
867         u_int8_t        status;     /* 0x00 - success */
868         u_int16_t       con_handle; /* connection handle */
869         u_int16_t       settings;   /* link policy settings */
870 } __attribute__ ((packed)) ng_hci_read_link_policy_settings_rp;
871
872 #define NG_HCI_OCF_WRITE_LINK_POLICY_SETTINGS   0x000d
873 typedef struct {
874         u_int16_t       con_handle; /* connection handle */
875         u_int16_t       settings;   /* link policy settings */
876 } __attribute__ ((packed)) ng_hci_write_link_policy_settings_cp;
877
878 typedef struct {
879         u_int8_t        status;     /* 0x00 - success */
880         u_int16_t       con_handle; /* connection handle */
881 } __attribute__ ((packed)) ng_hci_write_link_policy_settings_rp;
882
883 /**************************************************************************
884  **************************************************************************
885  **   Host controller and baseband commands and return parameters 
886  **************************************************************************
887  **************************************************************************/
888
889 #define NG_HCI_OGF_HC_BASEBAND                  0x03 /* OpCode Group Field */
890
891 #define NG_HCI_OCF_SET_EVENT_MASK               0x0001
892 typedef struct {
893         u_int8_t        event_mask[NG_HCI_EVENT_MASK_SIZE]; /* event_mask */
894 } __attribute__ ((packed)) ng_hci_set_event_mask_cp;
895
896 typedef ng_hci_status_rp        ng_hci_set_event_mask_rp;
897
898 #define NG_HCI_OCF_RESET                        0x0003
899 /* No command parameter(s) */
900 typedef ng_hci_status_rp        ng_hci_reset_rp;
901
902 #define NG_HCI_OCF_SET_EVENT_FILTER             0x0005
903 typedef struct {
904         u_int8_t        filter_type;           /* filter type */
905         u_int8_t        filter_condition_type; /* filter condition type */
906         u_int8_t        condition[0];          /* conditions - variable size */
907 } __attribute__ ((packed)) ng_hci_set_event_filter_cp;
908
909 typedef ng_hci_status_rp        ng_hci_set_event_filter_rp;
910
911 #define NG_HCI_OCF_FLUSH                        0x0008
912 typedef struct {
913         u_int16_t       con_handle; /* connection handle */
914 } __attribute__ ((packed)) ng_hci_flush_cp;
915
916 typedef struct {
917         u_int8_t        status;     /* 0x00 - success */
918         u_int16_t       con_handle; /* connection handle */
919 } __attribute__ ((packed)) ng_hci_flush_rp;
920
921 #define NG_HCI_OCF_READ_PIN_TYPE                0x0009
922 /* No command parameter(s) */
923 typedef struct {
924         u_int8_t        status;   /* 0x00 - success */
925         u_int8_t        pin_type; /* PIN type */
926 } __attribute__ ((packed)) ng_hci_read_pin_type_rp;
927
928 #define NG_HCI_OCF_WRITE_PIN_TYPE               0x000a
929 typedef struct {
930         u_int8_t        pin_type; /* PIN type */
931 } __attribute__ ((packed)) ng_hci_write_pin_type_cp;
932
933 typedef ng_hci_status_rp        ng_hci_write_pin_type_rp;
934
935 #define NG_HCI_OCF_CREATE_NEW_UNIT_KEY          0x000b
936 /* No command parameter(s) */
937 typedef ng_hci_status_rp        ng_hci_create_new_unit_key_rp;
938
939 #define NG_HCI_OCF_READ_STORED_LINK_KEY         0x000d
940 typedef struct {
941         bdaddr_t        bdaddr;   /* address */
942         u_int8_t        read_all; /* read all keys? 0x01 - yes */
943 } __attribute__ ((packed)) ng_hci_read_stored_link_key_cp;
944
945 typedef struct {
946         u_int8_t        status;        /* 0x00 - success */
947         u_int16_t       max_num_keys;  /* Max. number of keys */
948         u_int16_t       num_keys_read; /* Number of stored keys */
949 } __attribute__ ((packed)) ng_hci_read_stored_link_key_rp;
950
951 #define NG_HCI_OCF_WRITE_STORED_LINK_KEY        0x0011
952 typedef struct {
953         u_int8_t        num_keys_write; /* # of keys to write */
954 /* these are repeated "num_keys_write" times 
955         bdaddr_t        bdaddr;                --- remote address(es)
956         u_int8_t        key[NG_HCI_KEY_SIZE];  --- key(s) */
957 } __attribute__ ((packed)) ng_hci_write_stored_link_key_cp;
958
959 typedef struct {
960         u_int8_t        status;           /* 0x00 - success */
961         u_int8_t        num_keys_written; /* # of keys successfully written */
962 } __attribute__ ((packed)) ng_hci_write_stored_link_key_rp;
963
964 #define NG_HCI_OCF_DELETE_STORED_LINK_KEY       0x0012
965 typedef struct {
966         bdaddr_t        bdaddr;     /* address */
967         u_int8_t        delete_all; /* delete all keys? 0x01 - yes */
968 } __attribute__ ((packed)) ng_hci_delete_stored_link_key_cp;
969
970 typedef struct {
971         u_int8_t        status;           /* 0x00 - success */
972         u_int16_t       num_keys_deleted; /* Number of keys deleted */
973 } __attribute__ ((packed)) ng_hci_delete_stored_link_key_rp;
974
975 #define NG_HCI_OCF_CHANGE_LOCAL_NAME            0x0013
976 typedef struct {
977         char            name[NG_HCI_UNIT_NAME_SIZE]; /* new unit name */
978 } __attribute__ ((packed)) ng_hci_change_local_name_cp;
979
980 typedef ng_hci_status_rp        ng_hci_change_local_name_rp;
981
982 #define NG_HCI_OCF_READ_LOCAL_NAME              0x0014
983 /* No command parameter(s) */
984 typedef struct {
985         u_int8_t        status;  /* 0x00 - success */
986         char            name[NG_HCI_UNIT_NAME_SIZE]; /* unit name */
987 } __attribute__ ((packed)) ng_hci_read_local_name_rp;
988
989 #define NG_HCI_OCF_READ_CON_ACCEPT_TIMO         0x0015
990 /* No command parameter(s) */
991 typedef struct {
992         u_int8_t        status;  /* 0x00 - success */
993         u_int16_t       timeout; /* (timeout * 0.625) msec */
994 } __attribute__ ((packed)) ng_hci_read_con_accept_timo_rp;
995
996 #define NG_HCI_OCF_WRITE_CON_ACCEPT_TIMO        0x0016
997 typedef struct {
998         u_int16_t       timeout; /* (timeout * 0.625) msec */
999 } __attribute__ ((packed)) ng_hci_write_con_accept_timo_cp;
1000
1001 typedef ng_hci_status_rp        ng_hci_write_con_accept_timo_rp;
1002
1003 #define NG_HCI_OCF_READ_PAGE_TIMO               0x0017
1004 /* No command parameter(s) */
1005 typedef struct {
1006         u_int8_t        status;  /* 0x00 - success */
1007         u_int16_t       timeout; /* (timeout * 0.625) msec */
1008 } __attribute__ ((packed)) ng_hci_read_page_timo_rp;
1009
1010 #define NG_HCI_OCF_WRITE_PAGE_TIMO              0x0018
1011 typedef struct {
1012         u_int16_t       timeout; /* (timeout * 0.625) msec */
1013 } __attribute__ ((packed)) ng_hci_write_page_timo_cp;
1014
1015 typedef ng_hci_status_rp        ng_hci_write_page_timo_rp;
1016
1017 #define NG_HCI_OCF_READ_SCAN_ENABLE             0x0019
1018 /* No command parameter(s) */
1019 typedef struct {
1020         u_int8_t        status;      /* 0x00 - success */
1021         u_int8_t        scan_enable; /* Scan enable */
1022 } __attribute__ ((packed)) ng_hci_read_scan_enable_rp;
1023
1024 #define NG_HCI_OCF_WRITE_SCAN_ENABLE            0x001a
1025 typedef struct {
1026         u_int8_t        scan_enable; /* Scan enable */
1027 } __attribute__ ((packed)) ng_hci_write_scan_enable_cp;
1028
1029 typedef ng_hci_status_rp        ng_hci_write_scan_enable_rp;
1030
1031 #define NG_HCI_OCF_READ_PAGE_SCAN_ACTIVITY      0x001b
1032 /* No command parameter(s) */
1033 typedef struct {
1034         u_int8_t        status;             /* 0x00 - success */
1035         u_int16_t       page_scan_interval; /* interval * 0.625 msec */
1036         u_int16_t       page_scan_window;   /* window * 0.625 msec */
1037 } __attribute__ ((packed)) ng_hci_read_page_scan_activity_rp;
1038
1039 #define NG_HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY     0x001c
1040 typedef struct {
1041         u_int16_t       page_scan_interval; /* interval * 0.625 msec */
1042         u_int16_t       page_scan_window;   /* window * 0.625 msec */
1043 } __attribute__ ((packed)) ng_hci_write_page_scan_activity_cp;
1044
1045 typedef ng_hci_status_rp        ng_hci_write_page_scan_activity_rp;
1046
1047 #define NG_HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY   0x001d
1048 /* No command parameter(s) */
1049 typedef struct {
1050         u_int8_t        status;                /* 0x00 - success */
1051         u_int16_t       inquiry_scan_interval; /* interval * 0.625 msec */
1052         u_int16_t       inquiry_scan_window;   /* window * 0.625 msec */
1053 } __attribute__ ((packed)) ng_hci_read_inquiry_scan_activity_rp;
1054
1055 #define NG_HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY  0x001e
1056 typedef struct {
1057         u_int16_t       inquiry_scan_interval; /* interval * 0.625 msec */
1058         u_int16_t       inquiry_scan_window;   /* window * 0.625 msec */
1059 } __attribute__ ((packed)) ng_hci_write_inquiry_scan_activity_cp;
1060
1061 typedef ng_hci_status_rp        ng_hci_write_inquiry_scan_activity_rp;
1062
1063 #define NG_HCI_OCF_READ_AUTH_ENABLE             0x001f
1064 /* No command parameter(s) */
1065 typedef struct {
1066         u_int8_t        status;      /* 0x00 - success */
1067         u_int8_t        auth_enable; /* 0x01 - enabled */
1068 } __attribute__ ((packed)) ng_hci_read_auth_enable_rp;
1069
1070 #define NG_HCI_OCF_WRITE_AUTH_ENABLE            0x0020
1071 typedef struct {
1072         u_int8_t        auth_enable; /* 0x01 - enabled */
1073 } __attribute__ ((packed)) ng_hci_write_auth_enable_cp;
1074
1075 typedef ng_hci_status_rp        ng_hci_write_auth_enable_rp;
1076
1077 #define NG_HCI_OCF_READ_ENCRYPTION_MODE         0x0021
1078 /* No command parameter(s) */
1079 typedef struct {
1080         u_int8_t        status;          /* 0x00 - success */
1081         u_int8_t        encryption_mode; /* encryption mode */
1082 } __attribute__ ((packed)) ng_hci_read_encryption_mode_rp;
1083
1084 #define NG_HCI_OCF_WRITE_ENCRYPTION_MODE        0x0022
1085 typedef struct {
1086         u_int8_t        encryption_mode; /* encryption mode */
1087 } __attribute__ ((packed)) ng_hci_write_encryption_mode_cp;
1088
1089 typedef ng_hci_status_rp        ng_hci_write_encryption_mode_rp;
1090
1091 #define NG_HCI_OCF_READ_UNIT_CLASS              0x0023
1092 /* No command parameter(s) */
1093 typedef struct {
1094         u_int8_t        status;                    /* 0x00 - success */
1095         u_int8_t        uclass[NG_HCI_CLASS_SIZE]; /* unit class */
1096 } __attribute__ ((packed)) ng_hci_read_unit_class_rp;
1097
1098 #define NG_HCI_OCF_WRITE_UNIT_CLASS             0x0024
1099 typedef struct {
1100         u_int8_t        uclass[NG_HCI_CLASS_SIZE]; /* unit class */
1101 } __attribute__ ((packed)) ng_hci_write_unit_class_cp;
1102
1103 typedef ng_hci_status_rp        ng_hci_write_unit_class_rp;
1104
1105 #define NG_HCI_OCF_READ_VOICE_SETTINGS          0x0025
1106 /* No command parameter(s) */
1107 typedef struct {
1108         u_int8_t        status;   /* 0x00 - success */
1109         u_int16_t       settings; /* voice settings */
1110 } __attribute__ ((packed)) ng_hci_read_voice_settings_rp;
1111
1112 #define NG_HCI_OCF_WRITE_VOICE_SETTINGS         0x0026
1113 typedef struct {
1114         u_int16_t       settings; /* voice settings */
1115 } __attribute__ ((packed)) ng_hci_write_voice_settings_cp;
1116
1117 typedef ng_hci_status_rp        ng_hci_write_voice_settings_rp;
1118
1119 #define NG_HCI_OCF_READ_AUTO_FLUSH_TIMO         0x0027
1120 typedef struct {
1121         u_int16_t       con_handle; /* connection handle */
1122 } __attribute__ ((packed)) ng_hci_read_auto_flush_timo_cp;
1123
1124 typedef struct {
1125         u_int8_t        status;     /* 0x00 - success */
1126         u_int16_t       con_handle; /* connection handle */
1127         u_int16_t       timeout;    /* 0x00 - no flush, timeout * 0.625 msec */
1128 } __attribute__ ((packed)) ng_hci_read_auto_flush_timo_rp;
1129         
1130 #define NG_HCI_OCF_WRITE_AUTO_FLUSH_TIMO        0x0028
1131 typedef struct {
1132         u_int16_t       con_handle; /* connection handle */
1133         u_int16_t       timeout;    /* 0x00 - no flush, timeout * 0.625 msec */
1134 } __attribute__ ((packed)) ng_hci_write_auto_flush_timo_cp;
1135
1136 typedef struct {
1137         u_int8_t        status;     /* 0x00 - success */
1138         u_int16_t       con_handle; /* connection handle */
1139 } __attribute__ ((packed)) ng_hci_write_auto_flush_timo_rp;
1140
1141 #define NG_HCI_OCF_READ_NUM_BROADCAST_RETRANS   0x0029
1142 /* No command parameter(s) */
1143 typedef struct {
1144         u_int8_t        status;  /* 0x00 - success */
1145         u_int8_t        counter; /* number of broadcast retransmissions */
1146 } __attribute__ ((packed)) ng_hci_read_num_broadcast_retrans_rp;
1147
1148 #define NG_HCI_OCF_WRITE_NUM_BROADCAST_RETRANS  0x002a
1149 typedef struct {
1150         u_int8_t        counter; /* number of broadcast retransmissions */
1151 } __attribute__ ((packed)) ng_hci_write_num_broadcast_retrans_cp;
1152
1153 typedef ng_hci_status_rp        ng_hci_write_num_broadcast_retrans_rp;
1154
1155 #define NG_HCI_OCF_READ_HOLD_MODE_ACTIVITY      0x002b
1156 /* No command parameter(s) */
1157 typedef struct {
1158         u_int8_t        status;             /* 0x00 - success */
1159         u_int8_t        hold_mode_activity; /* Hold mode activities */
1160 } __attribute__ ((packed)) ng_hci_read_hold_mode_activity_rp;
1161
1162 #define NG_HCI_OCF_WRITE_HOLD_MODE_ACTIVITY     0x002c
1163 typedef struct {
1164         u_int8_t        hold_mode_activity; /* Hold mode activities */
1165 } __attribute__ ((packed)) ng_hci_write_hold_mode_activity_cp;
1166
1167 typedef ng_hci_status_rp        ng_hci_write_hold_mode_activity_rp;
1168
1169 #define NG_HCI_OCF_READ_XMIT_LEVEL              0x002d
1170 typedef struct {
1171         u_int16_t       con_handle; /* connection handle */
1172         u_int8_t        type;       /* Xmit level type */
1173 } __attribute__ ((packed)) ng_hci_read_xmit_level_cp;
1174
1175 typedef struct {
1176         u_int8_t        status;     /* 0x00 - success */
1177         u_int16_t       con_handle; /* connection handle */
1178         char            level;      /* -30 <= level <= 30 dBm */
1179 } __attribute__ ((packed)) ng_hci_read_xmit_level_rp;
1180
1181 #define NG_HCI_OCF_READ_SCO_FLOW_CONTROL        0x002e
1182 /* No command parameter(s) */
1183 typedef struct {
1184         u_int8_t        status;       /* 0x00 - success */
1185         u_int8_t        flow_control; /* 0x00 - disabled */
1186 } __attribute__ ((packed)) ng_hci_read_sco_flow_control_rp;
1187
1188 #define NG_HCI_OCF_WRITE_SCO_FLOW_CONTROL       0x002f
1189 typedef struct {
1190         u_int8_t        flow_control; /* 0x00 - disabled */
1191 } __attribute__ ((packed)) ng_hci_write_sco_flow_control_cp;
1192
1193 typedef ng_hci_status_rp        ng_hci_write_sco_flow_control_rp;
1194
1195 #define NG_HCI_OCF_H2HC_FLOW_CONTROL            0x0031
1196 typedef struct {
1197         u_int8_t        h2hc_flow; /* Host to Host controller flow control */
1198 } __attribute__ ((packed)) ng_hci_h2hc_flow_control_cp;
1199
1200 typedef ng_hci_status_rp        ng_hci_h2hc_flow_control_rp;
1201
1202 #define NG_HCI_OCF_HOST_BUFFER_SIZE             0x0033
1203 typedef struct {
1204         u_int16_t       max_acl_size; /* Max. size of ACL packet (bytes) */
1205         u_int8_t        max_sco_size; /* Max. size of SCO packet (bytes) */
1206         u_int16_t       num_acl_pkt;  /* Max. number of ACL packets */
1207         u_int16_t       num_sco_pkt;  /* Max. number of SCO packets */
1208 } __attribute__ ((packed)) ng_hci_host_buffer_size_cp;
1209
1210 typedef ng_hci_status_rp        ng_hci_host_buffer_size_rp;
1211
1212 #define NG_HCI_OCF_HOST_NUM_COMPL_PKTS          0x0035
1213 typedef struct {
1214         u_int8_t        num_con_handles; /* # of connection handles */
1215 /* these are repeated "num_con_handles" times
1216         u_int16_t       con_handle; --- connection handle(s)
1217         u_int16_t       compl_pkt;  --- # of completed packets */
1218 } __attribute__ ((packed)) ng_hci_host_num_compl_pkts_cp;
1219 /* No return parameter(s) */
1220
1221 #define NG_HCI_OCF_READ_LINK_SUPERVISION_TIMO   0x0036
1222 typedef struct {
1223         u_int16_t       con_handle; /* connection handle */
1224 } __attribute__ ((packed)) ng_hci_read_link_supervision_timo_cp;
1225
1226 typedef struct {
1227         u_int8_t        status;     /* 0x00 - success */
1228         u_int16_t       con_handle; /* connection handle */
1229         u_int16_t       timeout;    /* Link supervision timeout * 0.625 msec */
1230 } __attribute__ ((packed)) ng_hci_read_link_supervision_timo_rp;
1231
1232 #define NG_HCI_OCF_WRITE_LINK_SUPERVISION_TIMO  0x0037
1233 typedef struct {
1234         u_int16_t       con_handle; /* connection handle */
1235         u_int16_t       timeout;    /* Link supervision timeout * 0.625 msec */
1236 } __attribute__ ((packed)) ng_hci_write_link_supervision_timo_cp;
1237
1238 typedef struct {
1239         u_int8_t        status;     /* 0x00 - success */
1240         u_int16_t       con_handle; /* connection handle */
1241 } __attribute__ ((packed)) ng_hci_write_link_supervision_timo_rp;
1242
1243 #define NG_HCI_OCF_READ_SUPPORTED_IAC_NUM       0x0038
1244 /* No command parameter(s) */
1245 typedef struct {
1246         u_int8_t        status;  /* 0x00 - success */
1247         u_int8_t        num_iac; /* # of supported IAC during scan */
1248 } __attribute__ ((packed)) ng_hci_read_supported_iac_num_rp;
1249
1250 #define NG_HCI_OCF_READ_IAC_LAP                 0x0039
1251 /* No command parameter(s) */
1252 typedef struct {
1253         u_int8_t        status;  /* 0x00 - success */
1254         u_int8_t        num_iac; /* # of IAC */
1255 /* these are repeated "num_iac" times 
1256         u_int8_t        laps[NG_HCI_LAP_SIZE]; --- LAPs */
1257 } __attribute__ ((packed)) ng_hci_read_iac_lap_rp;
1258
1259 #define NG_HCI_OCF_WRITE_IAC_LAP                0x003a
1260 typedef struct {
1261         u_int8_t        num_iac; /* # of IAC */
1262 /* these are repeated "num_iac" times 
1263         u_int8_t        laps[NG_HCI_LAP_SIZE]; --- LAPs */
1264 } __attribute__ ((packed)) ng_hci_write_iac_lap_cp;
1265
1266 typedef ng_hci_status_rp        ng_hci_write_iac_lap_rp;
1267
1268 #define NG_HCI_OCF_READ_PAGE_SCAN_PERIOD        0x003b
1269 /* No command parameter(s) */
1270 typedef struct {
1271         u_int8_t        status;                /* 0x00 - success */
1272         u_int8_t        page_scan_period_mode; /* Page scan period mode */
1273 } __attribute__ ((packed)) ng_hci_read_page_scan_period_rp;
1274
1275 #define NG_HCI_OCF_WRITE_PAGE_SCAN_PERIOD       0x003c
1276 typedef struct {
1277         u_int8_t        page_scan_period_mode; /* Page scan period mode */
1278 } __attribute__ ((packed)) ng_hci_write_page_scan_period_cp;
1279
1280 typedef ng_hci_status_rp        ng_hci_write_page_scan_period_rp;
1281
1282 #define NG_HCI_OCF_READ_PAGE_SCAN               0x003d
1283 /* No command parameter(s) */
1284 typedef struct {
1285         u_int8_t        status;         /* 0x00 - success */
1286         u_int8_t        page_scan_mode; /* Page scan mode */
1287 } __attribute__ ((packed)) ng_hci_read_page_scan_rp;
1288
1289 #define NG_HCI_OCF_WRITE_PAGE_SCAN              0x003e
1290 typedef struct {
1291         u_int8_t        page_scan_mode; /* Page scan mode */
1292 } __attribute__ ((packed)) ng_hci_write_page_scan_cp;
1293
1294 typedef ng_hci_status_rp        ng_hci_write_page_scan_rp;
1295
1296 /**************************************************************************
1297  **************************************************************************
1298  **           Informational commands and return parameters 
1299  **     All commands in this category do not accept any parameters
1300  **************************************************************************
1301  **************************************************************************/
1302
1303 #define NG_HCI_OGF_INFO                         0x04 /* OpCode Group Field */
1304
1305 #define NG_HCI_OCF_READ_LOCAL_VER               0x0001
1306 typedef struct {
1307         u_int8_t        status;         /* 0x00 - success */
1308         u_int8_t        hci_version;    /* HCI version */
1309         u_int16_t       hci_revision;   /* HCI revision */
1310         u_int8_t        lmp_version;    /* LMP version */
1311         u_int16_t       manufacturer;   /* Hardware manufacturer name */
1312         u_int16_t       lmp_subversion; /* LMP sub-version */
1313 } __attribute__ ((packed)) ng_hci_read_local_ver_rp;
1314
1315 #define NG_HCI_OCF_READ_LOCAL_FEATURES          0x0003
1316 typedef struct {
1317         u_int8_t        status;                         /* 0x00 - success */
1318         u_int8_t        features[NG_HCI_FEATURES_SIZE]; /* LMP features bitmsk*/
1319 } __attribute__ ((packed)) ng_hci_read_local_features_rp;
1320
1321 #define NG_HCI_OCF_READ_BUFFER_SIZE             0x0005
1322 typedef struct {
1323         u_int8_t        status;       /* 0x00 - success */
1324         u_int16_t       max_acl_size; /* Max. size of ACL packet (bytes) */
1325         u_int8_t        max_sco_size; /* Max. size of SCO packet (bytes) */
1326         u_int16_t       num_acl_pkt;  /* Max. number of ACL packets */
1327         u_int16_t       num_sco_pkt;  /* Max. number of SCO packets */
1328 } __attribute__ ((packed)) ng_hci_read_buffer_size_rp;
1329
1330 #define NG_HCI_OCF_READ_COUNTRY_CODE            0x0007
1331 typedef struct {
1332         u_int8_t        status;       /* 0x00 - success */
1333         u_int8_t        country_code; /* 0x00 - NAM, EUR, JP; 0x01 - France */
1334 } __attribute__ ((packed)) ng_hci_read_country_code_rp;
1335
1336 #define NG_HCI_OCF_READ_BDADDR                  0x0009
1337 typedef struct {
1338         u_int8_t        status; /* 0x00 - success */
1339         bdaddr_t        bdaddr; /* unit address */
1340 } __attribute__ ((packed)) ng_hci_read_bdaddr_rp;
1341
1342 /**************************************************************************
1343  **************************************************************************
1344  **            Status commands and return parameters 
1345  **************************************************************************
1346  **************************************************************************/
1347
1348 #define NG_HCI_OGF_STATUS                       0x05 /* OpCode Group Field */
1349
1350 #define NG_HCI_OCF_READ_FAILED_CONTACT_CNTR     0x0001
1351 typedef struct {
1352         u_int16_t       con_handle; /* connection handle */
1353 } __attribute__ ((packed)) ng_hci_read_failed_contact_cntr_cp;
1354
1355 typedef struct {
1356         u_int8_t        status;     /* 0x00 - success */
1357         u_int16_t       con_handle; /* connection handle */
1358         u_int16_t       counter;    /* number of consecutive failed contacts */
1359 } __attribute__ ((packed)) ng_hci_read_failed_contact_cntr_rp;
1360
1361 #define NG_HCI_OCF_RESET_FAILED_CONTACT_CNTR    0x0002
1362 typedef struct {
1363         u_int16_t       con_handle; /* connection handle */
1364 } __attribute__ ((packed)) ng_hci_reset_failed_contact_cntr_cp;
1365
1366 typedef struct {
1367         u_int8_t        status;     /* 0x00 - success */
1368         u_int16_t       con_handle; /* connection handle */
1369 } __attribute__ ((packed)) ng_hci_reset_failed_contact_cntr_rp;
1370
1371 #define NG_HCI_OCF_GET_LINK_QUALITY             0x0003
1372 typedef struct {
1373         u_int16_t       con_handle; /* connection handle */
1374 } __attribute__ ((packed)) ng_hci_get_link_quality_cp;
1375
1376 typedef struct {
1377         u_int8_t        status;     /* 0x00 - success */
1378         u_int16_t       con_handle; /* connection handle */
1379         u_int8_t        quality;    /* higher value means better quality */
1380 } __attribute__ ((packed)) ng_hci_get_link_quality_rp;
1381
1382 #define NG_HCI_OCF_READ_RSSI                    0x0005
1383 typedef struct {
1384         u_int16_t       con_handle; /* connection handle */
1385 } __attribute__ ((packed)) ng_hci_read_rssi_cp;
1386
1387 typedef struct {
1388         u_int8_t        status;     /* 0x00 - success */
1389         u_int16_t       con_handle; /* connection handle */
1390         char            rssi;       /* -127 <= rssi <= 127 dB */
1391 } __attribute__ ((packed)) ng_hci_read_rssi_rp;
1392
1393 /**************************************************************************
1394  **************************************************************************
1395  **             Testing commands and return parameters 
1396  **************************************************************************
1397  **************************************************************************/
1398
1399 #define NG_HCI_OGF_TESTING                      0x06 /* OpCode Group Field */
1400
1401 #define NG_HCI_OCF_READ_LOOPBACK_MODE           0x0001
1402 /* No command parameter(s) */
1403 typedef struct {
1404         u_int8_t        status; /* 0x00 - success */
1405         u_int8_t        lbmode; /* loopback mode */
1406 } __attribute__ ((packed)) ng_hci_read_loopback_mode_rp;
1407
1408 #define NG_HCI_OCF_WRITE_LOOPBACK_MODE          0x0002
1409 typedef struct {
1410         u_int8_t        lbmode; /* loopback mode */
1411 } __attribute__ ((packed)) ng_hci_write_loopback_mode_cp;
1412
1413 typedef ng_hci_status_rp        ng_hci_write_loopback_mode_rp;
1414
1415 #define NG_HCI_OCF_ENABLE_UNIT_UNDER_TEST       0x0003
1416 /* No command parameter(s) */
1417 typedef ng_hci_status_rp        ng_hci_enable_unit_under_test_rp;
1418
1419 /**************************************************************************
1420  **************************************************************************
1421  **                Special HCI OpCode group field values
1422  **************************************************************************
1423  **************************************************************************/
1424
1425 #define NG_HCI_OGF_BT_LOGO                      0x3e    
1426
1427 #define NG_HCI_OGF_VENDOR                       0x3f
1428
1429 /**************************************************************************
1430  **************************************************************************
1431  **                         Events and event parameters
1432  **************************************************************************
1433  **************************************************************************/
1434
1435 #define NG_HCI_EVENT_INQUIRY_COMPL              0x01
1436 typedef struct {
1437         u_int8_t        status; /* 0x00 - success */
1438 } __attribute__ ((packed)) ng_hci_inquiry_compl_ep;
1439
1440 #define NG_HCI_EVENT_INQUIRY_RESULT             0x02
1441 typedef struct {
1442         u_int8_t        num_responses;      /* number of responses */
1443 /*      ng_hci_inquiry_response[num_responses]   -- see below */
1444 } __attribute__ ((packed)) ng_hci_inquiry_result_ep;
1445
1446 typedef struct {
1447         bdaddr_t        bdaddr;                   /* unit address */
1448         u_int8_t        page_scan_rep_mode;       /* page scan rep. mode */
1449         u_int8_t        page_scan_period_mode;    /* page scan period mode */
1450         u_int8_t        page_scan_mode;           /* page scan mode */
1451         u_int8_t        uclass[NG_HCI_CLASS_SIZE];/* unit class */
1452         u_int16_t       clock_offset;             /* clock offset */
1453 } __attribute__ ((packed)) ng_hci_inquiry_response;
1454
1455 #define NG_HCI_EVENT_CON_COMPL                  0x03
1456 typedef struct {
1457         u_int8_t        status;          /* 0x00 - success */
1458         u_int16_t       con_handle;      /* Connection handle */
1459         bdaddr_t        bdaddr;          /* remote unit address */
1460         u_int8_t        link_type;       /* Link type */
1461         u_int8_t        encryption_mode; /* Encryption mode */
1462 } __attribute__ ((packed)) ng_hci_con_compl_ep;
1463
1464 #define NG_HCI_EVENT_CON_REQ                    0x04
1465 typedef struct {
1466         bdaddr_t        bdaddr;                    /* remote unit address */
1467         u_int8_t        uclass[NG_HCI_CLASS_SIZE]; /* remote unit class */
1468         u_int8_t        link_type;                 /* link type */
1469 } __attribute__ ((packed)) ng_hci_con_req_ep;
1470
1471 #define NG_HCI_EVENT_DISCON_COMPL               0x05
1472 typedef struct {
1473         u_int8_t        status;     /* 0x00 - success */
1474         u_int16_t       con_handle; /* connection handle */
1475         u_int8_t        reason;     /* reason to disconnect */
1476 } __attribute__ ((packed)) ng_hci_discon_compl_ep;
1477
1478 #define NG_HCI_EVENT_AUTH_COMPL                 0x06
1479 typedef struct {
1480         u_int8_t        status;     /* 0x00 - success */
1481         u_int16_t       con_handle; /* connection handle */
1482 } __attribute__ ((packed)) ng_hci_auth_compl_ep;
1483
1484 #define NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL      0x7
1485 typedef struct {
1486         u_int8_t        status; /* 0x00 - success */
1487         bdaddr_t        bdaddr; /* remote unit address */
1488         char            name[NG_HCI_UNIT_NAME_SIZE]; /* remote unit name */
1489 } __attribute__ ((packed)) ng_hci_remote_name_req_compl_ep;
1490
1491 #define NG_HCI_EVENT_ENCRYPTION_CHANGE          0x08
1492 typedef struct {
1493         u_int8_t        status;            /* 0x00 - success */
1494         u_int16_t       con_handle;        /* Connection handle */
1495         u_int8_t        encryption_enable; /* 0x00 - disable */
1496 } __attribute__ ((packed)) ng_hci_encryption_change_ep;
1497
1498 #define NG_HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL  0x09
1499 typedef struct {
1500         u_int8_t        status;     /* 0x00 - success */
1501         u_int16_t       con_handle; /* Connection handle */
1502 } __attribute__ ((packed)) ng_hci_change_con_link_key_compl_ep;
1503
1504 #define NG_HCI_EVENT_MASTER_LINK_KEY_COMPL      0x0a
1505 typedef struct {
1506         u_int8_t        status;     /* 0x00 - success */
1507         u_int16_t       con_handle; /* Connection handle */
1508         u_int8_t        key_flag;   /* Key flag */
1509 } __attribute__ ((packed)) ng_hci_master_link_key_compl_ep;
1510
1511 #define NG_HCI_EVENT_READ_REMOTE_FEATURES_COMPL 0x0b
1512 typedef struct {
1513         u_int8_t        status;                         /* 0x00 - success */
1514         u_int16_t       con_handle;                     /* Connection handle */
1515         u_int8_t        features[NG_HCI_FEATURES_SIZE]; /* LMP features bitmsk*/
1516 } __attribute__ ((packed)) ng_hci_read_remote_features_compl_ep;
1517
1518 #define NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL 0x0c
1519 typedef struct {
1520         u_int8_t        status;         /* 0x00 - success */
1521         u_int16_t       con_handle;     /* Connection handle */
1522         u_int8_t        lmp_version;    /* LMP version */
1523         u_int16_t       manufacturer;   /* Hardware manufacturer name */
1524         u_int16_t       lmp_subversion; /* LMP sub-version */
1525 } __attribute__ ((packed)) ng_hci_read_remote_ver_info_compl_ep;
1526
1527 #define NG_HCI_EVENT_QOS_SETUP_COMPL            0x0d
1528 typedef struct {
1529         u_int8_t        status;          /* 0x00 - success */
1530         u_int16_t       con_handle;      /* connection handle */
1531         u_int8_t        flags;           /* reserved for future use */
1532         u_int8_t        service_type;    /* service type */
1533         u_int32_t       token_rate;      /* bytes per second */
1534         u_int32_t       peak_bandwidth;  /* bytes per second */
1535         u_int32_t       latency;         /* microseconds */
1536         u_int32_t       delay_variation; /* microseconds */
1537 } __attribute__ ((packed)) ng_hci_qos_setup_compl_ep;
1538
1539 #define NG_HCI_EVENT_COMMAND_COMPL              0x0e
1540 typedef struct {
1541         u_int8_t        num_cmd_pkts; /* # of HCI command packets */
1542         u_int16_t       opcode;       /* command OpCode */
1543         /* command return parameters (if any) */
1544 } __attribute__ ((packed)) ng_hci_command_compl_ep;
1545
1546 #define NG_HCI_EVENT_COMMAND_STATUS             0x0f
1547 typedef struct {
1548         u_int8_t        status;       /* 0x00 - pending */
1549         u_int8_t        num_cmd_pkts; /* # of HCI command packets */
1550         u_int16_t       opcode;       /* command OpCode */
1551 } __attribute__ ((packed)) ng_hci_command_status_ep;
1552
1553 #define NG_HCI_EVENT_HARDWARE_ERROR             0x10
1554 typedef struct {
1555         u_int8_t        hardware_code; /* hardware error code */
1556 } __attribute__ ((packed)) ng_hci_hardware_error_ep;
1557
1558 #define NG_HCI_EVENT_FLUSH_OCCUR                0x11
1559 typedef struct {
1560         u_int16_t       con_handle; /* connection handle */
1561 } __attribute__ ((packed)) ng_hci_flush_occur_ep;
1562
1563 #define NG_HCI_EVENT_ROLE_CHANGE                0x12
1564 typedef struct {
1565         u_int8_t        status; /* 0x00 - success */
1566         bdaddr_t        bdaddr; /* address of remote unit */
1567         u_int8_t        role;   /* new connection role */
1568 } __attribute__ ((packed)) ng_hci_role_change_ep;
1569
1570 #define NG_HCI_EVENT_NUM_COMPL_PKTS             0x13
1571 typedef struct {
1572         u_int8_t        num_con_handles; /* # of connection handles */
1573 /* these are repeated "num_con_handles" times 
1574         u_int16_t       con_handle; --- connection handle(s)
1575         u_int16_t       compl_pkt;  --- # of completed packets */
1576 } __attribute__ ((packed)) ng_hci_num_compl_pkts_ep;
1577
1578 #define NG_HCI_EVENT_MODE_CHANGE                0x14
1579 typedef struct {
1580         u_int8_t        status;     /* 0x00 - success */
1581         u_int16_t       con_handle; /* connection handle */
1582         u_int8_t        unit_mode;  /* remote unit mode */
1583         u_int16_t       interval;   /* interval * 0.625 msec */
1584 } __attribute__ ((packed)) ng_hci_mode_change_ep;
1585
1586 #define NG_HCI_EVENT_RETURN_LINK_KEYS           0x15
1587 typedef struct {
1588         u_int8_t        num_keys; /* # of keys */
1589 /* these are repeated "num_keys" times 
1590         bdaddr_t        bdaddr;               --- remote address(es)
1591         u_int8_t        key[NG_HCI_KEY_SIZE]; --- key(s) */
1592 } __attribute__ ((packed)) ng_hci_return_link_keys_ep;
1593
1594 #define NG_HCI_EVENT_PIN_CODE_REQ               0x16
1595 typedef struct {
1596         bdaddr_t        bdaddr; /* remote unit address */
1597 } __attribute__ ((packed)) ng_hci_pin_code_req_ep;
1598
1599 #define NG_HCI_EVENT_LINK_KEY_REQ               0x17
1600 typedef struct {
1601         bdaddr_t        bdaddr; /* remote unit address */
1602 } __attribute__ ((packed)) ng_hci_link_key_req_ep;
1603
1604 #define NG_HCI_EVENT_LINK_KEY_NOTIFICATION      0x18
1605 typedef struct {
1606         bdaddr_t        bdaddr;               /* remote unit address */
1607         u_int8_t        key[NG_HCI_KEY_SIZE]; /* link key */
1608         u_int8_t        key_type;             /* type of the key */
1609 } __attribute__ ((packed)) ng_hci_link_key_notification_ep;
1610
1611 #define NG_HCI_EVENT_LOOPBACK_COMMAND           0x19
1612 typedef struct {
1613         u_int8_t        command[0]; /* Command packet */
1614 } __attribute__ ((packed)) ng_hci_loopback_command_ep;
1615
1616 #define NG_HCI_EVENT_DATA_BUFFER_OVERFLOW       0x1a
1617 typedef struct {
1618         u_int8_t        link_type; /* Link type */
1619 } __attribute__ ((packed)) ng_hci_data_buffer_overflow_ep;
1620
1621 #define NG_HCI_EVENT_MAX_SLOT_CHANGE            0x1b
1622 typedef struct {
1623         u_int16_t       con_handle;    /* connection handle */
1624         u_int8_t        lmp_max_slots; /* Max. # of slots allowed */
1625 } __attribute__ ((packed)) ng_hci_max_slot_change_ep;
1626
1627 #define NG_HCI_EVENT_READ_CLOCK_OFFSET_COMPL    0x1c
1628 typedef struct {
1629         u_int8_t        status;       /* 0x00 - success */
1630         u_int16_t       con_handle;   /* Connection handle */
1631         u_int16_t       clock_offset; /* Clock offset */
1632 } __attribute__ ((packed)) ng_hci_read_clock_offset_compl_ep;
1633
1634 #define NG_HCI_EVENT_CON_PKT_TYPE_CHANGED       0x1d
1635 typedef struct {
1636         u_int8_t        status;     /* 0x00 - success */
1637         u_int16_t       con_handle; /* connection handle */
1638         u_int16_t       pkt_type;   /* packet type */
1639 } __attribute__ ((packed)) ng_hci_con_pkt_type_changed_ep;
1640
1641 #define NG_HCI_EVENT_QOS_VIOLATION              0x1e
1642 typedef struct {
1643         u_int16_t       con_handle; /* connection handle */
1644 } __attribute__ ((packed)) ng_hci_qos_violation_ep;
1645
1646 #define NG_HCI_EVENT_PAGE_SCAN_MODE_CHANGE      0x1f
1647 typedef struct {
1648         bdaddr_t        bdaddr;         /* destination address */
1649         u_int8_t        page_scan_mode; /* page scan mode */
1650 } __attribute__ ((packed)) ng_hci_page_scan_mode_change_ep;
1651
1652 #define NG_HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE  0x20
1653 typedef struct {
1654         bdaddr_t        bdaddr;             /* destination address */
1655         u_int8_t        page_scan_rep_mode; /* page scan repetition mode */
1656 } __attribute__ ((packed)) ng_hci_page_scan_rep_mode_change_ep;
1657
1658 #define NG_HCI_EVENT_BT_LOGO                    0xfe
1659
1660 #define NG_HCI_EVENT_VENDOR                     0xff
1661
1662 #endif /* ndef _NETGRAPH_HCI_H_ */