Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Grzegorz Kolodziejczyk and committed by
Marcel Holtmann
0477e2e8 e0fdbab1

+10
+2
fs/compat_ioctl.c
··· 570 570 #define BNEPCONNDEL _IOW('B', 201, int) 571 571 #define BNEPGETCONNLIST _IOR('B', 210, int) 572 572 #define BNEPGETCONNINFO _IOR('B', 211, int) 573 + #define BNEPGETSUPPFEAT _IOR('B', 212, int) 573 574 574 575 #define CMTPCONNADD _IOW('C', 200, int) 575 576 #define CMTPCONNDEL _IOW('C', 201, int) ··· 1248 1247 COMPATIBLE_IOCTL(BNEPCONNDEL) 1249 1248 COMPATIBLE_IOCTL(BNEPGETCONNLIST) 1250 1249 COMPATIBLE_IOCTL(BNEPGETCONNINFO) 1250 + COMPATIBLE_IOCTL(BNEPGETSUPPFEAT) 1251 1251 COMPATIBLE_IOCTL(CMTPCONNADD) 1252 1252 COMPATIBLE_IOCTL(CMTPCONNDEL) 1253 1253 COMPATIBLE_IOCTL(CMTPGETCONNLIST)
+1
net/bluetooth/bnep/bnep.h
··· 111 111 #define BNEPCONNDEL _IOW('B', 201, int) 112 112 #define BNEPGETCONNLIST _IOR('B', 210, int) 113 113 #define BNEPGETCONNINFO _IOR('B', 211, int) 114 + #define BNEPGETSUPPFEAT _IOR('B', 212, int) 114 115 115 116 struct bnep_connadd_req { 116 117 int sock; /* Connected socket */
+7
net/bluetooth/bnep/sock.c
··· 57 57 struct bnep_conninfo ci; 58 58 struct socket *nsock; 59 59 void __user *argp = (void __user *)arg; 60 + __u32 supp_feat = 0; 60 61 int err; 61 62 62 63 BT_DBG("cmd %x arg %lx", cmd, arg); ··· 120 119 return -EFAULT; 121 120 122 121 return err; 122 + 123 + case BNEPGETSUPPFEAT: 124 + if (copy_to_user(argp, &supp_feat, sizeof(supp_feat))) 125 + return -EFAULT; 126 + 127 + return 0; 123 128 124 129 default: 125 130 return -EINVAL;