aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2005-09-13 17:03:09 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-09-13 17:03:09 -0400
commitae01d2798d1825307044d75de11eb5c9ffb79c5a (patch)
treeae4b7f4aa08783855eec8725985ef22f0037ed93 /net
parentadcb5ad1e5ba3996d53a047c5486efa6e734b413 (diff)
parent0915e8865fe4684dc82f043ac7036f34bf89f52a (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/holtmann/bluetooth-2.6
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_event.c33
-rw-r--r--net/bluetooth/rfcomm/sock.c30
2 files changed, 58 insertions, 5 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index d6da0939216d..b61b4e8e36fd 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -558,6 +558,35 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
558 hci_dev_unlock(hdev); 558 hci_dev_unlock(hdev);
559} 559}
560 560
561/* Extended Inquiry Result */
562static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
563{
564 struct inquiry_data data;
565 struct extended_inquiry_info *info = (struct extended_inquiry_info *) (skb->data + 1);
566 int num_rsp = *((__u8 *) skb->data);
567
568 BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
569
570 if (!num_rsp)
571 return;
572
573 hci_dev_lock(hdev);
574
575 for (; num_rsp; num_rsp--) {
576 bacpy(&data.bdaddr, &info->bdaddr);
577 data.pscan_rep_mode = info->pscan_rep_mode;
578 data.pscan_period_mode = info->pscan_period_mode;
579 data.pscan_mode = 0x00;
580 memcpy(data.dev_class, info->dev_class, 3);
581 data.clock_offset = info->clock_offset;
582 data.rssi = info->rssi;
583 info++;
584 hci_inquiry_cache_update(hdev, &data);
585 }
586
587 hci_dev_unlock(hdev);
588}
589
561/* Connect Request */ 590/* Connect Request */
562static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) 591static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
563{ 592{
@@ -940,6 +969,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
940 hci_inquiry_result_with_rssi_evt(hdev, skb); 969 hci_inquiry_result_with_rssi_evt(hdev, skb);
941 break; 970 break;
942 971
972 case HCI_EV_EXTENDED_INQUIRY_RESULT:
973 hci_extended_inquiry_result_evt(hdev, skb);
974 break;
975
943 case HCI_EV_CONN_REQUEST: 976 case HCI_EV_CONN_REQUEST:
944 hci_conn_request_evt(hdev, skb); 977 hci_conn_request_evt(hdev, skb);
945 break; 978 break;
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 90e19eb6d3cc..f49e7e938bfb 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -363,6 +363,11 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
363 goto done; 363 goto done;
364 } 364 }
365 365
366 if (sk->sk_type != SOCK_STREAM) {
367 err = -EINVAL;
368 goto done;
369 }
370
366 write_lock_bh(&rfcomm_sk_list.lock); 371 write_lock_bh(&rfcomm_sk_list.lock);
367 372
368 if (sa->rc_channel && __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr)) { 373 if (sa->rc_channel && __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr)) {
@@ -393,13 +398,17 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a
393 if (addr->sa_family != AF_BLUETOOTH || alen < sizeof(struct sockaddr_rc)) 398 if (addr->sa_family != AF_BLUETOOTH || alen < sizeof(struct sockaddr_rc))
394 return -EINVAL; 399 return -EINVAL;
395 400
396 if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) 401 lock_sock(sk);
397 return -EBADFD;
398 402
399 if (sk->sk_type != SOCK_STREAM) 403 if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) {
400 return -EINVAL; 404 err = -EBADFD;
405 goto done;
406 }
401 407
402 lock_sock(sk); 408 if (sk->sk_type != SOCK_STREAM) {
409 err = -EINVAL;
410 goto done;
411 }
403 412
404 sk->sk_state = BT_CONNECT; 413 sk->sk_state = BT_CONNECT;
405 bacpy(&bt_sk(sk)->dst, &sa->rc_bdaddr); 414 bacpy(&bt_sk(sk)->dst, &sa->rc_bdaddr);
@@ -410,6 +419,7 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a
410 err = bt_sock_wait_state(sk, BT_CONNECTED, 419 err = bt_sock_wait_state(sk, BT_CONNECTED,
411 sock_sndtimeo(sk, flags & O_NONBLOCK)); 420 sock_sndtimeo(sk, flags & O_NONBLOCK));
412 421
422done:
413 release_sock(sk); 423 release_sock(sk);
414 return err; 424 return err;
415} 425}
@@ -428,6 +438,11 @@ static int rfcomm_sock_listen(struct socket *sock, int backlog)
428 goto done; 438 goto done;
429 } 439 }
430 440
441 if (sk->sk_type != SOCK_STREAM) {
442 err = -EINVAL;
443 goto done;
444 }
445
431 if (!rfcomm_pi(sk)->channel) { 446 if (!rfcomm_pi(sk)->channel) {
432 bdaddr_t *src = &bt_sk(sk)->src; 447 bdaddr_t *src = &bt_sk(sk)->src;
433 u8 channel; 448 u8 channel;
@@ -472,6 +487,11 @@ static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int f
472 goto done; 487 goto done;
473 } 488 }
474 489
490 if (sk->sk_type != SOCK_STREAM) {
491 err = -EINVAL;
492 goto done;
493 }
494
475 timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 495 timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);
476 496
477 BT_DBG("sk %p timeo %ld", sk, timeo); 497 BT_DBG("sk %p timeo %ld", sk, timeo);