diff options
-rw-r--r-- | include/net/bluetooth/hci_core.h | 14 | ||||
-rw-r--r-- | include/net/bluetooth/mgmt.h | 4 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 21 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 35 |
4 files changed, 44 insertions, 30 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 0a5a05d9109c..5f401e71584f 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -915,11 +915,13 @@ int mgmt_connectable(struct hci_dev *hdev, u8 connectable); | |||
915 | int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); | 915 | int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); |
916 | int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, | 916 | int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, |
917 | u8 persistent); | 917 | u8 persistent); |
918 | int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | 918 | int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
919 | int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | 919 | u8 addr_type); |
920 | int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | ||
921 | u8 addr_type); | ||
920 | int mgmt_disconnect_failed(struct hci_dev *hdev); | 922 | int mgmt_disconnect_failed(struct hci_dev *hdev); |
921 | int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, | 923 | int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
922 | u8 status); | 924 | u8 addr_type, u8 status); |
923 | int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); | 925 | int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); |
924 | int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | 926 | int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
925 | u8 status); | 927 | u8 status); |
@@ -935,8 +937,8 @@ int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); | |||
935 | int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); | 937 | int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); |
936 | int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, | 938 | int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, |
937 | u8 *randomizer, u8 status); | 939 | u8 *randomizer, u8 status); |
938 | int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, | 940 | int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
939 | u8 *dev_class, s8 rssi, u8 *eir); | 941 | u8 addr_type, u8 *dev_class, s8 rssi, u8 *eir); |
940 | int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); | 942 | int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); |
941 | int mgmt_inquiry_failed(struct hci_dev *hdev, u8 status); | 943 | int mgmt_inquiry_failed(struct hci_dev *hdev, u8 status); |
942 | int mgmt_discovering(struct hci_dev *hdev, u8 discovering); | 944 | int mgmt_discovering(struct hci_dev *hdev, u8 discovering); |
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 3e320c9cae8f..76a3f162ebfe 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -129,8 +129,8 @@ struct mgmt_rp_disconnect { | |||
129 | } __packed; | 129 | } __packed; |
130 | 130 | ||
131 | #define MGMT_ADDR_BREDR 0x00 | 131 | #define MGMT_ADDR_BREDR 0x00 |
132 | #define MGMT_ADDR_LE 0x01 | 132 | #define MGMT_ADDR_LE_PUBLIC 0x01 |
133 | #define MGMT_ADDR_BREDR_LE 0x02 | 133 | #define MGMT_ADDR_LE_RANDOM 0x02 |
134 | #define MGMT_ADDR_INVALID 0xff | 134 | #define MGMT_ADDR_INVALID 0xff |
135 | 135 | ||
136 | struct mgmt_addr_info { | 136 | struct mgmt_addr_info { |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index a89cf1f24e47..bbfaaa8c018f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1437,7 +1437,7 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * | |||
1437 | data.rssi = 0x00; | 1437 | data.rssi = 0x00; |
1438 | data.ssp_mode = 0x00; | 1438 | data.ssp_mode = 0x00; |
1439 | hci_inquiry_cache_update(hdev, &data); | 1439 | hci_inquiry_cache_update(hdev, &data); |
1440 | mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, | 1440 | mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, |
1441 | info->dev_class, 0, NULL); | 1441 | info->dev_class, 0, NULL); |
1442 | } | 1442 | } |
1443 | 1443 | ||
@@ -1472,7 +1472,8 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s | |||
1472 | conn->state = BT_CONFIG; | 1472 | conn->state = BT_CONFIG; |
1473 | hci_conn_hold(conn); | 1473 | hci_conn_hold(conn); |
1474 | conn->disc_timeout = HCI_DISCONN_TIMEOUT; | 1474 | conn->disc_timeout = HCI_DISCONN_TIMEOUT; |
1475 | mgmt_connected(hdev, &ev->bdaddr, conn->type); | 1475 | mgmt_connected(hdev, &ev->bdaddr, conn->type, |
1476 | conn->dst_type); | ||
1476 | } else | 1477 | } else |
1477 | conn->state = BT_CONNECTED; | 1478 | conn->state = BT_CONNECTED; |
1478 | 1479 | ||
@@ -1505,7 +1506,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s | |||
1505 | conn->state = BT_CLOSED; | 1506 | conn->state = BT_CLOSED; |
1506 | if (conn->type == ACL_LINK) | 1507 | if (conn->type == ACL_LINK) |
1507 | mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, | 1508 | mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, |
1508 | ev->status); | 1509 | conn->dst_type, ev->status); |
1509 | } | 1510 | } |
1510 | 1511 | ||
1511 | if (conn->type == ACL_LINK) | 1512 | if (conn->type == ACL_LINK) |
@@ -1620,7 +1621,8 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff | |||
1620 | conn->state = BT_CLOSED; | 1621 | conn->state = BT_CLOSED; |
1621 | 1622 | ||
1622 | if (conn->type == ACL_LINK || conn->type == LE_LINK) | 1623 | if (conn->type == ACL_LINK || conn->type == LE_LINK) |
1623 | mgmt_disconnected(hdev, &conn->dst, conn->type); | 1624 | mgmt_disconnected(hdev, &conn->dst, conn->type, |
1625 | conn->dst_type); | ||
1624 | 1626 | ||
1625 | hci_proto_disconn_cfm(conn, ev->reason); | 1627 | hci_proto_disconn_cfm(conn, ev->reason); |
1626 | hci_conn_del(conn); | 1628 | hci_conn_del(conn); |
@@ -2444,7 +2446,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct | |||
2444 | data.rssi = info->rssi; | 2446 | data.rssi = info->rssi; |
2445 | data.ssp_mode = 0x00; | 2447 | data.ssp_mode = 0x00; |
2446 | hci_inquiry_cache_update(hdev, &data); | 2448 | hci_inquiry_cache_update(hdev, &data); |
2447 | mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, | 2449 | mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, |
2448 | info->dev_class, info->rssi, | 2450 | info->dev_class, info->rssi, |
2449 | NULL); | 2451 | NULL); |
2450 | } | 2452 | } |
@@ -2461,7 +2463,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct | |||
2461 | data.rssi = info->rssi; | 2463 | data.rssi = info->rssi; |
2462 | data.ssp_mode = 0x00; | 2464 | data.ssp_mode = 0x00; |
2463 | hci_inquiry_cache_update(hdev, &data); | 2465 | hci_inquiry_cache_update(hdev, &data); |
2464 | mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, | 2466 | mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, |
2465 | info->dev_class, info->rssi, | 2467 | info->dev_class, info->rssi, |
2466 | NULL); | 2468 | NULL); |
2467 | } | 2469 | } |
@@ -2604,7 +2606,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct | |||
2604 | data.rssi = info->rssi; | 2606 | data.rssi = info->rssi; |
2605 | data.ssp_mode = 0x01; | 2607 | data.ssp_mode = 0x01; |
2606 | hci_inquiry_cache_update(hdev, &data); | 2608 | hci_inquiry_cache_update(hdev, &data); |
2607 | mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, | 2609 | mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, |
2608 | info->dev_class, info->rssi, info->data); | 2610 | info->dev_class, info->rssi, info->data); |
2609 | } | 2611 | } |
2610 | 2612 | ||
@@ -2868,14 +2870,15 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff | |||
2868 | } | 2870 | } |
2869 | 2871 | ||
2870 | if (ev->status) { | 2872 | if (ev->status) { |
2871 | mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, ev->status); | 2873 | mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, |
2874 | conn->dst_type, ev->status); | ||
2872 | hci_proto_connect_cfm(conn, ev->status); | 2875 | hci_proto_connect_cfm(conn, ev->status); |
2873 | conn->state = BT_CLOSED; | 2876 | conn->state = BT_CLOSED; |
2874 | hci_conn_del(conn); | 2877 | hci_conn_del(conn); |
2875 | goto unlock; | 2878 | goto unlock; |
2876 | } | 2879 | } |
2877 | 2880 | ||
2878 | mgmt_connected(hdev, &ev->bdaddr, conn->type); | 2881 | mgmt_connected(hdev, &ev->bdaddr, conn->type, conn->dst_type); |
2879 | 2882 | ||
2880 | conn->sec_level = BT_SECURITY_LOW; | 2883 | conn->sec_level = BT_SECURITY_LOW; |
2881 | conn->handle = __le16_to_cpu(ev->handle); | 2884 | conn->handle = __le16_to_cpu(ev->handle); |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a6720c6a4d2c..d23a803d69df 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1063,11 +1063,18 @@ failed: | |||
1063 | return err; | 1063 | return err; |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | static u8 link_to_mgmt(u8 link_type) | 1066 | static u8 link_to_mgmt(u8 link_type, u8 addr_type) |
1067 | { | 1067 | { |
1068 | switch (link_type) { | 1068 | switch (link_type) { |
1069 | case LE_LINK: | 1069 | case LE_LINK: |
1070 | return MGMT_ADDR_LE; | 1070 | switch (addr_type) { |
1071 | case ADDR_LE_DEV_PUBLIC: | ||
1072 | return MGMT_ADDR_LE_PUBLIC; | ||
1073 | case ADDR_LE_DEV_RANDOM: | ||
1074 | return MGMT_ADDR_LE_RANDOM; | ||
1075 | default: | ||
1076 | return MGMT_ADDR_INVALID; | ||
1077 | } | ||
1071 | case ACL_LINK: | 1078 | case ACL_LINK: |
1072 | return MGMT_ADDR_BREDR; | 1079 | return MGMT_ADDR_BREDR; |
1073 | default: | 1080 | default: |
@@ -1110,7 +1117,7 @@ static int get_connections(struct sock *sk, u16 index) | |||
1110 | i = 0; | 1117 | i = 0; |
1111 | list_for_each_entry(c, &hdev->conn_hash.list, list) { | 1118 | list_for_each_entry(c, &hdev->conn_hash.list, list) { |
1112 | bacpy(&rp->addr[i].bdaddr, &c->dst); | 1119 | bacpy(&rp->addr[i].bdaddr, &c->dst); |
1113 | rp->addr[i].type = link_to_mgmt(c->type); | 1120 | rp->addr[i].type = link_to_mgmt(c->type, c->dst_type); |
1114 | if (rp->addr[i].type == MGMT_ADDR_INVALID) | 1121 | if (rp->addr[i].type == MGMT_ADDR_INVALID) |
1115 | continue; | 1122 | continue; |
1116 | i++; | 1123 | i++; |
@@ -2088,12 +2095,13 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, | |||
2088 | return mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL); | 2095 | return mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL); |
2089 | } | 2096 | } |
2090 | 2097 | ||
2091 | int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type) | 2098 | int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
2099 | u8 addr_type) | ||
2092 | { | 2100 | { |
2093 | struct mgmt_addr_info ev; | 2101 | struct mgmt_addr_info ev; |
2094 | 2102 | ||
2095 | bacpy(&ev.bdaddr, bdaddr); | 2103 | bacpy(&ev.bdaddr, bdaddr); |
2096 | ev.type = link_to_mgmt(link_type); | 2104 | ev.type = link_to_mgmt(link_type, addr_type); |
2097 | 2105 | ||
2098 | return mgmt_event(MGMT_EV_CONNECTED, hdev, &ev, sizeof(ev), NULL); | 2106 | return mgmt_event(MGMT_EV_CONNECTED, hdev, &ev, sizeof(ev), NULL); |
2099 | } | 2107 | } |
@@ -2114,7 +2122,8 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) | |||
2114 | mgmt_pending_remove(cmd); | 2122 | mgmt_pending_remove(cmd); |
2115 | } | 2123 | } |
2116 | 2124 | ||
2117 | int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) | 2125 | int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
2126 | u8 addr_type) | ||
2118 | { | 2127 | { |
2119 | struct mgmt_addr_info ev; | 2128 | struct mgmt_addr_info ev; |
2120 | struct sock *sk = NULL; | 2129 | struct sock *sk = NULL; |
@@ -2123,7 +2132,7 @@ int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) | |||
2123 | mgmt_pending_foreach(MGMT_OP_DISCONNECT, hdev, disconnect_rsp, &sk); | 2132 | mgmt_pending_foreach(MGMT_OP_DISCONNECT, hdev, disconnect_rsp, &sk); |
2124 | 2133 | ||
2125 | bacpy(&ev.bdaddr, bdaddr); | 2134 | bacpy(&ev.bdaddr, bdaddr); |
2126 | ev.type = link_to_mgmt(type); | 2135 | ev.type = link_to_mgmt(link_type, addr_type); |
2127 | 2136 | ||
2128 | err = mgmt_event(MGMT_EV_DISCONNECTED, hdev, &ev, sizeof(ev), sk); | 2137 | err = mgmt_event(MGMT_EV_DISCONNECTED, hdev, &ev, sizeof(ev), sk); |
2129 | 2138 | ||
@@ -2149,13 +2158,13 @@ int mgmt_disconnect_failed(struct hci_dev *hdev) | |||
2149 | return err; | 2158 | return err; |
2150 | } | 2159 | } |
2151 | 2160 | ||
2152 | int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, | 2161 | int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
2153 | u8 status) | 2162 | u8 addr_type, u8 status) |
2154 | { | 2163 | { |
2155 | struct mgmt_ev_connect_failed ev; | 2164 | struct mgmt_ev_connect_failed ev; |
2156 | 2165 | ||
2157 | bacpy(&ev.addr.bdaddr, bdaddr); | 2166 | bacpy(&ev.addr.bdaddr, bdaddr); |
2158 | ev.addr.type = link_to_mgmt(type); | 2167 | ev.addr.type = link_to_mgmt(link_type, addr_type); |
2159 | ev.status = status; | 2168 | ev.status = status; |
2160 | 2169 | ||
2161 | return mgmt_event(MGMT_EV_CONNECT_FAILED, hdev, &ev, sizeof(ev), NULL); | 2170 | return mgmt_event(MGMT_EV_CONNECT_FAILED, hdev, &ev, sizeof(ev), NULL); |
@@ -2342,15 +2351,15 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, | |||
2342 | return err; | 2351 | return err; |
2343 | } | 2352 | } |
2344 | 2353 | ||
2345 | int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, | 2354 | int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
2346 | u8 *dev_class, s8 rssi, u8 *eir) | 2355 | u8 addr_type, u8 *dev_class, s8 rssi, u8 *eir) |
2347 | { | 2356 | { |
2348 | struct mgmt_ev_device_found ev; | 2357 | struct mgmt_ev_device_found ev; |
2349 | 2358 | ||
2350 | memset(&ev, 0, sizeof(ev)); | 2359 | memset(&ev, 0, sizeof(ev)); |
2351 | 2360 | ||
2352 | bacpy(&ev.addr.bdaddr, bdaddr); | 2361 | bacpy(&ev.addr.bdaddr, bdaddr); |
2353 | ev.addr.type = link_to_mgmt(type); | 2362 | ev.addr.type = link_to_mgmt(link_type, addr_type); |
2354 | ev.rssi = rssi; | 2363 | ev.rssi = rssi; |
2355 | 2364 | ||
2356 | if (eir) | 2365 | if (eir) |