aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-01-15 15:52:14 -0500
committerMarcel Holtmann <marcel@holtmann.org>2009-02-27 00:14:22 -0500
commitd58daf42d29a3a4a4d4be46cf47ceee096789680 (patch)
treec88a5820a44fe993e271437b0fcebdde7e8298d3 /net
parent91aa35a5aa3540223066bf6b51c935418c63a35d (diff)
Bluetooth: Preparation for usage of SOL_BLUETOOTH
The socket option levels SOL_L2CAP, SOL_RFOMM and SOL_SCO are currently in use by various Bluetooth applications. Going forward the common option level SOL_BLUETOOTH should be used. This patch prepares the clean split of the old and new option levels while keeping everything backward compatibility. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/l2cap.c51
-rw-r--r--net/bluetooth/rfcomm/sock.c51
-rw-r--r--net/bluetooth/sco.c27
3 files changed, 124 insertions, 5 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index b93748e224ff..df1a95e185c6 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -1106,7 +1106,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
1106 return err; 1106 return err;
1107} 1107}
1108 1108
1109static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen) 1109static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, int optlen)
1110{ 1110{
1111 struct sock *sk = sock->sk; 1111 struct sock *sk = sock->sk;
1112 struct l2cap_options opts; 1112 struct l2cap_options opts;
@@ -1152,7 +1152,29 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
1152 return err; 1152 return err;
1153} 1153}
1154 1154
1155static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) 1155static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
1156{
1157 struct sock *sk = sock->sk;
1158 int err = 0;
1159
1160 BT_DBG("sk %p", sk);
1161
1162 if (level == SOL_L2CAP)
1163 return l2cap_sock_setsockopt_old(sock, optname, optval, optlen);
1164
1165 lock_sock(sk);
1166
1167 switch (optname) {
1168 default:
1169 err = -ENOPROTOOPT;
1170 break;
1171 }
1172
1173 release_sock(sk);
1174 return err;
1175}
1176
1177static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __user *optval, int __user *optlen)
1156{ 1178{
1157 struct sock *sk = sock->sk; 1179 struct sock *sk = sock->sk;
1158 struct l2cap_options opts; 1180 struct l2cap_options opts;
@@ -1208,6 +1230,31 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
1208 return err; 1230 return err;
1209} 1231}
1210 1232
1233static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen)
1234{
1235 struct sock *sk = sock->sk;
1236 int len, err = 0;
1237
1238 BT_DBG("sk %p", sk);
1239
1240 if (level == SOL_L2CAP)
1241 return l2cap_sock_getsockopt_old(sock, optname, optval, optlen);
1242
1243 if (get_user(len, optlen))
1244 return -EFAULT;
1245
1246 lock_sock(sk);
1247
1248 switch (optname) {
1249 default:
1250 err = -ENOPROTOOPT;
1251 break;
1252 }
1253
1254 release_sock(sk);
1255 return err;
1256}
1257
1211static int l2cap_sock_shutdown(struct socket *sock, int how) 1258static int l2cap_sock_shutdown(struct socket *sock, int how)
1212{ 1259{
1213 struct sock *sk = sock->sk; 1260 struct sock *sk = sock->sk;
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index ce505f2a755b..65dd7133d72b 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -713,7 +713,7 @@ out:
713 return copied ? : err; 713 return copied ? : err;
714} 714}
715 715
716static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen) 716static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, int optlen)
717{ 717{
718 struct sock *sk = sock->sk; 718 struct sock *sk = sock->sk;
719 int err = 0; 719 int err = 0;
@@ -742,7 +742,29 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
742 return err; 742 return err;
743} 743}
744 744
745static int rfcomm_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) 745static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
746{
747 struct sock *sk = sock->sk;
748 int err = 0;
749
750 BT_DBG("sk %p", sk);
751
752 if (level == SOL_RFCOMM)
753 return rfcomm_sock_setsockopt_old(sock, optname, optval, optlen);
754
755 lock_sock(sk);
756
757 switch (optname) {
758 default:
759 err = -ENOPROTOOPT;
760 break;
761 }
762
763 release_sock(sk);
764 return err;
765}
766
767static int rfcomm_sock_getsockopt_old(struct socket *sock, int optname, char __user *optval, int __user *optlen)
746{ 768{
747 struct sock *sk = sock->sk; 769 struct sock *sk = sock->sk;
748 struct sock *l2cap_sk; 770 struct sock *l2cap_sk;
@@ -788,6 +810,31 @@ static int rfcomm_sock_getsockopt(struct socket *sock, int level, int optname, c
788 return err; 810 return err;
789} 811}
790 812
813static int rfcomm_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen)
814{
815 struct sock *sk = sock->sk;
816 int len, err = 0;
817
818 BT_DBG("sk %p", sk);
819
820 if (level == SOL_RFCOMM)
821 return rfcomm_sock_getsockopt_old(sock, optname, optval, optlen);
822
823 if (get_user(len, optlen))
824 return -EFAULT;
825
826 lock_sock(sk);
827
828 switch (optname) {
829 default:
830 err = -ENOPROTOOPT;
831 break;
832 }
833
834 release_sock(sk);
835 return err;
836}
837
791static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 838static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
792{ 839{
793 struct sock *sk __maybe_unused = sock->sk; 840 struct sock *sk __maybe_unused = sock->sk;
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 46fd8bf9a690..dea40d4bb6f5 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -668,7 +668,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char
668 return err; 668 return err;
669} 669}
670 670
671static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) 671static int sco_sock_getsockopt_old(struct socket *sock, int optname, char __user *optval, int __user *optlen)
672{ 672{
673 struct sock *sk = sock->sk; 673 struct sock *sk = sock->sk;
674 struct sco_options opts; 674 struct sco_options opts;
@@ -723,6 +723,31 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char
723 return err; 723 return err;
724} 724}
725 725
726static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen)
727{
728 struct sock *sk = sock->sk;
729 int len, err = 0;
730
731 BT_DBG("sk %p", sk);
732
733 if (level == SOL_SCO)
734 return sco_sock_getsockopt_old(sock, optname, optval, optlen);
735
736 if (get_user(len, optlen))
737 return -EFAULT;
738
739 lock_sock(sk);
740
741 switch (optname) {
742 default:
743 err = -ENOPROTOOPT;
744 break;
745 }
746
747 release_sock(sk);
748 return err;
749}
750
726static int sco_sock_release(struct socket *sock) 751static int sco_sock_release(struct socket *sock)
727{ 752{
728 struct sock *sk = sock->sk; 753 struct sock *sk = sock->sk;