1107120Sjulian/*
2107120Sjulian * ng_hci.h
3139823Simp */
4139823Simp
5139823Simp/*-
6107120Sjulian * Copyright (c) 2001 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7107120Sjulian * All rights reserved.
8107120Sjulian *
9107120Sjulian * Redistribution and use in source and binary forms, with or without
10107120Sjulian * modification, are permitted provided that the following conditions
11107120Sjulian * are met:
12107120Sjulian * 1. Redistributions of source code must retain the above copyright
13107120Sjulian *    notice, this list of conditions and the following disclaimer.
14107120Sjulian * 2. Redistributions in binary form must reproduce the above copyright
15107120Sjulian *    notice, this list of conditions and the following disclaimer in the
16107120Sjulian *    documentation and/or other materials provided with the distribution.
17107120Sjulian *
18107120Sjulian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19107120Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20107120Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21107120Sjulian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22107120Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23107120Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24107120Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25107120Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26107120Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27107120Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28107120Sjulian * SUCH DAMAGE.
29107120Sjulian *
30114878Sjulian * $Id: ng_hci.h,v 1.2 2003/03/18 00:09:37 max Exp $
31107120Sjulian * $FreeBSD: releng/10.3/sys/netgraph/bluetooth/include/ng_hci.h 158672 2006-05-17 00:13:07Z emax $
32107120Sjulian */
33107120Sjulian
34107120Sjulian/*
35107120Sjulian * This file contains everything that application needs to know about
36107120Sjulian * Host Controller Interface (HCI). All information was obtained from
37107120Sjulian * Bluetooth Specification Book v1.1.
38107120Sjulian *
39107120Sjulian * This file can be included by both kernel and userland applications.
40107120Sjulian *
41107120Sjulian * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth
42107120Sjulian *       specification refers to both devices and units. They are the
43107120Sjulian *       same thing (i think), so to be consistent word "unit" will be
44107120Sjulian *       used.
45107120Sjulian */
46107120Sjulian
47107120Sjulian#ifndef _NETGRAPH_HCI_H_
48122634Semax#define _NETGRAPH_HCI_H_
49107120Sjulian
50107120Sjulian/**************************************************************************
51107120Sjulian **************************************************************************
52107120Sjulian **     Netgraph node hook name, type name and type cookie and commands
53107120Sjulian **************************************************************************
54107120Sjulian **************************************************************************/
55107120Sjulian
56107120Sjulian/* Node type name and type cookie */
57107120Sjulian#define NG_HCI_NODE_TYPE			"hci"
58107120Sjulian#define NGM_HCI_COOKIE				1000774184
59107120Sjulian
60107120Sjulian/* Netgraph node hook names */
61107120Sjulian#define NG_HCI_HOOK_DRV				"drv" /* Driver <-> HCI */
62107120Sjulian#define NG_HCI_HOOK_ACL				"acl" /* HCI <-> Upper */
63107120Sjulian#define NG_HCI_HOOK_SCO				"sco" /* HCI <-> Upper */
64107120Sjulian#define NG_HCI_HOOK_RAW				"raw" /* HCI <-> Upper */
65107120Sjulian
66107120Sjulian/**************************************************************************
67107120Sjulian **************************************************************************
68107120Sjulian **                   Common defines and types (HCI)
69107120Sjulian **************************************************************************
70107120Sjulian **************************************************************************/
71107120Sjulian
72107120Sjulian/* All sizes are in bytes */
73107120Sjulian#define NG_HCI_BDADDR_SIZE			6   /* unit address */
74107120Sjulian#define NG_HCI_LAP_SIZE				3   /* unit LAP */
75107120Sjulian#define NG_HCI_KEY_SIZE				16  /* link key */
76107120Sjulian#define NG_HCI_PIN_SIZE				16  /* link PIN */
77107120Sjulian#define NG_HCI_EVENT_MASK_SIZE			8   /* event mask */
78107120Sjulian#define NG_HCI_CLASS_SIZE			3   /* unit class */
79107120Sjulian#define NG_HCI_FEATURES_SIZE			8   /* LMP features */
80107120Sjulian#define NG_HCI_UNIT_NAME_SIZE			248 /* unit name size */
81107120Sjulian
82107120Sjulian/* HCI specification */
83107120Sjulian#define NG_HCI_SPEC_V10				0x00 /* v1.0 */
84107120Sjulian#define NG_HCI_SPEC_V11				0x01 /* v1.1 */
85107120Sjulian/* 0x02 - 0xFF - reserved for future use */
86107120Sjulian
87107120Sjulian/* LMP features */
88107120Sjulian/* ------------------- byte 0 --------------------*/
89107120Sjulian#define NG_HCI_LMP_3SLOT			0x01
90107120Sjulian#define NG_HCI_LMP_5SLOT			0x02
91107120Sjulian#define NG_HCI_LMP_ENCRYPTION			0x04
92107120Sjulian#define NG_HCI_LMP_SLOT_OFFSET			0x08
93107120Sjulian#define NG_HCI_LMP_TIMING_ACCURACY		0x10
94107120Sjulian#define NG_HCI_LMP_SWITCH			0x20
95107120Sjulian#define NG_HCI_LMP_HOLD_MODE			0x40
96107120Sjulian#define NG_HCI_LMP_SNIFF_MODE			0x80
97107120Sjulian/* ------------------- byte 1 --------------------*/
98107120Sjulian#define NG_HCI_LMP_PARK_MODE			0x01
99107120Sjulian#define NG_HCI_LMP_RSSI				0x02
100107120Sjulian#define NG_HCI_LMP_CHANNEL_QUALITY		0x04
101107120Sjulian#define NG_HCI_LMP_SCO_LINK			0x08
102107120Sjulian#define NG_HCI_LMP_HV2_PKT			0x10
103107120Sjulian#define NG_HCI_LMP_HV3_PKT			0x20
104107120Sjulian#define NG_HCI_LMP_ULAW_LOG			0x40
105107120Sjulian#define NG_HCI_LMP_ALAW_LOG			0x80
106107120Sjulian/* ------------------- byte 2 --------------------*/
107107120Sjulian#define NG_HCI_LMP_CVSD				0x01
108107120Sjulian#define NG_HCI_LMP_PAGING_SCHEME		0x02
109107120Sjulian#define NG_HCI_LMP_POWER_CONTROL		0x04
110107120Sjulian#define NG_HCI_LMP_TRANSPARENT_SCO		0x08
111107120Sjulian#define NG_HCI_LMP_FLOW_CONTROL_LAG0		0x10
112107120Sjulian#define NG_HCI_LMP_FLOW_CONTROL_LAG1		0x20
113107120Sjulian#define NG_HCI_LMP_FLOW_CONTROL_LAG2		0x40
114107120Sjulian
115107120Sjulian/* Link types */
116107120Sjulian#define NG_HCI_LINK_SCO				0x00 /* Voice */
117107120Sjulian#define NG_HCI_LINK_ACL				0x01 /* Data */
118107120Sjulian/* 0x02 - 0xFF - reserved for future use */
119107120Sjulian
120107120Sjulian/* Packet types */
121107120Sjulian				/* 0x0001 - 0x0004 - reserved for future use */
122107120Sjulian#define NG_HCI_PKT_DM1				0x0008 /* ACL link */
123107120Sjulian#define NG_HCI_PKT_DH1				0x0010 /* ACL link */
124107120Sjulian#define NG_HCI_PKT_HV1				0x0020 /* SCO link */
125107120Sjulian#define NG_HCI_PKT_HV2				0x0040 /* SCO link */
126107120Sjulian#define NG_HCI_PKT_HV3				0x0080 /* SCO link */
127107120Sjulian				/* 0x0100 - 0x0200 - reserved for future use */
128107120Sjulian#define NG_HCI_PKT_DM3				0x0400 /* ACL link */
129107120Sjulian#define NG_HCI_PKT_DH3				0x0800 /* ACL link */
130107120Sjulian				/* 0x1000 - 0x2000 - reserved for future use */
131107120Sjulian#define NG_HCI_PKT_DM5				0x4000 /* ACL link */
132107120Sjulian#define NG_HCI_PKT_DH5				0x8000 /* ACL link */
133107120Sjulian
134107120Sjulian/*
135107120Sjulian * Connection modes/Unit modes
136107120Sjulian *
137107120Sjulian * This is confusing. It means that one of the units change its mode
138107120Sjulian * for the specific connection. For example one connection was put on
139107120Sjulian * hold (but i could be wrong :)
140107120Sjulian */
141107120Sjulian
142107120Sjulian#define NG_HCI_UNIT_MODE_ACTIVE			0x00
143107120Sjulian#define NG_HCI_UNIT_MODE_HOLD			0x01
144107120Sjulian#define NG_HCI_UNIT_MODE_SNIFF			0x02
145107120Sjulian#define NG_HCI_UNIT_MODE_PARK			0x03
146107120Sjulian/* 0x04 - 0xFF - reserved for future use */
147107120Sjulian
148107120Sjulian/* Page scan modes */
149107120Sjulian#define NG_HCI_MANDATORY_PAGE_SCAN_MODE		0x00
150107120Sjulian#define NG_HCI_OPTIONAL_PAGE_SCAN_MODE1		0x01
151107120Sjulian#define NG_HCI_OPTIONAL_PAGE_SCAN_MODE2		0x02
152107120Sjulian#define NG_HCI_OPTIONAL_PAGE_SCAN_MODE3		0x03
153107120Sjulian/* 0x04 - 0xFF - reserved for future use */
154107120Sjulian
155107120Sjulian/* Page scan repetition modes */
156107120Sjulian#define NG_HCI_SCAN_REP_MODE0			0x00
157107120Sjulian#define NG_HCI_SCAN_REP_MODE1			0x01
158107120Sjulian#define NG_HCI_SCAN_REP_MODE2			0x02
159107120Sjulian/* 0x03 - 0xFF - reserved for future use */
160107120Sjulian
161107120Sjulian/* Page scan period modes */
162107120Sjulian#define NG_HCI_PAGE_SCAN_PERIOD_MODE0		0x00
163107120Sjulian#define NG_HCI_PAGE_SCAN_PERIOD_MODE1		0x01
164107120Sjulian#define NG_HCI_PAGE_SCAN_PERIOD_MODE2		0x02
165107120Sjulian/* 0x03 - 0xFF - reserved for future use */
166107120Sjulian
167107120Sjulian/* Scan enable */
168107120Sjulian#define NG_HCI_NO_SCAN_ENABLE			0x00
169107120Sjulian#define NG_HCI_INQUIRY_ENABLE_PAGE_DISABLE	0x01
170107120Sjulian#define NG_HCI_INQUIRY_DISABLE_PAGE_ENABLE	0x02
171107120Sjulian#define NG_HCI_INQUIRY_ENABLE_PAGE_ENABLE	0x03
172107120Sjulian/* 0x04 - 0xFF - reserved for future use */
173107120Sjulian
174107120Sjulian/* Hold mode activities */
175107120Sjulian#define NG_HCI_HOLD_MODE_NO_CHANGE		0x00
176107120Sjulian#define NG_HCI_HOLD_MODE_SUSPEND_PAGE_SCAN	0x01
177107120Sjulian#define NG_HCI_HOLD_MODE_SUSPEND_INQUIRY_SCAN	0x02
178107120Sjulian#define NG_HCI_HOLD_MODE_SUSPEND_PERIOD_INQUIRY	0x04
179107120Sjulian/* 0x08 - 0x80 - reserved for future use */
180107120Sjulian
181107120Sjulian/* Connection roles */
182107120Sjulian#define NG_HCI_ROLE_MASTER			0x00
183107120Sjulian#define NG_HCI_ROLE_SLAVE			0x01
184107120Sjulian/* 0x02 - 0xFF - reserved for future use */
185107120Sjulian
186107120Sjulian/* Key flags */
187107120Sjulian#define NG_HCI_USE_SEMI_PERMANENT_LINK_KEYS	0x00
188107120Sjulian#define NG_HCI_USE_TEMPORARY_LINK_KEY		0x01
189107120Sjulian/* 0x02 - 0xFF - reserved for future use */
190107120Sjulian
191107120Sjulian/* Pin types */
192107120Sjulian#define NG_HCI_PIN_TYPE_VARIABLE		0x00
193107120Sjulian#define NG_HCI_PIN_TYPE_FIXED			0x01
194107120Sjulian
195107120Sjulian/* Link key types */
196107120Sjulian#define NG_HCI_LINK_KEY_TYPE_COMBINATION_KEY	0x00
197107120Sjulian#define NG_HCI_LINK_KEY_TYPE_LOCAL_UNIT_KEY	0x01
198107120Sjulian#define NG_HCI_LINK_KEY_TYPE_REMOTE_UNIT_KEY	0x02
199107120Sjulian/* 0x03 - 0xFF - reserved for future use */
200107120Sjulian
201107120Sjulian/* Encryption modes */
202107120Sjulian#define NG_HCI_ENCRYPTION_MODE_NONE		0x00
203107120Sjulian#define NG_HCI_ENCRYPTION_MODE_P2P		0x01
204107120Sjulian#define NG_HCI_ENCRYPTION_MODE_ALL		0x02
205107120Sjulian/* 0x03 - 0xFF - reserved for future use */
206107120Sjulian
207107120Sjulian/* Quality of service types */
208107120Sjulian#define NG_HCI_SERVICE_TYPE_NO_TRAFFIC		0x00
209107120Sjulian#define NG_HCI_SERVICE_TYPE_BEST_EFFORT		0x01
210107120Sjulian#define NG_HCI_SERVICE_TYPE_GUARANTEED		0x02
211107120Sjulian/* 0x03 - 0xFF - reserved for future use */
212107120Sjulian
213107120Sjulian/* Link policy settings */
214107120Sjulian#define NG_HCI_LINK_POLICY_DISABLE_ALL_LM_MODES	0x0000
215107120Sjulian#define NG_HCI_LINK_POLICY_ENABLE_ROLE_SWITCH	0x0001 /* Master/Slave switch */
216107120Sjulian#define NG_HCI_LINK_POLICY_ENABLE_HOLD_MODE	0x0002
217107120Sjulian#define NG_HCI_LINK_POLICY_ENABLE_SNIFF_MODE	0x0004
218107120Sjulian#define NG_HCI_LINK_POLICY_ENABLE_PARK_MODE	0x0008
219107120Sjulian/* 0x0010 - 0x8000 - reserved for future use */
220107120Sjulian
221107120Sjulian/* Event masks */
222107120Sjulian#define NG_HCI_EVMSK_ALL			0x00000000ffffffff
223107120Sjulian#define NG_HCI_EVMSK_NONE			0x0000000000000000
224107120Sjulian#define NG_HCI_EVMSK_INQUIRY_COMPL		0x0000000000000001
225107120Sjulian#define NG_HCI_EVMSK_INQUIRY_RESULT		0x0000000000000002
226107120Sjulian#define NG_HCI_EVMSK_CON_COMPL			0x0000000000000004
227107120Sjulian#define NG_HCI_EVMSK_CON_REQ			0x0000000000000008
228107120Sjulian#define NG_HCI_EVMSK_DISCON_COMPL		0x0000000000000010
229107120Sjulian#define NG_HCI_EVMSK_AUTH_COMPL			0x0000000000000020
230107120Sjulian#define NG_HCI_EVMSK_REMOTE_NAME_REQ_COMPL	0x0000000000000040
231107120Sjulian#define NG_HCI_EVMSK_ENCRYPTION_CHANGE		0x0000000000000080
232107120Sjulian#define NG_HCI_EVMSK_CHANGE_CON_LINK_KEY_COMPL	0x0000000000000100
233107120Sjulian#define NG_HCI_EVMSK_MASTER_LINK_KEY_COMPL	0x0000000000000200
234107120Sjulian#define NG_HCI_EVMSK_READ_REMOTE_FEATURES_COMPL	0x0000000000000400
235107120Sjulian#define NG_HCI_EVMSK_READ_REMOTE_VER_INFO_COMPL	0x0000000000000800
236107120Sjulian#define NG_HCI_EVMSK_QOS_SETUP_COMPL		0x0000000000001000
237107120Sjulian#define NG_HCI_EVMSK_COMMAND_COMPL		0x0000000000002000
238107120Sjulian#define NG_HCI_EVMSK_COMMAND_STATUS		0x0000000000004000
239107120Sjulian#define NG_HCI_EVMSK_HARDWARE_ERROR		0x0000000000008000
240107120Sjulian#define NG_HCI_EVMSK_FLUSH_OCCUR		0x0000000000010000
241107120Sjulian#define NG_HCI_EVMSK_ROLE_CHANGE		0x0000000000020000
242107120Sjulian#define NG_HCI_EVMSK_NUM_COMPL_PKTS		0x0000000000040000
243107120Sjulian#define NG_HCI_EVMSK_MODE_CHANGE		0x0000000000080000
244107120Sjulian#define NG_HCI_EVMSK_RETURN_LINK_KEYS		0x0000000000100000
245107120Sjulian#define NG_HCI_EVMSK_PIN_CODE_REQ		0x0000000000200000
246107120Sjulian#define NG_HCI_EVMSK_LINK_KEY_REQ		0x0000000000400000
247107120Sjulian#define NG_HCI_EVMSK_LINK_KEY_NOTIFICATION	0x0000000000800000
248107120Sjulian#define NG_HCI_EVMSK_LOOPBACK_COMMAND		0x0000000001000000
249107120Sjulian#define NG_HCI_EVMSK_DATA_BUFFER_OVERFLOW	0x0000000002000000
250107120Sjulian#define NG_HCI_EVMSK_MAX_SLOT_CHANGE		0x0000000004000000
251107120Sjulian#define NG_HCI_EVMSK_READ_CLOCK_OFFSET_COMLETE	0x0000000008000000
252107120Sjulian#define NG_HCI_EVMSK_CON_PKT_TYPE_CHANGED	0x0000000010000000
253107120Sjulian#define NG_HCI_EVMSK_QOS_VIOLATION		0x0000000020000000
254107120Sjulian#define NG_HCI_EVMSK_PAGE_SCAN_MODE_CHANGE	0x0000000040000000
255107120Sjulian#define NG_HCI_EVMSK_PAGE_SCAN_REP_MODE_CHANGE	0x0000000080000000
256107120Sjulian/* 0x0000000100000000 - 0x8000000000000000 - reserved for future use */
257107120Sjulian
258107120Sjulian/* Filter types */
259107120Sjulian#define NG_HCI_FILTER_TYPE_NONE			0x00
260107120Sjulian#define NG_HCI_FILTER_TYPE_INQUIRY_RESULT	0x01
261107120Sjulian#define NG_HCI_FILTER_TYPE_CON_SETUP		0x02
262107120Sjulian/* 0x03 - 0xFF - reserved for future use */
263107120Sjulian
264107120Sjulian/* Filter condition types for NG_HCI_FILTER_TYPE_INQUIRY_RESULT */
265107120Sjulian#define NG_HCI_FILTER_COND_INQUIRY_NEW_UNIT	0x00
266107120Sjulian#define NG_HCI_FILTER_COND_INQUIRY_UNIT_CLASS	0x01
267107120Sjulian#define NG_HCI_FILTER_COND_INQUIRY_BDADDR	0x02
268107120Sjulian/* 0x03 - 0xFF - reserved for future use */
269107120Sjulian
270107120Sjulian/* Filter condition types for NG_HCI_FILTER_TYPE_CON_SETUP */
271107120Sjulian#define NG_HCI_FILTER_COND_CON_ANY_UNIT		0x00
272107120Sjulian#define NG_HCI_FILTER_COND_CON_UNIT_CLASS	0x01
273107120Sjulian#define NG_HCI_FILTER_COND_CON_BDADDR		0x02
274107120Sjulian/* 0x03 - 0xFF - reserved for future use */
275107120Sjulian
276107120Sjulian/* Xmit level types */
277107120Sjulian#define NG_HCI_XMIT_LEVEL_CURRENT		0x00
278107120Sjulian#define NG_HCI_XMIT_LEVEL_MAXIMUM		0x01
279107120Sjulian/* 0x02 - 0xFF - reserved for future use */
280107120Sjulian
281107120Sjulian/* Host to Host Controller flow control */
282107120Sjulian#define NG_HCI_H2HC_FLOW_CONTROL_NONE		0x00
283107120Sjulian#define NG_HCI_H2HC_FLOW_CONTROL_ACL		0x01
284107120Sjulian#define NG_HCI_H2HC_FLOW_CONTROL_SCO		0x02
285107120Sjulian#define NG_HCI_H2HC_FLOW_CONTROL_BOTH		0x03	/* ACL and SCO */
286107120Sjulian/* 0x04 - 0xFF - reserved future use */
287107120Sjulian
288107120Sjulian/* Country codes */
289107120Sjulian#define NG_HCI_COUNTRY_CODE_NAM_EUR_JP		0x00
290107120Sjulian#define NG_HCI_COUNTRY_CODE_FRANCE		0x01
291107120Sjulian/* 0x02 - 0xFF - reserved future use */
292107120Sjulian
293107120Sjulian/* Loopback modes */
294107120Sjulian#define NG_HCI_LOOPBACK_NONE			0x00
295107120Sjulian#define NG_HCI_LOOPBACK_LOCAL			0x01
296107120Sjulian#define NG_HCI_LOOPBACK_REMOTE			0x02
297107120Sjulian/* 0x03 - 0xFF - reserved future use */
298107120Sjulian
299107120Sjulian/**************************************************************************
300107120Sjulian **************************************************************************
301107120Sjulian **                 Link level defines, headers and types
302107120Sjulian **************************************************************************
303107120Sjulian **************************************************************************/
304107120Sjulian
305107120Sjulian/*
306107120Sjulian * Macro(s) to combine OpCode and extract OGF (OpCode Group Field)
307107120Sjulian * and OCF (OpCode Command Field) from OpCode.
308107120Sjulian */
309107120Sjulian
310107120Sjulian#define NG_HCI_OPCODE(gf,cf)		((((gf) & 0x3f) << 10) | ((cf) & 0x3ff))
311107120Sjulian#define NG_HCI_OCF(op)			((op) & 0x3ff)
312107120Sjulian#define NG_HCI_OGF(op)			(((op) >> 10) & 0x3f)
313107120Sjulian
314107120Sjulian/*
315107120Sjulian * Marco(s) to extract/combine connection handle, BC (Broadcast) and
316107120Sjulian * PB (Packet boundary) flags.
317107120Sjulian */
318107120Sjulian
319107120Sjulian#define NG_HCI_CON_HANDLE(h)		((h) & 0x0fff)
320107120Sjulian#define NG_HCI_PB_FLAG(h)		(((h) & 0x3000) >> 12)
321107120Sjulian#define NG_HCI_BC_FLAG(h)		(((h) & 0xc000) >> 14)
322107120Sjulian#define NG_HCI_MK_CON_HANDLE(h, pb, bc) \
323107120Sjulian	(((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14))
324107120Sjulian
325107120Sjulian/* PB flag values */
326107120Sjulian					/* 00 - reserved for future use */
327107120Sjulian#define	NG_HCI_PACKET_FRAGMENT		0x1
328107120Sjulian#define	NG_HCI_PACKET_START		0x2
329107120Sjulian					/* 11 - reserved for future use */
330107120Sjulian
331107120Sjulian/* BC flag values */
332107120Sjulian#define NG_HCI_POINT2POINT		0x0 /* only Host controller to Host */
333107120Sjulian#define NG_HCI_BROADCAST_ACTIVE		0x1 /* both directions */
334107120Sjulian#define NG_HCI_BROADCAST_PICONET	0x2 /* both directions */
335107120Sjulian					/* 11 - reserved for future use */
336107120Sjulian
337107120Sjulian/* HCI command packet header */
338107120Sjulian#define NG_HCI_CMD_PKT			0x01
339107120Sjulian#define NG_HCI_CMD_PKT_SIZE		0xff /* without header */
340107120Sjuliantypedef struct {
341107120Sjulian	u_int8_t	type;   /* MUST be 0x1 */
342107120Sjulian	u_int16_t	opcode; /* OpCode */
343107120Sjulian	u_int8_t	length; /* parameter(s) length in bytes */
344107120Sjulian} __attribute__ ((packed)) ng_hci_cmd_pkt_t;
345107120Sjulian
346107120Sjulian/* ACL data packet header */
347107120Sjulian#define NG_HCI_ACL_DATA_PKT		0x02
348107120Sjulian#define NG_HCI_ACL_PKT_SIZE		0xffff /* without header */
349107120Sjuliantypedef struct {
350107120Sjulian	u_int8_t	type;        /* MUST be 0x2 */
351107120Sjulian	u_int16_t	con_handle;  /* connection handle + PB + BC flags */
352107120Sjulian	u_int16_t	length;      /* payload length in bytes */
353107120Sjulian} __attribute__ ((packed)) ng_hci_acldata_pkt_t;
354107120Sjulian
355107120Sjulian/* SCO data packet header */
356107120Sjulian#define NG_HCI_SCO_DATA_PKT		0x03
357107120Sjulian#define NG_HCI_SCO_PKT_SIZE		0xff /* without header */
358107120Sjuliantypedef struct {
359107120Sjulian	u_int8_t	type;       /* MUST be 0x3 */
360107120Sjulian	u_int16_t	con_handle; /* connection handle + reserved bits */
361107120Sjulian	u_int8_t	length;     /* payload length in bytes */
362107120Sjulian} __attribute__ ((packed)) ng_hci_scodata_pkt_t;
363107120Sjulian
364107120Sjulian/* HCI event packet header */
365107120Sjulian#define NG_HCI_EVENT_PKT		0x04
366107120Sjulian#define NG_HCI_EVENT_PKT_SIZE		0xff /* without header */
367107120Sjuliantypedef struct {
368107120Sjulian	u_int8_t	type;   /* MUST be 0x4 */
369107120Sjulian	u_int8_t	event;  /* event */
370107120Sjulian	u_int8_t	length; /* parameter(s) length in bytes */
371107120Sjulian} __attribute__ ((packed)) ng_hci_event_pkt_t;
372107120Sjulian
373107120Sjulian/* Bluetooth unit address */
374107120Sjuliantypedef struct {
375107120Sjulian	u_int8_t	b[NG_HCI_BDADDR_SIZE];
376107120Sjulian} __attribute__ ((packed)) bdaddr_t;
377107120Sjuliantypedef bdaddr_t *	bdaddr_p;
378107120Sjulian
379107120Sjulian/* Any BD_ADDR. Note: This is actually 7 bytes (count '\0' terminator) */
380107120Sjulian#define NG_HCI_BDADDR_ANY	((bdaddr_p) "\000\000\000\000\000\000")
381107120Sjulian
382107120Sjulian/* HCI status return parameter */
383107120Sjuliantypedef struct {
384107120Sjulian	u_int8_t	status; /* 0x00 - success */
385107120Sjulian} __attribute__ ((packed)) ng_hci_status_rp;
386107120Sjulian
387107120Sjulian/**************************************************************************
388107120Sjulian **************************************************************************
389107120Sjulian **        Upper layer protocol interface. LP_xxx event parameters
390107120Sjulian **************************************************************************
391107120Sjulian **************************************************************************/
392107120Sjulian
393107120Sjulian/* Connection Request Event */
394107120Sjulian#define NGM_HCI_LP_CON_REQ			1  /* Upper -> HCI */
395107120Sjuliantypedef struct {
396107120Sjulian	u_int16_t	link_type; /* type of connection */
397107120Sjulian	bdaddr_t	bdaddr;    /* remote unit address */
398107120Sjulian} ng_hci_lp_con_req_ep;
399107120Sjulian
400107120Sjulian/*
401107120Sjulian * XXX XXX XXX
402107120Sjulian *
403107120Sjulian * NOTE: This request is not defined by Bluetooth specification,
404107120Sjulian * but i find it useful :)
405107120Sjulian */
406107120Sjulian#define NGM_HCI_LP_DISCON_REQ			2 /* Upper -> HCI */
407107120Sjuliantypedef struct {
408107120Sjulian	u_int16_t	con_handle; /* connection handle */
409107120Sjulian	u_int16_t	reason;	    /* reason to disconnect (only low byte) */
410107120Sjulian} ng_hci_lp_discon_req_ep;
411107120Sjulian
412107120Sjulian/* Connection Confirmation Event */
413107120Sjulian#define NGM_HCI_LP_CON_CFM			3  /* HCI -> Upper */
414107120Sjuliantypedef struct {
415107120Sjulian	u_int8_t	status;     /* 0x00 - success */
416107120Sjulian	u_int8_t	link_type;  /* link type */
417107120Sjulian	u_int16_t	con_handle; /* con_handle */
418107120Sjulian	bdaddr_t	bdaddr;     /* remote unit address */
419107120Sjulian} ng_hci_lp_con_cfm_ep;
420107120Sjulian
421107120Sjulian/* Connection Indication Event */
422107120Sjulian#define NGM_HCI_LP_CON_IND			4  /* HCI -> Upper */
423107120Sjuliantypedef struct {
424107120Sjulian	u_int8_t	link_type;                 /* link type */
425107120Sjulian	u_int8_t	uclass[NG_HCI_CLASS_SIZE]; /* unit class */
426107120Sjulian	bdaddr_t	bdaddr;                    /* remote unit address */
427107120Sjulian} ng_hci_lp_con_ind_ep;
428107120Sjulian
429107120Sjulian/* Connection Response Event */
430107120Sjulian#define NGM_HCI_LP_CON_RSP			5  /* Upper -> HCI */
431107120Sjuliantypedef struct {
432107120Sjulian	u_int8_t	status;    /* 0x00 - accept connection */
433107120Sjulian	u_int8_t	link_type; /* link type */
434107120Sjulian	bdaddr_t	bdaddr;    /* remote unit address */
435107120Sjulian} ng_hci_lp_con_rsp_ep;
436107120Sjulian
437107120Sjulian/* Disconnection Indication Event */
438107120Sjulian#define NGM_HCI_LP_DISCON_IND			6  /* HCI -> Upper */
439107120Sjuliantypedef struct {
440107120Sjulian	u_int8_t	reason;     /* reason to disconnect (only low byte) */
441107120Sjulian	u_int8_t	link_type;  /* link type */
442107120Sjulian	u_int16_t	con_handle; /* connection handle */
443107120Sjulian} ng_hci_lp_discon_ind_ep;
444107120Sjulian
445107120Sjulian/* QoS Setup Request Event */
446107120Sjulian#define NGM_HCI_LP_QOS_REQ			7  /* Upper -> HCI */
447107120Sjuliantypedef struct {
448107120Sjulian	u_int16_t	con_handle;      /* connection handle */
449107120Sjulian	u_int8_t	flags;           /* reserved */
450107120Sjulian	u_int8_t	service_type;    /* service type */
451107120Sjulian	u_int32_t	token_rate;      /* bytes/sec */
452107120Sjulian	u_int32_t	peak_bandwidth;  /* bytes/sec */
453107120Sjulian	u_int32_t	latency;         /* msec */
454107120Sjulian	u_int32_t	delay_variation; /* msec */
455107120Sjulian} ng_hci_lp_qos_req_ep;
456107120Sjulian
457107120Sjulian/* QoS Conformition Event */
458107120Sjulian#define NGM_HCI_LP_QOS_CFM			8  /* HCI -> Upper */
459107120Sjuliantypedef struct {
460107120Sjulian	u_int16_t	status;          /* 0x00 - success  (only low byte) */
461107120Sjulian	u_int16_t	con_handle;      /* connection handle */
462107120Sjulian} ng_hci_lp_qos_cfm_ep;
463107120Sjulian
464107120Sjulian/* QoS Violation Indication Event */
465107120Sjulian#define NGM_HCI_LP_QOS_IND			9  /* HCI -> Upper */
466107120Sjuliantypedef struct {
467107120Sjulian	u_int16_t	con_handle; /* connection handle */
468107120Sjulian} ng_hci_lp_qos_ind_ep;
469107120Sjulian
470107120Sjulian/**************************************************************************
471107120Sjulian **************************************************************************
472107120Sjulian **                    HCI node command/event parameters
473107120Sjulian **************************************************************************
474107120Sjulian **************************************************************************/
475107120Sjulian
476107120Sjulian/* Debug levels */
477107120Sjulian#define NG_HCI_ALERT_LEVEL		1
478107120Sjulian#define NG_HCI_ERR_LEVEL		2
479107120Sjulian#define NG_HCI_WARN_LEVEL		3
480107120Sjulian#define NG_HCI_INFO_LEVEL		4
481107120Sjulian
482107120Sjulian/* Unit states */
483107120Sjulian#define NG_HCI_UNIT_CONNECTED		(1 << 0)
484107120Sjulian#define NG_HCI_UNIT_INITED		(1 << 1)
485107120Sjulian#define NG_HCI_UNIT_READY	(NG_HCI_UNIT_CONNECTED|NG_HCI_UNIT_INITED)
486107120Sjulian#define NG_HCI_UNIT_COMMAND_PENDING	(1 << 2)
487107120Sjulian
488107120Sjulian/* Connection state */
489107120Sjulian#define NG_HCI_CON_CLOSED		0 /* connection closed */
490107120Sjulian#define NG_HCI_CON_W4_LP_CON_RSP	1 /* wait for LP_ConnectRsp */
491107120Sjulian#define NG_HCI_CON_W4_CONN_COMPLETE	2 /* wait for Connection_Complete evt */
492107120Sjulian#define NG_HCI_CON_OPEN			3 /* connection open */
493107120Sjulian
494107120Sjulian/* Get HCI node (unit) state (see states above) */
495107120Sjulian#define NGM_HCI_NODE_GET_STATE			100  /* HCI -> User */
496107120Sjuliantypedef u_int16_t	ng_hci_node_state_ep;
497107120Sjulian
498107120Sjulian/* Turn on "inited" bit */
499107120Sjulian#define NGM_HCI_NODE_INIT			101 /* User -> HCI */
500107120Sjulian/* No parameters */
501107120Sjulian
502107120Sjulian/* Get/Set node debug level (see debug levels above) */
503107120Sjulian#define NGM_HCI_NODE_GET_DEBUG			102 /* HCI -> User */
504107120Sjulian#define NGM_HCI_NODE_SET_DEBUG			103 /* User -> HCI */
505107120Sjuliantypedef u_int16_t	ng_hci_node_debug_ep;
506107120Sjulian
507107120Sjulian/* Get node buffer info */
508107120Sjulian#define NGM_HCI_NODE_GET_BUFFER			104 /* HCI -> User */
509107120Sjuliantypedef struct {
510107120Sjulian	u_int8_t	cmd_free; /* number of free command packets */
511107120Sjulian	u_int8_t	sco_size; /* max. size of SCO packet */
512107120Sjulian	u_int16_t	sco_pkts; /* number of SCO packets */
513107120Sjulian	u_int16_t	sco_free; /* number of free SCO packets */
514107120Sjulian	u_int16_t	acl_size; /* max. size of ACL packet */
515107120Sjulian	u_int16_t	acl_pkts; /* number of ACL packets */
516107120Sjulian	u_int16_t	acl_free; /* number of free ACL packets */
517107120Sjulian} ng_hci_node_buffer_ep;
518107120Sjulian
519107120Sjulian/* Get BDADDR */
520107120Sjulian#define NGM_HCI_NODE_GET_BDADDR			105 /* HCI -> User */
521107120Sjulian/* bdaddr_t -- BDADDR */
522107120Sjulian
523107120Sjulian/* Get features */
524107120Sjulian#define NGM_HCI_NODE_GET_FEATURES		106 /* HCI -> User */
525107120Sjulian/* features[NG_HCI_FEATURES_SIZE] -- features */
526107120Sjulian
527107120Sjulian#define NGM_HCI_NODE_GET_STAT			107 /* HCI -> User */
528107120Sjuliantypedef struct {
529107120Sjulian	u_int32_t	cmd_sent;   /* number of HCI commands sent */
530107120Sjulian	u_int32_t	evnt_recv;  /* number of HCI events received */
531107120Sjulian	u_int32_t	acl_recv;   /* number of ACL packets received */
532107120Sjulian	u_int32_t	acl_sent;   /* number of ACL packets sent */
533107120Sjulian	u_int32_t	sco_recv;   /* number of SCO packets received */
534107120Sjulian	u_int32_t	sco_sent;   /* number of SCO packets sent */
535107120Sjulian	u_int32_t	bytes_recv; /* total number of bytes received */
536107120Sjulian	u_int32_t	bytes_sent; /* total number of bytes sent */
537107120Sjulian} ng_hci_node_stat_ep;
538107120Sjulian
539107120Sjulian#define NGM_HCI_NODE_RESET_STAT			108 /* User -> HCI */
540107120Sjulian/* No parameters */
541107120Sjulian
542107120Sjulian#define NGM_HCI_NODE_FLUSH_NEIGHBOR_CACHE	109 /* User -> HCI */
543107120Sjulian
544107120Sjulian#define NGM_HCI_NODE_GET_NEIGHBOR_CACHE		110 /* HCI -> User */
545107120Sjuliantypedef struct {
546107120Sjulian	u_int32_t	num_entries;	/* number of entries */
547107120Sjulian} ng_hci_node_get_neighbor_cache_ep;
548107120Sjulian
549107120Sjuliantypedef struct {
550107120Sjulian	u_int16_t	page_scan_rep_mode;             /* page rep scan mode */
551107120Sjulian	u_int16_t	page_scan_mode;                 /* page scan mode */
552107120Sjulian	u_int16_t	clock_offset;                   /* clock offset */
553107120Sjulian	bdaddr_t	bdaddr;                         /* bdaddr */
554107120Sjulian	u_int8_t	features[NG_HCI_FEATURES_SIZE]; /* features */
555107120Sjulian} ng_hci_node_neighbor_cache_entry_ep;
556107120Sjulian
557107120Sjulian#define NG_HCI_MAX_NEIGHBOR_NUM \
558107120Sjulian	((0xffff - sizeof(ng_hci_node_get_neighbor_cache_ep))/sizeof(ng_hci_node_neighbor_cache_entry_ep))
559107120Sjulian
560107120Sjulian#define NGM_HCI_NODE_GET_CON_LIST		111 /* HCI -> User */
561107120Sjuliantypedef struct {
562107120Sjulian	u_int32_t	num_connections; /* number of connections */
563107120Sjulian} ng_hci_node_con_list_ep;
564107120Sjulian
565107120Sjuliantypedef struct {
566107120Sjulian	u_int8_t	link_type;       /* ACL or SCO */
567107120Sjulian	u_int8_t	encryption_mode; /* none, p2p, ... */
568107120Sjulian	u_int8_t	mode;            /* ACTIVE, HOLD ... */
569107120Sjulian	u_int8_t	role;            /* MASTER/SLAVE */
570107120Sjulian	u_int16_t	state;           /* connection state */
571107120Sjulian	u_int16_t	reserved;        /* place holder */
572107120Sjulian	u_int16_t	pending;         /* number of pending packets */
573107120Sjulian	u_int16_t	queue_len;       /* number of packets in queue */
574107120Sjulian	u_int16_t	con_handle;      /* connection handle */
575107120Sjulian	bdaddr_t	bdaddr;          /* remote bdaddr */
576107120Sjulian} ng_hci_node_con_ep;
577107120Sjulian
578107120Sjulian#define NG_HCI_MAX_CON_NUM \
579107120Sjulian	((0xffff - sizeof(ng_hci_node_con_list_ep))/sizeof(ng_hci_node_con_ep))
580107120Sjulian
581107120Sjulian#define NGM_HCI_NODE_UP				112 /* HCI -> Upper */
582107120Sjuliantypedef struct {
583107120Sjulian	u_int16_t	pkt_size; /* max. ACL/SCO packet size (w/out header) */
584107120Sjulian	u_int16_t	num_pkts; /* ACL/SCO packet queue size */
585107120Sjulian	u_int16_t	reserved; /* place holder */
586107120Sjulian	bdaddr_t	bdaddr;	  /* bdaddr */
587107120Sjulian} ng_hci_node_up_ep;
588107120Sjulian
589107120Sjulian#define NGM_HCI_SYNC_CON_QUEUE			113 /* HCI -> Upper */
590107120Sjuliantypedef struct {
591107120Sjulian	u_int16_t	con_handle; /* connection handle */
592107120Sjulian	u_int16_t	completed;  /* number of completed packets */
593107120Sjulian} ng_hci_sync_con_queue_ep;
594107120Sjulian
595107120Sjulian#define NGM_HCI_NODE_GET_LINK_POLICY_SETTINGS_MASK	114 /* HCI -> User */
596107120Sjulian#define NGM_HCI_NODE_SET_LINK_POLICY_SETTINGS_MASK	115 /* User -> HCI */
597107120Sjuliantypedef u_int16_t	ng_hci_node_link_policy_mask_ep;
598107120Sjulian
599107120Sjulian#define NGM_HCI_NODE_GET_PACKET_MASK		116 /* HCI -> User */
600107120Sjulian#define NGM_HCI_NODE_SET_PACKET_MASK		117 /* User -> HCI */
601107120Sjuliantypedef u_int16_t	ng_hci_node_packet_mask_ep;
602107120Sjulian
603114878Sjulian#define NGM_HCI_NODE_GET_ROLE_SWITCH		118 /* HCI -> User */
604114878Sjulian#define NGM_HCI_NODE_SET_ROLE_SWITCH		119 /* User -> HCI */
605114878Sjuliantypedef u_int16_t	ng_hci_node_role_switch_ep;
606114878Sjulian
607158672Semax#define	NGM_HCI_NODE_LIST_NAMES			200 /* HCI -> User */
608158672Semax
609107120Sjulian/**************************************************************************
610107120Sjulian **************************************************************************
611107120Sjulian **             Link control commands and return parameters
612107120Sjulian **************************************************************************
613107120Sjulian **************************************************************************/
614107120Sjulian
615107120Sjulian#define NG_HCI_OGF_LINK_CONTROL			0x01 /* OpCode Group Field */
616107120Sjulian
617107120Sjulian#define NG_HCI_OCF_INQUIRY			0x0001
618107120Sjuliantypedef struct {
619107120Sjulian	u_int8_t	lap[NG_HCI_LAP_SIZE]; /* LAP */
620107120Sjulian	u_int8_t	inquiry_length; /* (N x 1.28) sec */
621107120Sjulian	u_int8_t	num_responses;  /* Max. # of responses before halted */
622107120Sjulian} __attribute__ ((packed)) ng_hci_inquiry_cp;
623107120Sjulian/* No return parameter(s) */
624107120Sjulian
625107120Sjulian#define NG_HCI_OCF_INQUIRY_CANCEL		0x0002
626107120Sjulian/* No command parameter(s) */
627107120Sjuliantypedef ng_hci_status_rp	ng_hci_inquiry_cancel_rp;
628107120Sjulian
629107120Sjulian#define NG_HCI_OCF_PERIODIC_INQUIRY		0x0003
630107120Sjuliantypedef struct {
631107120Sjulian	u_int16_t	max_period_length; /* Max. and min. amount of time */
632107120Sjulian	u_int16_t	min_period_length; /* between consecutive inquiries */
633107120Sjulian	u_int8_t	lap[NG_HCI_LAP_SIZE]; /* LAP */
634107120Sjulian	u_int8_t	inquiry_length;    /* (inquiry_length * 1.28) sec */
635107120Sjulian	u_int8_t	num_responses;     /* Max. # of responses */
636107120Sjulian} __attribute__ ((packed)) ng_hci_periodic_inquiry_cp;
637107120Sjulian
638107120Sjuliantypedef ng_hci_status_rp	ng_hci_periodic_inquiry_rp;
639107120Sjulian
640107120Sjulian#define NG_HCI_OCF_EXIT_PERIODIC_INQUIRY	0x0004
641107120Sjulian/* No command parameter(s) */
642107120Sjuliantypedef ng_hci_status_rp	ng_hci_exit_periodic_inquiry_rp;
643107120Sjulian
644107120Sjulian#define NG_HCI_OCF_CREATE_CON			0x0005
645107120Sjuliantypedef struct {
646107120Sjulian	bdaddr_t	bdaddr;             /* destination address */
647107120Sjulian	u_int16_t	pkt_type;           /* packet type */
648107120Sjulian	u_int8_t	page_scan_rep_mode; /* page scan repetition mode */
649107120Sjulian	u_int8_t	page_scan_mode;     /* page scan mode */
650107120Sjulian	u_int16_t	clock_offset;       /* clock offset */
651107120Sjulian	u_int8_t	accept_role_switch; /* accept role switch? 0x00 - no */
652107120Sjulian} __attribute__ ((packed)) ng_hci_create_con_cp;
653107120Sjulian/* No return parameter(s) */
654107120Sjulian
655107120Sjulian#define NG_HCI_OCF_DISCON			0x0006
656107120Sjuliantypedef struct {
657107120Sjulian	u_int16_t	con_handle; /* connection handle */
658107120Sjulian	u_int8_t	reason;     /* reason to disconnect */
659107120Sjulian} __attribute__ ((packed)) ng_hci_discon_cp;
660107120Sjulian/* No return parameter(s) */
661107120Sjulian
662107120Sjulian#define NG_HCI_OCF_ADD_SCO_CON			0x0007
663107120Sjuliantypedef struct {
664107120Sjulian	u_int16_t	con_handle; /* connection handle */
665107120Sjulian	u_int16_t	pkt_type;   /* packet type */
666107120Sjulian} __attribute__ ((packed)) ng_hci_add_sco_con_cp;
667107120Sjulian/* No return parameter(s) */
668107120Sjulian
669107120Sjulian#define NG_HCI_OCF_ACCEPT_CON			0x0009
670107120Sjuliantypedef struct {
671107120Sjulian	bdaddr_t	bdaddr; /* address of unit to be connected */
672107120Sjulian	u_int8_t	role;   /* connection role */
673107120Sjulian} __attribute__ ((packed)) ng_hci_accept_con_cp;
674107120Sjulian/* No return parameter(s) */
675107120Sjulian
676107120Sjulian#define NG_HCI_OCF_REJECT_CON			0x000a
677107120Sjuliantypedef struct {
678107120Sjulian	bdaddr_t	bdaddr; /* remote address */
679107120Sjulian	u_int8_t	reason; /* reason to reject */
680107120Sjulian} __attribute__ ((packed)) ng_hci_reject_con_cp;
681107120Sjulian/* No return parameter(s) */
682107120Sjulian
683107120Sjulian#define NG_HCI_OCF_LINK_KEY_REP			0x000b
684107120Sjuliantypedef struct {
685107120Sjulian	bdaddr_t	bdaddr;               /* remote address */
686107120Sjulian	u_int8_t	key[NG_HCI_KEY_SIZE]; /* key */
687107120Sjulian} __attribute__ ((packed)) ng_hci_link_key_rep_cp;
688107120Sjulian
689107120Sjuliantypedef struct {
690107120Sjulian	u_int8_t	status; /* 0x00 - success */
691107120Sjulian	bdaddr_t	bdaddr; /* unit address */
692107120Sjulian} __attribute__ ((packed)) ng_hci_link_key_rep_rp;
693107120Sjulian
694107120Sjulian#define NG_HCI_OCF_LINK_KEY_NEG_REP		0x000c
695107120Sjuliantypedef struct {
696107120Sjulian	bdaddr_t	bdaddr; /* remote address */
697107120Sjulian} __attribute__ ((packed)) ng_hci_link_key_neg_rep_cp;
698107120Sjulian
699107120Sjuliantypedef struct {
700107120Sjulian	u_int8_t	status; /* 0x00 - success */
701107120Sjulian	bdaddr_t	bdaddr; /* unit address */
702107120Sjulian} __attribute__ ((packed)) ng_hci_link_key_neg_rep_rp;
703107120Sjulian
704107120Sjulian#define NG_HCI_OCF_PIN_CODE_REP			0x000d
705107120Sjuliantypedef struct {
706107120Sjulian	bdaddr_t	bdaddr;               /* remote address */
707107120Sjulian	u_int8_t	pin_size;             /* pin code length (in bytes) */
708107120Sjulian	u_int8_t	pin[NG_HCI_PIN_SIZE]; /* pin code */
709107120Sjulian} __attribute__ ((packed)) ng_hci_pin_code_rep_cp;
710107120Sjulian
711107120Sjuliantypedef struct {
712107120Sjulian	u_int8_t	status; /* 0x00 - success */
713107120Sjulian	bdaddr_t	bdaddr; /* unit address */
714107120Sjulian} __attribute__ ((packed)) ng_hci_pin_code_rep_rp;
715107120Sjulian
716107120Sjulian#define NG_HCI_OCF_PIN_CODE_NEG_REP		0x000e
717107120Sjuliantypedef struct {
718107120Sjulian	bdaddr_t	bdaddr;  /* remote address */
719107120Sjulian} __attribute__ ((packed)) ng_hci_pin_code_neg_rep_cp;
720107120Sjulian
721107120Sjuliantypedef struct {
722107120Sjulian	u_int8_t	status; /* 0x00 - success */
723107120Sjulian	bdaddr_t	bdaddr; /* unit address */
724107120Sjulian} __attribute__ ((packed)) ng_hci_pin_code_neg_rep_rp;
725107120Sjulian
726107120Sjulian#define NG_HCI_OCF_CHANGE_CON_PKT_TYPE		0x000f
727107120Sjuliantypedef struct {
728107120Sjulian	u_int16_t	con_handle; /* connection handle */
729107120Sjulian	u_int16_t	pkt_type;   /* packet type */
730107120Sjulian} __attribute__ ((packed)) ng_hci_change_con_pkt_type_cp;
731107120Sjulian/* No return parameter(s) */
732107120Sjulian
733107120Sjulian#define NG_HCI_OCF_AUTH_REQ			0x0011
734107120Sjuliantypedef struct {
735107120Sjulian	u_int16_t	con_handle; /* connection handle */
736107120Sjulian} __attribute__ ((packed)) ng_hci_auth_req_cp;
737107120Sjulian/* No return parameter(s) */
738107120Sjulian
739107120Sjulian#define NG_HCI_OCF_SET_CON_ENCRYPTION		0x0013
740107120Sjuliantypedef struct {
741107120Sjulian	u_int16_t	con_handle;        /* connection handle */
742107120Sjulian	u_int8_t	encryption_enable; /* 0x00 - disable, 0x01 - enable */
743107120Sjulian} __attribute__ ((packed)) ng_hci_set_con_encryption_cp;
744107120Sjulian/* No return parameter(s) */
745107120Sjulian
746107120Sjulian#define NG_HCI_OCF_CHANGE_CON_LINK_KEY		0x0015
747107120Sjuliantypedef struct {
748107120Sjulian	u_int16_t	con_handle; /* connection handle */
749107120Sjulian} __attribute__ ((packed)) ng_hci_change_con_link_key_cp;
750107120Sjulian/* No return parameter(s) */
751107120Sjulian
752107120Sjulian#define NG_HCI_OCF_MASTER_LINK_KEY		0x0017
753107120Sjuliantypedef struct {
754107120Sjulian	u_int8_t	key_flag; /* key flag */
755107120Sjulian} __attribute__ ((packed)) ng_hci_master_link_key_cp;
756107120Sjulian/* No return parameter(s) */
757107120Sjulian
758107120Sjulian#define NG_HCI_OCF_REMOTE_NAME_REQ		0x0019
759107120Sjuliantypedef struct {
760107120Sjulian	bdaddr_t	bdaddr;             /* remote address */
761107120Sjulian	u_int8_t	page_scan_rep_mode; /* page scan repetition mode */
762107120Sjulian	u_int8_t	page_scan_mode;     /* page scan mode */
763107120Sjulian	u_int16_t	clock_offset;       /* clock offset */
764107120Sjulian} __attribute__ ((packed)) ng_hci_remote_name_req_cp;
765107120Sjulian/* No return parameter(s) */
766107120Sjulian
767107120Sjulian#define NG_HCI_OCF_READ_REMOTE_FEATURES		0x001b
768107120Sjuliantypedef struct {
769107120Sjulian	u_int16_t	con_handle; /* connection handle */
770107120Sjulian} __attribute__ ((packed)) ng_hci_read_remote_features_cp;
771107120Sjulian/* No return parameter(s) */
772107120Sjulian
773107120Sjulian#define NG_HCI_OCF_READ_REMOTE_VER_INFO		0x001d
774107120Sjuliantypedef struct {
775107120Sjulian	u_int16_t	con_handle; /* connection handle */
776107120Sjulian} __attribute__ ((packed)) ng_hci_read_remote_ver_info_cp;
777107120Sjulian/* No return parameter(s) */
778107120Sjulian
779107120Sjulian#define NG_HCI_OCF_READ_CLOCK_OFFSET		 0x001f
780107120Sjuliantypedef struct {
781107120Sjulian	u_int16_t	con_handle; /* connection handle */
782107120Sjulian} __attribute__ ((packed)) ng_hci_read_clock_offset_cp;
783107120Sjulian/* No return parameter(s) */
784107120Sjulian
785107120Sjulian/**************************************************************************
786107120Sjulian **************************************************************************
787107120Sjulian **        Link policy commands and return parameters
788107120Sjulian **************************************************************************
789107120Sjulian **************************************************************************/
790107120Sjulian
791107120Sjulian#define NG_HCI_OGF_LINK_POLICY			0x02 /* OpCode Group Field */
792107120Sjulian
793107120Sjulian#define NG_HCI_OCF_HOLD_MODE			0x0001
794107120Sjuliantypedef struct {
795107120Sjulian	u_int16_t	con_handle;   /* connection handle */
796107120Sjulian	u_int16_t	max_interval; /* (max_interval * 0.625) msec */
797107120Sjulian	u_int16_t	min_interval; /* (max_interval * 0.625) msec */
798107120Sjulian} __attribute__ ((packed)) ng_hci_hold_mode_cp;
799107120Sjulian/* No return parameter(s) */
800107120Sjulian
801107120Sjulian#define NG_HCI_OCF_SNIFF_MODE			0x0003
802107120Sjuliantypedef struct {
803107120Sjulian	u_int16_t	con_handle;   /* connection handle */
804107120Sjulian	u_int16_t	max_interval; /* (max_interval * 0.625) msec */
805107120Sjulian	u_int16_t	min_interval; /* (max_interval * 0.625) msec */
806107120Sjulian	u_int16_t	attempt;      /* (2 * attempt - 1) * 0.625 msec */
807107120Sjulian	u_int16_t	timeout;      /* (2 * attempt - 1) * 0.625 msec */
808107120Sjulian} __attribute__ ((packed)) ng_hci_sniff_mode_cp;
809107120Sjulian/* No return parameter(s) */
810107120Sjulian
811107120Sjulian#define NG_HCI_OCF_EXIT_SNIFF_MODE		0x0004
812107120Sjuliantypedef struct {
813107120Sjulian	u_int16_t	con_handle; /* connection handle */
814107120Sjulian} __attribute__ ((packed)) ng_hci_exit_sniff_mode_cp;
815107120Sjulian/* No return parameter(s) */
816107120Sjulian
817107120Sjulian#define NG_HCI_OCF_PARK_MODE			0x0005
818107120Sjuliantypedef struct {
819107120Sjulian	u_int16_t	con_handle;   /* connection handle */
820107120Sjulian	u_int16_t	max_interval; /* (max_interval * 0.625) msec */
821107120Sjulian	u_int16_t	min_interval; /* (max_interval * 0.625) msec */
822107120Sjulian} __attribute__ ((packed)) ng_hci_park_mode_cp;
823107120Sjulian/* No return parameter(s) */
824107120Sjulian
825107120Sjulian#define NG_HCI_OCF_EXIT_PARK_MODE		0x0006
826107120Sjuliantypedef struct {
827107120Sjulian	u_int16_t	con_handle; /* connection handle */
828107120Sjulian} __attribute__ ((packed)) ng_hci_exit_park_mode_cp;
829107120Sjulian/* No return parameter(s) */
830107120Sjulian
831107120Sjulian#define NG_HCI_OCF_QOS_SETUP			0x0007
832107120Sjuliantypedef struct {
833107120Sjulian	u_int16_t	con_handle;      /* connection handle */
834107120Sjulian	u_int8_t	flags;           /* reserved for future use */
835107120Sjulian	u_int8_t	service_type;    /* service type */
836107120Sjulian	u_int32_t	token_rate;      /* bytes per second */
837107120Sjulian	u_int32_t	peak_bandwidth;  /* bytes per second */
838107120Sjulian	u_int32_t	latency;         /* microseconds */
839107120Sjulian	u_int32_t	delay_variation; /* microseconds */
840107120Sjulian} __attribute__ ((packed)) ng_hci_qos_setup_cp;
841107120Sjulian/* No return parameter(s) */
842107120Sjulian
843107120Sjulian#define NG_HCI_OCF_ROLE_DISCOVERY		0x0009
844107120Sjuliantypedef struct {
845107120Sjulian	u_int16_t	con_handle; /* connection handle */
846107120Sjulian} __attribute__ ((packed)) ng_hci_role_discovery_cp;
847107120Sjulian
848107120Sjuliantypedef struct {
849107120Sjulian	u_int8_t	status;     /* 0x00 - success */
850107120Sjulian	u_int16_t	con_handle; /* connection handle */
851107120Sjulian	u_int8_t	role;       /* role for the connection handle */
852107120Sjulian} __attribute__ ((packed)) ng_hci_role_discovery_rp;
853107120Sjulian
854107120Sjulian#define NG_HCI_OCF_SWITCH_ROLE			0x000b
855107120Sjuliantypedef struct {
856107120Sjulian	bdaddr_t	bdaddr; /* remote address */
857107120Sjulian	u_int8_t	role;   /* new local role */
858107120Sjulian} __attribute__ ((packed)) ng_hci_switch_role_cp;
859107120Sjulian/* No return parameter(s) */
860107120Sjulian
861107120Sjulian#define NG_HCI_OCF_READ_LINK_POLICY_SETTINGS	0x000c
862107120Sjuliantypedef struct {
863107120Sjulian	u_int16_t	con_handle; /* connection handle */
864107120Sjulian} __attribute__ ((packed)) ng_hci_read_link_policy_settings_cp;
865107120Sjulian
866107120Sjuliantypedef struct {
867107120Sjulian	u_int8_t	status;     /* 0x00 - success */
868107120Sjulian	u_int16_t	con_handle; /* connection handle */
869107120Sjulian	u_int16_t	settings;   /* link policy settings */
870107120Sjulian} __attribute__ ((packed)) ng_hci_read_link_policy_settings_rp;
871107120Sjulian
872107120Sjulian#define NG_HCI_OCF_WRITE_LINK_POLICY_SETTINGS	0x000d
873107120Sjuliantypedef struct {
874107120Sjulian	u_int16_t	con_handle; /* connection handle */
875107120Sjulian	u_int16_t	settings;   /* link policy settings */
876107120Sjulian} __attribute__ ((packed)) ng_hci_write_link_policy_settings_cp;
877107120Sjulian
878107120Sjuliantypedef struct {
879107120Sjulian	u_int8_t	status;     /* 0x00 - success */
880107120Sjulian	u_int16_t	con_handle; /* connection handle */
881107120Sjulian} __attribute__ ((packed)) ng_hci_write_link_policy_settings_rp;
882107120Sjulian
883107120Sjulian/**************************************************************************
884107120Sjulian **************************************************************************
885107120Sjulian **   Host controller and baseband commands and return parameters
886107120Sjulian **************************************************************************
887107120Sjulian **************************************************************************/
888107120Sjulian
889107120Sjulian#define NG_HCI_OGF_HC_BASEBAND			0x03 /* OpCode Group Field */
890107120Sjulian
891107120Sjulian#define NG_HCI_OCF_SET_EVENT_MASK		0x0001
892107120Sjuliantypedef struct {
893107120Sjulian	u_int8_t	event_mask[NG_HCI_EVENT_MASK_SIZE]; /* event_mask */
894107120Sjulian} __attribute__ ((packed)) ng_hci_set_event_mask_cp;
895107120Sjulian
896107120Sjuliantypedef ng_hci_status_rp	ng_hci_set_event_mask_rp;
897107120Sjulian
898107120Sjulian#define NG_HCI_OCF_RESET			0x0003
899107120Sjulian/* No command parameter(s) */
900107120Sjuliantypedef ng_hci_status_rp	ng_hci_reset_rp;
901107120Sjulian
902107120Sjulian#define NG_HCI_OCF_SET_EVENT_FILTER		0x0005
903107120Sjuliantypedef struct {
904107120Sjulian	u_int8_t	filter_type;           /* filter type */
905107120Sjulian	u_int8_t	filter_condition_type; /* filter condition type */
906107120Sjulian	u_int8_t	condition[0];          /* conditions - variable size */
907107120Sjulian} __attribute__ ((packed)) ng_hci_set_event_filter_cp;
908107120Sjulian
909107120Sjuliantypedef ng_hci_status_rp	ng_hci_set_event_filter_rp;
910107120Sjulian
911107120Sjulian#define NG_HCI_OCF_FLUSH			0x0008
912107120Sjuliantypedef struct {
913107120Sjulian	u_int16_t	con_handle; /* connection handle */
914107120Sjulian} __attribute__ ((packed)) ng_hci_flush_cp;
915107120Sjulian
916107120Sjuliantypedef struct {
917107120Sjulian	u_int8_t	status;     /* 0x00 - success */
918107120Sjulian	u_int16_t	con_handle; /* connection handle */
919107120Sjulian} __attribute__ ((packed)) ng_hci_flush_rp;
920107120Sjulian
921107120Sjulian#define NG_HCI_OCF_READ_PIN_TYPE		0x0009
922107120Sjulian/* No command parameter(s) */
923107120Sjuliantypedef struct {
924107120Sjulian	u_int8_t	status;   /* 0x00 - success */
925107120Sjulian	u_int8_t	pin_type; /* PIN type */
926107120Sjulian} __attribute__ ((packed)) ng_hci_read_pin_type_rp;
927107120Sjulian
928107120Sjulian#define NG_HCI_OCF_WRITE_PIN_TYPE		0x000a
929107120Sjuliantypedef struct {
930107120Sjulian	u_int8_t	pin_type; /* PIN type */
931107120Sjulian} __attribute__ ((packed)) ng_hci_write_pin_type_cp;
932107120Sjulian
933107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_pin_type_rp;
934107120Sjulian
935107120Sjulian#define NG_HCI_OCF_CREATE_NEW_UNIT_KEY		0x000b
936107120Sjulian/* No command parameter(s) */
937107120Sjuliantypedef ng_hci_status_rp	ng_hci_create_new_unit_key_rp;
938107120Sjulian
939107120Sjulian#define NG_HCI_OCF_READ_STORED_LINK_KEY		0x000d
940107120Sjuliantypedef struct {
941107120Sjulian	bdaddr_t	bdaddr;   /* address */
942107120Sjulian	u_int8_t	read_all; /* read all keys? 0x01 - yes */
943107120Sjulian} __attribute__ ((packed)) ng_hci_read_stored_link_key_cp;
944107120Sjulian
945107120Sjuliantypedef struct {
946107120Sjulian	u_int8_t	status;        /* 0x00 - success */
947107120Sjulian	u_int16_t	max_num_keys;  /* Max. number of keys */
948107120Sjulian	u_int16_t	num_keys_read; /* Number of stored keys */
949107120Sjulian} __attribute__ ((packed)) ng_hci_read_stored_link_key_rp;
950107120Sjulian
951107120Sjulian#define NG_HCI_OCF_WRITE_STORED_LINK_KEY	0x0011
952107120Sjuliantypedef struct {
953107120Sjulian	u_int8_t	num_keys_write; /* # of keys to write */
954107120Sjulian/* these are repeated "num_keys_write" times
955107120Sjulian	bdaddr_t	bdaddr;                --- remote address(es)
956107120Sjulian	u_int8_t	key[NG_HCI_KEY_SIZE];  --- key(s) */
957107120Sjulian} __attribute__ ((packed)) ng_hci_write_stored_link_key_cp;
958107120Sjulian
959107120Sjuliantypedef struct {
960107120Sjulian	u_int8_t	status;           /* 0x00 - success */
961107120Sjulian	u_int8_t	num_keys_written; /* # of keys successfully written */
962107120Sjulian} __attribute__ ((packed)) ng_hci_write_stored_link_key_rp;
963107120Sjulian
964107120Sjulian#define NG_HCI_OCF_DELETE_STORED_LINK_KEY	0x0012
965107120Sjuliantypedef struct {
966107120Sjulian	bdaddr_t	bdaddr;     /* address */
967107120Sjulian	u_int8_t	delete_all; /* delete all keys? 0x01 - yes */
968107120Sjulian} __attribute__ ((packed)) ng_hci_delete_stored_link_key_cp;
969107120Sjulian
970107120Sjuliantypedef struct {
971107120Sjulian	u_int8_t	status;           /* 0x00 - success */
972107120Sjulian	u_int16_t	num_keys_deleted; /* Number of keys deleted */
973107120Sjulian} __attribute__ ((packed)) ng_hci_delete_stored_link_key_rp;
974107120Sjulian
975107120Sjulian#define NG_HCI_OCF_CHANGE_LOCAL_NAME		0x0013
976107120Sjuliantypedef struct {
977107120Sjulian	char		name[NG_HCI_UNIT_NAME_SIZE]; /* new unit name */
978107120Sjulian} __attribute__ ((packed)) ng_hci_change_local_name_cp;
979107120Sjulian
980107120Sjuliantypedef ng_hci_status_rp	ng_hci_change_local_name_rp;
981107120Sjulian
982107120Sjulian#define NG_HCI_OCF_READ_LOCAL_NAME		0x0014
983107120Sjulian/* No command parameter(s) */
984107120Sjuliantypedef struct {
985107120Sjulian	u_int8_t	status;  /* 0x00 - success */
986107120Sjulian	char		name[NG_HCI_UNIT_NAME_SIZE]; /* unit name */
987107120Sjulian} __attribute__ ((packed)) ng_hci_read_local_name_rp;
988107120Sjulian
989107120Sjulian#define NG_HCI_OCF_READ_CON_ACCEPT_TIMO		0x0015
990107120Sjulian/* No command parameter(s) */
991107120Sjuliantypedef struct {
992107120Sjulian	u_int8_t	status;  /* 0x00 - success */
993107120Sjulian	u_int16_t	timeout; /* (timeout * 0.625) msec */
994107120Sjulian} __attribute__ ((packed)) ng_hci_read_con_accept_timo_rp;
995107120Sjulian
996107120Sjulian#define NG_HCI_OCF_WRITE_CON_ACCEPT_TIMO	0x0016
997107120Sjuliantypedef struct {
998107120Sjulian	u_int16_t	timeout; /* (timeout * 0.625) msec */
999107120Sjulian} __attribute__ ((packed)) ng_hci_write_con_accept_timo_cp;
1000107120Sjulian
1001107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_con_accept_timo_rp;
1002107120Sjulian
1003107120Sjulian#define NG_HCI_OCF_READ_PAGE_TIMO		0x0017
1004107120Sjulian/* No command parameter(s) */
1005107120Sjuliantypedef struct {
1006107120Sjulian	u_int8_t	status;  /* 0x00 - success */
1007107120Sjulian	u_int16_t	timeout; /* (timeout * 0.625) msec */
1008107120Sjulian} __attribute__ ((packed)) ng_hci_read_page_timo_rp;
1009107120Sjulian
1010107120Sjulian#define NG_HCI_OCF_WRITE_PAGE_TIMO		0x0018
1011107120Sjuliantypedef struct {
1012107120Sjulian	u_int16_t	timeout; /* (timeout * 0.625) msec */
1013107120Sjulian} __attribute__ ((packed)) ng_hci_write_page_timo_cp;
1014107120Sjulian
1015107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_page_timo_rp;
1016107120Sjulian
1017107120Sjulian#define NG_HCI_OCF_READ_SCAN_ENABLE		0x0019
1018107120Sjulian/* No command parameter(s) */
1019107120Sjuliantypedef struct {
1020107120Sjulian	u_int8_t	status;      /* 0x00 - success */
1021107120Sjulian	u_int8_t	scan_enable; /* Scan enable */
1022107120Sjulian} __attribute__ ((packed)) ng_hci_read_scan_enable_rp;
1023107120Sjulian
1024107120Sjulian#define NG_HCI_OCF_WRITE_SCAN_ENABLE		0x001a
1025107120Sjuliantypedef struct {
1026107120Sjulian	u_int8_t	scan_enable; /* Scan enable */
1027107120Sjulian} __attribute__ ((packed)) ng_hci_write_scan_enable_cp;
1028107120Sjulian
1029107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_scan_enable_rp;
1030107120Sjulian
1031107120Sjulian#define NG_HCI_OCF_READ_PAGE_SCAN_ACTIVITY	0x001b
1032107120Sjulian/* No command parameter(s) */
1033107120Sjuliantypedef struct {
1034107120Sjulian	u_int8_t	status;             /* 0x00 - success */
1035107120Sjulian	u_int16_t	page_scan_interval; /* interval * 0.625 msec */
1036107120Sjulian	u_int16_t	page_scan_window;   /* window * 0.625 msec */
1037107120Sjulian} __attribute__ ((packed)) ng_hci_read_page_scan_activity_rp;
1038107120Sjulian
1039107120Sjulian#define NG_HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY	0x001c
1040107120Sjuliantypedef struct {
1041107120Sjulian	u_int16_t	page_scan_interval; /* interval * 0.625 msec */
1042107120Sjulian	u_int16_t	page_scan_window;   /* window * 0.625 msec */
1043107120Sjulian} __attribute__ ((packed)) ng_hci_write_page_scan_activity_cp;
1044107120Sjulian
1045107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_page_scan_activity_rp;
1046107120Sjulian
1047107120Sjulian#define NG_HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY	0x001d
1048107120Sjulian/* No command parameter(s) */
1049107120Sjuliantypedef struct {
1050107120Sjulian	u_int8_t	status;                /* 0x00 - success */
1051107120Sjulian	u_int16_t	inquiry_scan_interval; /* interval * 0.625 msec */
1052107120Sjulian	u_int16_t	inquiry_scan_window;   /* window * 0.625 msec */
1053107120Sjulian} __attribute__ ((packed)) ng_hci_read_inquiry_scan_activity_rp;
1054107120Sjulian
1055107120Sjulian#define NG_HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY	0x001e
1056107120Sjuliantypedef struct {
1057107120Sjulian	u_int16_t	inquiry_scan_interval; /* interval * 0.625 msec */
1058107120Sjulian	u_int16_t	inquiry_scan_window;   /* window * 0.625 msec */
1059107120Sjulian} __attribute__ ((packed)) ng_hci_write_inquiry_scan_activity_cp;
1060107120Sjulian
1061107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_inquiry_scan_activity_rp;
1062107120Sjulian
1063107120Sjulian#define NG_HCI_OCF_READ_AUTH_ENABLE		0x001f
1064107120Sjulian/* No command parameter(s) */
1065107120Sjuliantypedef struct {
1066107120Sjulian	u_int8_t	status;      /* 0x00 - success */
1067107120Sjulian	u_int8_t	auth_enable; /* 0x01 - enabled */
1068107120Sjulian} __attribute__ ((packed)) ng_hci_read_auth_enable_rp;
1069107120Sjulian
1070107120Sjulian#define NG_HCI_OCF_WRITE_AUTH_ENABLE		0x0020
1071107120Sjuliantypedef struct {
1072107120Sjulian	u_int8_t	auth_enable; /* 0x01 - enabled */
1073107120Sjulian} __attribute__ ((packed)) ng_hci_write_auth_enable_cp;
1074107120Sjulian
1075107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_auth_enable_rp;
1076107120Sjulian
1077107120Sjulian#define NG_HCI_OCF_READ_ENCRYPTION_MODE		0x0021
1078107120Sjulian/* No command parameter(s) */
1079107120Sjuliantypedef struct {
1080107120Sjulian	u_int8_t	status;          /* 0x00 - success */
1081107120Sjulian	u_int8_t	encryption_mode; /* encryption mode */
1082107120Sjulian} __attribute__ ((packed)) ng_hci_read_encryption_mode_rp;
1083107120Sjulian
1084107120Sjulian#define NG_HCI_OCF_WRITE_ENCRYPTION_MODE	0x0022
1085107120Sjuliantypedef struct {
1086107120Sjulian	u_int8_t	encryption_mode; /* encryption mode */
1087107120Sjulian} __attribute__ ((packed)) ng_hci_write_encryption_mode_cp;
1088107120Sjulian
1089107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_encryption_mode_rp;
1090107120Sjulian
1091107120Sjulian#define NG_HCI_OCF_READ_UNIT_CLASS		0x0023
1092107120Sjulian/* No command parameter(s) */
1093107120Sjuliantypedef struct {
1094107120Sjulian	u_int8_t	status;                    /* 0x00 - success */
1095107120Sjulian	u_int8_t	uclass[NG_HCI_CLASS_SIZE]; /* unit class */
1096107120Sjulian} __attribute__ ((packed)) ng_hci_read_unit_class_rp;
1097107120Sjulian
1098107120Sjulian#define NG_HCI_OCF_WRITE_UNIT_CLASS		0x0024
1099107120Sjuliantypedef struct {
1100107120Sjulian	u_int8_t	uclass[NG_HCI_CLASS_SIZE]; /* unit class */
1101107120Sjulian} __attribute__ ((packed)) ng_hci_write_unit_class_cp;
1102107120Sjulian
1103107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_unit_class_rp;
1104107120Sjulian
1105107120Sjulian#define NG_HCI_OCF_READ_VOICE_SETTINGS		0x0025
1106107120Sjulian/* No command parameter(s) */
1107107120Sjuliantypedef struct {
1108107120Sjulian	u_int8_t	status;   /* 0x00 - success */
1109107120Sjulian	u_int16_t	settings; /* voice settings */
1110107120Sjulian} __attribute__ ((packed)) ng_hci_read_voice_settings_rp;
1111107120Sjulian
1112107120Sjulian#define NG_HCI_OCF_WRITE_VOICE_SETTINGS		0x0026
1113107120Sjuliantypedef struct {
1114107120Sjulian	u_int16_t	settings; /* voice settings */
1115107120Sjulian} __attribute__ ((packed)) ng_hci_write_voice_settings_cp;
1116107120Sjulian
1117107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_voice_settings_rp;
1118107120Sjulian
1119107120Sjulian#define NG_HCI_OCF_READ_AUTO_FLUSH_TIMO		0x0027
1120107120Sjuliantypedef struct {
1121107120Sjulian	u_int16_t	con_handle; /* connection handle */
1122107120Sjulian} __attribute__ ((packed)) ng_hci_read_auto_flush_timo_cp;
1123107120Sjulian
1124107120Sjuliantypedef struct {
1125107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1126107120Sjulian	u_int16_t	con_handle; /* connection handle */
1127107120Sjulian	u_int16_t	timeout;    /* 0x00 - no flush, timeout * 0.625 msec */
1128107120Sjulian} __attribute__ ((packed)) ng_hci_read_auto_flush_timo_rp;
1129107120Sjulian
1130107120Sjulian#define NG_HCI_OCF_WRITE_AUTO_FLUSH_TIMO	0x0028
1131107120Sjuliantypedef struct {
1132107120Sjulian	u_int16_t	con_handle; /* connection handle */
1133107120Sjulian	u_int16_t	timeout;    /* 0x00 - no flush, timeout * 0.625 msec */
1134107120Sjulian} __attribute__ ((packed)) ng_hci_write_auto_flush_timo_cp;
1135107120Sjulian
1136107120Sjuliantypedef struct {
1137107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1138107120Sjulian	u_int16_t	con_handle; /* connection handle */
1139107120Sjulian} __attribute__ ((packed)) ng_hci_write_auto_flush_timo_rp;
1140107120Sjulian
1141107120Sjulian#define NG_HCI_OCF_READ_NUM_BROADCAST_RETRANS	0x0029
1142107120Sjulian/* No command parameter(s) */
1143107120Sjuliantypedef struct {
1144107120Sjulian	u_int8_t	status;  /* 0x00 - success */
1145107120Sjulian	u_int8_t	counter; /* number of broadcast retransmissions */
1146107120Sjulian} __attribute__ ((packed)) ng_hci_read_num_broadcast_retrans_rp;
1147107120Sjulian
1148107120Sjulian#define NG_HCI_OCF_WRITE_NUM_BROADCAST_RETRANS	0x002a
1149107120Sjuliantypedef struct {
1150107120Sjulian	u_int8_t	counter; /* number of broadcast retransmissions */
1151107120Sjulian} __attribute__ ((packed)) ng_hci_write_num_broadcast_retrans_cp;
1152107120Sjulian
1153107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_num_broadcast_retrans_rp;
1154107120Sjulian
1155107120Sjulian#define NG_HCI_OCF_READ_HOLD_MODE_ACTIVITY	0x002b
1156107120Sjulian/* No command parameter(s) */
1157107120Sjuliantypedef struct {
1158107120Sjulian	u_int8_t	status;             /* 0x00 - success */
1159107120Sjulian	u_int8_t	hold_mode_activity; /* Hold mode activities */
1160107120Sjulian} __attribute__ ((packed)) ng_hci_read_hold_mode_activity_rp;
1161107120Sjulian
1162107120Sjulian#define NG_HCI_OCF_WRITE_HOLD_MODE_ACTIVITY	0x002c
1163107120Sjuliantypedef struct {
1164107120Sjulian	u_int8_t	hold_mode_activity; /* Hold mode activities */
1165107120Sjulian} __attribute__ ((packed)) ng_hci_write_hold_mode_activity_cp;
1166107120Sjulian
1167107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_hold_mode_activity_rp;
1168107120Sjulian
1169107120Sjulian#define NG_HCI_OCF_READ_XMIT_LEVEL		0x002d
1170107120Sjuliantypedef struct {
1171107120Sjulian	u_int16_t	con_handle; /* connection handle */
1172107120Sjulian	u_int8_t	type;       /* Xmit level type */
1173107120Sjulian} __attribute__ ((packed)) ng_hci_read_xmit_level_cp;
1174107120Sjulian
1175107120Sjuliantypedef struct {
1176107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1177107120Sjulian	u_int16_t	con_handle; /* connection handle */
1178107120Sjulian	char		level;      /* -30 <= level <= 30 dBm */
1179107120Sjulian} __attribute__ ((packed)) ng_hci_read_xmit_level_rp;
1180107120Sjulian
1181107120Sjulian#define NG_HCI_OCF_READ_SCO_FLOW_CONTROL	0x002e
1182107120Sjulian/* No command parameter(s) */
1183107120Sjuliantypedef struct {
1184107120Sjulian	u_int8_t	status;       /* 0x00 - success */
1185107120Sjulian	u_int8_t	flow_control; /* 0x00 - disabled */
1186107120Sjulian} __attribute__ ((packed)) ng_hci_read_sco_flow_control_rp;
1187107120Sjulian
1188107120Sjulian#define NG_HCI_OCF_WRITE_SCO_FLOW_CONTROL	0x002f
1189107120Sjuliantypedef struct {
1190107120Sjulian	u_int8_t	flow_control; /* 0x00 - disabled */
1191107120Sjulian} __attribute__ ((packed)) ng_hci_write_sco_flow_control_cp;
1192107120Sjulian
1193107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_sco_flow_control_rp;
1194107120Sjulian
1195107120Sjulian#define NG_HCI_OCF_H2HC_FLOW_CONTROL		0x0031
1196107120Sjuliantypedef struct {
1197107120Sjulian	u_int8_t	h2hc_flow; /* Host to Host controller flow control */
1198107120Sjulian} __attribute__ ((packed)) ng_hci_h2hc_flow_control_cp;
1199107120Sjulian
1200107120Sjuliantypedef ng_hci_status_rp	ng_hci_h2hc_flow_control_rp;
1201107120Sjulian
1202107120Sjulian#define NG_HCI_OCF_HOST_BUFFER_SIZE		0x0033
1203107120Sjuliantypedef struct {
1204107120Sjulian	u_int16_t	max_acl_size; /* Max. size of ACL packet (bytes) */
1205107120Sjulian	u_int8_t	max_sco_size; /* Max. size of SCO packet (bytes) */
1206107120Sjulian	u_int16_t	num_acl_pkt;  /* Max. number of ACL packets */
1207107120Sjulian	u_int16_t	num_sco_pkt;  /* Max. number of SCO packets */
1208107120Sjulian} __attribute__ ((packed)) ng_hci_host_buffer_size_cp;
1209107120Sjulian
1210107120Sjuliantypedef ng_hci_status_rp	ng_hci_host_buffer_size_rp;
1211107120Sjulian
1212107120Sjulian#define NG_HCI_OCF_HOST_NUM_COMPL_PKTS		0x0035
1213107120Sjuliantypedef struct {
1214107120Sjulian	u_int8_t	num_con_handles; /* # of connection handles */
1215107120Sjulian/* these are repeated "num_con_handles" times
1216107120Sjulian	u_int16_t	con_handle; --- connection handle(s)
1217107120Sjulian	u_int16_t	compl_pkt;  --- # of completed packets */
1218107120Sjulian} __attribute__ ((packed)) ng_hci_host_num_compl_pkts_cp;
1219107120Sjulian/* No return parameter(s) */
1220107120Sjulian
1221107120Sjulian#define NG_HCI_OCF_READ_LINK_SUPERVISION_TIMO	0x0036
1222107120Sjuliantypedef struct {
1223107120Sjulian	u_int16_t	con_handle; /* connection handle */
1224107120Sjulian} __attribute__ ((packed)) ng_hci_read_link_supervision_timo_cp;
1225107120Sjulian
1226107120Sjuliantypedef struct {
1227107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1228107120Sjulian	u_int16_t	con_handle; /* connection handle */
1229107120Sjulian	u_int16_t	timeout;    /* Link supervision timeout * 0.625 msec */
1230107120Sjulian} __attribute__ ((packed)) ng_hci_read_link_supervision_timo_rp;
1231107120Sjulian
1232107120Sjulian#define NG_HCI_OCF_WRITE_LINK_SUPERVISION_TIMO	0x0037
1233107120Sjuliantypedef struct {
1234107120Sjulian	u_int16_t	con_handle; /* connection handle */
1235107120Sjulian	u_int16_t	timeout;    /* Link supervision timeout * 0.625 msec */
1236107120Sjulian} __attribute__ ((packed)) ng_hci_write_link_supervision_timo_cp;
1237107120Sjulian
1238107120Sjuliantypedef struct {
1239107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1240107120Sjulian	u_int16_t	con_handle; /* connection handle */
1241107120Sjulian} __attribute__ ((packed)) ng_hci_write_link_supervision_timo_rp;
1242107120Sjulian
1243107120Sjulian#define NG_HCI_OCF_READ_SUPPORTED_IAC_NUM	0x0038
1244107120Sjulian/* No command parameter(s) */
1245107120Sjuliantypedef struct {
1246107120Sjulian	u_int8_t	status;  /* 0x00 - success */
1247107120Sjulian	u_int8_t	num_iac; /* # of supported IAC during scan */
1248107120Sjulian} __attribute__ ((packed)) ng_hci_read_supported_iac_num_rp;
1249107120Sjulian
1250107120Sjulian#define NG_HCI_OCF_READ_IAC_LAP			0x0039
1251107120Sjulian/* No command parameter(s) */
1252107120Sjuliantypedef struct {
1253107120Sjulian	u_int8_t	status;  /* 0x00 - success */
1254107120Sjulian	u_int8_t	num_iac; /* # of IAC */
1255107120Sjulian/* these are repeated "num_iac" times
1256107120Sjulian	u_int8_t	laps[NG_HCI_LAP_SIZE]; --- LAPs */
1257107120Sjulian} __attribute__ ((packed)) ng_hci_read_iac_lap_rp;
1258107120Sjulian
1259107120Sjulian#define NG_HCI_OCF_WRITE_IAC_LAP		0x003a
1260107120Sjuliantypedef struct {
1261107120Sjulian	u_int8_t	num_iac; /* # of IAC */
1262107120Sjulian/* these are repeated "num_iac" times
1263107120Sjulian	u_int8_t	laps[NG_HCI_LAP_SIZE]; --- LAPs */
1264107120Sjulian} __attribute__ ((packed)) ng_hci_write_iac_lap_cp;
1265107120Sjulian
1266107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_iac_lap_rp;
1267107120Sjulian
1268107120Sjulian#define NG_HCI_OCF_READ_PAGE_SCAN_PERIOD	0x003b
1269107120Sjulian/* No command parameter(s) */
1270107120Sjuliantypedef struct {
1271107120Sjulian	u_int8_t	status;                /* 0x00 - success */
1272107120Sjulian	u_int8_t	page_scan_period_mode; /* Page scan period mode */
1273107120Sjulian} __attribute__ ((packed)) ng_hci_read_page_scan_period_rp;
1274107120Sjulian
1275107120Sjulian#define NG_HCI_OCF_WRITE_PAGE_SCAN_PERIOD	0x003c
1276107120Sjuliantypedef struct {
1277107120Sjulian	u_int8_t	page_scan_period_mode; /* Page scan period mode */
1278107120Sjulian} __attribute__ ((packed)) ng_hci_write_page_scan_period_cp;
1279107120Sjulian
1280107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_page_scan_period_rp;
1281107120Sjulian
1282107120Sjulian#define NG_HCI_OCF_READ_PAGE_SCAN		0x003d
1283107120Sjulian/* No command parameter(s) */
1284107120Sjuliantypedef struct {
1285107120Sjulian	u_int8_t	status;         /* 0x00 - success */
1286107120Sjulian	u_int8_t	page_scan_mode; /* Page scan mode */
1287107120Sjulian} __attribute__ ((packed)) ng_hci_read_page_scan_rp;
1288107120Sjulian
1289107120Sjulian#define NG_HCI_OCF_WRITE_PAGE_SCAN		0x003e
1290107120Sjuliantypedef struct {
1291107120Sjulian	u_int8_t	page_scan_mode; /* Page scan mode */
1292107120Sjulian} __attribute__ ((packed)) ng_hci_write_page_scan_cp;
1293107120Sjulian
1294107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_page_scan_rp;
1295107120Sjulian
1296107120Sjulian/**************************************************************************
1297107120Sjulian **************************************************************************
1298107120Sjulian **           Informational commands and return parameters
1299107120Sjulian **     All commands in this category do not accept any parameters
1300107120Sjulian **************************************************************************
1301107120Sjulian **************************************************************************/
1302107120Sjulian
1303107120Sjulian#define NG_HCI_OGF_INFO				0x04 /* OpCode Group Field */
1304107120Sjulian
1305107120Sjulian#define NG_HCI_OCF_READ_LOCAL_VER		0x0001
1306107120Sjuliantypedef struct {
1307107120Sjulian	u_int8_t	status;         /* 0x00 - success */
1308107120Sjulian	u_int8_t	hci_version;    /* HCI version */
1309107120Sjulian	u_int16_t	hci_revision;   /* HCI revision */
1310107120Sjulian	u_int8_t	lmp_version;    /* LMP version */
1311107120Sjulian	u_int16_t	manufacturer;   /* Hardware manufacturer name */
1312107120Sjulian	u_int16_t	lmp_subversion; /* LMP sub-version */
1313107120Sjulian} __attribute__ ((packed)) ng_hci_read_local_ver_rp;
1314107120Sjulian
1315107120Sjulian#define NG_HCI_OCF_READ_LOCAL_FEATURES		0x0003
1316107120Sjuliantypedef struct {
1317107120Sjulian	u_int8_t	status;                         /* 0x00 - success */
1318107120Sjulian	u_int8_t	features[NG_HCI_FEATURES_SIZE]; /* LMP features bitmsk*/
1319107120Sjulian} __attribute__ ((packed)) ng_hci_read_local_features_rp;
1320107120Sjulian
1321107120Sjulian#define NG_HCI_OCF_READ_BUFFER_SIZE		0x0005
1322107120Sjuliantypedef struct {
1323107120Sjulian	u_int8_t	status;       /* 0x00 - success */
1324107120Sjulian	u_int16_t	max_acl_size; /* Max. size of ACL packet (bytes) */
1325107120Sjulian	u_int8_t	max_sco_size; /* Max. size of SCO packet (bytes) */
1326107120Sjulian	u_int16_t	num_acl_pkt;  /* Max. number of ACL packets */
1327107120Sjulian	u_int16_t	num_sco_pkt;  /* Max. number of SCO packets */
1328107120Sjulian} __attribute__ ((packed)) ng_hci_read_buffer_size_rp;
1329107120Sjulian
1330107120Sjulian#define NG_HCI_OCF_READ_COUNTRY_CODE		0x0007
1331107120Sjuliantypedef struct {
1332107120Sjulian	u_int8_t	status;       /* 0x00 - success */
1333107120Sjulian	u_int8_t	country_code; /* 0x00 - NAM, EUR, JP; 0x01 - France */
1334107120Sjulian} __attribute__ ((packed)) ng_hci_read_country_code_rp;
1335107120Sjulian
1336107120Sjulian#define NG_HCI_OCF_READ_BDADDR			0x0009
1337107120Sjuliantypedef struct {
1338107120Sjulian	u_int8_t	status; /* 0x00 - success */
1339107120Sjulian	bdaddr_t	bdaddr; /* unit address */
1340107120Sjulian} __attribute__ ((packed)) ng_hci_read_bdaddr_rp;
1341107120Sjulian
1342107120Sjulian/**************************************************************************
1343107120Sjulian **************************************************************************
1344107120Sjulian **            Status commands and return parameters
1345107120Sjulian **************************************************************************
1346107120Sjulian **************************************************************************/
1347107120Sjulian
1348107120Sjulian#define NG_HCI_OGF_STATUS			0x05 /* OpCode Group Field */
1349107120Sjulian
1350107120Sjulian#define NG_HCI_OCF_READ_FAILED_CONTACT_CNTR	0x0001
1351107120Sjuliantypedef struct {
1352107120Sjulian	u_int16_t	con_handle; /* connection handle */
1353107120Sjulian} __attribute__ ((packed)) ng_hci_read_failed_contact_cntr_cp;
1354107120Sjulian
1355107120Sjuliantypedef struct {
1356107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1357107120Sjulian	u_int16_t	con_handle; /* connection handle */
1358107120Sjulian	u_int16_t	counter;    /* number of consecutive failed contacts */
1359107120Sjulian} __attribute__ ((packed)) ng_hci_read_failed_contact_cntr_rp;
1360107120Sjulian
1361107120Sjulian#define NG_HCI_OCF_RESET_FAILED_CONTACT_CNTR	0x0002
1362107120Sjuliantypedef struct {
1363107120Sjulian	u_int16_t	con_handle; /* connection handle */
1364107120Sjulian} __attribute__ ((packed)) ng_hci_reset_failed_contact_cntr_cp;
1365107120Sjulian
1366107120Sjuliantypedef struct {
1367107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1368107120Sjulian	u_int16_t	con_handle; /* connection handle */
1369107120Sjulian} __attribute__ ((packed)) ng_hci_reset_failed_contact_cntr_rp;
1370107120Sjulian
1371107120Sjulian#define NG_HCI_OCF_GET_LINK_QUALITY		0x0003
1372107120Sjuliantypedef struct {
1373107120Sjulian	u_int16_t	con_handle; /* connection handle */
1374107120Sjulian} __attribute__ ((packed)) ng_hci_get_link_quality_cp;
1375107120Sjulian
1376107120Sjuliantypedef struct {
1377107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1378107120Sjulian	u_int16_t	con_handle; /* connection handle */
1379107120Sjulian	u_int8_t	quality;    /* higher value means better quality */
1380107120Sjulian} __attribute__ ((packed)) ng_hci_get_link_quality_rp;
1381107120Sjulian
1382107120Sjulian#define NG_HCI_OCF_READ_RSSI			0x0005
1383107120Sjuliantypedef struct {
1384107120Sjulian	u_int16_t	con_handle; /* connection handle */
1385107120Sjulian} __attribute__ ((packed)) ng_hci_read_rssi_cp;
1386107120Sjulian
1387107120Sjuliantypedef struct {
1388107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1389107120Sjulian	u_int16_t	con_handle; /* connection handle */
1390107120Sjulian	char		rssi;       /* -127 <= rssi <= 127 dB */
1391107120Sjulian} __attribute__ ((packed)) ng_hci_read_rssi_rp;
1392107120Sjulian
1393107120Sjulian/**************************************************************************
1394107120Sjulian **************************************************************************
1395107120Sjulian **             Testing commands and return parameters
1396107120Sjulian **************************************************************************
1397107120Sjulian **************************************************************************/
1398107120Sjulian
1399107120Sjulian#define NG_HCI_OGF_TESTING			0x06 /* OpCode Group Field */
1400107120Sjulian
1401107120Sjulian#define NG_HCI_OCF_READ_LOOPBACK_MODE		0x0001
1402107120Sjulian/* No command parameter(s) */
1403107120Sjuliantypedef struct {
1404107120Sjulian	u_int8_t	status; /* 0x00 - success */
1405107120Sjulian	u_int8_t	lbmode; /* loopback mode */
1406107120Sjulian} __attribute__ ((packed)) ng_hci_read_loopback_mode_rp;
1407107120Sjulian
1408107120Sjulian#define NG_HCI_OCF_WRITE_LOOPBACK_MODE		0x0002
1409107120Sjuliantypedef struct {
1410107120Sjulian	u_int8_t	lbmode; /* loopback mode */
1411107120Sjulian} __attribute__ ((packed)) ng_hci_write_loopback_mode_cp;
1412107120Sjulian
1413107120Sjuliantypedef ng_hci_status_rp	ng_hci_write_loopback_mode_rp;
1414107120Sjulian
1415107120Sjulian#define NG_HCI_OCF_ENABLE_UNIT_UNDER_TEST	0x0003
1416107120Sjulian/* No command parameter(s) */
1417107120Sjuliantypedef ng_hci_status_rp	ng_hci_enable_unit_under_test_rp;
1418107120Sjulian
1419107120Sjulian/**************************************************************************
1420107120Sjulian **************************************************************************
1421107120Sjulian **                Special HCI OpCode group field values
1422107120Sjulian **************************************************************************
1423107120Sjulian **************************************************************************/
1424107120Sjulian
1425107120Sjulian#define NG_HCI_OGF_BT_LOGO			0x3e
1426107120Sjulian
1427107120Sjulian#define NG_HCI_OGF_VENDOR			0x3f
1428107120Sjulian
1429107120Sjulian/**************************************************************************
1430107120Sjulian **************************************************************************
1431107120Sjulian **                         Events and event parameters
1432107120Sjulian **************************************************************************
1433107120Sjulian **************************************************************************/
1434107120Sjulian
1435107120Sjulian#define NG_HCI_EVENT_INQUIRY_COMPL		0x01
1436107120Sjuliantypedef struct {
1437107120Sjulian	u_int8_t	status; /* 0x00 - success */
1438107120Sjulian} __attribute__ ((packed)) ng_hci_inquiry_compl_ep;
1439107120Sjulian
1440107120Sjulian#define NG_HCI_EVENT_INQUIRY_RESULT		0x02
1441107120Sjuliantypedef struct {
1442107120Sjulian	u_int8_t	num_responses;      /* number of responses */
1443133415Semax/*	ng_hci_inquiry_response[num_responses]   -- see below */
1444107120Sjulian} __attribute__ ((packed)) ng_hci_inquiry_result_ep;
1445107120Sjulian
1446133415Semaxtypedef struct {
1447133415Semax	bdaddr_t	bdaddr;                   /* unit address */
1448133415Semax	u_int8_t	page_scan_rep_mode;       /* page scan rep. mode */
1449133415Semax	u_int8_t	page_scan_period_mode;    /* page scan period mode */
1450133415Semax	u_int8_t	page_scan_mode;           /* page scan mode */
1451139686Semax	u_int8_t	uclass[NG_HCI_CLASS_SIZE];/* unit class */
1452133415Semax	u_int16_t	clock_offset;             /* clock offset */
1453133415Semax} __attribute__ ((packed)) ng_hci_inquiry_response;
1454133415Semax
1455107120Sjulian#define NG_HCI_EVENT_CON_COMPL			0x03
1456107120Sjuliantypedef struct {
1457107120Sjulian	u_int8_t	status;          /* 0x00 - success */
1458107120Sjulian	u_int16_t	con_handle;      /* Connection handle */
1459107120Sjulian	bdaddr_t	bdaddr;          /* remote unit address */
1460107120Sjulian	u_int8_t	link_type;       /* Link type */
1461107120Sjulian	u_int8_t	encryption_mode; /* Encryption mode */
1462107120Sjulian} __attribute__ ((packed)) ng_hci_con_compl_ep;
1463107120Sjulian
1464107120Sjulian#define NG_HCI_EVENT_CON_REQ			0x04
1465107120Sjuliantypedef struct {
1466107120Sjulian	bdaddr_t	bdaddr;                    /* remote unit address */
1467107120Sjulian	u_int8_t	uclass[NG_HCI_CLASS_SIZE]; /* remote unit class */
1468107120Sjulian	u_int8_t	link_type;                 /* link type */
1469107120Sjulian} __attribute__ ((packed)) ng_hci_con_req_ep;
1470107120Sjulian
1471107120Sjulian#define NG_HCI_EVENT_DISCON_COMPL		0x05
1472107120Sjuliantypedef struct {
1473107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1474107120Sjulian	u_int16_t	con_handle; /* connection handle */
1475107120Sjulian	u_int8_t	reason;     /* reason to disconnect */
1476107120Sjulian} __attribute__ ((packed)) ng_hci_discon_compl_ep;
1477107120Sjulian
1478107120Sjulian#define NG_HCI_EVENT_AUTH_COMPL			0x06
1479107120Sjuliantypedef struct {
1480107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1481107120Sjulian	u_int16_t	con_handle; /* connection handle */
1482107120Sjulian} __attribute__ ((packed)) ng_hci_auth_compl_ep;
1483107120Sjulian
1484107120Sjulian#define NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL	0x7
1485107120Sjuliantypedef struct {
1486107120Sjulian	u_int8_t	status; /* 0x00 - success */
1487107120Sjulian	bdaddr_t	bdaddr; /* remote unit address */
1488107120Sjulian	char		name[NG_HCI_UNIT_NAME_SIZE]; /* remote unit name */
1489107120Sjulian} __attribute__ ((packed)) ng_hci_remote_name_req_compl_ep;
1490107120Sjulian
1491107120Sjulian#define NG_HCI_EVENT_ENCRYPTION_CHANGE		0x08
1492107120Sjuliantypedef struct {
1493107120Sjulian	u_int8_t	status;            /* 0x00 - success */
1494107120Sjulian	u_int16_t	con_handle;        /* Connection handle */
1495107120Sjulian	u_int8_t	encryption_enable; /* 0x00 - disable */
1496107120Sjulian} __attribute__ ((packed)) ng_hci_encryption_change_ep;
1497107120Sjulian
1498107120Sjulian#define NG_HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL	0x09
1499107120Sjuliantypedef struct {
1500107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1501107120Sjulian	u_int16_t	con_handle; /* Connection handle */
1502107120Sjulian} __attribute__ ((packed)) ng_hci_change_con_link_key_compl_ep;
1503107120Sjulian
1504107120Sjulian#define NG_HCI_EVENT_MASTER_LINK_KEY_COMPL	0x0a
1505107120Sjuliantypedef struct {
1506107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1507107120Sjulian	u_int16_t	con_handle; /* Connection handle */
1508107120Sjulian	u_int8_t	key_flag;   /* Key flag */
1509107120Sjulian} __attribute__ ((packed)) ng_hci_master_link_key_compl_ep;
1510107120Sjulian
1511107120Sjulian#define NG_HCI_EVENT_READ_REMOTE_FEATURES_COMPL	0x0b
1512107120Sjuliantypedef struct {
1513107120Sjulian	u_int8_t	status;                         /* 0x00 - success */
1514107120Sjulian	u_int16_t	con_handle;                     /* Connection handle */
1515107120Sjulian	u_int8_t	features[NG_HCI_FEATURES_SIZE]; /* LMP features bitmsk*/
1516107120Sjulian} __attribute__ ((packed)) ng_hci_read_remote_features_compl_ep;
1517107120Sjulian
1518107120Sjulian#define NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL	0x0c
1519107120Sjuliantypedef struct {
1520107120Sjulian	u_int8_t	status;         /* 0x00 - success */
1521107120Sjulian	u_int16_t	con_handle;     /* Connection handle */
1522107120Sjulian	u_int8_t	lmp_version;    /* LMP version */
1523107120Sjulian	u_int16_t	manufacturer;   /* Hardware manufacturer name */
1524107120Sjulian	u_int16_t	lmp_subversion; /* LMP sub-version */
1525107120Sjulian} __attribute__ ((packed)) ng_hci_read_remote_ver_info_compl_ep;
1526107120Sjulian
1527107120Sjulian#define NG_HCI_EVENT_QOS_SETUP_COMPL		0x0d
1528107120Sjuliantypedef struct {
1529107120Sjulian	u_int8_t	status;          /* 0x00 - success */
1530107120Sjulian	u_int16_t	con_handle;      /* connection handle */
1531107120Sjulian	u_int8_t	flags;           /* reserved for future use */
1532107120Sjulian	u_int8_t	service_type;    /* service type */
1533107120Sjulian	u_int32_t	token_rate;      /* bytes per second */
1534107120Sjulian	u_int32_t	peak_bandwidth;  /* bytes per second */
1535107120Sjulian	u_int32_t	latency;         /* microseconds */
1536107120Sjulian	u_int32_t	delay_variation; /* microseconds */
1537107120Sjulian} __attribute__ ((packed)) ng_hci_qos_setup_compl_ep;
1538107120Sjulian
1539107120Sjulian#define NG_HCI_EVENT_COMMAND_COMPL		0x0e
1540107120Sjuliantypedef struct {
1541107120Sjulian	u_int8_t	num_cmd_pkts; /* # of HCI command packets */
1542107120Sjulian	u_int16_t	opcode;       /* command OpCode */
1543107120Sjulian	/* command return parameters (if any) */
1544107120Sjulian} __attribute__ ((packed)) ng_hci_command_compl_ep;
1545107120Sjulian
1546107120Sjulian#define NG_HCI_EVENT_COMMAND_STATUS		0x0f
1547107120Sjuliantypedef struct {
1548107120Sjulian	u_int8_t	status;       /* 0x00 - pending */
1549107120Sjulian	u_int8_t	num_cmd_pkts; /* # of HCI command packets */
1550107120Sjulian	u_int16_t	opcode;       /* command OpCode */
1551107120Sjulian} __attribute__ ((packed)) ng_hci_command_status_ep;
1552107120Sjulian
1553107120Sjulian#define NG_HCI_EVENT_HARDWARE_ERROR		0x10
1554107120Sjuliantypedef struct {
1555107120Sjulian	u_int8_t	hardware_code; /* hardware error code */
1556107120Sjulian} __attribute__ ((packed)) ng_hci_hardware_error_ep;
1557107120Sjulian
1558107120Sjulian#define NG_HCI_EVENT_FLUSH_OCCUR		0x11
1559107120Sjuliantypedef struct {
1560107120Sjulian	u_int16_t	con_handle; /* connection handle */
1561107120Sjulian} __attribute__ ((packed)) ng_hci_flush_occur_ep;
1562107120Sjulian
1563107120Sjulian#define NG_HCI_EVENT_ROLE_CHANGE		0x12
1564107120Sjuliantypedef struct {
1565107120Sjulian	u_int8_t	status; /* 0x00 - success */
1566107120Sjulian	bdaddr_t	bdaddr; /* address of remote unit */
1567107120Sjulian	u_int8_t	role;   /* new connection role */
1568107120Sjulian} __attribute__ ((packed)) ng_hci_role_change_ep;
1569107120Sjulian
1570107120Sjulian#define NG_HCI_EVENT_NUM_COMPL_PKTS		0x13
1571107120Sjuliantypedef struct {
1572107120Sjulian	u_int8_t	num_con_handles; /* # of connection handles */
1573107120Sjulian/* these are repeated "num_con_handles" times
1574107120Sjulian	u_int16_t	con_handle; --- connection handle(s)
1575107120Sjulian	u_int16_t	compl_pkt;  --- # of completed packets */
1576107120Sjulian} __attribute__ ((packed)) ng_hci_num_compl_pkts_ep;
1577107120Sjulian
1578107120Sjulian#define NG_HCI_EVENT_MODE_CHANGE		0x14
1579107120Sjuliantypedef struct {
1580107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1581107120Sjulian	u_int16_t	con_handle; /* connection handle */
1582107120Sjulian	u_int8_t	unit_mode;  /* remote unit mode */
1583107120Sjulian	u_int16_t	interval;   /* interval * 0.625 msec */
1584107120Sjulian} __attribute__ ((packed)) ng_hci_mode_change_ep;
1585107120Sjulian
1586107120Sjulian#define NG_HCI_EVENT_RETURN_LINK_KEYS		0x15
1587107120Sjuliantypedef struct {
1588107120Sjulian	u_int8_t	num_keys; /* # of keys */
1589107120Sjulian/* these are repeated "num_keys" times
1590107120Sjulian	bdaddr_t	bdaddr;               --- remote address(es)
1591107120Sjulian	u_int8_t	key[NG_HCI_KEY_SIZE]; --- key(s) */
1592107120Sjulian} __attribute__ ((packed)) ng_hci_return_link_keys_ep;
1593107120Sjulian
1594107120Sjulian#define NG_HCI_EVENT_PIN_CODE_REQ		0x16
1595107120Sjuliantypedef struct {
1596107120Sjulian	bdaddr_t	bdaddr; /* remote unit address */
1597107120Sjulian} __attribute__ ((packed)) ng_hci_pin_code_req_ep;
1598107120Sjulian
1599107120Sjulian#define NG_HCI_EVENT_LINK_KEY_REQ		0x17
1600107120Sjuliantypedef struct {
1601107120Sjulian	bdaddr_t	bdaddr; /* remote unit address */
1602107120Sjulian} __attribute__ ((packed)) ng_hci_link_key_req_ep;
1603107120Sjulian
1604107120Sjulian#define NG_HCI_EVENT_LINK_KEY_NOTIFICATION	0x18
1605107120Sjuliantypedef struct {
1606107120Sjulian	bdaddr_t	bdaddr;               /* remote unit address */
1607107120Sjulian	u_int8_t	key[NG_HCI_KEY_SIZE]; /* link key */
1608107120Sjulian	u_int8_t	key_type;             /* type of the key */
1609107120Sjulian} __attribute__ ((packed)) ng_hci_link_key_notification_ep;
1610107120Sjulian
1611107120Sjulian#define NG_HCI_EVENT_LOOPBACK_COMMAND		0x19
1612107120Sjuliantypedef struct {
1613107120Sjulian	u_int8_t	command[0]; /* Command packet */
1614107120Sjulian} __attribute__ ((packed)) ng_hci_loopback_command_ep;
1615107120Sjulian
1616107120Sjulian#define NG_HCI_EVENT_DATA_BUFFER_OVERFLOW	0x1a
1617107120Sjuliantypedef struct {
1618107120Sjulian	u_int8_t	link_type; /* Link type */
1619107120Sjulian} __attribute__ ((packed)) ng_hci_data_buffer_overflow_ep;
1620107120Sjulian
1621107120Sjulian#define NG_HCI_EVENT_MAX_SLOT_CHANGE		0x1b
1622107120Sjuliantypedef struct {
1623107120Sjulian	u_int16_t	con_handle;    /* connection handle */
1624107120Sjulian	u_int8_t	lmp_max_slots; /* Max. # of slots allowed */
1625107120Sjulian} __attribute__ ((packed)) ng_hci_max_slot_change_ep;
1626107120Sjulian
1627107120Sjulian#define NG_HCI_EVENT_READ_CLOCK_OFFSET_COMPL	0x1c
1628107120Sjuliantypedef struct {
1629107120Sjulian	u_int8_t	status;       /* 0x00 - success */
1630107120Sjulian	u_int16_t	con_handle;   /* Connection handle */
1631107120Sjulian	u_int16_t	clock_offset; /* Clock offset */
1632107120Sjulian} __attribute__ ((packed)) ng_hci_read_clock_offset_compl_ep;
1633107120Sjulian
1634107120Sjulian#define NG_HCI_EVENT_CON_PKT_TYPE_CHANGED	0x1d
1635107120Sjuliantypedef struct {
1636107120Sjulian	u_int8_t	status;     /* 0x00 - success */
1637107120Sjulian	u_int16_t	con_handle; /* connection handle */
1638107120Sjulian	u_int16_t	pkt_type;   /* packet type */
1639107120Sjulian} __attribute__ ((packed)) ng_hci_con_pkt_type_changed_ep;
1640107120Sjulian
1641107120Sjulian#define NG_HCI_EVENT_QOS_VIOLATION		0x1e
1642107120Sjuliantypedef struct {
1643107120Sjulian	u_int16_t	con_handle; /* connection handle */
1644107120Sjulian} __attribute__ ((packed)) ng_hci_qos_violation_ep;
1645107120Sjulian
1646107120Sjulian#define NG_HCI_EVENT_PAGE_SCAN_MODE_CHANGE	0x1f
1647107120Sjuliantypedef struct {
1648107120Sjulian	bdaddr_t	bdaddr;         /* destination address */
1649107120Sjulian	u_int8_t	page_scan_mode; /* page scan mode */
1650107120Sjulian} __attribute__ ((packed)) ng_hci_page_scan_mode_change_ep;
1651107120Sjulian
1652107120Sjulian#define NG_HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE	0x20
1653107120Sjuliantypedef struct {
1654107120Sjulian	bdaddr_t	bdaddr;             /* destination address */
1655107120Sjulian	u_int8_t	page_scan_rep_mode; /* page scan repetition mode */
1656107120Sjulian} __attribute__ ((packed)) ng_hci_page_scan_rep_mode_change_ep;
1657107120Sjulian
1658107120Sjulian#define NG_HCI_EVENT_BT_LOGO			0xfe
1659107120Sjulian
1660107120Sjulian#define NG_HCI_EVENT_VENDOR			0xff
1661107120Sjulian
1662107120Sjulian#endif /* ndef _NETGRAPH_HCI_H_ */
1663