1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef _BNEP_H
24#define _BNEP_H
25
26#include <linux/types.h>
27#include <net/bluetooth/bluetooth.h>
28
29#include <linux/crc32.h>
30
31
32#define BNEP_MAX_PROTO_FILTERS 5
33#define BNEP_MAX_MULTICAST_FILTERS 20
34
35
36#define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
37#define BNEP_UUID16 0x02
38#define BNEP_UUID32 0x04
39#define BNEP_UUID128 0x16
40
41#define BNEP_SVC_PANU 0x1115
42#define BNEP_SVC_NAP 0x1116
43#define BNEP_SVC_GN 0x1117
44
45
46#define BNEP_GENERAL 0x00
47#define BNEP_CONTROL 0x01
48#define BNEP_COMPRESSED 0x02
49#define BNEP_COMPRESSED_SRC_ONLY 0x03
50#define BNEP_COMPRESSED_DST_ONLY 0x04
51
52
53#define BNEP_CMD_NOT_UNDERSTOOD 0x00
54#define BNEP_SETUP_CONN_REQ 0x01
55#define BNEP_SETUP_CONN_RSP 0x02
56#define BNEP_FILTER_NET_TYPE_SET 0x03
57#define BNEP_FILTER_NET_TYPE_RSP 0x04
58#define BNEP_FILTER_MULTI_ADDR_SET 0x05
59#define BNEP_FILTER_MULTI_ADDR_RSP 0x06
60
61
62#define BNEP_EXT_CONTROL 0x00
63
64
65#define BNEP_SUCCESS 0x00
66
67#define BNEP_CONN_INVALID_DST 0x01
68#define BNEP_CONN_INVALID_SRC 0x02
69#define BNEP_CONN_INVALID_SVC 0x03
70#define BNEP_CONN_NOT_ALLOWED 0x04
71
72#define BNEP_FILTER_UNSUPPORTED_REQ 0x01
73#define BNEP_FILTER_INVALID_RANGE 0x02
74#define BNEP_FILTER_INVALID_MCADDR 0x02
75#define BNEP_FILTER_LIMIT_REACHED 0x03
76#define BNEP_FILTER_DENIED_SECURITY 0x04
77
78
79#define BNEP_MTU 1691
80#define BNEP_PSM 0x0f
81#define BNEP_FLUSH_TO 0xffff
82#define BNEP_CONNECT_TO 15
83#define BNEP_FILTER_TO 15
84
85
86#define BNEP_TYPE_MASK 0x7f
87#define BNEP_EXT_HEADER 0x80
88
89struct bnep_setup_conn_req {
90 __u8 type;
91 __u8 ctrl;
92 __u8 uuid_size;
93 __u8 service[0];
94} __attribute__((packed));
95
96struct bnep_set_filter_req {
97 __u8 type;
98 __u8 ctrl;
99 __u16 len;
100 __u8 list[0];
101} __attribute__((packed));
102
103struct bnep_control_rsp {
104 __u8 type;
105 __u8 ctrl;
106 __u16 resp;
107} __attribute__((packed));
108
109struct bnep_ext_hdr {
110 __u8 type;
111 __u8 len;
112 __u8 data[0];
113} __attribute__((packed));
114
115
116#define BNEPCONNADD _IOW('B', 200, int)
117#define BNEPCONNDEL _IOW('B', 201, int)
118#define BNEPGETCONNLIST _IOR('B', 210, int)
119#define BNEPGETCONNINFO _IOR('B', 211, int)
120
121struct bnep_connadd_req {
122 int sock;
123 __u32 flags;
124 __u16 role;
125 char device[16];
126};
127
128struct bnep_conndel_req {
129 __u32 flags;
130 __u8 dst[ETH_ALEN];
131};
132
133struct bnep_conninfo {
134 __u32 flags;
135 __u16 role;
136 __u16 state;
137 __u8 dst[ETH_ALEN];
138 char device[16];
139};
140
141struct bnep_connlist_req {
142 __u32 cnum;
143 struct bnep_conninfo *ci;
144};
145
146struct bnep_proto_filter {
147 __u16 start;
148 __u16 end;
149};
150
151int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock);
152int bnep_del_connection(struct bnep_conndel_req *req);
153int bnep_get_connlist(struct bnep_connlist_req *req);
154int bnep_get_conninfo(struct bnep_conninfo *ci);
155
156
157struct bnep_session {
158 struct list_head list;
159
160 unsigned int role;
161 unsigned long state;
162 unsigned long flags;
163 atomic_t killed;
164
165 struct ethhdr eh;
166 struct msghdr msg;
167
168 struct bnep_proto_filter proto_filter[BNEP_MAX_PROTO_FILTERS];
169 u64 mc_filter;
170
171 struct socket *sock;
172 struct net_device dev;
173 struct net_device_stats stats;
174};
175
176int bnep_net_init(struct net_device *dev);
177int bnep_sock_init(void);
178int bnep_sock_cleanup(void);
179
180static inline int bnep_mc_hash(__u8 *addr)
181{
182 return (crc32_be(~0, addr, ETH_ALEN) >> 26);
183}
184
185#endif
186