diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-01-15 15:52:14 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-02-27 00:14:22 -0500 |
commit | d58daf42d29a3a4a4d4be46cf47ceee096789680 (patch) | |
tree | c88a5820a44fe993e271437b0fcebdde7e8298d3 /net/bluetooth/rfcomm/sock.c | |
parent | 91aa35a5aa3540223066bf6b51c935418c63a35d (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/bluetooth/rfcomm/sock.c')
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 51 |
1 files changed, 49 insertions, 2 deletions
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 | ||
716 | static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen) | 716 | static 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 | ||
745 | static int rfcomm_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) | 745 | static 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 | |||
767 | static 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 | ||
813 | static 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 | |||
791 | static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | 838 | static 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; |