Bluetooth: Add secure flag for mgmt_pin_code_req
authorWaldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Thu, 28 Apr 2011 10:07:59 +0000 (12:07 +0200)
committerGustavo F. Padovan <padovan@profusion.mobi>
Thu, 28 Apr 2011 18:19:43 +0000 (15:19 -0300)
Extend the mgmt_pin_code_request interface to require secure
pin code (16 digit) for authentication.

This is a kernel part of the secure pin code requirement notification
to user space agent.

Code styling fix by Johan Hedberg.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
include/net/bluetooth/hci_core.h
include/net/bluetooth/mgmt.h
net/bluetooth/hci_event.c
net/bluetooth/mgmt.c

index 2da2eb9..2995e2e 100644 (file)
@@ -777,7 +777,7 @@ int mgmt_connected(u16 index, bdaddr_t *bdaddr);
 int mgmt_disconnected(u16 index, bdaddr_t *bdaddr);
 int mgmt_disconnect_failed(u16 index);
 int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status);
-int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr);
+int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure);
 int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
 int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
 int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value);
index 7434406..0e7de63 100644 (file)
@@ -253,6 +253,7 @@ struct mgmt_ev_connect_failed {
 #define MGMT_EV_PIN_CODE_REQUEST       0x000E
 struct mgmt_ev_pin_code_request {
        bdaddr_t bdaddr;
+       __u8 secure;
 } __packed;
 
 #define MGMT_EV_USER_CONFIRM_REQUEST   0x000F
index 9d50e90..577d638 100644 (file)
@@ -2022,8 +2022,16 @@ static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff
                hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY,
                                        sizeof(ev->bdaddr), &ev->bdaddr);
 
-       if (test_bit(HCI_MGMT, &hdev->flags))
-               mgmt_pin_code_request(hdev->id, &ev->bdaddr);
+       if (test_bit(HCI_MGMT, &hdev->flags)) {
+               u8 secure;
+
+               if (conn->pending_sec_level == BT_SECURITY_HIGH)
+                       secure = 1;
+               else
+                       secure = 0;
+
+               mgmt_pin_code_request(hdev->id, &ev->bdaddr, secure);
+       }
 
        hci_dev_unlock(hdev);
 }
index 4542396..a7b4937 100644 (file)
@@ -1942,11 +1942,12 @@ int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status)
        return mgmt_event(MGMT_EV_CONNECT_FAILED, index, &ev, sizeof(ev), NULL);
 }
 
-int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr)
+int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure)
 {
        struct mgmt_ev_pin_code_request ev;
 
        bacpy(&ev.bdaddr, bdaddr);
+       ev.secure = secure;
 
        return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, index, &ev, sizeof(ev),
                                                                        NULL);