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