Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0477e2e8 authored by Grzegorz Kolodziejczyk's avatar Grzegorz Kolodziejczyk Committed by Marcel Holtmann
Browse files

Bluetooth: bnep: Add support for get bnep features via ioctl



This is needed if user space wants to know supported bnep features
by kernel, e.g. if kernel supports sending response to bnep setup
control message. By now there is no possibility to know supported
features by kernel in case of bnep. Ioctls allows only to add connection,
delete connection, get connection list, get connection info. Adding
connection if it's possible (establishing network device connection) is
equivalent to starting bnep session. Bnep session handles data queue of
transmit, receive messages over bnep channel. It means that if we add
connection the received/transmitted data will be parsed immediately. In
case of get bnep features we want to know before session start, if we
should leave setup data on socket queue and let kernel to handle with it,
or in case of no setup handling support, if we should pull this message
and handle setup response within user space.

Signed-off-by: default avatarGrzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent e0fdbab1
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -570,6 +570,7 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, void __user *argp)
#define BNEPCONNDEL	_IOW('B', 201, int)
#define BNEPCONNDEL	_IOW('B', 201, int)
#define BNEPGETCONNLIST	_IOR('B', 210, int)
#define BNEPGETCONNLIST	_IOR('B', 210, int)
#define BNEPGETCONNINFO	_IOR('B', 211, int)
#define BNEPGETCONNINFO	_IOR('B', 211, int)
#define BNEPGETSUPPFEAT	_IOR('B', 212, int)


#define CMTPCONNADD	_IOW('C', 200, int)
#define CMTPCONNADD	_IOW('C', 200, int)
#define CMTPCONNDEL	_IOW('C', 201, int)
#define CMTPCONNDEL	_IOW('C', 201, int)
@@ -1247,6 +1248,7 @@ COMPATIBLE_IOCTL(BNEPCONNADD)
COMPATIBLE_IOCTL(BNEPCONNDEL)
COMPATIBLE_IOCTL(BNEPCONNDEL)
COMPATIBLE_IOCTL(BNEPGETCONNLIST)
COMPATIBLE_IOCTL(BNEPGETCONNLIST)
COMPATIBLE_IOCTL(BNEPGETCONNINFO)
COMPATIBLE_IOCTL(BNEPGETCONNINFO)
COMPATIBLE_IOCTL(BNEPGETSUPPFEAT)
COMPATIBLE_IOCTL(CMTPCONNADD)
COMPATIBLE_IOCTL(CMTPCONNADD)
COMPATIBLE_IOCTL(CMTPCONNDEL)
COMPATIBLE_IOCTL(CMTPCONNDEL)
COMPATIBLE_IOCTL(CMTPGETCONNLIST)
COMPATIBLE_IOCTL(CMTPGETCONNLIST)
+1 −0
Original line number Original line Diff line number Diff line
@@ -111,6 +111,7 @@ struct bnep_ext_hdr {
#define BNEPCONNDEL	_IOW('B', 201, int)
#define BNEPCONNDEL	_IOW('B', 201, int)
#define BNEPGETCONNLIST	_IOR('B', 210, int)
#define BNEPGETCONNLIST	_IOR('B', 210, int)
#define BNEPGETCONNINFO	_IOR('B', 211, int)
#define BNEPGETCONNINFO	_IOR('B', 211, int)
#define BNEPGETSUPPFEAT	_IOR('B', 212, int)


struct bnep_connadd_req {
struct bnep_connadd_req {
	int   sock;		/* Connected socket */
	int   sock;		/* Connected socket */
+7 −0
Original line number Original line Diff line number Diff line
@@ -57,6 +57,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
	struct bnep_conninfo ci;
	struct bnep_conninfo ci;
	struct socket *nsock;
	struct socket *nsock;
	void __user *argp = (void __user *)arg;
	void __user *argp = (void __user *)arg;
	__u32 supp_feat = 0;
	int err;
	int err;


	BT_DBG("cmd %x arg %lx", cmd, arg);
	BT_DBG("cmd %x arg %lx", cmd, arg);
@@ -120,6 +121,12 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long


		return err;
		return err;


	case BNEPGETSUPPFEAT:
		if (copy_to_user(argp, &supp_feat, sizeof(supp_feat)))
			return -EFAULT;

		return 0;

	default:
	default:
		return -EINVAL;
		return -EINVAL;
	}
	}