diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2011-11-07 16:13:39 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-11-08 10:05:57 -0500 |
commit | 4c659c3976e81f9def48993cd00988d53d7379f2 (patch) | |
tree | 57cdd17455a2b71ab545bcb609baa4990afa8dda /net/bluetooth/mgmt.c | |
parent | 86742e1eca319069490f6f20c2892baafc2a6922 (diff) |
Bluetooth: Add address type fields to mgmt messages that need them
This patch adds address type info (typically BR/EDR vs LE) to management
messages that need this. This also ensures conformance to the latest
management API specification.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 1939053c3fcd..4cb2f958fb10 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1069,6 +1069,18 @@ failed: | |||
1069 | return err; | 1069 | return err; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | static u8 link_to_mgmt(u8 link_type) | ||
1073 | { | ||
1074 | switch (link_type) { | ||
1075 | case LE_LINK: | ||
1076 | return MGMT_ADDR_LE; | ||
1077 | case ACL_LINK: | ||
1078 | return MGMT_ADDR_BREDR; | ||
1079 | default: | ||
1080 | return MGMT_ADDR_INVALID; | ||
1081 | } | ||
1082 | } | ||
1083 | |||
1072 | static int get_connections(struct sock *sk, u16 index) | 1084 | static int get_connections(struct sock *sk, u16 index) |
1073 | { | 1085 | { |
1074 | struct mgmt_rp_get_connections *rp; | 1086 | struct mgmt_rp_get_connections *rp; |
@@ -1092,7 +1104,7 @@ static int get_connections(struct sock *sk, u16 index) | |||
1092 | count++; | 1104 | count++; |
1093 | } | 1105 | } |
1094 | 1106 | ||
1095 | rp_len = sizeof(*rp) + (count * sizeof(bdaddr_t)); | 1107 | rp_len = sizeof(*rp) + (count * sizeof(struct mgmt_addr_info)); |
1096 | rp = kmalloc(rp_len, GFP_ATOMIC); | 1108 | rp = kmalloc(rp_len, GFP_ATOMIC); |
1097 | if (!rp) { | 1109 | if (!rp) { |
1098 | err = -ENOMEM; | 1110 | err = -ENOMEM; |
@@ -1102,8 +1114,16 @@ static int get_connections(struct sock *sk, u16 index) | |||
1102 | put_unaligned_le16(count, &rp->conn_count); | 1114 | put_unaligned_le16(count, &rp->conn_count); |
1103 | 1115 | ||
1104 | i = 0; | 1116 | i = 0; |
1105 | list_for_each_entry(c, &hdev->conn_hash.list, list) | 1117 | list_for_each_entry(c, &hdev->conn_hash.list, list) { |
1106 | bacpy(&rp->conn[i++], &c->dst); | 1118 | bacpy(&rp->addr[i].bdaddr, &c->dst); |
1119 | rp->addr[i].type = link_to_mgmt(c->type); | ||
1120 | if (rp->addr[i].type == MGMT_ADDR_INVALID) | ||
1121 | continue; | ||
1122 | i++; | ||
1123 | } | ||
1124 | |||
1125 | /* Recalculate length in case of filtered SCO connections, etc */ | ||
1126 | rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); | ||
1107 | 1127 | ||
1108 | err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len); | 1128 | err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len); |
1109 | 1129 | ||
@@ -2075,10 +2095,10 @@ int mgmt_new_link_key(u16 index, struct link_key *key, u8 persistent) | |||
2075 | 2095 | ||
2076 | int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type) | 2096 | int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type) |
2077 | { | 2097 | { |
2078 | struct mgmt_ev_connected ev; | 2098 | struct mgmt_addr_info ev; |
2079 | 2099 | ||
2080 | bacpy(&ev.bdaddr, bdaddr); | 2100 | bacpy(&ev.bdaddr, bdaddr); |
2081 | ev.link_type = link_type; | 2101 | ev.type = link_to_mgmt(link_type); |
2082 | 2102 | ||
2083 | return mgmt_event(MGMT_EV_CONNECTED, index, &ev, sizeof(ev), NULL); | 2103 | return mgmt_event(MGMT_EV_CONNECTED, index, &ev, sizeof(ev), NULL); |
2084 | } | 2104 | } |
@@ -2099,15 +2119,16 @@ static void disconnect_rsp(struct pending_cmd *cmd, void *data) | |||
2099 | mgmt_pending_remove(cmd); | 2119 | mgmt_pending_remove(cmd); |
2100 | } | 2120 | } |
2101 | 2121 | ||
2102 | int mgmt_disconnected(u16 index, bdaddr_t *bdaddr) | 2122 | int mgmt_disconnected(u16 index, bdaddr_t *bdaddr, u8 type) |
2103 | { | 2123 | { |
2104 | struct mgmt_ev_disconnected ev; | 2124 | struct mgmt_addr_info ev; |
2105 | struct sock *sk = NULL; | 2125 | struct sock *sk = NULL; |
2106 | int err; | 2126 | int err; |
2107 | 2127 | ||
2108 | mgmt_pending_foreach(MGMT_OP_DISCONNECT, index, disconnect_rsp, &sk); | 2128 | mgmt_pending_foreach(MGMT_OP_DISCONNECT, index, disconnect_rsp, &sk); |
2109 | 2129 | ||
2110 | bacpy(&ev.bdaddr, bdaddr); | 2130 | bacpy(&ev.bdaddr, bdaddr); |
2131 | ev.type = link_to_mgmt(type); | ||
2111 | 2132 | ||
2112 | err = mgmt_event(MGMT_EV_DISCONNECTED, index, &ev, sizeof(ev), sk); | 2133 | err = mgmt_event(MGMT_EV_DISCONNECTED, index, &ev, sizeof(ev), sk); |
2113 | 2134 | ||
@@ -2133,11 +2154,12 @@ int mgmt_disconnect_failed(u16 index) | |||
2133 | return err; | 2154 | return err; |
2134 | } | 2155 | } |
2135 | 2156 | ||
2136 | int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status) | 2157 | int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 type, u8 status) |
2137 | { | 2158 | { |
2138 | struct mgmt_ev_connect_failed ev; | 2159 | struct mgmt_ev_connect_failed ev; |
2139 | 2160 | ||
2140 | bacpy(&ev.bdaddr, bdaddr); | 2161 | bacpy(&ev.addr.bdaddr, bdaddr); |
2162 | ev.addr.type = link_to_mgmt(type); | ||
2141 | ev.status = status; | 2163 | ev.status = status; |
2142 | 2164 | ||
2143 | return mgmt_event(MGMT_EV_CONNECT_FAILED, index, &ev, sizeof(ev), NULL); | 2165 | return mgmt_event(MGMT_EV_CONNECT_FAILED, index, &ev, sizeof(ev), NULL); |
@@ -2325,14 +2347,15 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, | |||
2325 | return err; | 2347 | return err; |
2326 | } | 2348 | } |
2327 | 2349 | ||
2328 | int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, | 2350 | int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 type, u8 *dev_class, |
2329 | u8 *eir) | 2351 | s8 rssi, u8 *eir) |
2330 | { | 2352 | { |
2331 | struct mgmt_ev_device_found ev; | 2353 | struct mgmt_ev_device_found ev; |
2332 | 2354 | ||
2333 | memset(&ev, 0, sizeof(ev)); | 2355 | memset(&ev, 0, sizeof(ev)); |
2334 | 2356 | ||
2335 | bacpy(&ev.bdaddr, bdaddr); | 2357 | bacpy(&ev.addr.bdaddr, bdaddr); |
2358 | ev.addr.type = link_to_mgmt(type); | ||
2336 | ev.rssi = rssi; | 2359 | ev.rssi = rssi; |
2337 | 2360 | ||
2338 | if (eir) | 2361 | if (eir) |