aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2011-01-04 08:40:05 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2011-02-07 22:40:06 -0500
commit03b555e119de8288a16e086e1fbd223d9b429d3d (patch)
tree5f0dd5efc8439ba4300761bc9ebba22c3d718c06 /net
parent930e13363fb0e94db6e8b59c54dfb5c59355113e (diff)
Bluetooth: Reject pairing requests when in non-pairable mode
This patch adds the necessary logic to act accordingly when the HCI_PAIRABLE flag is not set. In that case PIN code replies as well as Secure Simple Pairing requests without a NoBonding requirement need to be rejected. Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_event.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index a8a38f17ef78..cf3014ae00e4 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1595,6 +1595,10 @@ static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff
1595 hci_conn_put(conn); 1595 hci_conn_put(conn);
1596 } 1596 }
1597 1597
1598 if (!test_bit(HCI_PAIRABLE, &hdev->flags))
1599 hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY,
1600 sizeof(ev->bdaddr), &ev->bdaddr);
1601
1598 hci_dev_unlock(hdev); 1602 hci_dev_unlock(hdev);
1599} 1603}
1600 1604
@@ -1885,9 +1889,52 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff
1885 hci_dev_lock(hdev); 1889 hci_dev_lock(hdev);
1886 1890
1887 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); 1891 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
1888 if (conn) 1892 if (!conn)
1889 hci_conn_hold(conn); 1893 goto unlock;
1894
1895 hci_conn_hold(conn);
1896
1897 if (!test_bit(HCI_MGMT, &hdev->flags))
1898 goto unlock;
1899
1900 if (test_bit(HCI_PAIRABLE, &hdev->flags) ||
1901 (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) {
1902 /* FIXME: Do IO capa response based on information
1903 * provided through the management interface */
1904 } else {
1905 struct hci_cp_io_capability_neg_reply cp;
1906
1907 bacpy(&cp.bdaddr, &ev->bdaddr);
1908 cp.reason = 0x16; /* Pairing not allowed */
1890 1909
1910 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_NEG_REPLY,
1911 sizeof(cp), &cp);
1912 }
1913
1914unlock:
1915 hci_dev_unlock(hdev);
1916}
1917
1918static inline void hci_io_capa_reply_evt(struct hci_dev *hdev, struct sk_buff *skb)
1919{
1920 struct hci_ev_io_capa_reply *ev = (void *) skb->data;
1921 struct hci_conn *conn;
1922
1923 BT_DBG("%s", hdev->name);
1924
1925 hci_dev_lock(hdev);
1926
1927 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
1928 if (!conn)
1929 goto unlock;
1930
1931 hci_conn_hold(conn);
1932
1933 conn->remote_cap = ev->capability;
1934 conn->remote_oob = ev->oob_data;
1935 conn->remote_auth = ev->authentication;
1936
1937unlock:
1891 hci_dev_unlock(hdev); 1938 hci_dev_unlock(hdev);
1892} 1939}
1893 1940
@@ -2051,6 +2098,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
2051 hci_io_capa_request_evt(hdev, skb); 2098 hci_io_capa_request_evt(hdev, skb);
2052 break; 2099 break;
2053 2100
2101 case HCI_EV_IO_CAPA_REPLY:
2102 hci_io_capa_reply_evt(hdev, skb);
2103 break;
2104
2054 case HCI_EV_SIMPLE_PAIR_COMPLETE: 2105 case HCI_EV_SIMPLE_PAIR_COMPLETE:
2055 hci_simple_pair_complete_evt(hdev, skb); 2106 hci_simple_pair_complete_evt(hdev, skb);
2056 break; 2107 break;