added a lot of printk output to ease writing of emulator
[linux-2.4.21-pre4.git] / include / net2 / bluetooth / hci.h
1 /* 
2    BlueZ - Bluetooth protocol stack for Linux
3    Copyright (C) 2000-2001 Qualcomm Incorporated
4
5    Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License version 2 as
9    published by the Free Software Foundation;
10
11    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15    CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
16    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
17    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
18    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20    ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
21    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
22    SOFTWARE IS DISCLAIMED.
23 */
24
25 /*
26  *  $Id: hci.h,v 1.1.1.1 2005/04/11 02:51:08 jack Exp $
27  */
28
29 #ifndef __HCI_H
30 #define __HCI_H
31
32 #define HCI_MAX_ACL_SIZE        1024
33 #define HCI_MAX_SCO_SIZE        255
34 #define HCI_MAX_EVENT_SIZE      260
35 #define HCI_MAX_FRAME_SIZE      (HCI_MAX_ACL_SIZE + 4)
36
37 /* HCI dev events */
38 #define HCI_DEV_REG     1
39 #define HCI_DEV_UNREG   2
40 #define HCI_DEV_UP      3
41 #define HCI_DEV_DOWN    4
42 #define HCI_DEV_SUSPEND 5
43 #define HCI_DEV_RESUME  6
44
45 /* HCI device types */
46 #define HCI_VHCI        0
47 #define HCI_USB         1
48 #define HCI_PCCARD      2
49 #define HCI_UART        3
50 #define HCI_RS232       4
51 #define HCI_PCI         5
52
53 /* HCI device flags */
54 enum {
55         HCI_UP,
56         HCI_INIT,
57         HCI_RUNNING,
58
59         HCI_PSCAN,
60         HCI_ISCAN,
61         HCI_AUTH,
62         HCI_ENCRYPT,
63         HCI_INQUIRY,
64
65         HCI_RAW
66 };
67
68 /* HCI ioctl defines */
69 #define HCIDEVUP        _IOW('H', 201, int)
70 #define HCIDEVDOWN      _IOW('H', 202, int)
71 #define HCIDEVRESET     _IOW('H', 203, int)
72 #define HCIDEVRESTAT    _IOW('H', 204, int)
73
74 #define HCIGETDEVLIST   _IOR('H', 210, int)
75 #define HCIGETDEVINFO   _IOR('H', 211, int)
76 #define HCIGETCONNLIST  _IOR('H', 212, int)
77 #define HCIGETCONNINFO  _IOR('H', 213, int)
78
79 #define HCISETRAW       _IOW('H', 220, int)
80 #define HCISETSCAN      _IOW('H', 221, int)
81 #define HCISETAUTH      _IOW('H', 222, int)
82 #define HCISETENCRYPT   _IOW('H', 223, int)
83 #define HCISETPTYPE     _IOW('H', 224, int)
84 #define HCISETLINKPOL   _IOW('H', 225, int)
85 #define HCISETLINKMODE  _IOW('H', 226, int)
86 #define HCISETACLMTU    _IOW('H', 227, int)
87 #define HCISETSCOMTU    _IOW('H', 228, int)
88
89 #define HCIINQUIRY      _IOR('H', 240, int)
90
91 /* HCI timeouts */
92 #define HCI_CONN_TIMEOUT        (HZ * 40)
93 #define HCI_DISCONN_TIMEOUT     (HZ * 2)
94 #define HCI_CONN_IDLE_TIMEOUT   (HZ * 60)
95
96 /* HCI Packet types */
97 #define HCI_COMMAND_PKT         0x01
98 #define HCI_ACLDATA_PKT         0x02
99 #define HCI_SCODATA_PKT         0x03
100 #define HCI_EVENT_PKT           0x04
101 #define HCI_UNKNOWN_PKT         0xff
102
103 /* HCI Packet types */
104 #define HCI_DM1         0x0008
105 #define HCI_DM3         0x0400
106 #define HCI_DM5         0x4000
107 #define HCI_DH1         0x0010
108 #define HCI_DH3         0x0800
109 #define HCI_DH5         0x8000
110
111 #define HCI_HV1         0x0020
112 #define HCI_HV2         0x0040
113 #define HCI_HV3         0x0080
114
115 #define SCO_PTYPE_MASK  (HCI_HV1 | HCI_HV2 | HCI_HV3)
116 #define ACL_PTYPE_MASK  (~SCO_PTYPE_MASK)
117
118 /* ACL flags */
119 #define ACL_CONT                0x01
120 #define ACL_START               0x02
121 #define ACL_ACTIVE_BCAST        0x04
122 #define ACL_PICO_BCAST          0x08
123
124 /* Baseband links */
125 #define SCO_LINK        0x00
126 #define ACL_LINK        0x01
127
128 /* LMP features */
129 #define LMP_3SLOT       0x01
130 #define LMP_5SLOT       0x02
131 #define LMP_ENCRYPT     0x04
132 #define LMP_SOFFSET     0x08
133 #define LMP_TACCURACY   0x10
134 #define LMP_RSWITCH     0x20
135 #define LMP_HOLD        0x40
136 #define LMP_SNIF        0x80
137
138 #define LMP_PARK        0x01
139 #define LMP_RSSI        0x02
140 #define LMP_QUALITY     0x04
141 #define LMP_SCO         0x08
142 #define LMP_HV2         0x10
143 #define LMP_HV3         0x20
144 #define LMP_ULAW        0x40
145 #define LMP_ALAW        0x80
146
147 #define LMP_CVSD        0x01
148 #define LMP_PSCHEME     0x02
149 #define LMP_PCONTROL    0x04
150
151 /* Link policies */
152 #define HCI_LP_RSWITCH  0x0001
153 #define HCI_LP_HOLD     0x0002
154 #define HCI_LP_SNIFF    0x0004
155 #define HCI_LP_PARK     0x0008
156
157 /* Link mode */
158 #define HCI_LM_ACCEPT   0x8000
159 #define HCI_LM_MASTER   0x0001
160 #define HCI_LM_AUTH     0x0002
161 #define HCI_LM_ENCRYPT  0x0004
162 #define HCI_LM_TRUSTED  0x0008
163
164 /* -----  HCI Commands ----- */
165 /* OGF & OCF values */
166
167 /* Informational Parameters */
168 #define OGF_INFO_PARAM  0x04
169
170 #define OCF_READ_LOCAL_VERSION  0x0001
171 typedef struct {
172         __u8  status;
173         __u8  hci_ver;
174         __u16 hci_rev;
175         __u8  lmp_ver;
176         __u16 manufacturer;
177         __u16 lmp_subver;
178 } __attribute__ ((packed)) read_local_version_rp;
179 #define READ_LOCAL_VERSION_RP_SIZE 9
180
181 #define OCF_READ_LOCAL_FEATURES 0x0003
182 typedef struct {
183         __u8 status;
184         __u8 features[8];
185 } __attribute__ ((packed)) read_local_features_rp;
186
187 #define OCF_READ_BUFFER_SIZE    0x0005
188 typedef struct {
189         __u8    status;
190         __u16   acl_mtu;
191         __u8    sco_mtu;
192         __u16   acl_max_pkt;
193         __u16   sco_max_pkt;
194 } __attribute__ ((packed)) read_buffer_size_rp;
195
196 #define OCF_READ_BD_ADDR        0x0009
197 typedef struct {
198         __u8 status;
199         bdaddr_t bdaddr;
200 } __attribute__ ((packed)) read_bd_addr_rp;
201
202 /* Host Controller and Baseband */
203 #define OGF_HOST_CTL    0x03
204 #define OCF_RESET               0x0003
205 #define OCF_READ_AUTH_ENABLE    0x001F
206 #define OCF_WRITE_AUTH_ENABLE   0x0020
207         #define AUTH_DISABLED           0x00
208         #define AUTH_ENABLED            0x01
209
210 #define OCF_READ_ENCRYPT_MODE   0x0021
211 #define OCF_WRITE_ENCRYPT_MODE  0x0022
212         #define ENCRYPT_DISABLED        0x00
213         #define ENCRYPT_P2P             0x01
214         #define ENCRYPT_BOTH            0x02
215
216 #define OCF_WRITE_CA_TIMEOUT    0x0016  
217 #define OCF_WRITE_PG_TIMEOUT    0x0018
218
219 #define OCF_WRITE_SCAN_ENABLE   0x001A
220         #define SCAN_DISABLED           0x00
221         #define SCAN_INQUIRY            0x01
222         #define SCAN_PAGE               0x02
223
224 #define OCF_SET_EVENT_FLT       0x0005
225 typedef struct {
226         __u8    flt_type;
227         __u8    cond_type;
228         __u8    condition[0];
229 } __attribute__ ((packed)) set_event_flt_cp;
230 #define SET_EVENT_FLT_CP_SIZE 2
231
232 /* Filter types */
233 #define FLT_CLEAR_ALL   0x00
234 #define FLT_INQ_RESULT  0x01
235 #define FLT_CONN_SETUP  0x02
236
237 /* CONN_SETUP Condition types */
238 #define CONN_SETUP_ALLOW_ALL    0x00
239 #define CONN_SETUP_ALLOW_CLASS  0x01
240 #define CONN_SETUP_ALLOW_BDADDR 0x02
241
242 /* CONN_SETUP Conditions */
243 #define CONN_SETUP_AUTO_OFF     0x01
244 #define CONN_SETUP_AUTO_ON      0x02
245
246 #define OCF_CHANGE_LOCAL_NAME   0x0013
247 typedef struct {
248         __u8    name[248];
249 } __attribute__ ((packed)) change_local_name_cp;
250 #define CHANGE_LOCAL_NAME_CP_SIZE 248 
251
252 #define OCF_READ_LOCAL_NAME     0x0014
253 typedef struct {
254         __u8    status;
255         __u8    name[248];
256 } __attribute__ ((packed)) read_local_name_rp;
257 #define READ_LOCAL_NAME_RP_SIZE 249 
258
259 #define OCF_READ_CLASS_OF_DEV   0x0023
260 typedef struct {
261         __u8    status;
262         __u8    dev_class[3];
263 } __attribute__ ((packed)) read_class_of_dev_rp;
264 #define READ_CLASS_OF_DEV_RP_SIZE 4 
265
266 #define OCF_WRITE_CLASS_OF_DEV  0x0024
267 typedef struct {
268         __u8    dev_class[3];
269 } __attribute__ ((packed)) write_class_of_dev_cp;
270 #define WRITE_CLASS_OF_DEV_CP_SIZE 3
271
272 #define OCF_HOST_BUFFER_SIZE    0x0033
273 typedef struct {
274         __u16   acl_mtu;
275         __u8    sco_mtu;
276         __u16   acl_max_pkt;
277         __u16   sco_max_pkt;
278 } __attribute__ ((packed)) host_buffer_size_cp;
279 #define HOST_BUFFER_SIZE_CP_SIZE 7
280
281 /* Link Control */
282 #define OGF_LINK_CTL    0x01 
283 #define OCF_CREATE_CONN         0x0005
284 typedef struct {
285         bdaddr_t bdaddr;
286         __u16   pkt_type;
287         __u8    pscan_rep_mode;
288         __u8    pscan_mode;
289         __u16   clock_offset;
290         __u8    role_switch;
291 } __attribute__ ((packed)) create_conn_cp;
292 #define CREATE_CONN_CP_SIZE 13
293
294 #define OCF_ACCEPT_CONN_REQ     0x0009
295 typedef struct {
296         bdaddr_t bdaddr;
297         __u8    role;
298 } __attribute__ ((packed)) accept_conn_req_cp;
299 #define ACCEPT_CONN_REQ_CP_SIZE 7
300
301 #define OCF_REJECT_CONN_REQ     0x000a
302 typedef struct {
303         bdaddr_t bdaddr;
304         __u8    reason;
305 } __attribute__ ((packed)) reject_conn_req_cp;
306 #define REJECT_CONN_REQ_CP_SIZE 7
307
308 #define OCF_DISCONNECT  0x0006
309 typedef struct {
310         __u16   handle;
311         __u8    reason;
312 } __attribute__ ((packed)) disconnect_cp;
313 #define DISCONNECT_CP_SIZE 3
314
315 #define OCF_ADD_SCO     0x0007
316 typedef struct {
317         __u16   handle;
318         __u16   pkt_type;
319 } __attribute__ ((packed)) add_sco_cp;
320 #define ADD_SCO_CP_SIZE 4
321
322 #define OCF_INQUIRY             0x0001
323 typedef struct {
324         __u8    lap[3];
325         __u8    length;
326         __u8    num_rsp;
327 } __attribute__ ((packed)) inquiry_cp;
328 #define INQUIRY_CP_SIZE 5
329
330 typedef struct {
331         __u8     status;
332         bdaddr_t bdaddr;
333 } __attribute__ ((packed)) status_bdaddr_rp;
334 #define STATUS_BDADDR_RP_SIZE 7
335
336 #define OCF_LINK_KEY_REPLY      0x000B
337 #define OCF_LINK_KEY_NEG_REPLY  0x000C
338 typedef struct {
339         bdaddr_t bdaddr;
340         __u8     link_key[16];
341 } __attribute__ ((packed)) link_key_reply_cp;
342 #define LINK_KEY_REPLY_CP_SIZE 22
343
344 #define OCF_PIN_CODE_REPLY      0x000D
345 #define OCF_PIN_CODE_NEG_REPLY  0x000E
346 typedef struct {
347         bdaddr_t bdaddr;
348         __u8     pin_len;
349         __u8     pin_code[16];
350 } __attribute__ ((packed)) pin_code_reply_cp;
351 #define PIN_CODE_REPLY_CP_SIZE 23
352
353 #define OCF_CHANGE_CONN_PTYPE   0x000F
354 typedef struct {
355         __u16    handle;
356         __u16    pkt_type;
357 } __attribute__ ((packed)) change_conn_ptype_cp;
358 #define CHANGE_CONN_PTYPE_CP_SIZE 4
359
360 #define OCF_AUTH_REQUESTED      0x0011
361 typedef struct {
362         __u16    handle;
363 } __attribute__ ((packed)) auth_requested_cp;
364 #define AUTH_REQUESTED_CP_SIZE 2
365
366 #define OCF_SET_CONN_ENCRYPT    0x0013
367 typedef struct {
368         __u16    handle;
369         __u8     encrypt;
370 } __attribute__ ((packed)) set_conn_encrypt_cp;
371 #define SET_CONN_ENCRYPT_CP_SIZE 3
372
373 #define OCF_REMOTE_NAME_REQ     0x0019
374 typedef struct {
375         bdaddr_t bdaddr;
376         __u8     pscan_rep_mode;
377         __u8     pscan_mode;
378         __u16    clock_offset;
379 } __attribute__ ((packed)) remote_name_req_cp;
380 #define REMOTE_NAME_REQ_CP_SIZE 10
381
382 #define OCF_READ_REMOTE_FEATURES 0x001B
383 typedef struct {
384         __u16   handle;
385 } __attribute__ ((packed)) read_remote_features_cp;
386 #define READ_REMOTE_FEATURES_CP_SIZE 2
387
388 #define OCF_READ_REMOTE_VERSION 0x001D
389 typedef struct {
390         __u16   handle;
391 } __attribute__ ((packed)) read_remote_version_cp;
392 #define READ_REMOTE_VERSION_CP_SIZE 2
393
394 /* Link Policy */
395 #define OGF_LINK_POLICY  0x02   
396 #define OCF_ROLE_DISCOVERY      0x0009
397 typedef struct {
398         __u16   handle;
399 } __attribute__ ((packed)) role_discovery_cp;
400 #define ROLE_DISCOVERY_CP_SIZE 2
401 typedef struct {
402         __u8    status;
403         __u16   handle;
404         __u8    role;
405 } __attribute__ ((packed)) role_discovery_rp;
406 #define ROLE_DISCOVERY_RP_SIZE 4
407
408 #define OCF_READ_LINK_POLICY    0x000C
409 typedef struct {
410         __u16   handle;
411 } __attribute__ ((packed)) read_link_policy_cp;
412 #define READ_LINK_POLICY_CP_SIZE 2
413 typedef struct {
414         __u8    status;
415         __u16   handle;
416         __u16   policy;
417 } __attribute__ ((packed)) read_link_policy_rp;
418 #define READ_LINK_POLICY_RP_SIZE 5
419
420 #define OCF_SWITCH_ROLE 0x000B
421 typedef struct {
422         bdaddr_t bdaddr;
423         __u8     role;
424 } __attribute__ ((packed)) switch_role_cp;
425 #define SWITCH_ROLE_CP_SIZE 7
426
427 #define OCF_WRITE_LINK_POLICY   0x000D
428 typedef struct {
429         __u16   handle;
430         __u16   policy;
431 } __attribute__ ((packed)) write_link_policy_cp;
432 #define WRITE_LINK_POLICY_CP_SIZE 4
433 typedef struct {
434         __u8    status;
435         __u16   handle;
436 } __attribute__ ((packed)) write_link_policy_rp;
437 #define WRITE_LINK_POLICY_RP_SIZE 3
438
439 /* Status params */
440 #define OGF_STATUS_PARAM        0x05
441
442 /* ---- HCI Events ---- */
443 #define EVT_INQUIRY_COMPLETE    0x01
444
445 #define EVT_INQUIRY_RESULT      0x02
446 typedef struct {
447         bdaddr_t        bdaddr;
448         __u8    pscan_rep_mode;
449         __u8    pscan_period_mode;
450         __u8    pscan_mode;
451         __u8    dev_class[3];
452         __u16   clock_offset;
453 } __attribute__ ((packed)) inquiry_info;
454 #define INQUIRY_INFO_SIZE 14
455
456 #define EVT_CONN_COMPLETE       0x03
457 typedef struct {
458         __u8    status;
459         __u16   handle;
460         bdaddr_t        bdaddr;
461         __u8    link_type;
462         __u8    encr_mode;
463 } __attribute__ ((packed)) evt_conn_complete;
464 #define EVT_CONN_COMPLETE_SIZE 13
465
466 #define EVT_CONN_REQUEST        0x04
467 typedef struct {
468         bdaddr_t        bdaddr;
469         __u8            dev_class[3];
470         __u8            link_type;
471 } __attribute__ ((packed)) evt_conn_request;
472 #define EVT_CONN_REQUEST_SIZE 10
473
474 #define EVT_DISCONN_COMPLETE    0x05
475 typedef struct {
476         __u8    status;
477         __u16   handle;
478         __u8    reason;
479 } __attribute__ ((packed)) evt_disconn_complete;
480 #define EVT_DISCONN_COMPLETE_SIZE 4
481
482 #define EVT_AUTH_COMPLETE       0x06
483 typedef struct {
484         __u8    status;
485         __u16   handle;
486 } __attribute__ ((packed)) evt_auth_complete;
487 #define EVT_AUTH_COMPLETE_SIZE 3
488
489 #define EVT_REMOTE_NAME_REQ_COMPLETE    0x07
490 typedef struct {
491         __u8     status;
492         bdaddr_t bdaddr;
493         __u8     name[248];
494 } __attribute__ ((packed)) evt_remote_name_req_complete;
495 #define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255
496
497 #define EVT_ENCRYPT_CHANGE      0x08
498 typedef struct {
499         __u8    status;
500         __u16   handle;
501         __u8    encrypt;
502 } __attribute__ ((packed)) evt_encrypt_change;
503 #define EVT_ENCRYPT_CHANGE_SIZE 5
504
505 #define EVT_QOS_SETUP_COMPLETE 0x0D
506 typedef struct {
507         __u8    service_type;
508         __u32   token_rate;
509         __u32   peak_bandwidth;
510         __u32   latency;
511         __u32   delay_variation;
512 } __attribute__ ((packed)) hci_qos;
513 typedef struct {
514         __u8    status;
515         __u16   handle;
516         hci_qos qos;
517 } __attribute__ ((packed)) evt_qos_setup_complete;
518 #define EVT_QOS_SETUP_COMPLETE_SIZE 20
519
520 #define EVT_CMD_COMPLETE        0x0e
521 typedef struct {
522         __u8    ncmd;
523         __u16   opcode;
524 } __attribute__ ((packed)) evt_cmd_complete;
525 #define EVT_CMD_COMPLETE_SIZE 3
526
527 #define EVT_CMD_STATUS          0x0f
528 typedef struct {
529         __u8    status;
530         __u8    ncmd;
531         __u16   opcode;
532 } __attribute__ ((packed)) evt_cmd_status;
533 #define EVT_CMD_STATUS_SIZE 4
534
535 #define EVT_NUM_COMP_PKTS       0x13
536 typedef struct {
537         __u8    num_hndl;
538         /* variable length part */
539 } __attribute__ ((packed)) evt_num_comp_pkts;
540 #define EVT_NUM_COMP_PKTS_SIZE 1
541
542 #define EVT_ROLE_CHANGE         0x12
543 typedef struct {
544         __u8     status;
545         bdaddr_t bdaddr;
546         __u8     role;
547 } __attribute__ ((packed)) evt_role_change;
548 #define EVT_ROLE_CHANGE_SIZE 8
549
550 #define EVT_PIN_CODE_REQ        0x16
551 typedef struct {
552         bdaddr_t bdaddr;
553 } __attribute__ ((packed)) evt_pin_code_req;
554 #define EVT_PIN_CODE_REQ_SIZE 6
555
556 #define EVT_LINK_KEY_REQ        0x17
557 typedef struct {
558         bdaddr_t bdaddr;
559 } __attribute__ ((packed)) evt_link_key_req;
560 #define EVT_LINK_KEY_REQ_SIZE 6
561
562 #define EVT_LINK_KEY_NOTIFY     0x18
563 typedef struct {
564         bdaddr_t bdaddr;
565         __u8     link_key[16];
566         __u8     key_type;
567 } __attribute__ ((packed)) evt_link_key_notify;
568 #define EVT_LINK_KEY_NOTIFY_SIZE 23
569
570 #define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0B
571 typedef struct {
572         __u8    status;
573         __u16   handle;
574         __u8    features[8];
575 } __attribute__ ((packed)) evt_read_remote_features_complete;
576 #define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
577
578 #define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C
579 typedef struct {
580         __u8    status;
581         __u16   handle;
582         __u8    lmp_ver;
583         __u16   manufacturer;
584         __u16   lmp_subver;
585 } __attribute__ ((packed)) evt_read_remote_version_complete;
586 #define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
587
588 /* Internal events generated by BlueZ stack */
589 #define EVT_STACK_INTERNAL      0xfd
590 typedef struct {
591         __u16   type;
592         __u8    data[0];
593 } __attribute__ ((packed)) evt_stack_internal;
594 #define EVT_STACK_INTERNAL_SIZE 2
595
596 #define EVT_SI_DEVICE   0x01
597 typedef struct {
598         __u16   event;
599         __u16   dev_id;
600 } __attribute__ ((packed)) evt_si_device;
601 #define EVT_SI_DEVICE_SIZE 4
602
603 #define EVT_SI_SECURITY 0x02
604 typedef struct {
605         __u16   event;
606         __u16   proto;
607         __u16   subproto;
608         __u8    incomming;
609 } __attribute__ ((packed)) evt_si_security;
610
611 /* --------  HCI Packet structures  -------- */
612 #define HCI_TYPE_LEN    1
613
614 typedef struct {
615         __u16   opcode;         /* OCF & OGF */
616         __u8    plen;
617 } __attribute__ ((packed))      hci_command_hdr;
618 #define HCI_COMMAND_HDR_SIZE    3
619
620 typedef struct {
621         __u8    evt;
622         __u8    plen;
623 } __attribute__ ((packed))      hci_event_hdr;
624 #define HCI_EVENT_HDR_SIZE      2
625
626 typedef struct {
627         __u16   handle;         /* Handle & Flags(PB, BC) */
628         __u16   dlen;
629 } __attribute__ ((packed))      hci_acl_hdr;
630 #define HCI_ACL_HDR_SIZE        4
631
632 typedef struct {
633         __u16   handle;
634         __u8    dlen;
635 } __attribute__ ((packed))      hci_sco_hdr;
636 #define HCI_SCO_HDR_SIZE        3
637
638 /* Command opcode pack/unpack */
639 #define cmd_opcode_pack(ogf, ocf)       (__u16)((ocf & 0x03ff)|(ogf << 10))
640 #define cmd_opcode_ogf(op)              (op >> 10)
641 #define cmd_opcode_ocf(op)              (op & 0x03ff)
642
643 /* ACL handle and flags pack/unpack */
644 #define acl_handle_pack(h, f)   (__u16)((h & 0x0fff)|(f << 12))
645 #define acl_handle(h)           (h & 0x0fff)
646 #define acl_flags(h)            (h >> 12)
647
648 /* HCI Socket options */
649 #define HCI_DATA_DIR    1
650 #define HCI_FILTER      2
651 #define HCI_TIME_STAMP  3
652
653 /* HCI CMSG flags */
654 #define HCI_CMSG_DIR    0x0001
655 #define HCI_CMSG_TSTAMP 0x0002
656
657 struct sockaddr_hci {
658         sa_family_t    hci_family;
659         unsigned short hci_dev;
660 };
661 #define HCI_DEV_NONE    0xffff
662
663 struct hci_filter {
664         __u32 type_mask;
665         __u32 event_mask[2];
666         __u16 opcode;
667 };
668
669 #define HCI_FLT_TYPE_BITS       31
670 #define HCI_FLT_EVENT_BITS      63
671 #define HCI_FLT_OGF_BITS        63
672 #define HCI_FLT_OCF_BITS        127
673
674 #if BITS_PER_LONG == 64
675 static inline void hci_set_bit(int nr, void *addr)
676 {
677         *((__u32 *) addr + (nr >> 5)) |= ((__u32) 1 << (nr & 31));
678 }
679 static inline int hci_test_bit(int nr, void *addr)
680 {
681         return *((__u32 *) addr + (nr >> 5)) & ((__u32) 1 << (nr & 31));
682 }
683 #else
684 #define hci_set_bit     set_bit
685 #define hci_test_bit    test_bit
686 #endif
687
688 /* Ioctl requests structures */
689 struct hci_dev_stats {
690         __u32 err_rx;
691         __u32 err_tx;
692         __u32 cmd_tx;
693         __u32 evt_rx;
694         __u32 acl_tx;
695         __u32 acl_rx;
696         __u32 sco_tx;
697         __u32 sco_rx;
698         __u32 byte_rx;
699         __u32 byte_tx;
700 };
701
702 struct hci_dev_info {
703         __u16 dev_id;
704         char  name[8];
705
706         bdaddr_t bdaddr;
707
708         __u32 flags;
709         __u8  type;
710
711         __u8  features[8];
712
713         __u32 pkt_type;
714         __u32 link_policy;
715         __u32 link_mode;
716
717         __u16 acl_mtu;
718         __u16 acl_pkts;
719         __u16 sco_mtu;
720         __u16 sco_pkts;
721
722         struct hci_dev_stats stat;
723 };
724
725 struct hci_conn_info {
726         __u16    handle;
727         bdaddr_t bdaddr;
728         __u8     type;
729         __u8     out;
730         __u16    state;
731         __u32    link_mode;
732 };
733
734 struct hci_dev_req {
735         __u16 dev_id;
736         __u32 dev_opt;
737 };
738
739 struct hci_dev_list_req {
740         __u16  dev_num;
741         struct hci_dev_req dev_req[0];  /* hci_dev_req structures */
742 };
743
744 struct hci_conn_list_req {
745         __u16  dev_id;
746         __u16  conn_num;
747         struct hci_conn_info conn_info[0];
748 };
749
750 struct hci_conn_info_req {
751         bdaddr_t bdaddr;
752         __u8     type;
753         struct   hci_conn_info conn_info[0];
754 };
755
756 struct hci_inquiry_req {
757         __u16 dev_id;
758         __u16 flags;
759         __u8  lap[3];
760         __u8  length;
761         __u8  num_rsp;
762 };
763 #define IREQ_CACHE_FLUSH 0x0001
764
765 struct hci_remotename_req {
766         __u16 dev_id;
767         __u16 flags;
768         bdaddr_t bdaddr;
769         __u8  name[248];
770 };
771
772 #endif /* __HCI_H */