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