Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)   BNEP protocol definition for Linux Bluetooth stack (BlueZ).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)   Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #ifndef _BNEP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #define _BNEP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/crc32.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <net/bluetooth/bluetooth.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /* Limits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define BNEP_MAX_PROTO_FILTERS		5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define BNEP_MAX_MULTICAST_FILTERS	20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /* UUIDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define BNEP_BASE_UUID	0x0000000000001000800000805F9B34FB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define BNEP_UUID16	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define BNEP_UUID32	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define BNEP_UUID128	0x16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define BNEP_SVC_PANU	0x1115
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define BNEP_SVC_NAP	0x1116
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define BNEP_SVC_GN	0x1117
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /* Packet types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define BNEP_GENERAL			0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define BNEP_CONTROL			0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define BNEP_COMPRESSED			0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define BNEP_COMPRESSED_SRC_ONLY	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define BNEP_COMPRESSED_DST_ONLY	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) /* Control types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define BNEP_CMD_NOT_UNDERSTOOD		0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define BNEP_SETUP_CONN_REQ		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define BNEP_SETUP_CONN_RSP		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define BNEP_FILTER_NET_TYPE_SET	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define BNEP_FILTER_NET_TYPE_RSP	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define BNEP_FILTER_MULTI_ADDR_SET	0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define BNEP_FILTER_MULTI_ADDR_RSP	0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) /* Extension types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define BNEP_EXT_CONTROL 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) /* Response messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define BNEP_SUCCESS 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define BNEP_CONN_INVALID_DST 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define BNEP_CONN_INVALID_SRC 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define BNEP_CONN_INVALID_SVC 0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define BNEP_CONN_NOT_ALLOWED 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define BNEP_FILTER_UNSUPPORTED_REQ	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define BNEP_FILTER_INVALID_RANGE	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define BNEP_FILTER_INVALID_MCADDR	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define BNEP_FILTER_LIMIT_REACHED	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define BNEP_FILTER_DENIED_SECURITY	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /* L2CAP settings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define BNEP_MTU	1691
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define BNEP_PSM	0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define BNEP_FLUSH_TO	0xffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define BNEP_CONNECT_TO	15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define BNEP_FILTER_TO	15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /* Headers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #define BNEP_TYPE_MASK	0x7f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define BNEP_EXT_HEADER	0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) struct bnep_setup_conn_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	__u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	__u8 ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	__u8 uuid_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	__u8 service[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) struct bnep_set_filter_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	__u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	__u8 ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	__be16 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	__u8 list[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) struct bnep_control_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	__u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	__u8 ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	__be16 resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) struct bnep_ext_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	__u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	__u8 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	__u8 data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) /* BNEP ioctl defines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define BNEPCONNADD	_IOW('B', 200, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define BNEPCONNDEL	_IOW('B', 201, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define BNEPGETCONNLIST	_IOR('B', 210, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define BNEPGETCONNINFO	_IOR('B', 211, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define BNEPGETSUPPFEAT	_IOR('B', 212, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define BNEP_SETUP_RESPONSE	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define BNEP_SETUP_RSP_SENT	10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct bnep_connadd_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	int   sock;		/* Connected socket */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	__u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	__u16 role;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	char  device[16];	/* Name of the Ethernet device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct bnep_conndel_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	__u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	__u8  dst[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct bnep_conninfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	__u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	__u16 role;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	__u16 state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	__u8  dst[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	char  device[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct bnep_connlist_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	__u32  cnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	struct bnep_conninfo __user *ci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct bnep_proto_filter {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	__u16 start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	__u16 end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) int bnep_del_connection(struct bnep_conndel_req *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) int bnep_get_connlist(struct bnep_connlist_req *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) int bnep_get_conninfo(struct bnep_conninfo *ci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* BNEP sessions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct bnep_session {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	unsigned int  role;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	unsigned long state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	atomic_t      terminate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	struct task_struct *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	struct ethhdr eh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct msghdr msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	struct bnep_proto_filter proto_filter[BNEP_MAX_PROTO_FILTERS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	unsigned long long mc_filter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	struct socket    *sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) void bnep_net_setup(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int bnep_sock_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) void bnep_sock_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static inline int bnep_mc_hash(__u8 *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	return crc32_be(~0, addr, ETH_ALEN) >> 26;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #endif