]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - net/bluetooth/bnep/bnep.h
UBUNTU: Ubuntu-4.15.0-96.97
[mirror_ubuntu-bionic-kernel.git] / net / bluetooth / bnep / bnep.h
CommitLineData
1da177e4
LT
1/*
2 BNEP protocol definition for Linux Bluetooth stack (BlueZ).
3 Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
8e87d142 4
1da177e4
LT
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2, as
7 published by the Free Software Foundation.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
c057b190 15 along with this program; if not, see <http://www.gnu.org/licenses/>.
1da177e4
LT
16*/
17
1da177e4
LT
18#ifndef _BNEP_H
19#define _BNEP_H
20
21#include <linux/types.h>
22#include <linux/crc32.h>
23#include <net/bluetooth/bluetooth.h>
24
3aad75a1
SJ
25/* Limits */
26#define BNEP_MAX_PROTO_FILTERS 5
27#define BNEP_MAX_MULTICAST_FILTERS 20
28
29/* UUIDs */
30#define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
31#define BNEP_UUID16 0x02
32#define BNEP_UUID32 0x04
33#define BNEP_UUID128 0x16
34
35#define BNEP_SVC_PANU 0x1115
36#define BNEP_SVC_NAP 0x1116
37#define BNEP_SVC_GN 0x1117
38
39/* Packet types */
40#define BNEP_GENERAL 0x00
41#define BNEP_CONTROL 0x01
42#define BNEP_COMPRESSED 0x02
43#define BNEP_COMPRESSED_SRC_ONLY 0x03
44#define BNEP_COMPRESSED_DST_ONLY 0x04
45
46/* Control types */
47#define BNEP_CMD_NOT_UNDERSTOOD 0x00
48#define BNEP_SETUP_CONN_REQ 0x01
49#define BNEP_SETUP_CONN_RSP 0x02
50#define BNEP_FILTER_NET_TYPE_SET 0x03
51#define BNEP_FILTER_NET_TYPE_RSP 0x04
52#define BNEP_FILTER_MULTI_ADDR_SET 0x05
53#define BNEP_FILTER_MULTI_ADDR_RSP 0x06
54
55/* Extension types */
56#define BNEP_EXT_CONTROL 0x00
57
58/* Response messages */
59#define BNEP_SUCCESS 0x00
60
61#define BNEP_CONN_INVALID_DST 0x01
62#define BNEP_CONN_INVALID_SRC 0x02
63#define BNEP_CONN_INVALID_SVC 0x03
64#define BNEP_CONN_NOT_ALLOWED 0x04
65
66#define BNEP_FILTER_UNSUPPORTED_REQ 0x01
67#define BNEP_FILTER_INVALID_RANGE 0x02
68#define BNEP_FILTER_INVALID_MCADDR 0x02
69#define BNEP_FILTER_LIMIT_REACHED 0x03
70#define BNEP_FILTER_DENIED_SECURITY 0x04
71
72/* L2CAP settings */
73#define BNEP_MTU 1691
74#define BNEP_PSM 0x0f
75#define BNEP_FLUSH_TO 0xffff
76#define BNEP_CONNECT_TO 15
77#define BNEP_FILTER_TO 15
78
79/* Headers */
80#define BNEP_TYPE_MASK 0x7f
81#define BNEP_EXT_HEADER 0x80
1da177e4
LT
82
83struct bnep_setup_conn_req {
3aad75a1
SJ
84 __u8 type;
85 __u8 ctrl;
86 __u8 uuid_size;
87 __u8 service[0];
bc10502d 88} __packed;
1da177e4
LT
89
90struct bnep_set_filter_req {
3aad75a1
SJ
91 __u8 type;
92 __u8 ctrl;
1bc5d448 93 __be16 len;
3aad75a1 94 __u8 list[0];
bc10502d 95} __packed;
1da177e4
LT
96
97struct bnep_control_rsp {
3aad75a1
SJ
98 __u8 type;
99 __u8 ctrl;
1bc5d448 100 __be16 resp;
bc10502d 101} __packed;
1da177e4
LT
102
103struct bnep_ext_hdr {
3aad75a1
SJ
104 __u8 type;
105 __u8 len;
106 __u8 data[0];
bc10502d 107} __packed;
1da177e4
LT
108
109/* BNEP ioctl defines */
110#define BNEPCONNADD _IOW('B', 200, int)
111#define BNEPCONNDEL _IOW('B', 201, int)
112#define BNEPGETCONNLIST _IOR('B', 210, int)
113#define BNEPGETCONNINFO _IOR('B', 211, int)
0477e2e8 114#define BNEPGETSUPPFEAT _IOR('B', 212, int)
1da177e4 115
836a061b
GK
116#define BNEP_SETUP_RESPONSE 0
117#define BNEP_SETUP_RSP_SENT 10
118
1da177e4 119struct bnep_connadd_req {
3aad75a1 120 int sock; /* Connected socket */
1da177e4
LT
121 __u32 flags;
122 __u16 role;
3aad75a1 123 char device[16]; /* Name of the Ethernet device */
1da177e4
LT
124};
125
126struct bnep_conndel_req {
127 __u32 flags;
128 __u8 dst[ETH_ALEN];
129};
130
131struct bnep_conninfo {
132 __u32 flags;
133 __u16 role;
8e87d142 134 __u16 state;
1da177e4
LT
135 __u8 dst[ETH_ALEN];
136 char device[16];
137};
138
139struct bnep_connlist_req {
140 __u32 cnum;
141 struct bnep_conninfo __user *ci;
142};
143
144struct bnep_proto_filter {
145 __u16 start;
146 __u16 end;
147};
148
149int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock);
150int bnep_del_connection(struct bnep_conndel_req *req);
151int bnep_get_connlist(struct bnep_connlist_req *req);
152int bnep_get_conninfo(struct bnep_conninfo *ci);
153
3aad75a1 154/* BNEP sessions */
1da177e4
LT
155struct bnep_session {
156 struct list_head list;
8e87d142 157
1da177e4 158 unsigned int role;
8e87d142
YH
159 unsigned long state;
160 unsigned long flags;
751c10a5 161 atomic_t terminate;
f4d7cd4a 162 struct task_struct *task;
1da177e4
LT
163
164 struct ethhdr eh;
165 struct msghdr msg;
166
167 struct bnep_proto_filter proto_filter[BNEP_MAX_PROTO_FILTERS];
a418b893 168 unsigned long long mc_filter;
8e87d142 169
1da177e4
LT
170 struct socket *sock;
171 struct net_device *dev;
1da177e4
LT
172};
173
174void bnep_net_setup(struct net_device *dev);
175int bnep_sock_init(void);
a4e2acf0 176void bnep_sock_cleanup(void);
1da177e4
LT
177
178static inline int bnep_mc_hash(__u8 *addr)
179{
3aad75a1 180 return crc32_be(~0, addr, ETH_ALEN) >> 26;
1da177e4
LT
181}
182
183#endif