Skip to contentSkip to conversation

Bluetooth: add BT_CONNINFO socketopt

RFC New Gustavo F. Padovan 1 participant 1 message Feb 15, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 Bluetooth: add BT_CONNINFO socketopt

ATT needs to know to link key type before run some of it procedures. Using the socket sec_level doesn't work because the socket may not reflect the real sec_level of the link.

---
 include/net/bluetooth/bluetooth.h |    2 ++
 net/bluetooth/l2cap_sock.c        |   11 +++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)
include/net/bluetooth/bluetooth.h +2 -0
index 4375043..dea93df 100644
@@ -66,6 +66,8 @@ struct bt_security {
 
 #define BT_FLUSHABLE	8
 
+#define BT_CONNINFO	9
+
 #define BT_FLUSHABLE_OFF	0
 #define BT_FLUSHABLE_ON		1
 
net/bluetooth/l2cap_sock.c +11 -0
index 484e717..c249617 100644
@@ -468,6 +468,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
 {
 	struct sock *sk = sock->sk;
 	struct bt_security sec;
+	struct hci_conn *hconn = (void *)l2cap_pi(sk)->conn;
 	int len, err = 0;
 
 	BT_DBG("sk %p", sk);
@@ -516,6 +517,16 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
 
 		break;
 
+	case BT_CONNINFO:
+		if (sk->sk_state != BT_CONNECTED) {
+			err = -EINVAL;
+			break;
+		}
+
+		if (put_user(hconn->sec_level, (u32 __user *) optval))
+			err = -EFAULT;
+		break;
+
 	default:
 		err = -ENOPROTOOPT;
 		break;
Signature · 1 line
1.7.4