1 /* SPDX-License-Identifier: GPL-2.0-only */
3 BNEP protocol definition for Linux Bluetooth stack (BlueZ).
4 Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
11 #include <linux/types.h>
12 #include <linux/crc32.h>
13 #include <net/bluetooth/bluetooth.h>
16 #define BNEP_MAX_PROTO_FILTERS 5
17 #define BNEP_MAX_MULTICAST_FILTERS 20
20 #define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
21 #define BNEP_UUID16 0x02
22 #define BNEP_UUID32 0x04
23 #define BNEP_UUID128 0x16
25 #define BNEP_SVC_PANU 0x1115
26 #define BNEP_SVC_NAP 0x1116
27 #define BNEP_SVC_GN 0x1117
30 #define BNEP_GENERAL 0x00
31 #define BNEP_CONTROL 0x01
32 #define BNEP_COMPRESSED 0x02
33 #define BNEP_COMPRESSED_SRC_ONLY 0x03
34 #define BNEP_COMPRESSED_DST_ONLY 0x04
37 #define BNEP_CMD_NOT_UNDERSTOOD 0x00
38 #define BNEP_SETUP_CONN_REQ 0x01
39 #define BNEP_SETUP_CONN_RSP 0x02
40 #define BNEP_FILTER_NET_TYPE_SET 0x03
41 #define BNEP_FILTER_NET_TYPE_RSP 0x04
42 #define BNEP_FILTER_MULTI_ADDR_SET 0x05
43 #define BNEP_FILTER_MULTI_ADDR_RSP 0x06
46 #define BNEP_EXT_CONTROL 0x00
48 /* Response messages */
49 #define BNEP_SUCCESS 0x00
51 #define BNEP_CONN_INVALID_DST 0x01
52 #define BNEP_CONN_INVALID_SRC 0x02
53 #define BNEP_CONN_INVALID_SVC 0x03
54 #define BNEP_CONN_NOT_ALLOWED 0x04
56 #define BNEP_FILTER_UNSUPPORTED_REQ 0x01
57 #define BNEP_FILTER_INVALID_RANGE 0x02
58 #define BNEP_FILTER_INVALID_MCADDR 0x02
59 #define BNEP_FILTER_LIMIT_REACHED 0x03
60 #define BNEP_FILTER_DENIED_SECURITY 0x04
65 #define BNEP_FLUSH_TO 0xffff
66 #define BNEP_CONNECT_TO 15
67 #define BNEP_FILTER_TO 15
70 #define BNEP_TYPE_MASK 0x7f
71 #define BNEP_EXT_HEADER 0x80
73 struct bnep_setup_conn_req
{
80 struct bnep_set_filter_req
{
87 struct bnep_control_rsp
{
99 /* BNEP ioctl defines */
100 #define BNEPCONNADD _IOW('B', 200, int)
101 #define BNEPCONNDEL _IOW('B', 201, int)
102 #define BNEPGETCONNLIST _IOR('B', 210, int)
103 #define BNEPGETCONNINFO _IOR('B', 211, int)
104 #define BNEPGETSUPPFEAT _IOR('B', 212, int)
106 #define BNEP_SETUP_RESPONSE 0
107 #define BNEP_SETUP_RSP_SENT 10
109 struct bnep_connadd_req
{
110 int sock
; /* Connected socket */
113 char device
[16]; /* Name of the Ethernet device */
116 struct bnep_conndel_req
{
121 struct bnep_conninfo
{
129 struct bnep_connlist_req
{
131 struct bnep_conninfo __user
*ci
;
134 struct bnep_proto_filter
{
139 int bnep_add_connection(struct bnep_connadd_req
*req
, struct socket
*sock
);
140 int bnep_del_connection(struct bnep_conndel_req
*req
);
141 int bnep_get_connlist(struct bnep_connlist_req
*req
);
142 int bnep_get_conninfo(struct bnep_conninfo
*ci
);
145 struct bnep_session
{
146 struct list_head list
;
152 struct task_struct
*task
;
157 struct bnep_proto_filter proto_filter
[BNEP_MAX_PROTO_FILTERS
];
158 unsigned long long mc_filter
;
161 struct net_device
*dev
;
164 void bnep_net_setup(struct net_device
*dev
);
165 int bnep_sock_init(void);
166 void bnep_sock_cleanup(void);
168 static inline int bnep_mc_hash(__u8
*addr
)
170 return crc32_be(~0, addr
, ETH_ALEN
) >> 26;