diff options
author | Ville Tervo <ville.tervo@nokia.com> | 2011-02-10 20:38:49 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-02-16 14:32:55 -0500 |
commit | acd7d3708555b3da7522e23c183cc21efc785f72 (patch) | |
tree | 41a15cea1207308c26c344a2bc585175be432fae /net/bluetooth/l2cap_sock.c | |
parent | 6ed58ec520ad2b2fe3f955c8a5fd0eecafccebdf (diff) |
Bluetooth: Add LE connection support to L2CAP
Add basic LE connection support to L2CAP. LE
connection can be created by specifying cid
in struct sockaddr_l2
Signed-off-by: Ville Tervo <ville.tervo@nokia.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/l2cap_sock.c')
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 21f5385ca24d..f45d361e84d1 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -168,13 +168,13 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al | |||
168 | len = min_t(unsigned int, sizeof(la), alen); | 168 | len = min_t(unsigned int, sizeof(la), alen); |
169 | memcpy(&la, addr, len); | 169 | memcpy(&la, addr, len); |
170 | 170 | ||
171 | if (la.l2_cid) | 171 | if (la.l2_cid && la.l2_psm) |
172 | return -EINVAL; | 172 | return -EINVAL; |
173 | 173 | ||
174 | lock_sock(sk); | 174 | lock_sock(sk); |
175 | 175 | ||
176 | if ((sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) | 176 | if ((sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) |
177 | && !la.l2_psm) { | 177 | && !(la.l2_psm || la.l2_cid)) { |
178 | err = -EINVAL; | 178 | err = -EINVAL; |
179 | goto done; | 179 | goto done; |
180 | } | 180 | } |
@@ -216,7 +216,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al | |||
216 | 216 | ||
217 | /* PSM must be odd and lsb of upper byte must be 0 */ | 217 | /* PSM must be odd and lsb of upper byte must be 0 */ |
218 | if ((__le16_to_cpu(la.l2_psm) & 0x0101) != 0x0001 && | 218 | if ((__le16_to_cpu(la.l2_psm) & 0x0101) != 0x0001 && |
219 | sk->sk_type != SOCK_RAW) { | 219 | sk->sk_type != SOCK_RAW && !la.l2_cid) { |
220 | err = -EINVAL; | 220 | err = -EINVAL; |
221 | goto done; | 221 | goto done; |
222 | } | 222 | } |
@@ -224,6 +224,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al | |||
224 | /* Set destination address and psm */ | 224 | /* Set destination address and psm */ |
225 | bacpy(&bt_sk(sk)->dst, &la.l2_bdaddr); | 225 | bacpy(&bt_sk(sk)->dst, &la.l2_bdaddr); |
226 | l2cap_pi(sk)->psm = la.l2_psm; | 226 | l2cap_pi(sk)->psm = la.l2_psm; |
227 | l2cap_pi(sk)->dcid = la.l2_cid; | ||
227 | 228 | ||
228 | err = l2cap_do_connect(sk); | 229 | err = l2cap_do_connect(sk); |
229 | if (err) | 230 | if (err) |