0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _BNEP_H
0009 #define _BNEP_H
0010
0011 #include <linux/types.h>
0012 #include <linux/crc32.h>
0013 #include <net/bluetooth/bluetooth.h>
0014
0015
0016 #define BNEP_MAX_PROTO_FILTERS 5
0017 #define BNEP_MAX_MULTICAST_FILTERS 20
0018
0019
0020 #define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB
0021 #define BNEP_UUID16 0x02
0022 #define BNEP_UUID32 0x04
0023 #define BNEP_UUID128 0x16
0024
0025 #define BNEP_SVC_PANU 0x1115
0026 #define BNEP_SVC_NAP 0x1116
0027 #define BNEP_SVC_GN 0x1117
0028
0029
0030 #define BNEP_GENERAL 0x00
0031 #define BNEP_CONTROL 0x01
0032 #define BNEP_COMPRESSED 0x02
0033 #define BNEP_COMPRESSED_SRC_ONLY 0x03
0034 #define BNEP_COMPRESSED_DST_ONLY 0x04
0035
0036
0037 #define BNEP_CMD_NOT_UNDERSTOOD 0x00
0038 #define BNEP_SETUP_CONN_REQ 0x01
0039 #define BNEP_SETUP_CONN_RSP 0x02
0040 #define BNEP_FILTER_NET_TYPE_SET 0x03
0041 #define BNEP_FILTER_NET_TYPE_RSP 0x04
0042 #define BNEP_FILTER_MULTI_ADDR_SET 0x05
0043 #define BNEP_FILTER_MULTI_ADDR_RSP 0x06
0044
0045
0046 #define BNEP_EXT_CONTROL 0x00
0047
0048
0049 #define BNEP_SUCCESS 0x00
0050
0051 #define BNEP_CONN_INVALID_DST 0x01
0052 #define BNEP_CONN_INVALID_SRC 0x02
0053 #define BNEP_CONN_INVALID_SVC 0x03
0054 #define BNEP_CONN_NOT_ALLOWED 0x04
0055
0056 #define BNEP_FILTER_UNSUPPORTED_REQ 0x01
0057 #define BNEP_FILTER_INVALID_RANGE 0x02
0058 #define BNEP_FILTER_INVALID_MCADDR 0x02
0059 #define BNEP_FILTER_LIMIT_REACHED 0x03
0060 #define BNEP_FILTER_DENIED_SECURITY 0x04
0061
0062
0063 #define BNEP_MTU 1691
0064 #define BNEP_PSM 0x0f
0065 #define BNEP_FLUSH_TO 0xffff
0066 #define BNEP_CONNECT_TO 15
0067 #define BNEP_FILTER_TO 15
0068
0069
0070 #define BNEP_TYPE_MASK 0x7f
0071 #define BNEP_EXT_HEADER 0x80
0072
0073 struct bnep_setup_conn_req {
0074 __u8 type;
0075 __u8 ctrl;
0076 __u8 uuid_size;
0077 __u8 service[];
0078 } __packed;
0079
0080 struct bnep_set_filter_req {
0081 __u8 type;
0082 __u8 ctrl;
0083 __be16 len;
0084 __u8 list[];
0085 } __packed;
0086
0087 struct bnep_control_rsp {
0088 __u8 type;
0089 __u8 ctrl;
0090 __be16 resp;
0091 } __packed;
0092
0093 struct bnep_ext_hdr {
0094 __u8 type;
0095 __u8 len;
0096 __u8 data[];
0097 } __packed;
0098
0099
0100 #define BNEPCONNADD _IOW('B', 200, int)
0101 #define BNEPCONNDEL _IOW('B', 201, int)
0102 #define BNEPGETCONNLIST _IOR('B', 210, int)
0103 #define BNEPGETCONNINFO _IOR('B', 211, int)
0104 #define BNEPGETSUPPFEAT _IOR('B', 212, int)
0105
0106 #define BNEP_SETUP_RESPONSE 0
0107 #define BNEP_SETUP_RSP_SENT 10
0108
0109 struct bnep_connadd_req {
0110 int sock;
0111 __u32 flags;
0112 __u16 role;
0113 char device[16];
0114 };
0115
0116 struct bnep_conndel_req {
0117 __u32 flags;
0118 __u8 dst[ETH_ALEN];
0119 };
0120
0121 struct bnep_conninfo {
0122 __u32 flags;
0123 __u16 role;
0124 __u16 state;
0125 __u8 dst[ETH_ALEN];
0126 char device[16];
0127 };
0128
0129 struct bnep_connlist_req {
0130 __u32 cnum;
0131 struct bnep_conninfo __user *ci;
0132 };
0133
0134 struct bnep_proto_filter {
0135 __u16 start;
0136 __u16 end;
0137 };
0138
0139 int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock);
0140 int bnep_del_connection(struct bnep_conndel_req *req);
0141 int bnep_get_connlist(struct bnep_connlist_req *req);
0142 int bnep_get_conninfo(struct bnep_conninfo *ci);
0143
0144
0145 struct bnep_session {
0146 struct list_head list;
0147
0148 unsigned int role;
0149 unsigned long state;
0150 unsigned long flags;
0151 atomic_t terminate;
0152 struct task_struct *task;
0153
0154 struct ethhdr eh;
0155 struct msghdr msg;
0156
0157 struct bnep_proto_filter proto_filter[BNEP_MAX_PROTO_FILTERS];
0158 unsigned long long mc_filter;
0159
0160 struct socket *sock;
0161 struct net_device *dev;
0162 };
0163
0164 void bnep_net_setup(struct net_device *dev);
0165 int bnep_sock_init(void);
0166 void bnep_sock_cleanup(void);
0167
0168 static inline int bnep_mc_hash(__u8 *addr)
0169 {
0170 return crc32_be(~0, addr, ETH_ALEN) >> 26;
0171 }
0172
0173 #endif