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 #ifndef __HCI_SOCK_H
26 #define __HCI_SOCK_H
27 
28 /* Socket options */
29 #define HCI_DATA_DIR	1
30 #define HCI_FILTER	2
31 #define HCI_TIME_STAMP	3
32 
33 /* CMSG flags */
34 #define HCI_CMSG_DIR	0x01
35 #define HCI_CMSG_TSTAMP	0x02
36 
37 struct sockaddr_hci {
38 	sa_family_t    hci_family;
39 	unsigned short hci_dev;
40 	unsigned short hci_channel;
41 };
42 #define HCI_DEV_NONE	0xffff
43 
44 #define HCI_CHANNEL_RAW		0
45 #define HCI_CHANNEL_USER	1
46 #define HCI_CHANNEL_MONITOR	2
47 #define HCI_CHANNEL_CONTROL	3
48 #define HCI_CHANNEL_LOGGING	4
49 
50 struct hci_filter {
51 	unsigned long type_mask;
52 	unsigned long event_mask[2];
53 	__le16 opcode;
54 };
55 
56 struct hci_ufilter {
57 	__u32  type_mask;
58 	__u32  event_mask[2];
59 	__le16 opcode;
60 };
61 
62 #define HCI_FLT_TYPE_BITS	31
63 #define HCI_FLT_EVENT_BITS	63
64 #define HCI_FLT_OGF_BITS	63
65 #define HCI_FLT_OCF_BITS	127
66 
67 /* Ioctl defines */
68 #define HCIDEVUP	_IOW('H', 201, int)
69 #define HCIDEVDOWN	_IOW('H', 202, int)
70 #define HCIDEVRESET	_IOW('H', 203, int)
71 #define HCIDEVRESTAT	_IOW('H', 204, int)
72 
73 #define HCIGETDEVLIST	_IOR('H', 210, int)
74 #define HCIGETDEVINFO	_IOR('H', 211, int)
75 #define HCIGETCONNLIST	_IOR('H', 212, int)
76 #define HCIGETCONNINFO	_IOR('H', 213, int)
77 #define HCIGETAUTHINFO	_IOR('H', 215, 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 HCIBLOCKADDR	_IOW('H', 230, int)
90 #define HCIUNBLOCKADDR	_IOW('H', 231, int)
91 
92 #define HCIINQUIRY	_IOR('H', 240, int)
93 
94 /* Ioctl requests structures */
95 struct hci_dev_stats {
96 	__u32 err_rx;
97 	__u32 err_tx;
98 	__u32 cmd_tx;
99 	__u32 evt_rx;
100 	__u32 acl_tx;
101 	__u32 acl_rx;
102 	__u32 sco_tx;
103 	__u32 sco_rx;
104 	__u32 byte_rx;
105 	__u32 byte_tx;
106 };
107 
108 struct hci_dev_info {
109 	__u16 dev_id;
110 	char  name[8];
111 
112 	bdaddr_t bdaddr;
113 
114 	__u32 flags;
115 	__u8  type;
116 
117 	__u8  features[8];
118 
119 	__u32 pkt_type;
120 	__u32 link_policy;
121 	__u32 link_mode;
122 
123 	__u16 acl_mtu;
124 	__u16 acl_pkts;
125 	__u16 sco_mtu;
126 	__u16 sco_pkts;
127 
128 	struct hci_dev_stats stat;
129 };
130 
131 struct hci_conn_info {
132 	__u16    handle;
133 	bdaddr_t bdaddr;
134 	__u8     type;
135 	__u8     out;
136 	__u16    state;
137 	__u32    link_mode;
138 };
139 
140 struct hci_dev_req {
141 	__u16  dev_id;
142 	__u32  dev_opt;
143 };
144 
145 struct hci_dev_list_req {
146 	__u16  dev_num;
147 	struct hci_dev_req dev_req[];	/* hci_dev_req structures */
148 };
149 
150 struct hci_conn_list_req {
151 	__u16  dev_id;
152 	__u16  conn_num;
153 	struct hci_conn_info conn_info[];
154 };
155 
156 struct hci_conn_info_req {
157 	bdaddr_t bdaddr;
158 	__u8     type;
159 	struct   hci_conn_info conn_info[];
160 };
161 
162 struct hci_auth_info_req {
163 	bdaddr_t bdaddr;
164 	__u8     type;
165 };
166 
167 struct hci_inquiry_req {
168 	__u16 dev_id;
169 	__u16 flags;
170 	__u8  lap[3];
171 	__u8  length;
172 	__u8  num_rsp;
173 };
174 #define IREQ_CACHE_FLUSH 0x0001
175 
176 #endif /* __HCI_SOCK_H */
177