diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-02-15 21:20:31 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-02-27 00:14:47 -0500 |
commit | 2a517ca687232adc8f14893730644da712010ffc (patch) | |
tree | 564d08647266370fd21ad5a0e0ee726e3f2ae113 /net/bluetooth | |
parent | 8bf4794174659b06d43cc5e290cd384757374613 (diff) |
Bluetooth: Disallow usage of L2CAP CID setting for now
In the future the L2CAP layer will have full support for fixed channels
and right now it already can export the channel assignment, but for the
functions bind() and connect() the usage of only CID 0 is allowed. This
allows an easy detection if the kernel supports fixed channels or not,
because otherwise it would impossible for application to tell.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/l2cap.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 79a4325a1388..7c6768c2a530 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -799,6 +799,9 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) | |||
799 | len = min_t(unsigned int, sizeof(la), alen); | 799 | len = min_t(unsigned int, sizeof(la), alen); |
800 | memcpy(&la, addr, len); | 800 | memcpy(&la, addr, len); |
801 | 801 | ||
802 | if (la.l2_cid) | ||
803 | return -EINVAL; | ||
804 | |||
802 | lock_sock(sk); | 805 | lock_sock(sk); |
803 | 806 | ||
804 | if (sk->sk_state != BT_OPEN) { | 807 | if (sk->sk_state != BT_OPEN) { |
@@ -929,19 +932,20 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al | |||
929 | struct sockaddr_l2 la; | 932 | struct sockaddr_l2 la; |
930 | int len, err = 0; | 933 | int len, err = 0; |
931 | 934 | ||
932 | lock_sock(sk); | ||
933 | |||
934 | BT_DBG("sk %p", sk); | 935 | BT_DBG("sk %p", sk); |
935 | 936 | ||
936 | if (!addr || addr->sa_family != AF_BLUETOOTH) { | 937 | if (!addr || addr->sa_family != AF_BLUETOOTH) |
937 | err = -EINVAL; | 938 | return -EINVAL; |
938 | goto done; | ||
939 | } | ||
940 | 939 | ||
941 | memset(&la, 0, sizeof(la)); | 940 | memset(&la, 0, sizeof(la)); |
942 | len = min_t(unsigned int, sizeof(la), alen); | 941 | len = min_t(unsigned int, sizeof(la), alen); |
943 | memcpy(&la, addr, len); | 942 | memcpy(&la, addr, len); |
944 | 943 | ||
944 | if (la.l2_cid) | ||
945 | return -EINVAL; | ||
946 | |||
947 | lock_sock(sk); | ||
948 | |||
945 | if (sk->sk_type == SOCK_SEQPACKET && !la.l2_psm) { | 949 | if (sk->sk_type == SOCK_SEQPACKET && !la.l2_psm) { |
946 | err = -EINVAL; | 950 | err = -EINVAL; |
947 | goto done; | 951 | goto done; |