Commit 0477e2e868ceead7fd96218e1a062e01631ce717

Authored by Grzegorz Kolodziejczyk
Committed by Marcel Holtmann
1 parent e0fdbab169

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>

Showing 3 changed files with 10 additions and 0 deletions Side-by-side Diff

... ... @@ -570,6 +570,7 @@
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)
... ... @@ -1247,6 +1248,7 @@
1247 1248 COMPATIBLE_IOCTL(BNEPCONNDEL)
1248 1249 COMPATIBLE_IOCTL(BNEPGETCONNLIST)
1249 1250 COMPATIBLE_IOCTL(BNEPGETCONNINFO)
  1251 +COMPATIBLE_IOCTL(BNEPGETSUPPFEAT)
1250 1252 COMPATIBLE_IOCTL(CMTPCONNADD)
1251 1253 COMPATIBLE_IOCTL(CMTPCONNDEL)
1252 1254 COMPATIBLE_IOCTL(CMTPGETCONNLIST)
net/bluetooth/bnep/bnep.h
... ... @@ -111,6 +111,7 @@
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 */
net/bluetooth/bnep/sock.c
... ... @@ -57,6 +57,7 @@
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);
... ... @@ -119,6 +120,12 @@
119 120 return -EFAULT;
120 121  
121 122 return err;
  123 +
  124 + case BNEPGETSUPPFEAT:
  125 + if (copy_to_user(argp, &supp_feat, sizeof(supp_feat)))
  126 + return -EFAULT;
  127 +
  128 + return 0;
122 129  
123 130 default:
124 131 return -EINVAL;