xref: /openbmc/linux/include/net/bluetooth/hci_sock.h (revision e291c116f60f3c1ca98090f0f8e7c77e658562fb)
1f49daa81SMarcel Holtmann /*
2f49daa81SMarcel Holtmann    BlueZ - Bluetooth protocol stack for Linux
3f49daa81SMarcel Holtmann    Copyright (C) 2000-2001 Qualcomm Incorporated
4f49daa81SMarcel Holtmann 
5f49daa81SMarcel Holtmann    Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6f49daa81SMarcel Holtmann 
7f49daa81SMarcel Holtmann    This program is free software; you can redistribute it and/or modify
8f49daa81SMarcel Holtmann    it under the terms of the GNU General Public License version 2 as
9f49daa81SMarcel Holtmann    published by the Free Software Foundation;
10f49daa81SMarcel Holtmann 
11f49daa81SMarcel Holtmann    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12f49daa81SMarcel Holtmann    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13f49daa81SMarcel Holtmann    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14f49daa81SMarcel Holtmann    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15f49daa81SMarcel Holtmann    CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16f49daa81SMarcel Holtmann    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17f49daa81SMarcel Holtmann    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18f49daa81SMarcel Holtmann    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19f49daa81SMarcel Holtmann 
20f49daa81SMarcel Holtmann    ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21f49daa81SMarcel Holtmann    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22f49daa81SMarcel Holtmann    SOFTWARE IS DISCLAIMED.
23f49daa81SMarcel Holtmann */
24f49daa81SMarcel Holtmann 
25f49daa81SMarcel Holtmann #ifndef __HCI_SOCK_H
26f49daa81SMarcel Holtmann #define __HCI_SOCK_H
27f49daa81SMarcel Holtmann 
28f49daa81SMarcel Holtmann /* Socket options */
29f49daa81SMarcel Holtmann #define HCI_DATA_DIR	1
30f49daa81SMarcel Holtmann #define HCI_FILTER	2
31f49daa81SMarcel Holtmann #define HCI_TIME_STAMP	3
32f49daa81SMarcel Holtmann 
33f49daa81SMarcel Holtmann /* CMSG flags */
34*32929e1fSAlain Michaud #define HCI_CMSG_DIR	0x01
35*32929e1fSAlain Michaud #define HCI_CMSG_TSTAMP	0x02
36f49daa81SMarcel Holtmann 
37f49daa81SMarcel Holtmann struct sockaddr_hci {
38f49daa81SMarcel Holtmann 	sa_family_t    hci_family;
39f49daa81SMarcel Holtmann 	unsigned short hci_dev;
40f49daa81SMarcel Holtmann 	unsigned short hci_channel;
41f49daa81SMarcel Holtmann };
42f49daa81SMarcel Holtmann #define HCI_DEV_NONE	0xffff
43f49daa81SMarcel Holtmann 
44f49daa81SMarcel Holtmann #define HCI_CHANNEL_RAW		0
45f49daa81SMarcel Holtmann #define HCI_CHANNEL_USER	1
46f49daa81SMarcel Holtmann #define HCI_CHANNEL_MONITOR	2
47f49daa81SMarcel Holtmann #define HCI_CHANNEL_CONTROL	3
48ac714949SMarcel Holtmann #define HCI_CHANNEL_LOGGING	4
49f49daa81SMarcel Holtmann 
50f49daa81SMarcel Holtmann struct hci_filter {
51f49daa81SMarcel Holtmann 	unsigned long type_mask;
52f49daa81SMarcel Holtmann 	unsigned long event_mask[2];
53f49daa81SMarcel Holtmann 	__le16 opcode;
54f49daa81SMarcel Holtmann };
55f49daa81SMarcel Holtmann 
56f49daa81SMarcel Holtmann struct hci_ufilter {
57f49daa81SMarcel Holtmann 	__u32  type_mask;
58f49daa81SMarcel Holtmann 	__u32  event_mask[2];
59f49daa81SMarcel Holtmann 	__le16 opcode;
60f49daa81SMarcel Holtmann };
61f49daa81SMarcel Holtmann 
62f49daa81SMarcel Holtmann #define HCI_FLT_TYPE_BITS	31
63f49daa81SMarcel Holtmann #define HCI_FLT_EVENT_BITS	63
64f49daa81SMarcel Holtmann #define HCI_FLT_OGF_BITS	63
65f49daa81SMarcel Holtmann #define HCI_FLT_OCF_BITS	127
66f49daa81SMarcel Holtmann 
67f49daa81SMarcel Holtmann /* Ioctl defines */
68f49daa81SMarcel Holtmann #define HCIDEVUP	_IOW('H', 201, int)
69f49daa81SMarcel Holtmann #define HCIDEVDOWN	_IOW('H', 202, int)
70f49daa81SMarcel Holtmann #define HCIDEVRESET	_IOW('H', 203, int)
71f49daa81SMarcel Holtmann #define HCIDEVRESTAT	_IOW('H', 204, int)
72f49daa81SMarcel Holtmann 
73f49daa81SMarcel Holtmann #define HCIGETDEVLIST	_IOR('H', 210, int)
74f49daa81SMarcel Holtmann #define HCIGETDEVINFO	_IOR('H', 211, int)
75f49daa81SMarcel Holtmann #define HCIGETCONNLIST	_IOR('H', 212, int)
76f49daa81SMarcel Holtmann #define HCIGETCONNINFO	_IOR('H', 213, int)
77f49daa81SMarcel Holtmann #define HCIGETAUTHINFO	_IOR('H', 215, int)
78f49daa81SMarcel Holtmann 
79f49daa81SMarcel Holtmann #define HCISETRAW	_IOW('H', 220, int)
80f49daa81SMarcel Holtmann #define HCISETSCAN	_IOW('H', 221, int)
81f49daa81SMarcel Holtmann #define HCISETAUTH	_IOW('H', 222, int)
82f49daa81SMarcel Holtmann #define HCISETENCRYPT	_IOW('H', 223, int)
83f49daa81SMarcel Holtmann #define HCISETPTYPE	_IOW('H', 224, int)
84f49daa81SMarcel Holtmann #define HCISETLINKPOL	_IOW('H', 225, int)
85f49daa81SMarcel Holtmann #define HCISETLINKMODE	_IOW('H', 226, int)
86f49daa81SMarcel Holtmann #define HCISETACLMTU	_IOW('H', 227, int)
87f49daa81SMarcel Holtmann #define HCISETSCOMTU	_IOW('H', 228, int)
88f49daa81SMarcel Holtmann 
89f49daa81SMarcel Holtmann #define HCIBLOCKADDR	_IOW('H', 230, int)
90f49daa81SMarcel Holtmann #define HCIUNBLOCKADDR	_IOW('H', 231, int)
91f49daa81SMarcel Holtmann 
92f49daa81SMarcel Holtmann #define HCIINQUIRY	_IOR('H', 240, int)
93f49daa81SMarcel Holtmann 
94f49daa81SMarcel Holtmann /* Ioctl requests structures */
95f49daa81SMarcel Holtmann struct hci_dev_stats {
96f49daa81SMarcel Holtmann 	__u32 err_rx;
97f49daa81SMarcel Holtmann 	__u32 err_tx;
98f49daa81SMarcel Holtmann 	__u32 cmd_tx;
99f49daa81SMarcel Holtmann 	__u32 evt_rx;
100f49daa81SMarcel Holtmann 	__u32 acl_tx;
101f49daa81SMarcel Holtmann 	__u32 acl_rx;
102f49daa81SMarcel Holtmann 	__u32 sco_tx;
103f49daa81SMarcel Holtmann 	__u32 sco_rx;
104f49daa81SMarcel Holtmann 	__u32 byte_rx;
105f49daa81SMarcel Holtmann 	__u32 byte_tx;
106f49daa81SMarcel Holtmann };
107f49daa81SMarcel Holtmann 
108f49daa81SMarcel Holtmann struct hci_dev_info {
109f49daa81SMarcel Holtmann 	__u16 dev_id;
110f49daa81SMarcel Holtmann 	char  name[8];
111f49daa81SMarcel Holtmann 
112f49daa81SMarcel Holtmann 	bdaddr_t bdaddr;
113f49daa81SMarcel Holtmann 
114f49daa81SMarcel Holtmann 	__u32 flags;
115f49daa81SMarcel Holtmann 	__u8  type;
116f49daa81SMarcel Holtmann 
117f49daa81SMarcel Holtmann 	__u8  features[8];
118f49daa81SMarcel Holtmann 
119f49daa81SMarcel Holtmann 	__u32 pkt_type;
120f49daa81SMarcel Holtmann 	__u32 link_policy;
121f49daa81SMarcel Holtmann 	__u32 link_mode;
122f49daa81SMarcel Holtmann 
123f49daa81SMarcel Holtmann 	__u16 acl_mtu;
124f49daa81SMarcel Holtmann 	__u16 acl_pkts;
125f49daa81SMarcel Holtmann 	__u16 sco_mtu;
126f49daa81SMarcel Holtmann 	__u16 sco_pkts;
127f49daa81SMarcel Holtmann 
128f49daa81SMarcel Holtmann 	struct hci_dev_stats stat;
129f49daa81SMarcel Holtmann };
130f49daa81SMarcel Holtmann 
131f49daa81SMarcel Holtmann struct hci_conn_info {
132f49daa81SMarcel Holtmann 	__u16    handle;
133f49daa81SMarcel Holtmann 	bdaddr_t bdaddr;
134f49daa81SMarcel Holtmann 	__u8     type;
135f49daa81SMarcel Holtmann 	__u8     out;
136f49daa81SMarcel Holtmann 	__u16    state;
137f49daa81SMarcel Holtmann 	__u32    link_mode;
138f49daa81SMarcel Holtmann };
139f49daa81SMarcel Holtmann 
140f49daa81SMarcel Holtmann struct hci_dev_req {
141f49daa81SMarcel Holtmann 	__u16  dev_id;
142f49daa81SMarcel Holtmann 	__u32  dev_opt;
143f49daa81SMarcel Holtmann };
144f49daa81SMarcel Holtmann 
145f49daa81SMarcel Holtmann struct hci_dev_list_req {
146f49daa81SMarcel Holtmann 	__u16  dev_num;
147a7e45454SGustavo A. R. Silva 	struct hci_dev_req dev_req[];	/* hci_dev_req structures */
148f49daa81SMarcel Holtmann };
149f49daa81SMarcel Holtmann 
150f49daa81SMarcel Holtmann struct hci_conn_list_req {
151f49daa81SMarcel Holtmann 	__u16  dev_id;
152f49daa81SMarcel Holtmann 	__u16  conn_num;
153a7e45454SGustavo A. R. Silva 	struct hci_conn_info conn_info[];
154f49daa81SMarcel Holtmann };
155f49daa81SMarcel Holtmann 
156f49daa81SMarcel Holtmann struct hci_conn_info_req {
157f49daa81SMarcel Holtmann 	bdaddr_t bdaddr;
158f49daa81SMarcel Holtmann 	__u8     type;
159a7e45454SGustavo A. R. Silva 	struct   hci_conn_info conn_info[];
160f49daa81SMarcel Holtmann };
161f49daa81SMarcel Holtmann 
162f49daa81SMarcel Holtmann struct hci_auth_info_req {
163f49daa81SMarcel Holtmann 	bdaddr_t bdaddr;
164f49daa81SMarcel Holtmann 	__u8     type;
165f49daa81SMarcel Holtmann };
166f49daa81SMarcel Holtmann 
167f49daa81SMarcel Holtmann struct hci_inquiry_req {
168f49daa81SMarcel Holtmann 	__u16 dev_id;
169f49daa81SMarcel Holtmann 	__u16 flags;
170f49daa81SMarcel Holtmann 	__u8  lap[3];
171f49daa81SMarcel Holtmann 	__u8  length;
172f49daa81SMarcel Holtmann 	__u8  num_rsp;
173f49daa81SMarcel Holtmann };
174f49daa81SMarcel Holtmann #define IREQ_CACHE_FLUSH 0x0001
175f49daa81SMarcel Holtmann 
176f49daa81SMarcel Holtmann #endif /* __HCI_SOCK_H */
177