aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-12-02 09:34:18 -0500
committerMarcel Holtmann <marcel@holtmann.org>2013-12-05 10:05:34 -0500
commit1f435424ce2c93c31c3887ec67e3afb6056f18f6 (patch)
tree93a7aed7a02b6984dfb3b4adfe45a4e4142eb8dd /net
parent64b4f8dc763d5c26dea0f483d6e475540eaf9759 (diff)
Bluetooth: Add new BT_SNDMTU and BT_RCVMTU socket options
This patch adds new socket options for LE sockets since the existing L2CAP_OPTIONS socket option is not usable for LE. For now, the new socket options also require LE CoC support to be explicitly enabled to leave some playroom in case something needs to be changed in a backwards incompatible way. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/l2cap_sock.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index a20fcc3ddcd9..01d65bc99b0c 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -534,6 +534,41 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
534 err = -EFAULT; 534 err = -EFAULT;
535 break; 535 break;
536 536
537 case BT_SNDMTU:
538 if (!enable_lecoc) {
539 err = -EPROTONOSUPPORT;
540 break;
541 }
542
543 if (!bdaddr_type_is_le(chan->src_type)) {
544 err = -EINVAL;
545 break;
546 }
547
548 if (sk->sk_state != BT_CONNECTED) {
549 err = -ENOTCONN;
550 break;
551 }
552
553 if (put_user(chan->omtu, (u16 __user *) optval))
554 err = -EFAULT;
555 break;
556
557 case BT_RCVMTU:
558 if (!enable_lecoc) {
559 err = -EPROTONOSUPPORT;
560 break;
561 }
562
563 if (!bdaddr_type_is_le(chan->src_type)) {
564 err = -EINVAL;
565 break;
566 }
567
568 if (put_user(chan->imtu, (u16 __user *) optval))
569 err = -EFAULT;
570 break;
571
537 default: 572 default:
538 err = -ENOPROTOOPT; 573 err = -ENOPROTOOPT;
539 break; 574 break;
@@ -834,6 +869,47 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
834 869
835 break; 870 break;
836 871
872 case BT_SNDMTU:
873 if (!enable_lecoc) {
874 err = -EPROTONOSUPPORT;
875 break;
876 }
877
878 if (!bdaddr_type_is_le(chan->src_type)) {
879 err = -EINVAL;
880 break;
881 }
882
883 /* Setting is not supported as it's the remote side that
884 * decides this.
885 */
886 err = -EPERM;
887 break;
888
889 case BT_RCVMTU:
890 if (!enable_lecoc) {
891 err = -EPROTONOSUPPORT;
892 break;
893 }
894
895 if (!bdaddr_type_is_le(chan->src_type)) {
896 err = -EINVAL;
897 break;
898 }
899
900 if (sk->sk_state == BT_CONNECTED) {
901 err = -EISCONN;
902 break;
903 }
904
905 if (get_user(opt, (u32 __user *) optval)) {
906 err = -EFAULT;
907 break;
908 }
909
910 chan->imtu = opt;
911 break;
912
837 default: 913 default:
838 err = -ENOPROTOOPT; 914 err = -ENOPROTOOPT;
839 break; 915 break;