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/l2cap.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/l2cap.c')
-rw-r--r-- | net/bluetooth/l2cap.c | 51 |
1 files changed, 49 insertions, 2 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 | ||
1109 | static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen) | 1109 | static 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 | ||
1155 | static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) | 1155 | static 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 | |||
1177 | static 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 | ||
1233 | static 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 | |||
1211 | static int l2cap_sock_shutdown(struct socket *sock, int how) | 1258 | static int l2cap_sock_shutdown(struct socket *sock, int how) |
1212 | { | 1259 | { |
1213 | struct sock *sk = sock->sk; | 1260 | struct sock *sk = sock->sk; |