]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netgraph/bluetooth/include/ng_hci.h
MFC r316914: 7801 add more by-dnode routines
[FreeBSD/FreeBSD.git] / sys / netgraph / 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$
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_LE_EVENT_MASK_SIZE               8   /* event mask */
79 #define NG_HCI_CLASS_SIZE                       3   /* unit class */
80 #define NG_HCI_FEATURES_SIZE                    8   /* LMP features */
81 #define NG_HCI_UNIT_NAME_SIZE                   248 /* unit name size */
82 #define NG_HCI_COMMANDS_SIZE                    64  /*Command list BMP size*/
83 #define NG_HCI_EXTINQ_MAX                       240 /**/
84 /* HCI specification */
85 #define NG_HCI_SPEC_V10                         0x00 /* v1.0 */
86 #define NG_HCI_SPEC_V11                         0x01 /* v1.1 */
87 /* 0x02 - 0xFF - reserved for future use */
88
89 /* LMP features */
90 /* ------------------- byte 0 --------------------*/
91 #define NG_HCI_LMP_3SLOT                        0x01
92 #define NG_HCI_LMP_5SLOT                        0x02
93 #define NG_HCI_LMP_ENCRYPTION                   0x04
94 #define NG_HCI_LMP_SLOT_OFFSET                  0x08
95 #define NG_HCI_LMP_TIMING_ACCURACY              0x10
96 #define NG_HCI_LMP_SWITCH                       0x20
97 #define NG_HCI_LMP_HOLD_MODE                    0x40
98 #define NG_HCI_LMP_SNIFF_MODE                   0x80
99 /* ------------------- byte 1 --------------------*/
100 #define NG_HCI_LMP_PARK_MODE                    0x01
101 #define NG_HCI_LMP_RSSI                         0x02
102 #define NG_HCI_LMP_CHANNEL_QUALITY              0x04
103 #define NG_HCI_LMP_SCO_LINK                     0x08
104 #define NG_HCI_LMP_HV2_PKT                      0x10
105 #define NG_HCI_LMP_HV3_PKT                      0x20
106 #define NG_HCI_LMP_ULAW_LOG                     0x40
107 #define NG_HCI_LMP_ALAW_LOG                     0x80
108 /* ------------------- byte 2 --------------------*/
109 #define NG_HCI_LMP_CVSD                         0x01
110 #define NG_HCI_LMP_PAGING_SCHEME                0x02
111 #define NG_HCI_LMP_POWER_CONTROL                0x04
112 #define NG_HCI_LMP_TRANSPARENT_SCO              0x08
113 #define NG_HCI_LMP_FLOW_CONTROL_LAG0            0x10
114 #define NG_HCI_LMP_FLOW_CONTROL_LAG1            0x20
115 #define NG_HCI_LMP_FLOW_CONTROL_LAG2            0x40
116
117 /* Link types */
118 #define NG_HCI_LINK_SCO                         0x00 /* Voice */
119 #define NG_HCI_LINK_ACL                         0x01 /* Data */
120 #define NG_HCI_LINK_LE_PUBLIC                   0x02 /* LE Public*/
121 #define NG_HCI_LINK_LE_RANDOM                   0x03 /* LE Random*/
122 /* 0x02 - 0xFF - reserved for future use */
123
124 /* Packet types */
125                                 /* 0x0001 - 0x0004 - reserved for future use */
126 #define NG_HCI_PKT_DM1                          0x0008 /* ACL link */
127 #define NG_HCI_PKT_DH1                          0x0010 /* ACL link */
128 #define NG_HCI_PKT_HV1                          0x0020 /* SCO link */
129 #define NG_HCI_PKT_HV2                          0x0040 /* SCO link */
130 #define NG_HCI_PKT_HV3                          0x0080 /* SCO link */
131                                 /* 0x0100 - 0x0200 - reserved for future use */
132 #define NG_HCI_PKT_DM3                          0x0400 /* ACL link */
133 #define NG_HCI_PKT_DH3                          0x0800 /* ACL link */
134                                 /* 0x1000 - 0x2000 - reserved for future use */
135 #define NG_HCI_PKT_DM5                          0x4000 /* ACL link */
136 #define NG_HCI_PKT_DH5                          0x8000 /* ACL link */
137
138 /* 
139  * Connection modes/Unit modes
140  *
141  * This is confusing. It means that one of the units change its mode
142  * for the specific connection. For example one connection was put on 
143  * hold (but i could be wrong :) 
144  */
145
146 #define NG_HCI_UNIT_MODE_ACTIVE                 0x00
147 #define NG_HCI_UNIT_MODE_HOLD                   0x01
148 #define NG_HCI_UNIT_MODE_SNIFF                  0x02
149 #define NG_HCI_UNIT_MODE_PARK                   0x03
150 /* 0x04 - 0xFF - reserved for future use */
151
152 /* Page scan modes */
153 #define NG_HCI_MANDATORY_PAGE_SCAN_MODE         0x00
154 #define NG_HCI_OPTIONAL_PAGE_SCAN_MODE1         0x01
155 #define NG_HCI_OPTIONAL_PAGE_SCAN_MODE2         0x02
156 #define NG_HCI_OPTIONAL_PAGE_SCAN_MODE3         0x03
157 /* 0x04 - 0xFF - reserved for future use */
158
159 /* Page scan repetition modes */
160 #define NG_HCI_SCAN_REP_MODE0                   0x00
161 #define NG_HCI_SCAN_REP_MODE1                   0x01
162 #define NG_HCI_SCAN_REP_MODE2                   0x02
163 /* 0x03 - 0xFF - reserved for future use */
164
165 /* Page scan period modes */
166 #define NG_HCI_PAGE_SCAN_PERIOD_MODE0           0x00
167 #define NG_HCI_PAGE_SCAN_PERIOD_MODE1           0x01
168 #define NG_HCI_PAGE_SCAN_PERIOD_MODE2           0x02
169 /* 0x03 - 0xFF - reserved for future use */
170
171 /* Scan enable */
172 #define NG_HCI_NO_SCAN_ENABLE                   0x00
173 #define NG_HCI_INQUIRY_ENABLE_PAGE_DISABLE      0x01
174 #define NG_HCI_INQUIRY_DISABLE_PAGE_ENABLE      0x02
175 #define NG_HCI_INQUIRY_ENABLE_PAGE_ENABLE       0x03
176 /* 0x04 - 0xFF - reserved for future use */
177
178 /* Hold mode activities */
179 #define NG_HCI_HOLD_MODE_NO_CHANGE              0x00
180 #define NG_HCI_HOLD_MODE_SUSPEND_PAGE_SCAN      0x01
181 #define NG_HCI_HOLD_MODE_SUSPEND_INQUIRY_SCAN   0x02
182 #define NG_HCI_HOLD_MODE_SUSPEND_PERIOD_INQUIRY 0x04
183 /* 0x08 - 0x80 - reserved for future use */
184
185 /* Connection roles */
186 #define NG_HCI_ROLE_MASTER                      0x00
187 #define NG_HCI_ROLE_SLAVE                       0x01
188 /* 0x02 - 0xFF - reserved for future use */
189
190 /* Key flags */
191 #define NG_HCI_USE_SEMI_PERMANENT_LINK_KEYS     0x00
192 #define NG_HCI_USE_TEMPORARY_LINK_KEY           0x01
193 /* 0x02 - 0xFF - reserved for future use */
194
195 /* Pin types */
196 #define NG_HCI_PIN_TYPE_VARIABLE                0x00
197 #define NG_HCI_PIN_TYPE_FIXED                   0x01
198
199 /* Link key types */
200 #define NG_HCI_LINK_KEY_TYPE_COMBINATION_KEY    0x00
201 #define NG_HCI_LINK_KEY_TYPE_LOCAL_UNIT_KEY     0x01
202 #define NG_HCI_LINK_KEY_TYPE_REMOTE_UNIT_KEY    0x02
203 /* 0x03 - 0xFF - reserved for future use */
204
205 /* Encryption modes */
206 #define NG_HCI_ENCRYPTION_MODE_NONE             0x00
207 #define NG_HCI_ENCRYPTION_MODE_P2P              0x01
208 #define NG_HCI_ENCRYPTION_MODE_ALL              0x02
209 /* 0x03 - 0xFF - reserved for future use */
210
211 /* Quality of service types */
212 #define NG_HCI_SERVICE_TYPE_NO_TRAFFIC          0x00
213 #define NG_HCI_SERVICE_TYPE_BEST_EFFORT         0x01
214 #define NG_HCI_SERVICE_TYPE_GUARANTEED          0x02
215 /* 0x03 - 0xFF - reserved for future use */
216
217 /* Link policy settings */
218 #define NG_HCI_LINK_POLICY_DISABLE_ALL_LM_MODES 0x0000
219 #define NG_HCI_LINK_POLICY_ENABLE_ROLE_SWITCH   0x0001 /* Master/Slave switch */
220 #define NG_HCI_LINK_POLICY_ENABLE_HOLD_MODE     0x0002
221 #define NG_HCI_LINK_POLICY_ENABLE_SNIFF_MODE    0x0004
222 #define NG_HCI_LINK_POLICY_ENABLE_PARK_MODE     0x0008
223 /* 0x0010 - 0x8000 - reserved for future use */
224
225 /* Event masks */
226 #define NG_HCI_EVMSK_ALL                        0x00000000ffffffff
227 #define NG_HCI_EVMSK_NONE                       0x0000000000000000
228 #define NG_HCI_EVMSK_INQUIRY_COMPL              0x0000000000000001
229 #define NG_HCI_EVMSK_INQUIRY_RESULT             0x0000000000000002
230 #define NG_HCI_EVMSK_CON_COMPL                  0x0000000000000004
231 #define NG_HCI_EVMSK_CON_REQ                    0x0000000000000008
232 #define NG_HCI_EVMSK_DISCON_COMPL               0x0000000000000010
233 #define NG_HCI_EVMSK_AUTH_COMPL                 0x0000000000000020
234 #define NG_HCI_EVMSK_REMOTE_NAME_REQ_COMPL      0x0000000000000040
235 #define NG_HCI_EVMSK_ENCRYPTION_CHANGE          0x0000000000000080
236 #define NG_HCI_EVMSK_CHANGE_CON_LINK_KEY_COMPL  0x0000000000000100
237 #define NG_HCI_EVMSK_MASTER_LINK_KEY_COMPL      0x0000000000000200
238 #define NG_HCI_EVMSK_READ_REMOTE_FEATURES_COMPL 0x0000000000000400
239 #define NG_HCI_EVMSK_READ_REMOTE_VER_INFO_COMPL 0x0000000000000800
240 #define NG_HCI_EVMSK_QOS_SETUP_COMPL            0x0000000000001000
241 #define NG_HCI_EVMSK_COMMAND_COMPL              0x0000000000002000
242 #define NG_HCI_EVMSK_COMMAND_STATUS             0x0000000000004000
243 #define NG_HCI_EVMSK_HARDWARE_ERROR             0x0000000000008000
244 #define NG_HCI_EVMSK_FLUSH_OCCUR                0x0000000000010000
245 #define NG_HCI_EVMSK_ROLE_CHANGE                0x0000000000020000
246 #define NG_HCI_EVMSK_NUM_COMPL_PKTS             0x0000000000040000
247 #define NG_HCI_EVMSK_MODE_CHANGE                0x0000000000080000
248 #define NG_HCI_EVMSK_RETURN_LINK_KEYS           0x0000000000100000
249 #define NG_HCI_EVMSK_PIN_CODE_REQ               0x0000000000200000
250 #define NG_HCI_EVMSK_LINK_KEY_REQ               0x0000000000400000
251 #define NG_HCI_EVMSK_LINK_KEY_NOTIFICATION      0x0000000000800000
252 #define NG_HCI_EVMSK_LOOPBACK_COMMAND           0x0000000001000000
253 #define NG_HCI_EVMSK_DATA_BUFFER_OVERFLOW       0x0000000002000000
254 #define NG_HCI_EVMSK_MAX_SLOT_CHANGE            0x0000000004000000
255 #define NG_HCI_EVMSK_READ_CLOCK_OFFSET_COMLETE  0x0000000008000000
256 #define NG_HCI_EVMSK_CON_PKT_TYPE_CHANGED       0x0000000010000000
257 #define NG_HCI_EVMSK_QOS_VIOLATION              0x0000000020000000
258 #define NG_HCI_EVMSK_PAGE_SCAN_MODE_CHANGE      0x0000000040000000
259 #define NG_HCI_EVMSK_PAGE_SCAN_REP_MODE_CHANGE  0x0000000080000000
260 /* 0x0000000100000000 - 0x8000000000000000 - reserved for future use */
261
262 /* Filter types */
263 #define NG_HCI_FILTER_TYPE_NONE                 0x00
264 #define NG_HCI_FILTER_TYPE_INQUIRY_RESULT       0x01
265 #define NG_HCI_FILTER_TYPE_CON_SETUP            0x02
266 /* 0x03 - 0xFF - reserved for future use */
267
268 /* Filter condition types for NG_HCI_FILTER_TYPE_INQUIRY_RESULT */
269 #define NG_HCI_FILTER_COND_INQUIRY_NEW_UNIT     0x00
270 #define NG_HCI_FILTER_COND_INQUIRY_UNIT_CLASS   0x01
271 #define NG_HCI_FILTER_COND_INQUIRY_BDADDR       0x02
272 /* 0x03 - 0xFF - reserved for future use */
273
274 /* Filter condition types for NG_HCI_FILTER_TYPE_CON_SETUP */
275 #define NG_HCI_FILTER_COND_CON_ANY_UNIT         0x00
276 #define NG_HCI_FILTER_COND_CON_UNIT_CLASS       0x01
277 #define NG_HCI_FILTER_COND_CON_BDADDR           0x02
278 /* 0x03 - 0xFF - reserved for future use */
279
280 /* Xmit level types */
281 #define NG_HCI_XMIT_LEVEL_CURRENT               0x00
282 #define NG_HCI_XMIT_LEVEL_MAXIMUM               0x01
283 /* 0x02 - 0xFF - reserved for future use */
284
285 /* Host to Host Controller flow control */
286 #define NG_HCI_H2HC_FLOW_CONTROL_NONE           0x00
287 #define NG_HCI_H2HC_FLOW_CONTROL_ACL            0x01
288 #define NG_HCI_H2HC_FLOW_CONTROL_SCO            0x02
289 #define NG_HCI_H2HC_FLOW_CONTROL_BOTH           0x03    /* ACL and SCO */
290 /* 0x04 - 0xFF - reserved future use */
291
292 /* Country codes */
293 #define NG_HCI_COUNTRY_CODE_NAM_EUR_JP          0x00
294 #define NG_HCI_COUNTRY_CODE_FRANCE              0x01
295 /* 0x02 - 0xFF - reserved future use */
296
297 /* Loopback modes */
298 #define NG_HCI_LOOPBACK_NONE                    0x00
299 #define NG_HCI_LOOPBACK_LOCAL                   0x01
300 #define NG_HCI_LOOPBACK_REMOTE                  0x02
301 /* 0x03 - 0xFF - reserved future use */
302
303 /**************************************************************************
304  **************************************************************************
305  **                 Link level defines, headers and types
306  **************************************************************************
307  **************************************************************************/
308
309 /* 
310  * Macro(s) to combine OpCode and extract OGF (OpCode Group Field) 
311  * and OCF (OpCode Command Field) from OpCode.
312  */
313
314 #define NG_HCI_OPCODE(gf,cf)            ((((gf) & 0x3f) << 10) | ((cf) & 0x3ff))
315 #define NG_HCI_OCF(op)                  ((op) & 0x3ff)
316 #define NG_HCI_OGF(op)                  (((op) >> 10) & 0x3f)
317
318 /* 
319  * Marco(s) to extract/combine connection handle, BC (Broadcast) and 
320  * PB (Packet boundary) flags.
321  */
322
323 #define NG_HCI_CON_HANDLE(h)            ((h) & 0x0fff)
324 #define NG_HCI_PB_FLAG(h)               (((h) & 0x3000) >> 12)
325 #define NG_HCI_BC_FLAG(h)               (((h) & 0xc000) >> 14)
326 #define NG_HCI_MK_CON_HANDLE(h, pb, bc) \
327         (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14))
328
329 /* PB flag values */
330                                         /* 00 - reserved for future use */
331 #define NG_HCI_PACKET_FRAGMENT          0x1 
332 #define NG_HCI_PACKET_START             0x2
333                                         /* 11 - reserved for future use */
334
335 /* BC flag values */
336 #define NG_HCI_POINT2POINT              0x0 /* only Host controller to Host */
337 #define NG_HCI_BROADCAST_ACTIVE         0x1 /* both directions */
338 #define NG_HCI_BROADCAST_PICONET        0x2 /* both directions */
339                                         /* 11 - reserved for future use */
340
341 /* HCI command packet header */
342 #define NG_HCI_CMD_PKT                  0x01
343 #define NG_HCI_CMD_PKT_SIZE             0xff /* without header */
344 typedef struct {
345         u_int8_t        type;   /* MUST be 0x1 */
346         u_int16_t       opcode; /* OpCode */
347         u_int8_t        length; /* parameter(s) length in bytes */
348 } __attribute__ ((packed)) ng_hci_cmd_pkt_t;
349
350 /* ACL data packet header */
351 #define NG_HCI_ACL_DATA_PKT             0x02
352 #define NG_HCI_ACL_PKT_SIZE             0xffff /* without header */
353 typedef struct {
354         u_int8_t        type;        /* MUST be 0x2 */
355         u_int16_t       con_handle;  /* connection handle + PB + BC flags */
356         u_int16_t       length;      /* payload length in bytes */
357 } __attribute__ ((packed)) ng_hci_acldata_pkt_t;
358
359 /* SCO data packet header */
360 #define NG_HCI_SCO_DATA_PKT             0x03
361 #define NG_HCI_SCO_PKT_SIZE             0xff /* without header */
362 typedef struct {
363         u_int8_t        type;       /* MUST be 0x3 */
364         u_int16_t       con_handle; /* connection handle + reserved bits */
365         u_int8_t        length;     /* payload length in bytes */
366 } __attribute__ ((packed)) ng_hci_scodata_pkt_t;
367
368 /* HCI event packet header */
369 #define NG_HCI_EVENT_PKT                0x04
370 #define NG_HCI_EVENT_PKT_SIZE           0xff /* without header */
371 typedef struct {
372         u_int8_t        type;   /* MUST be 0x4 */
373         u_int8_t        event;  /* event */
374         u_int8_t        length; /* parameter(s) length in bytes */
375 } __attribute__ ((packed)) ng_hci_event_pkt_t;
376
377 /* Bluetooth unit address */
378 typedef struct {
379         u_int8_t        b[NG_HCI_BDADDR_SIZE];
380 } __attribute__ ((packed)) bdaddr_t;
381 typedef bdaddr_t *      bdaddr_p;
382
383 /* Any BD_ADDR. Note: This is actually 7 bytes (count '\0' terminator) */
384 #define NG_HCI_BDADDR_ANY       ((bdaddr_p) "\000\000\000\000\000\000")
385
386 /* HCI status return parameter */
387 typedef struct {
388         u_int8_t        status; /* 0x00 - success */
389 } __attribute__ ((packed)) ng_hci_status_rp;
390
391 /**************************************************************************
392  **************************************************************************
393  **        Upper layer protocol interface. LP_xxx event parameters
394  **************************************************************************
395  **************************************************************************/
396
397 /* Connection Request Event */
398 #define NGM_HCI_LP_CON_REQ                      1  /* Upper -> HCI */
399 typedef struct {
400         u_int16_t       link_type; /* type of connection */
401         bdaddr_t        bdaddr;    /* remote unit address */
402 } ng_hci_lp_con_req_ep;
403
404 /*
405  * XXX XXX XXX
406  *
407  * NOTE: This request is not defined by Bluetooth specification, 
408  * but i find it useful :)
409  */
410 #define NGM_HCI_LP_DISCON_REQ                   2 /* Upper -> HCI */
411 typedef struct {
412         u_int16_t       con_handle; /* connection handle */
413         u_int16_t       reason;     /* reason to disconnect (only low byte) */
414 } ng_hci_lp_discon_req_ep;
415
416 /* Connection Confirmation Event */
417 #define NGM_HCI_LP_CON_CFM                      3  /* HCI -> Upper */
418 typedef struct {
419         u_int8_t        status;     /* 0x00 - success */
420         u_int8_t        link_type;  /* link type */
421         u_int16_t       con_handle; /* con_handle */
422         bdaddr_t        bdaddr;     /* remote unit address */
423 } ng_hci_lp_con_cfm_ep;
424
425 /* Connection Indication Event */
426 #define NGM_HCI_LP_CON_IND                      4  /* HCI -> Upper */
427 typedef struct {
428         u_int8_t        link_type;                 /* link type */
429         u_int8_t        uclass[NG_HCI_CLASS_SIZE]; /* unit class */
430         bdaddr_t        bdaddr;                    /* remote unit address */
431 } ng_hci_lp_con_ind_ep;
432
433 /* Connection Response Event */
434 #define NGM_HCI_LP_CON_RSP                      5  /* Upper -> HCI */
435 typedef struct {
436         u_int8_t        status;    /* 0x00 - accept connection */
437         u_int8_t        link_type; /* link type */
438         bdaddr_t        bdaddr;    /* remote unit address */
439 } ng_hci_lp_con_rsp_ep;
440
441 /* Disconnection Indication Event */
442 #define NGM_HCI_LP_DISCON_IND                   6  /* HCI -> Upper */
443 typedef struct {
444         u_int8_t        reason;     /* reason to disconnect (only low byte) */
445         u_int8_t        link_type;  /* link type */
446         u_int16_t       con_handle; /* connection handle */
447 } ng_hci_lp_discon_ind_ep;
448
449 /* QoS Setup Request Event */
450 #define NGM_HCI_LP_QOS_REQ                      7  /* Upper -> HCI */
451 typedef struct {
452         u_int16_t       con_handle;      /* connection handle */
453         u_int8_t        flags;           /* reserved */
454         u_int8_t        service_type;    /* service type */
455         u_int32_t       token_rate;      /* bytes/sec */
456         u_int32_t       peak_bandwidth;  /* bytes/sec */
457         u_int32_t       latency;         /* msec */
458         u_int32_t       delay_variation; /* msec */
459 } ng_hci_lp_qos_req_ep;
460
461 /* QoS Conformition Event */
462 #define NGM_HCI_LP_QOS_CFM                      8  /* HCI -> Upper */
463 typedef struct {
464         u_int16_t       status;          /* 0x00 - success  (only low byte) */
465         u_int16_t       con_handle;      /* connection handle */
466 } ng_hci_lp_qos_cfm_ep;
467
468 /* QoS Violation Indication Event */
469 #define NGM_HCI_LP_QOS_IND                      9  /* HCI -> Upper */
470 typedef struct {
471         u_int16_t       con_handle; /* connection handle */
472 } ng_hci_lp_qos_ind_ep;
473 /*Encryption Change event*/
474 #define NGM_HCI_LP_ENC_CHG                      10 /* HCI->Upper*/
475 typedef struct {
476         uint16_t con_handle;
477         uint8_t status;
478         uint8_t link_type; 
479 }ng_hci_lp_enc_change_ep;
480 /**************************************************************************
481  **************************************************************************
482  **                    HCI node command/event parameters
483  **************************************************************************
484  **************************************************************************/
485
486 /* Debug levels */
487 #define NG_HCI_ALERT_LEVEL              1
488 #define NG_HCI_ERR_LEVEL                2
489 #define NG_HCI_WARN_LEVEL               3
490 #define NG_HCI_INFO_LEVEL               4
491
492 /* Unit states */
493 #define NG_HCI_UNIT_CONNECTED           (1 << 0)
494 #define NG_HCI_UNIT_INITED              (1 << 1)
495 #define NG_HCI_UNIT_READY       (NG_HCI_UNIT_CONNECTED|NG_HCI_UNIT_INITED)
496 #define NG_HCI_UNIT_COMMAND_PENDING     (1 << 2)
497
498 /* Connection state */
499 #define NG_HCI_CON_CLOSED               0 /* connection closed */
500 #define NG_HCI_CON_W4_LP_CON_RSP        1 /* wait for LP_ConnectRsp */
501 #define NG_HCI_CON_W4_CONN_COMPLETE     2 /* wait for Connection_Complete evt */
502 #define NG_HCI_CON_OPEN                 3 /* connection open */
503
504 /* Get HCI node (unit) state (see states above) */
505 #define NGM_HCI_NODE_GET_STATE                  100  /* HCI -> User */
506 typedef u_int16_t       ng_hci_node_state_ep;
507
508 /* Turn on "inited" bit */
509 #define NGM_HCI_NODE_INIT                       101 /* User -> HCI */
510 /* No parameters */
511
512 /* Get/Set node debug level (see debug levels above) */
513 #define NGM_HCI_NODE_GET_DEBUG                  102 /* HCI -> User */
514 #define NGM_HCI_NODE_SET_DEBUG                  103 /* User -> HCI */
515 typedef u_int16_t       ng_hci_node_debug_ep;
516
517 /* Get node buffer info */
518 #define NGM_HCI_NODE_GET_BUFFER                 104 /* HCI -> User */
519 typedef struct {
520         u_int8_t        cmd_free; /* number of free command packets */
521         u_int8_t        sco_size; /* max. size of SCO packet */
522         u_int16_t       sco_pkts; /* number of SCO packets */
523         u_int16_t       sco_free; /* number of free SCO packets */
524         u_int16_t       acl_size; /* max. size of ACL packet */
525         u_int16_t       acl_pkts; /* number of ACL packets */
526         u_int16_t       acl_free; /* number of free ACL packets */
527 } ng_hci_node_buffer_ep;
528
529 /* Get BDADDR */
530 #define NGM_HCI_NODE_GET_BDADDR                 105 /* HCI -> User */
531 /* bdaddr_t -- BDADDR */
532
533 /* Get features */
534 #define NGM_HCI_NODE_GET_FEATURES               106 /* HCI -> User */
535 /* features[NG_HCI_FEATURES_SIZE] -- features */
536
537 #define NGM_HCI_NODE_GET_STAT                   107 /* HCI -> User */
538 typedef struct {
539         u_int32_t       cmd_sent;   /* number of HCI commands sent */
540         u_int32_t       evnt_recv;  /* number of HCI events received */
541         u_int32_t       acl_recv;   /* number of ACL packets received */
542         u_int32_t       acl_sent;   /* number of ACL packets sent */
543         u_int32_t       sco_recv;   /* number of SCO packets received */
544         u_int32_t       sco_sent;   /* number of SCO packets sent */
545         u_int32_t       bytes_recv; /* total number of bytes received */
546         u_int32_t       bytes_sent; /* total number of bytes sent */
547 } ng_hci_node_stat_ep;
548
549 #define NGM_HCI_NODE_RESET_STAT                 108 /* User -> HCI */
550 /* No parameters */
551
552 #define NGM_HCI_NODE_FLUSH_NEIGHBOR_CACHE       109 /* User -> HCI */
553
554 #define NGM_HCI_NODE_GET_NEIGHBOR_CACHE         110 /* HCI -> User */
555 typedef struct {
556         u_int32_t       num_entries;    /* number of entries */
557 } ng_hci_node_get_neighbor_cache_ep;
558
559 typedef struct {
560         u_int16_t       page_scan_rep_mode;             /* page rep scan mode */
561         u_int16_t       page_scan_mode;                 /* page scan mode */
562         u_int16_t       clock_offset;                   /* clock offset */
563         bdaddr_t        bdaddr;                         /* bdaddr */
564         u_int8_t        features[NG_HCI_FEATURES_SIZE]; /* features */
565         uint8_t         addrtype;
566         uint8_t         extinq_size; /* MAX 240*/
567         uint8_t         extinq_data[NG_HCI_EXTINQ_MAX];
568 } ng_hci_node_neighbor_cache_entry_ep;
569
570 #define NG_HCI_MAX_NEIGHBOR_NUM \
571         ((0xffff - sizeof(ng_hci_node_get_neighbor_cache_ep))/sizeof(ng_hci_node_neighbor_cache_entry_ep))
572
573 #define NGM_HCI_NODE_GET_CON_LIST               111 /* HCI -> User */
574 typedef struct {
575         u_int32_t       num_connections; /* number of connections */
576 } ng_hci_node_con_list_ep;
577
578 typedef struct {
579         u_int8_t        link_type;       /* ACL or SCO */
580         u_int8_t        encryption_mode; /* none, p2p, ... */
581         u_int8_t        mode;            /* ACTIVE, HOLD ... */
582         u_int8_t        role;            /* MASTER/SLAVE */
583         u_int16_t       state;           /* connection state */
584         u_int16_t       reserved;        /* place holder */
585         u_int16_t       pending;         /* number of pending packets */
586         u_int16_t       queue_len;       /* number of packets in queue */
587         u_int16_t       con_handle;      /* connection handle */
588         bdaddr_t        bdaddr;          /* remote bdaddr */
589 } ng_hci_node_con_ep;
590
591 #define NG_HCI_MAX_CON_NUM \
592         ((0xffff - sizeof(ng_hci_node_con_list_ep))/sizeof(ng_hci_node_con_ep))
593
594 #define NGM_HCI_NODE_UP                         112 /* HCI -> Upper */
595 typedef struct {
596         u_int16_t       pkt_size; /* max. ACL/SCO packet size (w/out header) */
597         u_int16_t       num_pkts; /* ACL/SCO packet queue size */
598         u_int16_t       reserved; /* place holder */
599         bdaddr_t        bdaddr;   /* bdaddr */
600 } ng_hci_node_up_ep;
601
602 #define NGM_HCI_SYNC_CON_QUEUE                  113 /* HCI -> Upper */
603 typedef struct {
604         u_int16_t       con_handle; /* connection handle */
605         u_int16_t       completed;  /* number of completed packets */
606 } ng_hci_sync_con_queue_ep;
607
608 #define NGM_HCI_NODE_GET_LINK_POLICY_SETTINGS_MASK      114 /* HCI -> User */
609 #define NGM_HCI_NODE_SET_LINK_POLICY_SETTINGS_MASK      115 /* User -> HCI */
610 typedef u_int16_t       ng_hci_node_link_policy_mask_ep;
611
612 #define NGM_HCI_NODE_GET_PACKET_MASK            116 /* HCI -> User */
613 #define NGM_HCI_NODE_SET_PACKET_MASK            117 /* User -> HCI */
614 typedef u_int16_t       ng_hci_node_packet_mask_ep;
615
616 #define NGM_HCI_NODE_GET_ROLE_SWITCH            118 /* HCI -> User */
617 #define NGM_HCI_NODE_SET_ROLE_SWITCH            119 /* User -> HCI */
618 typedef u_int16_t       ng_hci_node_role_switch_ep;
619
620 #define NGM_HCI_NODE_LIST_NAMES                 200 /* HCI -> User */
621
622 /**************************************************************************
623  **************************************************************************
624  **             Link control commands and return parameters
625  **************************************************************************
626  **************************************************************************/
627
628 #define NG_HCI_OGF_LINK_CONTROL                 0x01 /* OpCode Group Field */
629
630 #define NG_HCI_OCF_INQUIRY                      0x0001
631 typedef struct {
632         u_int8_t        lap[NG_HCI_LAP_SIZE]; /* LAP */
633         u_int8_t        inquiry_length; /* (N x 1.28) sec */
634         u_int8_t        num_responses;  /* Max. # of responses before halted */
635 } __attribute__ ((packed)) ng_hci_inquiry_cp;
636 /* No return parameter(s) */
637
638 #define NG_HCI_OCF_INQUIRY_CANCEL               0x0002
639 /* No command parameter(s) */
640 typedef ng_hci_status_rp        ng_hci_inquiry_cancel_rp;
641
642 #define NG_HCI_OCF_PERIODIC_INQUIRY             0x0003
643 typedef struct {
644         u_int16_t       max_period_length; /* Max. and min. amount of time */
645         u_int16_t       min_period_length; /* between consecutive inquiries */
646         u_int8_t        lap[NG_HCI_LAP_SIZE]; /* LAP */
647         u_int8_t        inquiry_length;    /* (inquiry_length * 1.28) sec */
648         u_int8_t        num_responses;     /* Max. # of responses */
649 } __attribute__ ((packed)) ng_hci_periodic_inquiry_cp;
650
651 typedef ng_hci_status_rp        ng_hci_periodic_inquiry_rp;
652         
653 #define NG_HCI_OCF_EXIT_PERIODIC_INQUIRY        0x0004
654 /* No command parameter(s) */
655 typedef ng_hci_status_rp        ng_hci_exit_periodic_inquiry_rp;
656
657 #define NG_HCI_OCF_CREATE_CON                   0x0005
658 typedef struct {
659         bdaddr_t        bdaddr;             /* destination address */
660         u_int16_t       pkt_type;           /* packet type */
661         u_int8_t        page_scan_rep_mode; /* page scan repetition mode */
662         u_int8_t        page_scan_mode;     /* page scan mode */
663         u_int16_t       clock_offset;       /* clock offset */
664         u_int8_t        accept_role_switch; /* accept role switch? 0x00 - no */
665 } __attribute__ ((packed)) ng_hci_create_con_cp;
666 /* No return parameter(s) */
667
668 #define NG_HCI_OCF_DISCON                       0x0006
669 typedef struct {
670         u_int16_t       con_handle; /* connection handle */
671         u_int8_t        reason;     /* reason to disconnect */
672 } __attribute__ ((packed)) ng_hci_discon_cp;
673 /* No return parameter(s) */
674
675 #define NG_HCI_OCF_ADD_SCO_CON                  0x0007
676 typedef struct {
677         u_int16_t       con_handle; /* connection handle */
678         u_int16_t       pkt_type;   /* packet type */
679 } __attribute__ ((packed)) ng_hci_add_sco_con_cp;
680 /* No return parameter(s) */
681
682 #define NG_HCI_OCF_ACCEPT_CON                   0x0009
683 typedef struct {
684         bdaddr_t        bdaddr; /* address of unit to be connected */
685         u_int8_t        role;   /* connection role */
686 } __attribute__ ((packed)) ng_hci_accept_con_cp;
687 /* No return parameter(s) */
688
689 #define NG_HCI_OCF_REJECT_CON                   0x000a
690 typedef struct {
691         bdaddr_t        bdaddr; /* remote address */
692         u_int8_t        reason; /* reason to reject */
693 } __attribute__ ((packed)) ng_hci_reject_con_cp;
694 /* No return parameter(s) */
695
696 #define NG_HCI_OCF_LINK_KEY_REP                 0x000b
697 typedef struct {
698         bdaddr_t        bdaddr;               /* remote address */
699         u_int8_t        key[NG_HCI_KEY_SIZE]; /* key */
700 } __attribute__ ((packed)) ng_hci_link_key_rep_cp;
701
702 typedef struct {
703         u_int8_t        status; /* 0x00 - success */
704         bdaddr_t        bdaddr; /* unit address */
705 } __attribute__ ((packed)) ng_hci_link_key_rep_rp;
706
707 #define NG_HCI_OCF_LINK_KEY_NEG_REP             0x000c
708 typedef struct {
709         bdaddr_t        bdaddr; /* remote address */
710 } __attribute__ ((packed)) ng_hci_link_key_neg_rep_cp;
711
712 typedef struct {
713         u_int8_t        status; /* 0x00 - success */
714         bdaddr_t        bdaddr; /* unit address */
715 } __attribute__ ((packed)) ng_hci_link_key_neg_rep_rp;
716
717 #define NG_HCI_OCF_PIN_CODE_REP                 0x000d
718 typedef struct {
719         bdaddr_t        bdaddr;               /* remote address */
720         u_int8_t        pin_size;             /* pin code length (in bytes) */
721         u_int8_t        pin[NG_HCI_PIN_SIZE]; /* pin code */
722 } __attribute__ ((packed)) ng_hci_pin_code_rep_cp;
723
724 typedef struct {
725         u_int8_t        status; /* 0x00 - success */
726         bdaddr_t        bdaddr; /* unit address */
727 } __attribute__ ((packed)) ng_hci_pin_code_rep_rp;
728
729 #define NG_HCI_OCF_PIN_CODE_NEG_REP             0x000e
730 typedef struct {
731         bdaddr_t        bdaddr;  /* remote address */
732 } __attribute__ ((packed)) ng_hci_pin_code_neg_rep_cp;
733
734 typedef struct {
735         u_int8_t        status; /* 0x00 - success */
736         bdaddr_t        bdaddr; /* unit address */
737 } __attribute__ ((packed)) ng_hci_pin_code_neg_rep_rp;
738
739 #define NG_HCI_OCF_CHANGE_CON_PKT_TYPE          0x000f
740 typedef struct {
741         u_int16_t       con_handle; /* connection handle */
742         u_int16_t       pkt_type;   /* packet type */
743 } __attribute__ ((packed)) ng_hci_change_con_pkt_type_cp;
744 /* No return parameter(s) */
745
746 #define NG_HCI_OCF_AUTH_REQ                     0x0011
747 typedef struct {
748         u_int16_t       con_handle; /* connection handle */
749 } __attribute__ ((packed)) ng_hci_auth_req_cp;
750 /* No return parameter(s) */
751
752 #define NG_HCI_OCF_SET_CON_ENCRYPTION           0x0013
753 typedef struct {
754         u_int16_t       con_handle;        /* connection handle */
755         u_int8_t        encryption_enable; /* 0x00 - disable, 0x01 - enable */
756 } __attribute__ ((packed)) ng_hci_set_con_encryption_cp;
757 /* No return parameter(s) */
758
759 #define NG_HCI_OCF_CHANGE_CON_LINK_KEY          0x0015
760 typedef struct {
761         u_int16_t       con_handle; /* connection handle */
762 } __attribute__ ((packed)) ng_hci_change_con_link_key_cp;
763 /* No return parameter(s) */
764
765 #define NG_HCI_OCF_MASTER_LINK_KEY              0x0017
766 typedef struct {
767         u_int8_t        key_flag; /* key flag */
768 } __attribute__ ((packed)) ng_hci_master_link_key_cp;
769 /* No return parameter(s) */
770
771 #define NG_HCI_OCF_REMOTE_NAME_REQ              0x0019
772 typedef struct {
773         bdaddr_t        bdaddr;             /* remote address */
774         u_int8_t        page_scan_rep_mode; /* page scan repetition mode */
775         u_int8_t        page_scan_mode;     /* page scan mode */
776         u_int16_t       clock_offset;       /* clock offset */
777 } __attribute__ ((packed)) ng_hci_remote_name_req_cp;
778 /* No return parameter(s) */
779
780 #define NG_HCI_OCF_READ_REMOTE_FEATURES         0x001b
781 typedef struct {
782         u_int16_t       con_handle; /* connection handle */
783 } __attribute__ ((packed)) ng_hci_read_remote_features_cp;
784 /* No return parameter(s) */
785
786 #define NG_HCI_OCF_READ_REMOTE_VER_INFO         0x001d
787 typedef struct {
788         u_int16_t       con_handle; /* connection handle */
789 } __attribute__ ((packed)) ng_hci_read_remote_ver_info_cp;
790 /* No return parameter(s) */
791
792 #define NG_HCI_OCF_READ_CLOCK_OFFSET             0x001f
793 typedef struct {
794         u_int16_t       con_handle; /* connection handle */
795 } __attribute__ ((packed)) ng_hci_read_clock_offset_cp;
796 /* No return parameter(s) */
797
798 /**************************************************************************
799  **************************************************************************
800  **        Link policy commands and return parameters
801  **************************************************************************
802  **************************************************************************/
803
804 #define NG_HCI_OGF_LINK_POLICY                  0x02 /* OpCode Group Field */
805
806 #define NG_HCI_OCF_HOLD_MODE                    0x0001
807 typedef struct {
808         u_int16_t       con_handle;   /* connection handle */
809         u_int16_t       max_interval; /* (max_interval * 0.625) msec */
810         u_int16_t       min_interval; /* (max_interval * 0.625) msec */
811 } __attribute__ ((packed)) ng_hci_hold_mode_cp;
812 /* No return parameter(s) */
813
814 #define NG_HCI_OCF_SNIFF_MODE                   0x0003
815 typedef struct {
816         u_int16_t       con_handle;   /* connection handle */
817         u_int16_t       max_interval; /* (max_interval * 0.625) msec */
818         u_int16_t       min_interval; /* (max_interval * 0.625) msec */
819         u_int16_t       attempt;      /* (2 * attempt - 1) * 0.625 msec */
820         u_int16_t       timeout;      /* (2 * attempt - 1) * 0.625 msec */
821 } __attribute__ ((packed)) ng_hci_sniff_mode_cp;
822 /* No return parameter(s) */
823
824 #define NG_HCI_OCF_EXIT_SNIFF_MODE              0x0004
825 typedef struct {
826         u_int16_t       con_handle; /* connection handle */
827 } __attribute__ ((packed)) ng_hci_exit_sniff_mode_cp;
828 /* No return parameter(s) */
829
830 #define NG_HCI_OCF_PARK_MODE                    0x0005
831 typedef struct {
832         u_int16_t       con_handle;   /* connection handle */
833         u_int16_t       max_interval; /* (max_interval * 0.625) msec */
834         u_int16_t       min_interval; /* (max_interval * 0.625) msec */
835 } __attribute__ ((packed)) ng_hci_park_mode_cp;
836 /* No return parameter(s) */
837
838 #define NG_HCI_OCF_EXIT_PARK_MODE               0x0006
839 typedef struct {
840         u_int16_t       con_handle; /* connection handle */
841 } __attribute__ ((packed)) ng_hci_exit_park_mode_cp;
842 /* No return parameter(s) */
843
844 #define NG_HCI_OCF_QOS_SETUP                    0x0007
845 typedef struct {
846         u_int16_t       con_handle;      /* connection handle */
847         u_int8_t        flags;           /* reserved for future use */
848         u_int8_t        service_type;    /* service type */
849         u_int32_t       token_rate;      /* bytes per second */
850         u_int32_t       peak_bandwidth;  /* bytes per second */
851         u_int32_t       latency;         /* microseconds */
852         u_int32_t       delay_variation; /* microseconds */
853 } __attribute__ ((packed)) ng_hci_qos_setup_cp;
854 /* No return parameter(s) */
855
856 #define NG_HCI_OCF_ROLE_DISCOVERY               0x0009
857 typedef struct {
858         u_int16_t       con_handle; /* connection handle */
859 } __attribute__ ((packed)) ng_hci_role_discovery_cp;
860
861 typedef struct {
862         u_int8_t        status;     /* 0x00 - success */
863         u_int16_t       con_handle; /* connection handle */
864         u_int8_t        role;       /* role for the connection handle */
865 } __attribute__ ((packed)) ng_hci_role_discovery_rp;
866
867 #define NG_HCI_OCF_SWITCH_ROLE                  0x000b
868 typedef struct {
869         bdaddr_t        bdaddr; /* remote address */
870         u_int8_t        role;   /* new local role */
871 } __attribute__ ((packed)) ng_hci_switch_role_cp;
872 /* No return parameter(s) */
873
874 #define NG_HCI_OCF_READ_LINK_POLICY_SETTINGS    0x000c
875 typedef struct {
876         u_int16_t       con_handle; /* connection handle */
877 } __attribute__ ((packed)) ng_hci_read_link_policy_settings_cp;
878         
879 typedef struct {
880         u_int8_t        status;     /* 0x00 - success */
881         u_int16_t       con_handle; /* connection handle */
882         u_int16_t       settings;   /* link policy settings */
883 } __attribute__ ((packed)) ng_hci_read_link_policy_settings_rp;
884
885 #define NG_HCI_OCF_WRITE_LINK_POLICY_SETTINGS   0x000d
886 typedef struct {
887         u_int16_t       con_handle; /* connection handle */
888         u_int16_t       settings;   /* link policy settings */
889 } __attribute__ ((packed)) ng_hci_write_link_policy_settings_cp;
890
891 typedef struct {
892         u_int8_t        status;     /* 0x00 - success */
893         u_int16_t       con_handle; /* connection handle */
894 } __attribute__ ((packed)) ng_hci_write_link_policy_settings_rp;
895
896 /**************************************************************************
897  **************************************************************************
898  **   Host controller and baseband commands and return parameters 
899  **************************************************************************
900  **************************************************************************/
901
902 #define NG_HCI_OGF_HC_BASEBAND                  0x03 /* OpCode Group Field */
903
904 #define NG_HCI_OCF_SET_EVENT_MASK               0x0001
905 typedef struct {
906         u_int8_t        event_mask[NG_HCI_EVENT_MASK_SIZE]; /* event_mask */
907 } __attribute__ ((packed)) ng_hci_set_event_mask_cp;
908
909 typedef ng_hci_status_rp        ng_hci_set_event_mask_rp;
910 #define NG_HCI_EVENT_MASK_DEFAULT 0x1fffffffffff
911 #define NG_HCI_EVENT_MASK_LE  0x2000000000000000
912
913 #define NG_HCI_OCF_RESET                        0x0003
914 /* No command parameter(s) */
915 typedef ng_hci_status_rp        ng_hci_reset_rp;
916
917 #define NG_HCI_OCF_SET_EVENT_FILTER             0x0005
918 typedef struct {
919         u_int8_t        filter_type;           /* filter type */
920         u_int8_t        filter_condition_type; /* filter condition type */
921         u_int8_t        condition[0];          /* conditions - variable size */
922 } __attribute__ ((packed)) ng_hci_set_event_filter_cp;
923
924 typedef ng_hci_status_rp        ng_hci_set_event_filter_rp;
925
926 #define NG_HCI_OCF_FLUSH                        0x0008
927 typedef struct {
928         u_int16_t       con_handle; /* connection handle */
929 } __attribute__ ((packed)) ng_hci_flush_cp;
930
931 typedef struct {
932         u_int8_t        status;     /* 0x00 - success */
933         u_int16_t       con_handle; /* connection handle */
934 } __attribute__ ((packed)) ng_hci_flush_rp;
935
936 #define NG_HCI_OCF_READ_PIN_TYPE                0x0009
937 /* No command parameter(s) */
938 typedef struct {
939         u_int8_t        status;   /* 0x00 - success */
940         u_int8_t        pin_type; /* PIN type */
941 } __attribute__ ((packed)) ng_hci_read_pin_type_rp;
942
943 #define NG_HCI_OCF_WRITE_PIN_TYPE               0x000a
944 typedef struct {
945         u_int8_t        pin_type; /* PIN type */
946 } __attribute__ ((packed)) ng_hci_write_pin_type_cp;
947
948 typedef ng_hci_status_rp        ng_hci_write_pin_type_rp;
949
950 #define NG_HCI_OCF_CREATE_NEW_UNIT_KEY          0x000b
951 /* No command parameter(s) */
952 typedef ng_hci_status_rp        ng_hci_create_new_unit_key_rp;
953
954 #define NG_HCI_OCF_READ_STORED_LINK_KEY         0x000d
955 typedef struct {
956         bdaddr_t        bdaddr;   /* address */
957         u_int8_t        read_all; /* read all keys? 0x01 - yes */
958 } __attribute__ ((packed)) ng_hci_read_stored_link_key_cp;
959
960 typedef struct {
961         u_int8_t        status;        /* 0x00 - success */
962         u_int16_t       max_num_keys;  /* Max. number of keys */
963         u_int16_t       num_keys_read; /* Number of stored keys */
964 } __attribute__ ((packed)) ng_hci_read_stored_link_key_rp;
965
966 #define NG_HCI_OCF_WRITE_STORED_LINK_KEY        0x0011
967 typedef struct {
968         u_int8_t        num_keys_write; /* # of keys to write */
969 /* these are repeated "num_keys_write" times 
970         bdaddr_t        bdaddr;                --- remote address(es)
971         u_int8_t        key[NG_HCI_KEY_SIZE];  --- key(s) */
972 } __attribute__ ((packed)) ng_hci_write_stored_link_key_cp;
973
974 typedef struct {
975         u_int8_t        status;           /* 0x00 - success */
976         u_int8_t        num_keys_written; /* # of keys successfully written */
977 } __attribute__ ((packed)) ng_hci_write_stored_link_key_rp;
978
979 #define NG_HCI_OCF_DELETE_STORED_LINK_KEY       0x0012
980 typedef struct {
981         bdaddr_t        bdaddr;     /* address */
982         u_int8_t        delete_all; /* delete all keys? 0x01 - yes */
983 } __attribute__ ((packed)) ng_hci_delete_stored_link_key_cp;
984
985 typedef struct {
986         u_int8_t        status;           /* 0x00 - success */
987         u_int16_t       num_keys_deleted; /* Number of keys deleted */
988 } __attribute__ ((packed)) ng_hci_delete_stored_link_key_rp;
989
990 #define NG_HCI_OCF_CHANGE_LOCAL_NAME            0x0013
991 typedef struct {
992         char            name[NG_HCI_UNIT_NAME_SIZE]; /* new unit name */
993 } __attribute__ ((packed)) ng_hci_change_local_name_cp;
994
995 typedef ng_hci_status_rp        ng_hci_change_local_name_rp;
996
997 #define NG_HCI_OCF_READ_LOCAL_NAME              0x0014
998 /* No command parameter(s) */
999 typedef struct {
1000         u_int8_t        status;  /* 0x00 - success */
1001         char            name[NG_HCI_UNIT_NAME_SIZE]; /* unit name */
1002 } __attribute__ ((packed)) ng_hci_read_local_name_rp;
1003
1004 #define NG_HCI_OCF_READ_CON_ACCEPT_TIMO         0x0015
1005 /* No command parameter(s) */
1006 typedef struct {
1007         u_int8_t        status;  /* 0x00 - success */
1008         u_int16_t       timeout; /* (timeout * 0.625) msec */
1009 } __attribute__ ((packed)) ng_hci_read_con_accept_timo_rp;
1010
1011 #define NG_HCI_OCF_WRITE_CON_ACCEPT_TIMO        0x0016
1012 typedef struct {
1013         u_int16_t       timeout; /* (timeout * 0.625) msec */
1014 } __attribute__ ((packed)) ng_hci_write_con_accept_timo_cp;
1015
1016 typedef ng_hci_status_rp        ng_hci_write_con_accept_timo_rp;
1017
1018 #define NG_HCI_OCF_READ_PAGE_TIMO               0x0017
1019 /* No command parameter(s) */
1020 typedef struct {
1021         u_int8_t        status;  /* 0x00 - success */
1022         u_int16_t       timeout; /* (timeout * 0.625) msec */
1023 } __attribute__ ((packed)) ng_hci_read_page_timo_rp;
1024
1025 #define NG_HCI_OCF_WRITE_PAGE_TIMO              0x0018
1026 typedef struct {
1027         u_int16_t       timeout; /* (timeout * 0.625) msec */
1028 } __attribute__ ((packed)) ng_hci_write_page_timo_cp;
1029
1030 typedef ng_hci_status_rp        ng_hci_write_page_timo_rp;
1031
1032 #define NG_HCI_OCF_READ_SCAN_ENABLE             0x0019
1033 /* No command parameter(s) */
1034 typedef struct {
1035         u_int8_t        status;      /* 0x00 - success */
1036         u_int8_t        scan_enable; /* Scan enable */
1037 } __attribute__ ((packed)) ng_hci_read_scan_enable_rp;
1038
1039 #define NG_HCI_OCF_WRITE_SCAN_ENABLE            0x001a
1040 typedef struct {
1041         u_int8_t        scan_enable; /* Scan enable */
1042 } __attribute__ ((packed)) ng_hci_write_scan_enable_cp;
1043
1044 typedef ng_hci_status_rp        ng_hci_write_scan_enable_rp;
1045
1046 #define NG_HCI_OCF_READ_PAGE_SCAN_ACTIVITY      0x001b
1047 /* No command parameter(s) */
1048 typedef struct {
1049         u_int8_t        status;             /* 0x00 - success */
1050         u_int16_t       page_scan_interval; /* interval * 0.625 msec */
1051         u_int16_t       page_scan_window;   /* window * 0.625 msec */
1052 } __attribute__ ((packed)) ng_hci_read_page_scan_activity_rp;
1053
1054 #define NG_HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY     0x001c
1055 typedef struct {
1056         u_int16_t       page_scan_interval; /* interval * 0.625 msec */
1057         u_int16_t       page_scan_window;   /* window * 0.625 msec */
1058 } __attribute__ ((packed)) ng_hci_write_page_scan_activity_cp;
1059
1060 typedef ng_hci_status_rp        ng_hci_write_page_scan_activity_rp;
1061
1062 #define NG_HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY   0x001d
1063 /* No command parameter(s) */
1064 typedef struct {
1065         u_int8_t        status;                /* 0x00 - success */
1066         u_int16_t       inquiry_scan_interval; /* interval * 0.625 msec */
1067         u_int16_t       inquiry_scan_window;   /* window * 0.625 msec */
1068 } __attribute__ ((packed)) ng_hci_read_inquiry_scan_activity_rp;
1069
1070 #define NG_HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY  0x001e
1071 typedef struct {
1072         u_int16_t       inquiry_scan_interval; /* interval * 0.625 msec */
1073         u_int16_t       inquiry_scan_window;   /* window * 0.625 msec */
1074 } __attribute__ ((packed)) ng_hci_write_inquiry_scan_activity_cp;
1075
1076 typedef ng_hci_status_rp        ng_hci_write_inquiry_scan_activity_rp;
1077
1078 #define NG_HCI_OCF_READ_AUTH_ENABLE             0x001f
1079 /* No command parameter(s) */
1080 typedef struct {
1081         u_int8_t        status;      /* 0x00 - success */
1082         u_int8_t        auth_enable; /* 0x01 - enabled */
1083 } __attribute__ ((packed)) ng_hci_read_auth_enable_rp;
1084
1085 #define NG_HCI_OCF_WRITE_AUTH_ENABLE            0x0020
1086 typedef struct {
1087         u_int8_t        auth_enable; /* 0x01 - enabled */
1088 } __attribute__ ((packed)) ng_hci_write_auth_enable_cp;
1089
1090 typedef ng_hci_status_rp        ng_hci_write_auth_enable_rp;
1091
1092 #define NG_HCI_OCF_READ_ENCRYPTION_MODE         0x0021
1093 /* No command parameter(s) */
1094 typedef struct {
1095         u_int8_t        status;          /* 0x00 - success */
1096         u_int8_t        encryption_mode; /* encryption mode */
1097 } __attribute__ ((packed)) ng_hci_read_encryption_mode_rp;
1098
1099 #define NG_HCI_OCF_WRITE_ENCRYPTION_MODE        0x0022
1100 typedef struct {
1101         u_int8_t        encryption_mode; /* encryption mode */
1102 } __attribute__ ((packed)) ng_hci_write_encryption_mode_cp;
1103
1104 typedef ng_hci_status_rp        ng_hci_write_encryption_mode_rp;
1105
1106 #define NG_HCI_OCF_READ_UNIT_CLASS              0x0023
1107 /* No command parameter(s) */
1108 typedef struct {
1109         u_int8_t        status;                    /* 0x00 - success */
1110         u_int8_t        uclass[NG_HCI_CLASS_SIZE]; /* unit class */
1111 } __attribute__ ((packed)) ng_hci_read_unit_class_rp;
1112
1113 #define NG_HCI_OCF_WRITE_UNIT_CLASS             0x0024
1114 typedef struct {
1115         u_int8_t        uclass[NG_HCI_CLASS_SIZE]; /* unit class */
1116 } __attribute__ ((packed)) ng_hci_write_unit_class_cp;
1117
1118 typedef ng_hci_status_rp        ng_hci_write_unit_class_rp;
1119
1120 #define NG_HCI_OCF_READ_VOICE_SETTINGS          0x0025
1121 /* No command parameter(s) */
1122 typedef struct {
1123         u_int8_t        status;   /* 0x00 - success */
1124         u_int16_t       settings; /* voice settings */
1125 } __attribute__ ((packed)) ng_hci_read_voice_settings_rp;
1126
1127 #define NG_HCI_OCF_WRITE_VOICE_SETTINGS         0x0026
1128 typedef struct {
1129         u_int16_t       settings; /* voice settings */
1130 } __attribute__ ((packed)) ng_hci_write_voice_settings_cp;
1131
1132 typedef ng_hci_status_rp        ng_hci_write_voice_settings_rp;
1133
1134 #define NG_HCI_OCF_READ_AUTO_FLUSH_TIMO         0x0027
1135 typedef struct {
1136         u_int16_t       con_handle; /* connection handle */
1137 } __attribute__ ((packed)) ng_hci_read_auto_flush_timo_cp;
1138
1139 typedef struct {
1140         u_int8_t        status;     /* 0x00 - success */
1141         u_int16_t       con_handle; /* connection handle */
1142         u_int16_t       timeout;    /* 0x00 - no flush, timeout * 0.625 msec */
1143 } __attribute__ ((packed)) ng_hci_read_auto_flush_timo_rp;
1144         
1145 #define NG_HCI_OCF_WRITE_AUTO_FLUSH_TIMO        0x0028
1146 typedef struct {
1147         u_int16_t       con_handle; /* connection handle */
1148         u_int16_t       timeout;    /* 0x00 - no flush, timeout * 0.625 msec */
1149 } __attribute__ ((packed)) ng_hci_write_auto_flush_timo_cp;
1150
1151 typedef struct {
1152         u_int8_t        status;     /* 0x00 - success */
1153         u_int16_t       con_handle; /* connection handle */
1154 } __attribute__ ((packed)) ng_hci_write_auto_flush_timo_rp;
1155
1156 #define NG_HCI_OCF_READ_NUM_BROADCAST_RETRANS   0x0029
1157 /* No command parameter(s) */
1158 typedef struct {
1159         u_int8_t        status;  /* 0x00 - success */
1160         u_int8_t        counter; /* number of broadcast retransmissions */
1161 } __attribute__ ((packed)) ng_hci_read_num_broadcast_retrans_rp;
1162
1163 #define NG_HCI_OCF_WRITE_NUM_BROADCAST_RETRANS  0x002a
1164 typedef struct {
1165         u_int8_t        counter; /* number of broadcast retransmissions */
1166 } __attribute__ ((packed)) ng_hci_write_num_broadcast_retrans_cp;
1167
1168 typedef ng_hci_status_rp        ng_hci_write_num_broadcast_retrans_rp;
1169
1170 #define NG_HCI_OCF_READ_HOLD_MODE_ACTIVITY      0x002b
1171 /* No command parameter(s) */
1172 typedef struct {
1173         u_int8_t        status;             /* 0x00 - success */
1174         u_int8_t        hold_mode_activity; /* Hold mode activities */
1175 } __attribute__ ((packed)) ng_hci_read_hold_mode_activity_rp;
1176
1177 #define NG_HCI_OCF_WRITE_HOLD_MODE_ACTIVITY     0x002c
1178 typedef struct {
1179         u_int8_t        hold_mode_activity; /* Hold mode activities */
1180 } __attribute__ ((packed)) ng_hci_write_hold_mode_activity_cp;
1181
1182 typedef ng_hci_status_rp        ng_hci_write_hold_mode_activity_rp;
1183
1184 #define NG_HCI_OCF_READ_XMIT_LEVEL              0x002d
1185 typedef struct {
1186         u_int16_t       con_handle; /* connection handle */
1187         u_int8_t        type;       /* Xmit level type */
1188 } __attribute__ ((packed)) ng_hci_read_xmit_level_cp;
1189
1190 typedef struct {
1191         u_int8_t        status;     /* 0x00 - success */
1192         u_int16_t       con_handle; /* connection handle */
1193         char            level;      /* -30 <= level <= 30 dBm */
1194 } __attribute__ ((packed)) ng_hci_read_xmit_level_rp;
1195
1196 #define NG_HCI_OCF_READ_SCO_FLOW_CONTROL        0x002e
1197 /* No command parameter(s) */
1198 typedef struct {
1199         u_int8_t        status;       /* 0x00 - success */
1200         u_int8_t        flow_control; /* 0x00 - disabled */
1201 } __attribute__ ((packed)) ng_hci_read_sco_flow_control_rp;
1202
1203 #define NG_HCI_OCF_WRITE_SCO_FLOW_CONTROL       0x002f
1204 typedef struct {
1205         u_int8_t        flow_control; /* 0x00 - disabled */
1206 } __attribute__ ((packed)) ng_hci_write_sco_flow_control_cp;
1207
1208 typedef ng_hci_status_rp        ng_hci_write_sco_flow_control_rp;
1209
1210 #define NG_HCI_OCF_H2HC_FLOW_CONTROL            0x0031
1211 typedef struct {
1212         u_int8_t        h2hc_flow; /* Host to Host controller flow control */
1213 } __attribute__ ((packed)) ng_hci_h2hc_flow_control_cp;
1214
1215 typedef ng_hci_status_rp        ng_hci_h2hc_flow_control_rp;
1216
1217 #define NG_HCI_OCF_HOST_BUFFER_SIZE             0x0033
1218 typedef struct {
1219         u_int16_t       max_acl_size; /* Max. size of ACL packet (bytes) */
1220         u_int8_t        max_sco_size; /* Max. size of SCO packet (bytes) */
1221         u_int16_t       num_acl_pkt;  /* Max. number of ACL packets */
1222         u_int16_t       num_sco_pkt;  /* Max. number of SCO packets */
1223 } __attribute__ ((packed)) ng_hci_host_buffer_size_cp;
1224
1225 typedef ng_hci_status_rp        ng_hci_host_buffer_size_rp;
1226
1227 #define NG_HCI_OCF_HOST_NUM_COMPL_PKTS          0x0035
1228 typedef struct {
1229         u_int8_t        num_con_handles; /* # of connection handles */
1230 /* these are repeated "num_con_handles" times
1231         u_int16_t       con_handle; --- connection handle(s)
1232         u_int16_t       compl_pkt;  --- # of completed packets */
1233 } __attribute__ ((packed)) ng_hci_host_num_compl_pkts_cp;
1234 /* No return parameter(s) */
1235
1236 #define NG_HCI_OCF_READ_LINK_SUPERVISION_TIMO   0x0036
1237 typedef struct {
1238         u_int16_t       con_handle; /* connection handle */
1239 } __attribute__ ((packed)) ng_hci_read_link_supervision_timo_cp;
1240
1241 typedef struct {
1242         u_int8_t        status;     /* 0x00 - success */
1243         u_int16_t       con_handle; /* connection handle */
1244         u_int16_t       timeout;    /* Link supervision timeout * 0.625 msec */
1245 } __attribute__ ((packed)) ng_hci_read_link_supervision_timo_rp;
1246
1247 #define NG_HCI_OCF_WRITE_LINK_SUPERVISION_TIMO  0x0037
1248 typedef struct {
1249         u_int16_t       con_handle; /* connection handle */
1250         u_int16_t       timeout;    /* Link supervision timeout * 0.625 msec */
1251 } __attribute__ ((packed)) ng_hci_write_link_supervision_timo_cp;
1252
1253 typedef struct {
1254         u_int8_t        status;     /* 0x00 - success */
1255         u_int16_t       con_handle; /* connection handle */
1256 } __attribute__ ((packed)) ng_hci_write_link_supervision_timo_rp;
1257
1258 #define NG_HCI_OCF_READ_SUPPORTED_IAC_NUM       0x0038
1259 /* No command parameter(s) */
1260 typedef struct {
1261         u_int8_t        status;  /* 0x00 - success */
1262         u_int8_t        num_iac; /* # of supported IAC during scan */
1263 } __attribute__ ((packed)) ng_hci_read_supported_iac_num_rp;
1264
1265 #define NG_HCI_OCF_READ_IAC_LAP                 0x0039
1266 /* No command parameter(s) */
1267 typedef struct {
1268         u_int8_t        status;  /* 0x00 - success */
1269         u_int8_t        num_iac; /* # of IAC */
1270 /* these are repeated "num_iac" times 
1271         u_int8_t        laps[NG_HCI_LAP_SIZE]; --- LAPs */
1272 } __attribute__ ((packed)) ng_hci_read_iac_lap_rp;
1273
1274 #define NG_HCI_OCF_WRITE_IAC_LAP                0x003a
1275 typedef struct {
1276         u_int8_t        num_iac; /* # of IAC */
1277 /* these are repeated "num_iac" times 
1278         u_int8_t        laps[NG_HCI_LAP_SIZE]; --- LAPs */
1279 } __attribute__ ((packed)) ng_hci_write_iac_lap_cp;
1280
1281 typedef ng_hci_status_rp        ng_hci_write_iac_lap_rp;
1282
1283 /*0x003b-0x003e commands are depricated v2.0 or later*/
1284 #define NG_HCI_OCF_READ_PAGE_SCAN_PERIOD        0x003b
1285 /* No command parameter(s) */
1286 typedef struct {
1287         u_int8_t        status;                /* 0x00 - success */
1288         u_int8_t        page_scan_period_mode; /* Page scan period mode */
1289 } __attribute__ ((packed)) ng_hci_read_page_scan_period_rp;
1290
1291 #define NG_HCI_OCF_WRITE_PAGE_SCAN_PERIOD       0x003c
1292 typedef struct {
1293         u_int8_t        page_scan_period_mode; /* Page scan period mode */
1294 } __attribute__ ((packed)) ng_hci_write_page_scan_period_cp;
1295
1296 typedef ng_hci_status_rp        ng_hci_write_page_scan_period_rp;
1297
1298 #define NG_HCI_OCF_READ_PAGE_SCAN               0x003d
1299 /* No command parameter(s) */
1300 typedef struct {
1301         u_int8_t        status;         /* 0x00 - success */
1302         u_int8_t        page_scan_mode; /* Page scan mode */
1303 } __attribute__ ((packed)) ng_hci_read_page_scan_rp;
1304
1305 #define NG_HCI_OCF_WRITE_PAGE_SCAN              0x003e
1306 typedef struct {
1307         u_int8_t        page_scan_mode; /* Page scan mode */
1308 } __attribute__ ((packed)) ng_hci_write_page_scan_cp;
1309
1310 typedef ng_hci_status_rp        ng_hci_write_page_scan_rp;
1311
1312 #define NG_HCI_OCF_READ_LE_HOST_SUPPORTED  0x6c
1313 typedef struct {
1314         u_int8_t        status;         /* 0x00 - success */
1315         u_int8_t        le_supported_host ;/* LE host supported?*/
1316         u_int8_t        simultaneous_le_host; /* BR/LE simulateneous? */
1317 } __attribute__ ((packed)) ng_hci_read_le_host_supported_rp;
1318
1319 #define NG_HCI_OCF_WRITE_LE_HOST_SUPPORTED  0x6d
1320 typedef struct {
1321         u_int8_t        le_supported_host; /* LE host supported?*/
1322         u_int8_t        simultaneous_le_host; /* LE host supported?*/
1323 } __attribute__ ((packed)) ng_hci_write_le_host_supported_cp;
1324
1325 typedef ng_hci_status_rp        ng_hci_write_le_host_supported_rp;
1326
1327 /**************************************************************************
1328  **************************************************************************
1329  **           Informational commands and return parameters 
1330  **     All commands in this category do not accept any parameters
1331  **************************************************************************
1332  **************************************************************************/
1333
1334 #define NG_HCI_OGF_INFO                         0x04 /* OpCode Group Field */
1335
1336 #define NG_HCI_OCF_READ_LOCAL_VER               0x0001
1337 typedef struct {
1338         u_int8_t        status;         /* 0x00 - success */
1339         u_int8_t        hci_version;    /* HCI version */
1340         u_int16_t       hci_revision;   /* HCI revision */
1341         u_int8_t        lmp_version;    /* LMP version */
1342         u_int16_t       manufacturer;   /* Hardware manufacturer name */
1343         u_int16_t       lmp_subversion; /* LMP sub-version */
1344 } __attribute__ ((packed)) ng_hci_read_local_ver_rp;
1345
1346 #define NG_HCI_OCF_READ_LOCAL_COMMANDS          0x0002
1347 typedef struct {
1348         u_int8_t        status;                         /* 0x00 - success */
1349         u_int8_t        features[NG_HCI_COMMANDS_SIZE]; /* command bitmsk*/
1350 } __attribute__ ((packed)) ng_hci_read_local_commands_rp;
1351
1352 #define NG_HCI_OCF_READ_LOCAL_FEATURES          0x0003
1353 typedef struct {
1354         u_int8_t        status;                         /* 0x00 - success */
1355         u_int8_t        features[NG_HCI_FEATURES_SIZE]; /* LMP features bitmsk*/
1356 } __attribute__ ((packed)) ng_hci_read_local_features_rp;
1357
1358 #define NG_HCI_OCF_READ_BUFFER_SIZE             0x0005
1359 typedef struct {
1360         u_int8_t        status;       /* 0x00 - success */
1361         u_int16_t       max_acl_size; /* Max. size of ACL packet (bytes) */
1362         u_int8_t        max_sco_size; /* Max. size of SCO packet (bytes) */
1363         u_int16_t       num_acl_pkt;  /* Max. number of ACL packets */
1364         u_int16_t       num_sco_pkt;  /* Max. number of SCO packets */
1365 } __attribute__ ((packed)) ng_hci_read_buffer_size_rp;
1366
1367 #define NG_HCI_OCF_READ_COUNTRY_CODE            0x0007
1368 typedef struct {
1369         u_int8_t        status;       /* 0x00 - success */
1370         u_int8_t        country_code; /* 0x00 - NAM, EUR, JP; 0x01 - France */
1371 } __attribute__ ((packed)) ng_hci_read_country_code_rp;
1372
1373 #define NG_HCI_OCF_READ_BDADDR                  0x0009
1374 typedef struct {
1375         u_int8_t        status; /* 0x00 - success */
1376         bdaddr_t        bdaddr; /* unit address */
1377 } __attribute__ ((packed)) ng_hci_read_bdaddr_rp;
1378
1379 /**************************************************************************
1380  **************************************************************************
1381  **            Status commands and return parameters 
1382  **************************************************************************
1383  **************************************************************************/
1384
1385 #define NG_HCI_OGF_STATUS                       0x05 /* OpCode Group Field */
1386
1387 #define NG_HCI_OCF_READ_FAILED_CONTACT_CNTR     0x0001
1388 typedef struct {
1389         u_int16_t       con_handle; /* connection handle */
1390 } __attribute__ ((packed)) ng_hci_read_failed_contact_cntr_cp;
1391
1392 typedef struct {
1393         u_int8_t        status;     /* 0x00 - success */
1394         u_int16_t       con_handle; /* connection handle */
1395         u_int16_t       counter;    /* number of consecutive failed contacts */
1396 } __attribute__ ((packed)) ng_hci_read_failed_contact_cntr_rp;
1397
1398 #define NG_HCI_OCF_RESET_FAILED_CONTACT_CNTR    0x0002
1399 typedef struct {
1400         u_int16_t       con_handle; /* connection handle */
1401 } __attribute__ ((packed)) ng_hci_reset_failed_contact_cntr_cp;
1402
1403 typedef struct {
1404         u_int8_t        status;     /* 0x00 - success */
1405         u_int16_t       con_handle; /* connection handle */
1406 } __attribute__ ((packed)) ng_hci_reset_failed_contact_cntr_rp;
1407
1408 #define NG_HCI_OCF_GET_LINK_QUALITY             0x0003
1409 typedef struct {
1410         u_int16_t       con_handle; /* connection handle */
1411 } __attribute__ ((packed)) ng_hci_get_link_quality_cp;
1412
1413 typedef struct {
1414         u_int8_t        status;     /* 0x00 - success */
1415         u_int16_t       con_handle; /* connection handle */
1416         u_int8_t        quality;    /* higher value means better quality */
1417 } __attribute__ ((packed)) ng_hci_get_link_quality_rp;
1418
1419 #define NG_HCI_OCF_READ_RSSI                    0x0005
1420 typedef struct {
1421         u_int16_t       con_handle; /* connection handle */
1422 } __attribute__ ((packed)) ng_hci_read_rssi_cp;
1423
1424 typedef struct {
1425         u_int8_t        status;     /* 0x00 - success */
1426         u_int16_t       con_handle; /* connection handle */
1427         char            rssi;       /* -127 <= rssi <= 127 dB */
1428 } __attribute__ ((packed)) ng_hci_read_rssi_rp;
1429
1430 /**************************************************************************
1431  **************************************************************************
1432  **             Testing commands and return parameters 
1433  **************************************************************************
1434  **************************************************************************/
1435
1436 #define NG_HCI_OGF_TESTING                      0x06 /* OpCode Group Field */
1437
1438 #define NG_HCI_OCF_READ_LOOPBACK_MODE           0x0001
1439 /* No command parameter(s) */
1440 typedef struct {
1441         u_int8_t        status; /* 0x00 - success */
1442         u_int8_t        lbmode; /* loopback mode */
1443 } __attribute__ ((packed)) ng_hci_read_loopback_mode_rp;
1444
1445 #define NG_HCI_OCF_WRITE_LOOPBACK_MODE          0x0002
1446 typedef struct {
1447         u_int8_t        lbmode; /* loopback mode */
1448 } __attribute__ ((packed)) ng_hci_write_loopback_mode_cp;
1449
1450 typedef ng_hci_status_rp        ng_hci_write_loopback_mode_rp;
1451
1452 #define NG_HCI_OCF_ENABLE_UNIT_UNDER_TEST       0x0003
1453 /* No command parameter(s) */
1454 typedef ng_hci_status_rp        ng_hci_enable_unit_under_test_rp;
1455
1456 /**************************************************************************
1457  **************************************************************************
1458  **                LE OpCode group field
1459  **************************************************************************
1460  **************************************************************************/
1461
1462 #define NG_HCI_OGF_LE                   0x08 /* OpCode Group Field */
1463 #define NG_HCI_OCF_LE_SET_EVENT_MASK                    0x0001
1464 typedef struct {
1465         u_int8_t        event_mask[NG_HCI_LE_EVENT_MASK_SIZE]; /* event_mask*/
1466         
1467 } __attribute__ ((packed)) ng_hci_le_set_event_mask_cp;
1468 typedef ng_hci_status_rp        ng_hci_le_set_event_mask_rp;
1469 #define NG_HCI_LE_EVENT_MASK_ALL 0x1f
1470
1471 #define NG_HCI_OCF_LE_READ_BUFFER_SIZE                  0x0002
1472 /*No command parameter */
1473 typedef struct {
1474         u_int8_t        status; /*status*/
1475         u_int16_t       hc_le_data_packet_length;
1476         u_int8_t        hc_total_num_le_data_packets; 
1477 } __attribute__ ((packed)) ng_hci_le_read_buffer_size_rp;
1478
1479
1480 #define NG_HCI_OCF_LE_READ_LOCAL_SUPPORTED_FEATURES     0x0003
1481 /*No command parameter */
1482 typedef struct {
1483         u_int8_t        status; /*status*/
1484         u_int64_t       le_features;
1485 } __attribute__ ((packed)) ng_hci_le_read_local_supported_features_rp;
1486
1487 #define NG_HCI_OCF_LE_SET_RANDOM_ADDRESS                0x0005
1488 typedef struct {
1489         bdaddr_t        random_address;
1490 } __attribute__ ((packed)) ng_hci_le_set_random_address_cp_;
1491 typedef ng_hci_status_rp        ng_hci_le_set_random_address_rp;
1492
1493 #define NG_HCI_OCF_LE_SET_ADVERTISING_PARAMETERS        0x0006
1494 typedef struct {
1495         u_int16_t       advertising_interval_min;
1496         u_int16_t       advertising_interval_max;
1497         u_int8_t        advertising_type;
1498         u_int8_t        own_address_type;
1499         u_int8_t        direct_address_type;
1500         bdaddr_t        direct_address;
1501         u_int8_t        advertising_channel_map;
1502         u_int8_t        advertising_filter_policy;
1503 } __attribute__ ((packed)) ng_hci_le_set_advertising_parameters_cp;
1504 typedef ng_hci_status_rp        ng_hci_le_set_advertising_parameters_rp;
1505
1506 #define NG_HCI_OCF_LE_READ_ADVERTISING_CHANNEL_TX_POWER 0x0007
1507 /*No command parameter*/
1508 typedef struct {
1509         u_int8_t status;
1510         u_int8_t transmit_power_level;
1511 } __attribute__ ((packed)) ng_hci_le_read_advertising_channel_tx_power_rp;
1512
1513 #define NG_HCI_OCF_LE_SET_ADVERTISING_DATA              0x0008
1514 #define NG_HCI_ADVERTISING_DATA_SIZE 31
1515 typedef struct {
1516         u_int8_t advertising_data_length;
1517         char advertising_data[NG_HCI_ADVERTISING_DATA_SIZE];
1518 } __attribute__ ((packed)) ng_hci_le_set_advertising_data_cp;
1519 typedef ng_hci_status_rp        ng_hci_le_set_advertising_data_rp;
1520
1521 #define NG_HCI_OCF_LE_SET_SCAN_RESPONSE_DATA            0x0009
1522
1523 typedef struct {
1524         u_int8_t scan_response_data_length;
1525         char scan_response_data[NG_HCI_ADVERTISING_DATA_SIZE];
1526 } __attribute__ ((packed)) ng_hci_le_set_scan_response_data_cp;
1527 typedef ng_hci_status_rp        ng_hci_le_set_scan_response_data_rp;
1528
1529 #define NG_HCI_OCF_LE_SET_ADVERTISE_ENABLE              0x000a
1530 typedef struct {
1531         u_int8_t advertising_enable;
1532 }__attribute__ ((packed)) ng_hci_le_set_advertise_enable_cp;
1533 typedef ng_hci_status_rp        ng_hci_le_set_advertise_enable_rp;
1534
1535 #define NG_HCI_OCF_LE_SET_SCAN_PARAMETERS               0x000b
1536 typedef struct {
1537         u_int8_t le_scan_type;
1538         u_int16_t le_scan_interval;
1539         u_int16_t le_scan_window;
1540         u_int8_t own_address_type;
1541         u_int8_t scanning_filter_policy;
1542 }__attribute__ ((packed)) ng_hci_le_set_scan_parameters_cp;
1543 typedef ng_hci_status_rp        ng_hci_le_set_scan_parameters_rp;
1544
1545 #define NG_HCI_OCF_LE_SET_SCAN_ENABLE                   0x000c
1546 typedef struct {
1547         u_int8_t le_scan_enable;
1548         u_int8_t filter_duplicates;
1549 }__attribute__ ((packed)) ng_hci_le_set_scan_enable_cp;
1550 typedef ng_hci_status_rp        ng_hci_le_set_scan_enable_rp;
1551
1552 #define NG_HCI_OCF_LE_CREATE_CONNECTION                 0x000d
1553 typedef struct {
1554         u_int16_t scan_interval;
1555         u_int16_t scan_window;
1556         u_int8_t filter_policy;
1557         u_int8_t peer_addr_type;
1558         bdaddr_t peer_addr;
1559         u_int8_t own_address_type;
1560         u_int16_t conn_interval_min;
1561         u_int16_t conn_interval_max;
1562         u_int16_t conn_latency;
1563         u_int16_t supervision_timeout;
1564         u_int16_t min_ce_length;
1565         u_int16_t max_ce_length;
1566 }__attribute__((packed)) ng_hci_le_create_connection_cp;
1567 /* No return parameters. */
1568 #define NG_HCI_OCF_LE_CREATE_CONNECTION_CANCEL          0x000e
1569 /*No command parameter*/        
1570 typedef ng_hci_status_rp        ng_hci_le_create_connection_cancel_rp;  
1571 #define NG_HCI_OCF_LE_READ_WHITE_LIST_SIZE              0x000f
1572 /*No command parameter*/        
1573 typedef struct {
1574         u_int8_t status;
1575         u_int8_t white_list_size;
1576 } __attribute__ ((packed)) ng_hci_le_read_white_list_size_rp;
1577         
1578 #define NG_HCI_OCF_LE_CLEAR_WHITE_LIST                  0x0010
1579 /* No command parameters. */
1580 typedef ng_hci_status_rp        ng_hci_le_clear_white_list_rp;  
1581 #define NG_HCI_OCF_LE_ADD_DEVICE_TO_WHITE_LIST          0x0011
1582 typedef struct {
1583         u_int8_t address_type;
1584         bdaddr_t address;
1585 } __attribute__ ((packed)) ng_hci_le_add_device_to_white_list_cp;
1586 typedef ng_hci_status_rp        ng_hci_le_add_device_to_white_list_rp;  
1587
1588 #define NG_HCI_OCF_LE_REMOVE_DEVICE_FROM_WHITE_LIST     0x0012
1589 typedef struct {
1590         u_int8_t address_type;
1591         bdaddr_t address;
1592 } __attribute__ ((packed)) ng_hci_le_remove_device_from_white_list_cp;
1593 typedef ng_hci_status_rp        ng_hci_le_remove_device_from_white_list_rp;
1594
1595 #define NG_HCI_OCF_LE_CONNECTION_UPDATE                 0x0013
1596 typedef struct {
1597         u_int16_t connection_handle;
1598         u_int16_t conn_interval_min;
1599         u_int16_t conn_interval_max;
1600         u_int16_t conn_latency;
1601         u_int16_t supervision_timeout;
1602         u_int16_t minimum_ce_length;
1603         u_int16_t maximum_ce_length;
1604 }__attribute__ ((packed)) ng_hci_le_connection_update_cp;
1605 /*no return parameter*/
1606
1607 #define NG_HCI_OCF_LE_SET_HOST_CHANNEL_CLASSIFICATION   0x0014
1608 typedef struct{
1609         u_int8_t le_channel_map[5];
1610 }__attribute__ ((packed)) ng_hci_le_set_host_channel_classification_cp;
1611 typedef ng_hci_status_rp        ng_hci_le_set_host_channel_classification_rp;
1612
1613 #define NG_HCI_OCF_LE_READ_CHANNEL_MAP                  0x0015
1614 typedef struct {
1615         u_int16_t connection_handle;
1616 }__attribute__ ((packed)) ng_hci_le_read_channel_map_cp;
1617 typedef struct {
1618         u_int8_t status;
1619         u_int16_t connection_handle;
1620         u_int8_t le_channel_map[5];
1621 } __attribute__ ((packed)) ng_hci_le_read_channel_map_rp;
1622         
1623 #define NG_HCI_OCF_LE_READ_REMOTE_USED_FEATURES         0x0016
1624 typedef struct {
1625         u_int16_t connection_handle;
1626 }__attribute__ ((packed)) ng_hci_le_read_remote_used_features_cp;
1627 /*No return parameter*/
1628 #define NG_HCI_128BIT 16
1629 #define NG_HCI_OCF_LE_ENCRYPT                           0x0017
1630 typedef struct {
1631         u_int8_t key[NG_HCI_128BIT];
1632         u_int8_t plaintext_data[NG_HCI_128BIT];
1633 }__attribute__ ((packed)) ng_hci_le_encrypt_cp; 
1634 typedef struct {
1635         u_int8_t status;
1636         u_int8_t plaintext_data[NG_HCI_128BIT];
1637 }__attribute__ ((packed)) ng_hci_le_encrypt_rp; 
1638
1639 #define NG_HCI_OCF_LE_RAND                              0x0018
1640 /*No command parameter*/
1641 typedef struct {
1642         u_int8_t status;
1643         u_int64_t random_number;
1644 }__attribute__ ((packed)) ng_hci_le_rand_rp;    
1645         
1646 #define NG_HCI_OCF_LE_START_ENCRYPTION                  0x0019
1647 typedef struct {
1648         u_int16_t connection_handle;
1649         u_int64_t random_number;
1650         u_int16_t encrypted_diversifier;
1651         u_int8_t long_term_key[NG_HCI_128BIT];
1652 }__attribute__ ((packed)) ng_hci_le_start_encryption_cp;        
1653 /*No return parameter*/
1654 #define NG_HCI_OCF_LE_LONG_TERM_KEY_REQUEST_REPLY       0x001a
1655 typedef struct {
1656         u_int16_t connection_handle;
1657         u_int8_t long_term_key[NG_HCI_128BIT];
1658 }__attribute__ ((packed)) ng_hci_le_long_term_key_request_reply_cp;     
1659 typedef struct {
1660         u_int8_t status;
1661         u_int16_t connection_handle;
1662 }__attribute__ ((packed)) ng_hci_le_long_term_key_request_reply_rp;     
1663
1664 #define NG_HCI_OCF_LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY 0x001b
1665 typedef struct{
1666         u_int16_t connection_handle;
1667 }ng_hci_le_long_term_key_request_negative_reply_cp;
1668 typedef struct {
1669         u_int8_t status;
1670         u_int16_t connection_handle;
1671 }__attribute__ ((packed)) ng_hci_le_long_term_key_request_negative_reply_rp;
1672
1673
1674 #define NG_HCI_OCF_LE_READ_SUPPORTED_STATUS             0x001c
1675 /*No command parameter*/
1676 typedef struct {
1677         u_int8_t status;
1678         u_int64_t le_status;
1679 }__attribute__ ((packed)) ng_hci_le_read_supported_status_rp;
1680
1681 #define NG_HCI_OCF_LE_RECEIVER_TEST                     0x001d
1682 typedef struct{
1683         u_int8_t rx_frequency;
1684 } __attribute__((packed)) ng_le_receiver_test_cp;
1685 typedef ng_hci_status_rp        ng_hci_le_receiver_test_rp;
1686
1687 #define NG_HCI_OCF_LE_TRANSMITTER_TEST                  0x001e
1688 typedef struct{
1689         u_int8_t tx_frequency;
1690         u_int8_t length_of_test_data;
1691         u_int8_t packet_payload;
1692 } __attribute__((packed)) ng_le_transmitter_test_cp;
1693 typedef ng_hci_status_rp        ng_hci_le_transmitter_test_rp;
1694
1695 #define NG_HCI_OCF_LE_TEST_END                          0x001f
1696 /* No command parameter. */
1697 typedef struct {
1698         u_int8_t status;
1699         u_int16_t number_of_packets;
1700 }__attribute__ ((packed)) ng_hci_le_test_end_rp;
1701
1702 /**************************************************************************
1703  **************************************************************************
1704  **                Special HCI OpCode group field values
1705  **************************************************************************
1706  **************************************************************************/
1707
1708 #define NG_HCI_OGF_BT_LOGO                      0x3e    
1709
1710 #define NG_HCI_OGF_VENDOR                       0x3f
1711
1712 /**************************************************************************
1713  **************************************************************************
1714  **                         Events and event parameters
1715  **************************************************************************
1716  **************************************************************************/
1717
1718 #define NG_HCI_EVENT_INQUIRY_COMPL              0x01
1719 typedef struct {
1720         u_int8_t        status; /* 0x00 - success */
1721 } __attribute__ ((packed)) ng_hci_inquiry_compl_ep;
1722
1723 #define NG_HCI_EVENT_INQUIRY_RESULT             0x02
1724 typedef struct {
1725         u_int8_t        num_responses;      /* number of responses */
1726 /*      ng_hci_inquiry_response[num_responses]   -- see below */
1727 } __attribute__ ((packed)) ng_hci_inquiry_result_ep;
1728
1729 typedef struct {
1730         bdaddr_t        bdaddr;                   /* unit address */
1731         u_int8_t        page_scan_rep_mode;       /* page scan rep. mode */
1732         u_int8_t        page_scan_period_mode;    /* page scan period mode */
1733         u_int8_t        page_scan_mode;           /* page scan mode */
1734         u_int8_t        uclass[NG_HCI_CLASS_SIZE];/* unit class */
1735         u_int16_t       clock_offset;             /* clock offset */
1736 } __attribute__ ((packed)) ng_hci_inquiry_response;
1737
1738 #define NG_HCI_EVENT_CON_COMPL                  0x03
1739 typedef struct {
1740         u_int8_t        status;          /* 0x00 - success */
1741         u_int16_t       con_handle;      /* Connection handle */
1742         bdaddr_t        bdaddr;          /* remote unit address */
1743         u_int8_t        link_type;       /* Link type */
1744         u_int8_t        encryption_mode; /* Encryption mode */
1745 } __attribute__ ((packed)) ng_hci_con_compl_ep;
1746
1747 #define NG_HCI_EVENT_CON_REQ                    0x04
1748 typedef struct {
1749         bdaddr_t        bdaddr;                    /* remote unit address */
1750         u_int8_t        uclass[NG_HCI_CLASS_SIZE]; /* remote unit class */
1751         u_int8_t        link_type;                 /* link type */
1752 } __attribute__ ((packed)) ng_hci_con_req_ep;
1753
1754 #define NG_HCI_EVENT_DISCON_COMPL               0x05
1755 typedef struct {
1756         u_int8_t        status;     /* 0x00 - success */
1757         u_int16_t       con_handle; /* connection handle */
1758         u_int8_t        reason;     /* reason to disconnect */
1759 } __attribute__ ((packed)) ng_hci_discon_compl_ep;
1760
1761 #define NG_HCI_EVENT_AUTH_COMPL                 0x06
1762 typedef struct {
1763         u_int8_t        status;     /* 0x00 - success */
1764         u_int16_t       con_handle; /* connection handle */
1765 } __attribute__ ((packed)) ng_hci_auth_compl_ep;
1766
1767 #define NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL      0x7
1768 typedef struct {
1769         u_int8_t        status; /* 0x00 - success */
1770         bdaddr_t        bdaddr; /* remote unit address */
1771         char            name[NG_HCI_UNIT_NAME_SIZE]; /* remote unit name */
1772 } __attribute__ ((packed)) ng_hci_remote_name_req_compl_ep;
1773
1774 #define NG_HCI_EVENT_ENCRYPTION_CHANGE          0x08
1775 typedef struct {
1776         u_int8_t        status;            /* 0x00 - success */
1777         u_int16_t       con_handle;        /* Connection handle */
1778         u_int8_t        encryption_enable; /* 0x00 - disable */
1779 } __attribute__ ((packed)) ng_hci_encryption_change_ep;
1780
1781 #define NG_HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL  0x09
1782 typedef struct {
1783         u_int8_t        status;     /* 0x00 - success */
1784         u_int16_t       con_handle; /* Connection handle */
1785 } __attribute__ ((packed)) ng_hci_change_con_link_key_compl_ep;
1786
1787 #define NG_HCI_EVENT_MASTER_LINK_KEY_COMPL      0x0a
1788 typedef struct {
1789         u_int8_t        status;     /* 0x00 - success */
1790         u_int16_t       con_handle; /* Connection handle */
1791         u_int8_t        key_flag;   /* Key flag */
1792 } __attribute__ ((packed)) ng_hci_master_link_key_compl_ep;
1793
1794 #define NG_HCI_EVENT_READ_REMOTE_FEATURES_COMPL 0x0b
1795 typedef struct {
1796         u_int8_t        status;                         /* 0x00 - success */
1797         u_int16_t       con_handle;                     /* Connection handle */
1798         u_int8_t        features[NG_HCI_FEATURES_SIZE]; /* LMP features bitmsk*/
1799 } __attribute__ ((packed)) ng_hci_read_remote_features_compl_ep;
1800
1801 #define NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL 0x0c
1802 typedef struct {
1803         u_int8_t        status;         /* 0x00 - success */
1804         u_int16_t       con_handle;     /* Connection handle */
1805         u_int8_t        lmp_version;    /* LMP version */
1806         u_int16_t       manufacturer;   /* Hardware manufacturer name */
1807         u_int16_t       lmp_subversion; /* LMP sub-version */
1808 } __attribute__ ((packed)) ng_hci_read_remote_ver_info_compl_ep;
1809
1810 #define NG_HCI_EVENT_QOS_SETUP_COMPL            0x0d
1811 typedef struct {
1812         u_int8_t        status;          /* 0x00 - success */
1813         u_int16_t       con_handle;      /* connection handle */
1814         u_int8_t        flags;           /* reserved for future use */
1815         u_int8_t        service_type;    /* service type */
1816         u_int32_t       token_rate;      /* bytes per second */
1817         u_int32_t       peak_bandwidth;  /* bytes per second */
1818         u_int32_t       latency;         /* microseconds */
1819         u_int32_t       delay_variation; /* microseconds */
1820 } __attribute__ ((packed)) ng_hci_qos_setup_compl_ep;
1821
1822 #define NG_HCI_EVENT_COMMAND_COMPL              0x0e
1823 typedef struct {
1824         u_int8_t        num_cmd_pkts; /* # of HCI command packets */
1825         u_int16_t       opcode;       /* command OpCode */
1826         /* command return parameters (if any) */
1827 } __attribute__ ((packed)) ng_hci_command_compl_ep;
1828
1829 #define NG_HCI_EVENT_COMMAND_STATUS             0x0f
1830 typedef struct {
1831         u_int8_t        status;       /* 0x00 - pending */
1832         u_int8_t        num_cmd_pkts; /* # of HCI command packets */
1833         u_int16_t       opcode;       /* command OpCode */
1834 } __attribute__ ((packed)) ng_hci_command_status_ep;
1835
1836 #define NG_HCI_EVENT_HARDWARE_ERROR             0x10
1837 typedef struct {
1838         u_int8_t        hardware_code; /* hardware error code */
1839 } __attribute__ ((packed)) ng_hci_hardware_error_ep;
1840
1841 #define NG_HCI_EVENT_FLUSH_OCCUR                0x11
1842 typedef struct {
1843         u_int16_t       con_handle; /* connection handle */
1844 } __attribute__ ((packed)) ng_hci_flush_occur_ep;
1845
1846 #define NG_HCI_EVENT_ROLE_CHANGE                0x12
1847 typedef struct {
1848         u_int8_t        status; /* 0x00 - success */
1849         bdaddr_t        bdaddr; /* address of remote unit */
1850         u_int8_t        role;   /* new connection role */
1851 } __attribute__ ((packed)) ng_hci_role_change_ep;
1852
1853 #define NG_HCI_EVENT_NUM_COMPL_PKTS             0x13
1854 typedef struct {
1855         u_int8_t        num_con_handles; /* # of connection handles */
1856 /* these are repeated "num_con_handles" times 
1857         u_int16_t       con_handle; --- connection handle(s)
1858         u_int16_t       compl_pkt;  --- # of completed packets */
1859 } __attribute__ ((packed)) ng_hci_num_compl_pkts_ep;
1860
1861 #define NG_HCI_EVENT_MODE_CHANGE                0x14
1862 typedef struct {
1863         u_int8_t        status;     /* 0x00 - success */
1864         u_int16_t       con_handle; /* connection handle */
1865         u_int8_t        unit_mode;  /* remote unit mode */
1866         u_int16_t       interval;   /* interval * 0.625 msec */
1867 } __attribute__ ((packed)) ng_hci_mode_change_ep;
1868
1869 #define NG_HCI_EVENT_RETURN_LINK_KEYS           0x15
1870 typedef struct {
1871         u_int8_t        num_keys; /* # of keys */
1872 /* these are repeated "num_keys" times 
1873         bdaddr_t        bdaddr;               --- remote address(es)
1874         u_int8_t        key[NG_HCI_KEY_SIZE]; --- key(s) */
1875 } __attribute__ ((packed)) ng_hci_return_link_keys_ep;
1876
1877 #define NG_HCI_EVENT_PIN_CODE_REQ               0x16
1878 typedef struct {
1879         bdaddr_t        bdaddr; /* remote unit address */
1880 } __attribute__ ((packed)) ng_hci_pin_code_req_ep;
1881
1882 #define NG_HCI_EVENT_LINK_KEY_REQ               0x17
1883 typedef struct {
1884         bdaddr_t        bdaddr; /* remote unit address */
1885 } __attribute__ ((packed)) ng_hci_link_key_req_ep;
1886
1887 #define NG_HCI_EVENT_LINK_KEY_NOTIFICATION      0x18
1888 typedef struct {
1889         bdaddr_t        bdaddr;               /* remote unit address */
1890         u_int8_t        key[NG_HCI_KEY_SIZE]; /* link key */
1891         u_int8_t        key_type;             /* type of the key */
1892 } __attribute__ ((packed)) ng_hci_link_key_notification_ep;
1893
1894 #define NG_HCI_EVENT_LOOPBACK_COMMAND           0x19
1895 typedef struct {
1896         u_int8_t        command[0]; /* Command packet */
1897 } __attribute__ ((packed)) ng_hci_loopback_command_ep;
1898
1899 #define NG_HCI_EVENT_DATA_BUFFER_OVERFLOW       0x1a
1900 typedef struct {
1901         u_int8_t        link_type; /* Link type */
1902 } __attribute__ ((packed)) ng_hci_data_buffer_overflow_ep;
1903
1904 #define NG_HCI_EVENT_MAX_SLOT_CHANGE            0x1b
1905 typedef struct {
1906         u_int16_t       con_handle;    /* connection handle */
1907         u_int8_t        lmp_max_slots; /* Max. # of slots allowed */
1908 } __attribute__ ((packed)) ng_hci_max_slot_change_ep;
1909
1910 #define NG_HCI_EVENT_READ_CLOCK_OFFSET_COMPL    0x1c
1911 typedef struct {
1912         u_int8_t        status;       /* 0x00 - success */
1913         u_int16_t       con_handle;   /* Connection handle */
1914         u_int16_t       clock_offset; /* Clock offset */
1915 } __attribute__ ((packed)) ng_hci_read_clock_offset_compl_ep;
1916
1917 #define NG_HCI_EVENT_CON_PKT_TYPE_CHANGED       0x1d
1918 typedef struct {
1919         u_int8_t        status;     /* 0x00 - success */
1920         u_int16_t       con_handle; /* connection handle */
1921         u_int16_t       pkt_type;   /* packet type */
1922 } __attribute__ ((packed)) ng_hci_con_pkt_type_changed_ep;
1923
1924 #define NG_HCI_EVENT_QOS_VIOLATION              0x1e
1925 typedef struct {
1926         u_int16_t       con_handle; /* connection handle */
1927 } __attribute__ ((packed)) ng_hci_qos_violation_ep;
1928
1929 #define NG_HCI_EVENT_PAGE_SCAN_MODE_CHANGE      0x1f
1930 typedef struct {
1931         bdaddr_t        bdaddr;         /* destination address */
1932         u_int8_t        page_scan_mode; /* page scan mode */
1933 } __attribute__ ((packed)) ng_hci_page_scan_mode_change_ep;
1934
1935 #define NG_HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE  0x20
1936 typedef struct {
1937         bdaddr_t        bdaddr;             /* destination address */
1938         u_int8_t        page_scan_rep_mode; /* page scan repetition mode */
1939 } __attribute__ ((packed)) ng_hci_page_scan_rep_mode_change_ep;
1940 #define NG_HCI_EVENT_LE                         0x3e
1941 typedef struct {
1942         u_int8_t        subevent_code;  
1943 }__attribute__ ((packed)) ng_hci_le_ep;
1944
1945 #define NG_HCI_LEEV_CON_COMPL           0x01
1946
1947 typedef struct {
1948         u_int8_t        status;
1949         u_int16_t       handle;
1950         u_int8_t        role;
1951         u_int8_t        address_type;
1952         bdaddr_t        address;
1953         u_int16_t       interval;
1954         u_int8_t        latency;
1955         u_int16_t       supervision_timeout;
1956         u_int8_t        master_clock_accracy;
1957         
1958 } __attribute__ ((packed)) ng_hci_le_connection_complete_ep;
1959
1960 #define NG_HCI_LEEV_ADVREP 0x02
1961 typedef struct {
1962         u_int8_t num_reports;
1963         
1964 }__attribute__ ((packed)) ng_hci_le_advertising_report_ep;
1965 #define NG_HCI_SCAN_RESPONSE_DATA_MAX 0x1f
1966
1967 typedef struct {
1968         u_int8_t event_type;
1969         u_int8_t addr_type;
1970         bdaddr_t bdaddr;
1971         u_int8_t length_data;
1972         u_int8_t data[NG_HCI_SCAN_RESPONSE_DATA_MAX];
1973 }__attribute__((packed)) ng_hci_le_advreport;
1974
1975 #define NG_HCI_LEEV_CON_UPDATE_COMPL 0x03
1976 typedef struct {
1977         u_int8_t status;
1978         u_int16_t connection_handle;
1979         u_int16_t conn_interval;
1980         u_int16_t conn_latency;
1981         u_int16_t supervision_timeout;
1982 }__attribute__((packed)) ng_hci_connection_update_complete_ep;
1983 #define NG_HCI_LEEV_READ_REMOTE_FEATURES_COMPL 0x04
1984 //TBD
1985 #define NG_HCI_LEEV_LONG_TERM_KEY_REQUEST 0x05
1986 //TBD
1987
1988
1989 #define NG_HCI_EVENT_BT_LOGO                    0xfe
1990
1991 #define NG_HCI_EVENT_VENDOR                     0xff
1992
1993 #endif /* ndef _NETGRAPH_HCI_H_ */