Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * wpa_supplicant - WNM |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 3 | * Copyright (c) 2011-2013, Qualcomm Atheros, Inc. |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 4 | * |
| 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
| 7 | */ |
| 8 | |
| 9 | #include "utils/includes.h" |
| 10 | |
| 11 | #include "utils/common.h" |
| 12 | #include "common/ieee802_11_defs.h" |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 13 | #include "common/ieee802_11_common.h" |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 14 | #include "common/wpa_ctrl.h" |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 15 | #include "rsn_supp/wpa.h" |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 16 | #include "wpa_supplicant_i.h" |
| 17 | #include "driver_i.h" |
| 18 | #include "scan.h" |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 19 | #include "ctrl_iface.h" |
| 20 | #include "bss.h" |
| 21 | #include "wnm_sta.h" |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 22 | #include "hs20_supplicant.h" |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 23 | |
| 24 | #define MAX_TFS_IE_LEN 1024 |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 25 | #define WNM_MAX_NEIGHBOR_REPORT 10 |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 26 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 27 | |
| 28 | /* get the TFS IE from driver */ |
| 29 | static int ieee80211_11_get_tfs_ie(struct wpa_supplicant *wpa_s, u8 *buf, |
| 30 | u16 *buf_len, enum wnm_oper oper) |
| 31 | { |
| 32 | wpa_printf(MSG_DEBUG, "%s: TFS get operation %d", __func__, oper); |
| 33 | |
| 34 | return wpa_drv_wnm_oper(wpa_s, oper, wpa_s->bssid, buf, buf_len); |
| 35 | } |
| 36 | |
| 37 | |
| 38 | /* set the TFS IE to driver */ |
| 39 | static int ieee80211_11_set_tfs_ie(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 40 | const u8 *addr, const u8 *buf, u16 buf_len, |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 41 | enum wnm_oper oper) |
| 42 | { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 43 | u16 len = buf_len; |
| 44 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 45 | wpa_printf(MSG_DEBUG, "%s: TFS set operation %d", __func__, oper); |
| 46 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 47 | return wpa_drv_wnm_oper(wpa_s, oper, addr, (u8 *) buf, &len); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | |
| 51 | /* MLME-SLEEPMODE.request */ |
| 52 | int ieee802_11_send_wnmsleep_req(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 53 | u8 action, u16 intval, struct wpabuf *tfs_req) |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 54 | { |
| 55 | struct ieee80211_mgmt *mgmt; |
| 56 | int res; |
| 57 | size_t len; |
| 58 | struct wnm_sleep_element *wnmsleep_ie; |
| 59 | u8 *wnmtfs_ie; |
| 60 | u8 wnmsleep_ie_len; |
| 61 | u16 wnmtfs_ie_len; /* possibly multiple IE(s) */ |
| 62 | enum wnm_oper tfs_oper = action == 0 ? WNM_SLEEP_TFS_REQ_IE_ADD : |
| 63 | WNM_SLEEP_TFS_REQ_IE_NONE; |
| 64 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 65 | wpa_printf(MSG_DEBUG, "WNM: Request to send WNM-Sleep Mode Request " |
| 66 | "action=%s to " MACSTR, |
| 67 | action == 0 ? "enter" : "exit", |
| 68 | MAC2STR(wpa_s->bssid)); |
| 69 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 70 | /* WNM-Sleep Mode IE */ |
| 71 | wnmsleep_ie_len = sizeof(struct wnm_sleep_element); |
| 72 | wnmsleep_ie = os_zalloc(sizeof(struct wnm_sleep_element)); |
| 73 | if (wnmsleep_ie == NULL) |
| 74 | return -1; |
| 75 | wnmsleep_ie->eid = WLAN_EID_WNMSLEEP; |
| 76 | wnmsleep_ie->len = wnmsleep_ie_len - 2; |
| 77 | wnmsleep_ie->action_type = action; |
| 78 | wnmsleep_ie->status = WNM_STATUS_SLEEP_ACCEPT; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 79 | wnmsleep_ie->intval = host_to_le16(intval); |
| 80 | wpa_hexdump(MSG_DEBUG, "WNM: WNM-Sleep Mode element", |
| 81 | (u8 *) wnmsleep_ie, wnmsleep_ie_len); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 82 | |
| 83 | /* TFS IE(s) */ |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 84 | if (tfs_req) { |
| 85 | wnmtfs_ie_len = wpabuf_len(tfs_req); |
| 86 | wnmtfs_ie = os_malloc(wnmtfs_ie_len); |
| 87 | if (wnmtfs_ie == NULL) { |
| 88 | os_free(wnmsleep_ie); |
| 89 | return -1; |
| 90 | } |
| 91 | os_memcpy(wnmtfs_ie, wpabuf_head(tfs_req), wnmtfs_ie_len); |
| 92 | } else { |
| 93 | wnmtfs_ie = os_zalloc(MAX_TFS_IE_LEN); |
| 94 | if (wnmtfs_ie == NULL) { |
| 95 | os_free(wnmsleep_ie); |
| 96 | return -1; |
| 97 | } |
| 98 | if (ieee80211_11_get_tfs_ie(wpa_s, wnmtfs_ie, &wnmtfs_ie_len, |
| 99 | tfs_oper)) { |
| 100 | wnmtfs_ie_len = 0; |
| 101 | os_free(wnmtfs_ie); |
| 102 | wnmtfs_ie = NULL; |
| 103 | } |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 104 | } |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 105 | wpa_hexdump(MSG_DEBUG, "WNM: TFS Request element", |
| 106 | (u8 *) wnmtfs_ie, wnmtfs_ie_len); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 107 | |
| 108 | mgmt = os_zalloc(sizeof(*mgmt) + wnmsleep_ie_len + wnmtfs_ie_len); |
| 109 | if (mgmt == NULL) { |
| 110 | wpa_printf(MSG_DEBUG, "MLME: Failed to allocate buffer for " |
| 111 | "WNM-Sleep Request action frame"); |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 112 | os_free(wnmsleep_ie); |
| 113 | os_free(wnmtfs_ie); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 114 | return -1; |
| 115 | } |
| 116 | |
| 117 | os_memcpy(mgmt->da, wpa_s->bssid, ETH_ALEN); |
| 118 | os_memcpy(mgmt->sa, wpa_s->own_addr, ETH_ALEN); |
| 119 | os_memcpy(mgmt->bssid, wpa_s->bssid, ETH_ALEN); |
| 120 | mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 121 | WLAN_FC_STYPE_ACTION); |
| 122 | mgmt->u.action.category = WLAN_ACTION_WNM; |
| 123 | mgmt->u.action.u.wnm_sleep_req.action = WNM_SLEEP_MODE_REQ; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 124 | mgmt->u.action.u.wnm_sleep_req.dialogtoken = 1; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 125 | os_memcpy(mgmt->u.action.u.wnm_sleep_req.variable, wnmsleep_ie, |
| 126 | wnmsleep_ie_len); |
| 127 | /* copy TFS IE here */ |
| 128 | if (wnmtfs_ie_len > 0) { |
| 129 | os_memcpy(mgmt->u.action.u.wnm_sleep_req.variable + |
| 130 | wnmsleep_ie_len, wnmtfs_ie, wnmtfs_ie_len); |
| 131 | } |
| 132 | |
| 133 | len = 1 + sizeof(mgmt->u.action.u.wnm_sleep_req) + wnmsleep_ie_len + |
| 134 | wnmtfs_ie_len; |
| 135 | |
| 136 | res = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, |
| 137 | wpa_s->own_addr, wpa_s->bssid, |
| 138 | &mgmt->u.action.category, len, 0); |
| 139 | if (res < 0) |
| 140 | wpa_printf(MSG_DEBUG, "Failed to send WNM-Sleep Request " |
| 141 | "(action=%d, intval=%d)", action, intval); |
Dmitry Shmidt | b70d0bb | 2015-11-16 10:43:06 -0800 | [diff] [blame] | 142 | else |
| 143 | wpa_s->wnmsleep_used = 1; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 144 | |
| 145 | os_free(wnmsleep_ie); |
| 146 | os_free(wnmtfs_ie); |
| 147 | os_free(mgmt); |
| 148 | |
| 149 | return res; |
| 150 | } |
| 151 | |
| 152 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 153 | static void wnm_sleep_mode_enter_success(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 154 | const u8 *tfsresp_ie_start, |
| 155 | const u8 *tfsresp_ie_end) |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 156 | { |
| 157 | wpa_drv_wnm_oper(wpa_s, WNM_SLEEP_ENTER_CONFIRM, |
| 158 | wpa_s->bssid, NULL, NULL); |
| 159 | /* remove GTK/IGTK ?? */ |
| 160 | |
| 161 | /* set the TFS Resp IE(s) */ |
| 162 | if (tfsresp_ie_start && tfsresp_ie_end && |
| 163 | tfsresp_ie_end - tfsresp_ie_start >= 0) { |
| 164 | u16 tfsresp_ie_len; |
| 165 | tfsresp_ie_len = (tfsresp_ie_end + tfsresp_ie_end[1] + 2) - |
| 166 | tfsresp_ie_start; |
| 167 | wpa_printf(MSG_DEBUG, "TFS Resp IE(s) found"); |
| 168 | /* pass the TFS Resp IE(s) to driver for processing */ |
| 169 | if (ieee80211_11_set_tfs_ie(wpa_s, wpa_s->bssid, |
| 170 | tfsresp_ie_start, |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 171 | tfsresp_ie_len, |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 172 | WNM_SLEEP_TFS_RESP_IE_SET)) |
| 173 | wpa_printf(MSG_DEBUG, "WNM: Fail to set TFS Resp IE"); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | |
| 178 | static void wnm_sleep_mode_exit_success(struct wpa_supplicant *wpa_s, |
| 179 | const u8 *frm, u16 key_len_total) |
| 180 | { |
| 181 | u8 *ptr, *end; |
| 182 | u8 gtk_len; |
| 183 | |
| 184 | wpa_drv_wnm_oper(wpa_s, WNM_SLEEP_EXIT_CONFIRM, wpa_s->bssid, |
| 185 | NULL, NULL); |
| 186 | |
| 187 | /* Install GTK/IGTK */ |
| 188 | |
| 189 | /* point to key data field */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 190 | ptr = (u8 *) frm + 1 + 2; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 191 | end = ptr + key_len_total; |
| 192 | wpa_hexdump_key(MSG_DEBUG, "WNM: Key Data", ptr, key_len_total); |
| 193 | |
Jouni Malinen | 17de68d | 2015-11-09 15:25:41 -0800 | [diff] [blame] | 194 | if (key_len_total && !wpa_sm_pmf_enabled(wpa_s->wpa)) { |
| 195 | wpa_msg(wpa_s, MSG_INFO, |
| 196 | "WNM: Ignore Key Data in WNM-Sleep Mode Response - PMF not enabled"); |
| 197 | return; |
| 198 | } |
| 199 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 200 | while (end - ptr > 1) { |
| 201 | if (2 + ptr[1] > end - ptr) { |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 202 | wpa_printf(MSG_DEBUG, "WNM: Invalid Key Data element " |
| 203 | "length"); |
| 204 | if (end > ptr) { |
| 205 | wpa_hexdump(MSG_DEBUG, "WNM: Remaining data", |
| 206 | ptr, end - ptr); |
| 207 | } |
| 208 | break; |
| 209 | } |
| 210 | if (*ptr == WNM_SLEEP_SUBELEM_GTK) { |
| 211 | if (ptr[1] < 11 + 5) { |
| 212 | wpa_printf(MSG_DEBUG, "WNM: Too short GTK " |
| 213 | "subelem"); |
| 214 | break; |
| 215 | } |
| 216 | gtk_len = *(ptr + 4); |
| 217 | if (ptr[1] < 11 + gtk_len || |
| 218 | gtk_len < 5 || gtk_len > 32) { |
| 219 | wpa_printf(MSG_DEBUG, "WNM: Invalid GTK " |
| 220 | "subelem"); |
| 221 | break; |
| 222 | } |
| 223 | wpa_wnmsleep_install_key( |
| 224 | wpa_s->wpa, |
| 225 | WNM_SLEEP_SUBELEM_GTK, |
| 226 | ptr); |
| 227 | ptr += 13 + gtk_len; |
| 228 | #ifdef CONFIG_IEEE80211W |
| 229 | } else if (*ptr == WNM_SLEEP_SUBELEM_IGTK) { |
| 230 | if (ptr[1] < 2 + 6 + WPA_IGTK_LEN) { |
| 231 | wpa_printf(MSG_DEBUG, "WNM: Too short IGTK " |
| 232 | "subelem"); |
| 233 | break; |
| 234 | } |
| 235 | wpa_wnmsleep_install_key(wpa_s->wpa, |
| 236 | WNM_SLEEP_SUBELEM_IGTK, ptr); |
| 237 | ptr += 10 + WPA_IGTK_LEN; |
| 238 | #endif /* CONFIG_IEEE80211W */ |
| 239 | } else |
| 240 | break; /* skip the loop */ |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 245 | static void ieee802_11_rx_wnmsleep_resp(struct wpa_supplicant *wpa_s, |
| 246 | const u8 *frm, int len) |
| 247 | { |
| 248 | /* |
Dmitry Shmidt | 21de214 | 2014-04-08 10:50:52 -0700 | [diff] [blame] | 249 | * Action [1] | Dialog Token [1] | Key Data Len [2] | Key Data | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 250 | * WNM-Sleep Mode IE | TFS Response IE |
| 251 | */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 252 | const u8 *pos = frm; /* point to payload after the action field */ |
Dmitry Shmidt | 21de214 | 2014-04-08 10:50:52 -0700 | [diff] [blame] | 253 | u16 key_len_total; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 254 | struct wnm_sleep_element *wnmsleep_ie = NULL; |
| 255 | /* multiple TFS Resp IE (assuming consecutive) */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 256 | const u8 *tfsresp_ie_start = NULL; |
| 257 | const u8 *tfsresp_ie_end = NULL; |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 258 | size_t left; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 259 | |
Dmitry Shmidt | b70d0bb | 2015-11-16 10:43:06 -0800 | [diff] [blame] | 260 | if (!wpa_s->wnmsleep_used) { |
| 261 | wpa_printf(MSG_DEBUG, |
| 262 | "WNM: Ignore WNM-Sleep Mode Response frame since WNM-Sleep Mode has not been used in this association"); |
| 263 | return; |
| 264 | } |
| 265 | |
Dmitry Shmidt | 21de214 | 2014-04-08 10:50:52 -0700 | [diff] [blame] | 266 | if (len < 3) |
| 267 | return; |
| 268 | key_len_total = WPA_GET_LE16(frm + 1); |
| 269 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 270 | wpa_printf(MSG_DEBUG, "WNM-Sleep Mode Response token=%u key_len_total=%d", |
| 271 | frm[0], key_len_total); |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 272 | left = len - 3; |
| 273 | if (key_len_total > left) { |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 274 | wpa_printf(MSG_INFO, "WNM: Too short frame for Key Data field"); |
| 275 | return; |
| 276 | } |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 277 | pos += 3 + key_len_total; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 278 | while (pos - frm + 1 < len) { |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 279 | u8 ie_len = *(pos + 1); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 280 | if (2 + ie_len > frm + len - pos) { |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 281 | wpa_printf(MSG_INFO, "WNM: Invalid IE len %u", ie_len); |
| 282 | break; |
| 283 | } |
| 284 | wpa_hexdump(MSG_DEBUG, "WNM: Element", pos, 2 + ie_len); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 285 | if (*pos == WLAN_EID_WNMSLEEP && ie_len >= 4) |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 286 | wnmsleep_ie = (struct wnm_sleep_element *) pos; |
| 287 | else if (*pos == WLAN_EID_TFS_RESP) { |
| 288 | if (!tfsresp_ie_start) |
| 289 | tfsresp_ie_start = pos; |
| 290 | tfsresp_ie_end = pos; |
| 291 | } else |
| 292 | wpa_printf(MSG_DEBUG, "EID %d not recognized", *pos); |
| 293 | pos += ie_len + 2; |
| 294 | } |
| 295 | |
| 296 | if (!wnmsleep_ie) { |
| 297 | wpa_printf(MSG_DEBUG, "No WNM-Sleep IE found"); |
| 298 | return; |
| 299 | } |
| 300 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 301 | if (wnmsleep_ie->status == WNM_STATUS_SLEEP_ACCEPT || |
| 302 | wnmsleep_ie->status == WNM_STATUS_SLEEP_EXIT_ACCEPT_GTK_UPDATE) { |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 303 | wpa_printf(MSG_DEBUG, "Successfully recv WNM-Sleep Response " |
| 304 | "frame (action=%d, intval=%d)", |
| 305 | wnmsleep_ie->action_type, wnmsleep_ie->intval); |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 306 | if (wnmsleep_ie->action_type == WNM_SLEEP_MODE_ENTER) { |
| 307 | wnm_sleep_mode_enter_success(wpa_s, tfsresp_ie_start, |
| 308 | tfsresp_ie_end); |
| 309 | } else if (wnmsleep_ie->action_type == WNM_SLEEP_MODE_EXIT) { |
| 310 | wnm_sleep_mode_exit_success(wpa_s, frm, key_len_total); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 311 | } |
| 312 | } else { |
| 313 | wpa_printf(MSG_DEBUG, "Reject recv WNM-Sleep Response frame " |
| 314 | "(action=%d, intval=%d)", |
| 315 | wnmsleep_ie->action_type, wnmsleep_ie->intval); |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 316 | if (wnmsleep_ie->action_type == WNM_SLEEP_MODE_ENTER) |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 317 | wpa_drv_wnm_oper(wpa_s, WNM_SLEEP_ENTER_FAIL, |
| 318 | wpa_s->bssid, NULL, NULL); |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 319 | else if (wnmsleep_ie->action_type == WNM_SLEEP_MODE_EXIT) |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 320 | wpa_drv_wnm_oper(wpa_s, WNM_SLEEP_EXIT_FAIL, |
| 321 | wpa_s->bssid, NULL, NULL); |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 326 | void wnm_deallocate_memory(struct wpa_supplicant *wpa_s) |
| 327 | { |
| 328 | int i; |
| 329 | |
| 330 | for (i = 0; i < wpa_s->wnm_num_neighbor_report; i++) { |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 331 | os_free(wpa_s->wnm_neighbor_report_elements[i].meas_pilot); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 332 | os_free(wpa_s->wnm_neighbor_report_elements[i].mul_bssid); |
| 333 | } |
| 334 | |
Dmitry Shmidt | 21de214 | 2014-04-08 10:50:52 -0700 | [diff] [blame] | 335 | wpa_s->wnm_num_neighbor_report = 0; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 336 | os_free(wpa_s->wnm_neighbor_report_elements); |
| 337 | wpa_s->wnm_neighbor_report_elements = NULL; |
| 338 | } |
| 339 | |
| 340 | |
| 341 | static void wnm_parse_neighbor_report_elem(struct neighbor_report *rep, |
| 342 | u8 id, u8 elen, const u8 *pos) |
| 343 | { |
| 344 | switch (id) { |
| 345 | case WNM_NEIGHBOR_TSF: |
| 346 | if (elen < 2 + 2) { |
| 347 | wpa_printf(MSG_DEBUG, "WNM: Too short TSF"); |
| 348 | break; |
| 349 | } |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 350 | rep->tsf_offset = WPA_GET_LE16(pos); |
| 351 | rep->beacon_int = WPA_GET_LE16(pos + 2); |
| 352 | rep->tsf_present = 1; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 353 | break; |
| 354 | case WNM_NEIGHBOR_CONDENSED_COUNTRY_STRING: |
| 355 | if (elen < 2) { |
| 356 | wpa_printf(MSG_DEBUG, "WNM: Too short condensed " |
| 357 | "country string"); |
| 358 | break; |
| 359 | } |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 360 | os_memcpy(rep->country, pos, 2); |
| 361 | rep->country_present = 1; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 362 | break; |
| 363 | case WNM_NEIGHBOR_BSS_TRANSITION_CANDIDATE: |
| 364 | if (elen < 1) { |
| 365 | wpa_printf(MSG_DEBUG, "WNM: Too short BSS transition " |
| 366 | "candidate"); |
| 367 | break; |
| 368 | } |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 369 | rep->preference = pos[0]; |
| 370 | rep->preference_present = 1; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 371 | break; |
| 372 | case WNM_NEIGHBOR_BSS_TERMINATION_DURATION: |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 373 | rep->bss_term_tsf = WPA_GET_LE64(pos); |
| 374 | rep->bss_term_dur = WPA_GET_LE16(pos + 8); |
| 375 | rep->bss_term_present = 1; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 376 | break; |
| 377 | case WNM_NEIGHBOR_BEARING: |
| 378 | if (elen < 8) { |
| 379 | wpa_printf(MSG_DEBUG, "WNM: Too short neighbor " |
| 380 | "bearing"); |
| 381 | break; |
| 382 | } |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 383 | rep->bearing = WPA_GET_LE16(pos); |
| 384 | rep->distance = WPA_GET_LE32(pos + 2); |
| 385 | rep->rel_height = WPA_GET_LE16(pos + 2 + 4); |
| 386 | rep->bearing_present = 1; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 387 | break; |
| 388 | case WNM_NEIGHBOR_MEASUREMENT_PILOT: |
Dmitry Shmidt | f940fbd | 2014-04-10 10:23:13 -0700 | [diff] [blame] | 389 | if (elen < 1) { |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 390 | wpa_printf(MSG_DEBUG, "WNM: Too short measurement " |
| 391 | "pilot"); |
| 392 | break; |
| 393 | } |
Dmitry Shmidt | f940fbd | 2014-04-10 10:23:13 -0700 | [diff] [blame] | 394 | os_free(rep->meas_pilot); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 395 | rep->meas_pilot = os_zalloc(sizeof(struct measurement_pilot)); |
| 396 | if (rep->meas_pilot == NULL) |
| 397 | break; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 398 | rep->meas_pilot->measurement_pilot = pos[0]; |
Dmitry Shmidt | f940fbd | 2014-04-10 10:23:13 -0700 | [diff] [blame] | 399 | rep->meas_pilot->subelem_len = elen - 1; |
| 400 | os_memcpy(rep->meas_pilot->subelems, pos + 1, elen - 1); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 401 | break; |
| 402 | case WNM_NEIGHBOR_RRM_ENABLED_CAPABILITIES: |
Dmitry Shmidt | f940fbd | 2014-04-10 10:23:13 -0700 | [diff] [blame] | 403 | if (elen < 5) { |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 404 | wpa_printf(MSG_DEBUG, "WNM: Too short RRM enabled " |
| 405 | "capabilities"); |
| 406 | break; |
| 407 | } |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 408 | os_memcpy(rep->rm_capab, pos, 5); |
| 409 | rep->rm_capab_present = 1; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 410 | break; |
| 411 | case WNM_NEIGHBOR_MULTIPLE_BSSID: |
Dmitry Shmidt | f940fbd | 2014-04-10 10:23:13 -0700 | [diff] [blame] | 412 | if (elen < 1) { |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 413 | wpa_printf(MSG_DEBUG, "WNM: Too short multiple BSSID"); |
| 414 | break; |
| 415 | } |
Dmitry Shmidt | f940fbd | 2014-04-10 10:23:13 -0700 | [diff] [blame] | 416 | os_free(rep->mul_bssid); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 417 | rep->mul_bssid = os_zalloc(sizeof(struct multiple_bssid)); |
| 418 | if (rep->mul_bssid == NULL) |
| 419 | break; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 420 | rep->mul_bssid->max_bssid_indicator = pos[0]; |
Dmitry Shmidt | f940fbd | 2014-04-10 10:23:13 -0700 | [diff] [blame] | 421 | rep->mul_bssid->subelem_len = elen - 1; |
| 422 | os_memcpy(rep->mul_bssid->subelems, pos + 1, elen - 1); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 423 | break; |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 428 | static int wnm_nei_get_chan(struct wpa_supplicant *wpa_s, u8 op_class, u8 chan) |
| 429 | { |
| 430 | struct wpa_bss *bss = wpa_s->current_bss; |
| 431 | const char *country = NULL; |
Dmitry Shmidt | b97e428 | 2016-02-08 10:16:07 -0800 | [diff] [blame] | 432 | int freq; |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 433 | |
| 434 | if (bss) { |
| 435 | const u8 *elem = wpa_bss_get_ie(bss, WLAN_EID_COUNTRY); |
| 436 | |
| 437 | if (elem && elem[1] >= 2) |
| 438 | country = (const char *) (elem + 2); |
| 439 | } |
| 440 | |
Dmitry Shmidt | b97e428 | 2016-02-08 10:16:07 -0800 | [diff] [blame] | 441 | freq = ieee80211_chan_to_freq(country, op_class, chan); |
| 442 | if (freq <= 0 && op_class == 0) { |
| 443 | /* |
| 444 | * Some APs do not advertise correct operating class |
| 445 | * information. Try to determine the most likely operating |
| 446 | * frequency based on the channel number. |
| 447 | */ |
| 448 | if (chan >= 1 && chan <= 13) |
| 449 | freq = 2407 + chan * 5; |
| 450 | else if (chan == 14) |
| 451 | freq = 2484; |
| 452 | else if (chan >= 36 && chan <= 169) |
| 453 | freq = 5000 + chan * 5; |
| 454 | } |
| 455 | return freq; |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 459 | static void wnm_parse_neighbor_report(struct wpa_supplicant *wpa_s, |
| 460 | const u8 *pos, u8 len, |
| 461 | struct neighbor_report *rep) |
| 462 | { |
| 463 | u8 left = len; |
| 464 | |
| 465 | if (left < 13) { |
| 466 | wpa_printf(MSG_DEBUG, "WNM: Too short neighbor report"); |
| 467 | return; |
| 468 | } |
| 469 | |
| 470 | os_memcpy(rep->bssid, pos, ETH_ALEN); |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 471 | rep->bssid_info = WPA_GET_LE32(pos + ETH_ALEN); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 472 | rep->regulatory_class = *(pos + 10); |
| 473 | rep->channel_number = *(pos + 11); |
| 474 | rep->phy_type = *(pos + 12); |
| 475 | |
| 476 | pos += 13; |
| 477 | left -= 13; |
| 478 | |
| 479 | while (left >= 2) { |
| 480 | u8 id, elen; |
| 481 | |
| 482 | id = *pos++; |
| 483 | elen = *pos++; |
Dmitry Shmidt | f940fbd | 2014-04-10 10:23:13 -0700 | [diff] [blame] | 484 | wpa_printf(MSG_DEBUG, "WNM: Subelement id=%u len=%u", id, elen); |
| 485 | left -= 2; |
| 486 | if (elen > left) { |
| 487 | wpa_printf(MSG_DEBUG, |
| 488 | "WNM: Truncated neighbor report subelement"); |
| 489 | break; |
| 490 | } |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 491 | wnm_parse_neighbor_report_elem(rep, id, elen, pos); |
Dmitry Shmidt | f940fbd | 2014-04-10 10:23:13 -0700 | [diff] [blame] | 492 | left -= elen; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 493 | pos += elen; |
| 494 | } |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 495 | |
| 496 | rep->freq = wnm_nei_get_chan(wpa_s, rep->regulatory_class, |
| 497 | rep->channel_number); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 501 | static struct wpa_bss * |
| 502 | compare_scan_neighbor_results(struct wpa_supplicant *wpa_s) |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 503 | { |
| 504 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 505 | u8 i; |
| 506 | struct wpa_bss *bss = wpa_s->current_bss; |
| 507 | struct wpa_bss *target; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 508 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 509 | if (!bss) |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 510 | return 0; |
| 511 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 512 | wpa_printf(MSG_DEBUG, "WNM: Current BSS " MACSTR " RSSI %d", |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 513 | MAC2STR(wpa_s->bssid), bss->level); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 514 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 515 | for (i = 0; i < wpa_s->wnm_num_neighbor_report; i++) { |
| 516 | struct neighbor_report *nei; |
| 517 | |
| 518 | nei = &wpa_s->wnm_neighbor_report_elements[i]; |
| 519 | if (nei->preference_present && nei->preference == 0) { |
| 520 | wpa_printf(MSG_DEBUG, "Skip excluded BSS " MACSTR, |
| 521 | MAC2STR(nei->bssid)); |
| 522 | continue; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 523 | } |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 524 | |
| 525 | target = wpa_bss_get_bssid(wpa_s, nei->bssid); |
| 526 | if (!target) { |
| 527 | wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR |
| 528 | " (pref %d) not found in scan results", |
| 529 | MAC2STR(nei->bssid), |
| 530 | nei->preference_present ? nei->preference : |
| 531 | -1); |
| 532 | continue; |
| 533 | } |
| 534 | |
| 535 | if (bss->ssid_len != target->ssid_len || |
| 536 | os_memcmp(bss->ssid, target->ssid, bss->ssid_len) != 0) { |
| 537 | /* |
| 538 | * TODO: Could consider allowing transition to another |
| 539 | * ESS if PMF was enabled for the association. |
| 540 | */ |
| 541 | wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR |
| 542 | " (pref %d) in different ESS", |
| 543 | MAC2STR(nei->bssid), |
| 544 | nei->preference_present ? nei->preference : |
| 545 | -1); |
| 546 | continue; |
| 547 | } |
| 548 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame^] | 549 | if (wpa_is_bss_tmp_disallowed(wpa_s, target->bssid)) { |
| 550 | wpa_printf(MSG_DEBUG, |
| 551 | "MBO: Candidate BSS " MACSTR |
| 552 | " retry delay is not over yet", |
| 553 | MAC2STR(nei->bssid)); |
| 554 | continue; |
| 555 | } |
| 556 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 557 | if (target->level < bss->level && target->level < -80) { |
| 558 | wpa_printf(MSG_DEBUG, "Candidate BSS " MACSTR |
| 559 | " (pref %d) does not have sufficient signal level (%d)", |
| 560 | MAC2STR(nei->bssid), |
| 561 | nei->preference_present ? nei->preference : |
| 562 | -1, |
| 563 | target->level); |
| 564 | continue; |
| 565 | } |
| 566 | |
| 567 | wpa_printf(MSG_DEBUG, |
| 568 | "WNM: Found an acceptable preferred transition candidate BSS " |
| 569 | MACSTR " (RSSI %d)", |
| 570 | MAC2STR(nei->bssid), target->level); |
| 571 | return target; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 572 | } |
| 573 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 574 | return NULL; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame^] | 578 | static int wpa_bss_ies_eq(struct wpa_bss *a, struct wpa_bss *b, u8 eid) |
| 579 | { |
| 580 | const u8 *ie_a, *ie_b; |
| 581 | |
| 582 | if (!a || !b) |
| 583 | return 0; |
| 584 | |
| 585 | ie_a = wpa_bss_get_ie(a, eid); |
| 586 | ie_b = wpa_bss_get_ie(b, eid); |
| 587 | |
| 588 | if (!ie_a || !ie_b || ie_a[1] != ie_b[1]) |
| 589 | return 0; |
| 590 | |
| 591 | return os_memcmp(ie_a, ie_b, ie_a[1]) == 0; |
| 592 | } |
| 593 | |
| 594 | |
| 595 | static u32 wnm_get_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) |
| 596 | { |
| 597 | u32 info = 0; |
| 598 | |
| 599 | info |= NEI_REP_BSSID_INFO_AP_UNKNOWN_REACH; |
| 600 | |
| 601 | /* |
| 602 | * Leave the security and key scope bits unset to indicate that the |
| 603 | * security information is not available. |
| 604 | */ |
| 605 | |
| 606 | if (bss->caps & WLAN_CAPABILITY_SPECTRUM_MGMT) |
| 607 | info |= NEI_REP_BSSID_INFO_SPECTRUM_MGMT; |
| 608 | if (bss->caps & WLAN_CAPABILITY_QOS) |
| 609 | info |= NEI_REP_BSSID_INFO_QOS; |
| 610 | if (bss->caps & WLAN_CAPABILITY_APSD) |
| 611 | info |= NEI_REP_BSSID_INFO_APSD; |
| 612 | if (bss->caps & WLAN_CAPABILITY_RADIO_MEASUREMENT) |
| 613 | info |= NEI_REP_BSSID_INFO_RM; |
| 614 | if (bss->caps & WLAN_CAPABILITY_DELAYED_BLOCK_ACK) |
| 615 | info |= NEI_REP_BSSID_INFO_DELAYED_BA; |
| 616 | if (bss->caps & WLAN_CAPABILITY_IMM_BLOCK_ACK) |
| 617 | info |= NEI_REP_BSSID_INFO_IMM_BA; |
| 618 | if (wpa_bss_ies_eq(bss, wpa_s->current_bss, WLAN_EID_MOBILITY_DOMAIN)) |
| 619 | info |= NEI_REP_BSSID_INFO_MOBILITY_DOMAIN; |
| 620 | if (wpa_bss_ies_eq(bss, wpa_s->current_bss, WLAN_EID_HT_CAP)) |
| 621 | info |= NEI_REP_BSSID_INFO_HT; |
| 622 | |
| 623 | return info; |
| 624 | } |
| 625 | |
| 626 | |
| 627 | static int wnm_add_nei_rep(u8 *buf, size_t len, const u8 *bssid, u32 bss_info, |
| 628 | u8 op_class, u8 chan, u8 phy_type, u8 pref) |
| 629 | { |
| 630 | u8 *pos = buf; |
| 631 | |
| 632 | if (len < 18) { |
| 633 | wpa_printf(MSG_DEBUG, |
| 634 | "WNM: Not enough room for Neighbor Report element"); |
| 635 | return -1; |
| 636 | } |
| 637 | |
| 638 | *pos++ = WLAN_EID_NEIGHBOR_REPORT; |
| 639 | /* length: 13 for basic neighbor report + 3 for preference subelement */ |
| 640 | *pos++ = 16; |
| 641 | os_memcpy(pos, bssid, ETH_ALEN); |
| 642 | pos += ETH_ALEN; |
| 643 | WPA_PUT_LE32(pos, bss_info); |
| 644 | pos += 4; |
| 645 | *pos++ = op_class; |
| 646 | *pos++ = chan; |
| 647 | *pos++ = phy_type; |
| 648 | *pos++ = WNM_NEIGHBOR_BSS_TRANSITION_CANDIDATE; |
| 649 | *pos++ = 1; |
| 650 | *pos++ = pref; |
| 651 | return pos - buf; |
| 652 | } |
| 653 | |
| 654 | |
| 655 | static int wnm_nei_rep_add_bss(struct wpa_supplicant *wpa_s, |
| 656 | struct wpa_bss *bss, u8 *buf, size_t len, |
| 657 | u8 pref) |
| 658 | { |
| 659 | const u8 *ie; |
| 660 | u8 op_class, chan; |
| 661 | int sec_chan = 0, vht = 0; |
| 662 | enum phy_type phy_type; |
| 663 | u32 info; |
| 664 | struct ieee80211_ht_operation *ht_oper = NULL; |
| 665 | struct ieee80211_vht_operation *vht_oper = NULL; |
| 666 | |
| 667 | ie = wpa_bss_get_ie(bss, WLAN_EID_HT_OPERATION); |
| 668 | if (ie && ie[1] >= 2) { |
| 669 | ht_oper = (struct ieee80211_ht_operation *) (ie + 2); |
| 670 | |
| 671 | if (ht_oper->ht_param & HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE) |
| 672 | sec_chan = 1; |
| 673 | else if (ht_oper->ht_param & |
| 674 | HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW) |
| 675 | sec_chan = -1; |
| 676 | } |
| 677 | |
| 678 | ie = wpa_bss_get_ie(bss, WLAN_EID_VHT_OPERATION); |
| 679 | if (ie && ie[1] >= 1) { |
| 680 | vht_oper = (struct ieee80211_vht_operation *) (ie + 2); |
| 681 | |
| 682 | if (vht_oper->vht_op_info_chwidth == VHT_CHANWIDTH_80MHZ || |
| 683 | vht_oper->vht_op_info_chwidth == VHT_CHANWIDTH_160MHZ || |
| 684 | vht_oper->vht_op_info_chwidth == VHT_CHANWIDTH_80P80MHZ) |
| 685 | vht = vht_oper->vht_op_info_chwidth; |
| 686 | } |
| 687 | |
| 688 | if (ieee80211_freq_to_channel_ext(bss->freq, sec_chan, vht, &op_class, |
| 689 | &chan) == NUM_HOSTAPD_MODES) { |
| 690 | wpa_printf(MSG_DEBUG, |
| 691 | "WNM: Cannot determine operating class and channel"); |
| 692 | return -2; |
| 693 | } |
| 694 | |
| 695 | phy_type = ieee80211_get_phy_type(bss->freq, (ht_oper != NULL), |
| 696 | (vht_oper != NULL)); |
| 697 | if (phy_type == PHY_TYPE_UNSPECIFIED) { |
| 698 | wpa_printf(MSG_DEBUG, |
| 699 | "WNM: Cannot determine BSS phy type for Neighbor Report"); |
| 700 | return -2; |
| 701 | } |
| 702 | |
| 703 | info = wnm_get_bss_info(wpa_s, bss); |
| 704 | |
| 705 | return wnm_add_nei_rep(buf, len, bss->bssid, info, op_class, chan, |
| 706 | phy_type, pref); |
| 707 | } |
| 708 | |
| 709 | |
| 710 | static int wnm_add_cand_list(struct wpa_supplicant *wpa_s, u8 *buf, size_t len) |
| 711 | { |
| 712 | u8 *pos = buf; |
| 713 | unsigned int i, pref = 255; |
| 714 | struct os_reltime now; |
| 715 | struct wpa_ssid *ssid = wpa_s->current_ssid; |
| 716 | |
| 717 | if (!ssid) |
| 718 | return 0; |
| 719 | |
| 720 | /* |
| 721 | * TODO: Define when scan results are no longer valid for the candidate |
| 722 | * list. |
| 723 | */ |
| 724 | os_get_reltime(&now); |
| 725 | if (os_reltime_expired(&now, &wpa_s->last_scan, 10)) |
| 726 | return 0; |
| 727 | |
| 728 | wpa_printf(MSG_DEBUG, |
| 729 | "WNM: Add candidate list to BSS Transition Management Response frame"); |
| 730 | for (i = 0; i < wpa_s->last_scan_res_used && pref; i++) { |
| 731 | struct wpa_bss *bss = wpa_s->last_scan_res[i]; |
| 732 | int res; |
| 733 | |
| 734 | if (wpa_scan_res_match(wpa_s, i, bss, ssid, 1)) { |
| 735 | res = wnm_nei_rep_add_bss(wpa_s, bss, pos, len, pref--); |
| 736 | if (res == -2) |
| 737 | continue; /* could not build entry for BSS */ |
| 738 | if (res < 0) |
| 739 | break; /* no more room for candidates */ |
| 740 | if (pref == 1) |
| 741 | break; |
| 742 | |
| 743 | pos += res; |
| 744 | len -= res; |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | wpa_hexdump(MSG_DEBUG, |
| 749 | "WNM: BSS Transition Management Response candidate list", |
| 750 | buf, pos - buf); |
| 751 | |
| 752 | return pos - buf; |
| 753 | } |
| 754 | |
| 755 | |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 756 | static void wnm_send_bss_transition_mgmt_resp( |
| 757 | struct wpa_supplicant *wpa_s, u8 dialog_token, |
| 758 | enum bss_trans_mgmt_status_code status, u8 delay, |
| 759 | const u8 *target_bssid) |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 760 | { |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame^] | 761 | u8 buf[2000], *pos; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 762 | struct ieee80211_mgmt *mgmt; |
| 763 | size_t len; |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 764 | int res; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 765 | |
| 766 | wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Response " |
| 767 | "to " MACSTR " dialog_token=%u status=%u delay=%d", |
| 768 | MAC2STR(wpa_s->bssid), dialog_token, status, delay); |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 769 | if (!wpa_s->current_bss) { |
| 770 | wpa_printf(MSG_DEBUG, |
| 771 | "WNM: Current BSS not known - drop response"); |
| 772 | return; |
| 773 | } |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 774 | |
| 775 | mgmt = (struct ieee80211_mgmt *) buf; |
| 776 | os_memset(&buf, 0, sizeof(buf)); |
| 777 | os_memcpy(mgmt->da, wpa_s->bssid, ETH_ALEN); |
| 778 | os_memcpy(mgmt->sa, wpa_s->own_addr, ETH_ALEN); |
| 779 | os_memcpy(mgmt->bssid, wpa_s->bssid, ETH_ALEN); |
| 780 | mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 781 | WLAN_FC_STYPE_ACTION); |
| 782 | mgmt->u.action.category = WLAN_ACTION_WNM; |
| 783 | mgmt->u.action.u.bss_tm_resp.action = WNM_BSS_TRANS_MGMT_RESP; |
| 784 | mgmt->u.action.u.bss_tm_resp.dialog_token = dialog_token; |
| 785 | mgmt->u.action.u.bss_tm_resp.status_code = status; |
| 786 | mgmt->u.action.u.bss_tm_resp.bss_termination_delay = delay; |
| 787 | pos = mgmt->u.action.u.bss_tm_resp.variable; |
| 788 | if (target_bssid) { |
| 789 | os_memcpy(pos, target_bssid, ETH_ALEN); |
| 790 | pos += ETH_ALEN; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 791 | } else if (status == WNM_BSS_TM_ACCEPT) { |
| 792 | /* |
| 793 | * P802.11-REVmc clarifies that the Target BSSID field is always |
| 794 | * present when status code is zero, so use a fake value here if |
| 795 | * no BSSID is yet known. |
| 796 | */ |
| 797 | os_memset(pos, 0, ETH_ALEN); |
| 798 | pos += ETH_ALEN; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 799 | } |
| 800 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame^] | 801 | if (status == WNM_BSS_TM_ACCEPT) |
| 802 | pos += wnm_add_cand_list(wpa_s, pos, buf + sizeof(buf) - pos); |
| 803 | |
| 804 | #ifdef CONFIG_MBO |
| 805 | if (status != WNM_BSS_TM_ACCEPT) { |
| 806 | pos += wpas_mbo_ie_bss_trans_reject( |
| 807 | wpa_s, pos, buf + sizeof(buf) - pos, |
| 808 | MBO_TRANSITION_REJECT_REASON_UNSPECIFIED); |
| 809 | } |
| 810 | #endif /* CONFIG_MBO */ |
| 811 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 812 | len = pos - (u8 *) &mgmt->u.action.category; |
| 813 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 814 | res = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, |
| 815 | wpa_s->own_addr, wpa_s->bssid, |
| 816 | &mgmt->u.action.category, len, 0); |
| 817 | if (res < 0) { |
| 818 | wpa_printf(MSG_DEBUG, |
| 819 | "WNM: Failed to send BSS Transition Management Response"); |
| 820 | } |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 824 | int wnm_scan_process(struct wpa_supplicant *wpa_s, int reply_on_fail) |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 825 | { |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 826 | struct wpa_bss *bss; |
| 827 | struct wpa_ssid *ssid = wpa_s->current_ssid; |
| 828 | enum bss_trans_mgmt_status_code status = WNM_BSS_TM_REJECT_UNSPECIFIED; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 829 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 830 | if (!wpa_s->wnm_neighbor_report_elements) |
| 831 | return 0; |
| 832 | |
| 833 | if (os_reltime_before(&wpa_s->wnm_cand_valid_until, |
| 834 | &wpa_s->scan_trigger_time)) { |
| 835 | wpa_printf(MSG_DEBUG, "WNM: Previously stored BSS transition candidate list is not valid anymore - drop it"); |
| 836 | wnm_deallocate_memory(wpa_s); |
| 837 | return 0; |
| 838 | } |
| 839 | |
| 840 | if (!wpa_s->current_bss || |
| 841 | os_memcmp(wpa_s->wnm_cand_from_bss, wpa_s->current_bss->bssid, |
| 842 | ETH_ALEN) != 0) { |
| 843 | wpa_printf(MSG_DEBUG, "WNM: Stored BSS transition candidate list not from the current BSS - ignore it"); |
| 844 | return 0; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | /* Compare the Neighbor Report and scan results */ |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 848 | bss = compare_scan_neighbor_results(wpa_s); |
| 849 | if (!bss) { |
| 850 | wpa_printf(MSG_DEBUG, "WNM: No BSS transition candidate match found"); |
| 851 | status = WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES; |
| 852 | goto send_bss_resp_fail; |
| 853 | } |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 854 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 855 | /* Associate to the network */ |
| 856 | /* Send the BSS Management Response - Accept */ |
| 857 | if (wpa_s->wnm_reply) { |
| 858 | wpa_s->wnm_reply = 0; |
| 859 | wnm_send_bss_transition_mgmt_resp(wpa_s, |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 860 | wpa_s->wnm_dialog_token, |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 861 | WNM_BSS_TM_ACCEPT, |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 862 | 0, bss->bssid); |
| 863 | } |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 864 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 865 | if (bss == wpa_s->current_bss) { |
| 866 | wpa_printf(MSG_DEBUG, |
| 867 | "WNM: Already associated with the preferred candidate"); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 868 | wnm_deallocate_memory(wpa_s); |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 869 | return 1; |
| 870 | } |
| 871 | |
| 872 | wpa_s->reassociate = 1; |
| 873 | wpa_supplicant_connect(wpa_s, bss, ssid); |
| 874 | wnm_deallocate_memory(wpa_s); |
| 875 | return 1; |
| 876 | |
| 877 | send_bss_resp_fail: |
| 878 | if (!reply_on_fail) |
| 879 | return 0; |
| 880 | |
| 881 | /* Send reject response for all the failures */ |
| 882 | |
| 883 | if (wpa_s->wnm_reply) { |
| 884 | wpa_s->wnm_reply = 0; |
| 885 | wnm_send_bss_transition_mgmt_resp(wpa_s, |
| 886 | wpa_s->wnm_dialog_token, |
| 887 | status, 0, NULL); |
| 888 | } |
| 889 | wnm_deallocate_memory(wpa_s); |
| 890 | |
| 891 | return 0; |
| 892 | } |
| 893 | |
| 894 | |
| 895 | static int cand_pref_compar(const void *a, const void *b) |
| 896 | { |
| 897 | const struct neighbor_report *aa = a; |
| 898 | const struct neighbor_report *bb = b; |
| 899 | |
| 900 | if (!aa->preference_present && !bb->preference_present) |
| 901 | return 0; |
| 902 | if (!aa->preference_present) |
| 903 | return 1; |
| 904 | if (!bb->preference_present) |
| 905 | return -1; |
| 906 | if (bb->preference > aa->preference) |
| 907 | return 1; |
| 908 | if (bb->preference < aa->preference) |
| 909 | return -1; |
| 910 | return 0; |
| 911 | } |
| 912 | |
| 913 | |
| 914 | static void wnm_sort_cand_list(struct wpa_supplicant *wpa_s) |
| 915 | { |
| 916 | if (!wpa_s->wnm_neighbor_report_elements) |
| 917 | return; |
| 918 | qsort(wpa_s->wnm_neighbor_report_elements, |
| 919 | wpa_s->wnm_num_neighbor_report, sizeof(struct neighbor_report), |
| 920 | cand_pref_compar); |
| 921 | } |
| 922 | |
| 923 | |
| 924 | static void wnm_dump_cand_list(struct wpa_supplicant *wpa_s) |
| 925 | { |
| 926 | unsigned int i; |
| 927 | |
| 928 | wpa_printf(MSG_DEBUG, "WNM: BSS Transition Candidate List"); |
| 929 | if (!wpa_s->wnm_neighbor_report_elements) |
| 930 | return; |
| 931 | for (i = 0; i < wpa_s->wnm_num_neighbor_report; i++) { |
| 932 | struct neighbor_report *nei; |
| 933 | |
| 934 | nei = &wpa_s->wnm_neighbor_report_elements[i]; |
| 935 | wpa_printf(MSG_DEBUG, "%u: " MACSTR |
| 936 | " info=0x%x op_class=%u chan=%u phy=%u pref=%d freq=%d", |
| 937 | i, MAC2STR(nei->bssid), nei->bssid_info, |
| 938 | nei->regulatory_class, |
| 939 | nei->channel_number, nei->phy_type, |
| 940 | nei->preference_present ? nei->preference : -1, |
| 941 | nei->freq); |
| 942 | } |
| 943 | } |
| 944 | |
| 945 | |
| 946 | static int chan_supported(struct wpa_supplicant *wpa_s, int freq) |
| 947 | { |
| 948 | unsigned int i; |
| 949 | |
| 950 | for (i = 0; i < wpa_s->hw.num_modes; i++) { |
| 951 | struct hostapd_hw_modes *mode = &wpa_s->hw.modes[i]; |
| 952 | int j; |
| 953 | |
| 954 | for (j = 0; j < mode->num_channels; j++) { |
| 955 | struct hostapd_channel_data *chan; |
| 956 | |
| 957 | chan = &mode->channels[j]; |
| 958 | if (chan->freq == freq && |
| 959 | !(chan->flag & HOSTAPD_CHAN_DISABLED)) |
| 960 | return 1; |
| 961 | } |
| 962 | } |
| 963 | |
| 964 | return 0; |
| 965 | } |
| 966 | |
| 967 | |
| 968 | static void wnm_set_scan_freqs(struct wpa_supplicant *wpa_s) |
| 969 | { |
| 970 | int *freqs; |
| 971 | int num_freqs = 0; |
| 972 | unsigned int i; |
| 973 | |
| 974 | if (!wpa_s->wnm_neighbor_report_elements) |
| 975 | return; |
| 976 | |
| 977 | if (wpa_s->hw.modes == NULL) |
| 978 | return; |
| 979 | |
| 980 | os_free(wpa_s->next_scan_freqs); |
| 981 | wpa_s->next_scan_freqs = NULL; |
| 982 | |
| 983 | freqs = os_calloc(wpa_s->wnm_num_neighbor_report + 1, sizeof(int)); |
| 984 | if (freqs == NULL) |
| 985 | return; |
| 986 | |
| 987 | for (i = 0; i < wpa_s->wnm_num_neighbor_report; i++) { |
| 988 | struct neighbor_report *nei; |
| 989 | |
| 990 | nei = &wpa_s->wnm_neighbor_report_elements[i]; |
| 991 | if (nei->freq <= 0) { |
| 992 | wpa_printf(MSG_DEBUG, |
| 993 | "WNM: Unknown neighbor operating frequency for " |
| 994 | MACSTR " - scan all channels", |
| 995 | MAC2STR(nei->bssid)); |
| 996 | os_free(freqs); |
| 997 | return; |
| 998 | } |
| 999 | if (chan_supported(wpa_s, nei->freq)) |
| 1000 | add_freq(freqs, &num_freqs, nei->freq); |
| 1001 | } |
| 1002 | |
| 1003 | if (num_freqs == 0) { |
| 1004 | os_free(freqs); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1005 | return; |
| 1006 | } |
| 1007 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1008 | wpa_printf(MSG_DEBUG, |
| 1009 | "WNM: Scan %d frequencies based on transition candidate list", |
| 1010 | num_freqs); |
| 1011 | wpa_s->next_scan_freqs = freqs; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1015 | static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s, |
| 1016 | const u8 *pos, const u8 *end, |
| 1017 | int reply) |
| 1018 | { |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1019 | unsigned int beacon_int; |
| 1020 | u8 valid_int; |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame^] | 1021 | #ifdef CONFIG_MBO |
| 1022 | const u8 *vendor; |
| 1023 | #endif /* CONFIG_MBO */ |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1024 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1025 | if (end - pos < 5) |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1026 | return; |
| 1027 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1028 | if (wpa_s->current_bss) |
| 1029 | beacon_int = wpa_s->current_bss->beacon_int; |
| 1030 | else |
| 1031 | beacon_int = 100; /* best guess */ |
| 1032 | |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1033 | wpa_s->wnm_dialog_token = pos[0]; |
| 1034 | wpa_s->wnm_mode = pos[1]; |
| 1035 | wpa_s->wnm_dissoc_timer = WPA_GET_LE16(pos + 2); |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1036 | valid_int = pos[4]; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1037 | wpa_s->wnm_reply = reply; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1038 | |
| 1039 | wpa_printf(MSG_DEBUG, "WNM: BSS Transition Management Request: " |
| 1040 | "dialog_token=%u request_mode=0x%x " |
| 1041 | "disassoc_timer=%u validity_interval=%u", |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1042 | wpa_s->wnm_dialog_token, wpa_s->wnm_mode, |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1043 | wpa_s->wnm_dissoc_timer, valid_int); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1044 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1045 | pos += 5; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1046 | |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 1047 | if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_BSS_TERMINATION_INCLUDED) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1048 | if (end - pos < 12) { |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1049 | wpa_printf(MSG_DEBUG, "WNM: Too short BSS TM Request"); |
| 1050 | return; |
| 1051 | } |
| 1052 | os_memcpy(wpa_s->wnm_bss_termination_duration, pos, 12); |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1053 | pos += 12; /* BSS Termination Duration */ |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1054 | } |
| 1055 | |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 1056 | if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT) { |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1057 | char url[256]; |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 1058 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1059 | if (end - pos < 1 || 1 + pos[0] > end - pos) { |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1060 | wpa_printf(MSG_DEBUG, "WNM: Invalid BSS Transition " |
| 1061 | "Management Request (URL)"); |
| 1062 | return; |
| 1063 | } |
| 1064 | os_memcpy(url, pos + 1, pos[0]); |
| 1065 | url[pos[0]] = '\0'; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1066 | pos += 1 + pos[0]; |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 1067 | |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 1068 | wpa_msg(wpa_s, MSG_INFO, ESS_DISASSOC_IMMINENT "%d %u %s", |
| 1069 | wpa_sm_pmf_enabled(wpa_s->wpa), |
| 1070 | wpa_s->wnm_dissoc_timer * beacon_int * 128 / 125, url); |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1071 | } |
| 1072 | |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 1073 | if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_DISASSOC_IMMINENT) { |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1074 | wpa_msg(wpa_s, MSG_INFO, "WNM: Disassociation Imminent - " |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1075 | "Disassociation Timer %u", wpa_s->wnm_dissoc_timer); |
| 1076 | if (wpa_s->wnm_dissoc_timer && !wpa_s->scanning) { |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1077 | /* TODO: mark current BSS less preferred for |
| 1078 | * selection */ |
| 1079 | wpa_printf(MSG_DEBUG, "Trying to find another BSS"); |
| 1080 | wpa_supplicant_req_scan(wpa_s, 0, 0); |
| 1081 | } |
| 1082 | } |
| 1083 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame^] | 1084 | #ifdef CONFIG_MBO |
| 1085 | vendor = get_ie(pos, end - pos, WLAN_EID_VENDOR_SPECIFIC); |
| 1086 | if (vendor) |
| 1087 | wpas_mbo_ie_trans_req(wpa_s, vendor + 2, vendor[1]); |
| 1088 | #endif /* CONFIG_MBO */ |
| 1089 | |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 1090 | if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED) { |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1091 | unsigned int valid_ms; |
| 1092 | |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1093 | wpa_msg(wpa_s, MSG_INFO, "WNM: Preferred List Available"); |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1094 | wnm_deallocate_memory(wpa_s); |
| 1095 | wpa_s->wnm_neighbor_report_elements = os_calloc( |
| 1096 | WNM_MAX_NEIGHBOR_REPORT, |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1097 | sizeof(struct neighbor_report)); |
| 1098 | if (wpa_s->wnm_neighbor_report_elements == NULL) |
| 1099 | return; |
| 1100 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1101 | while (end - pos >= 2 && |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1102 | wpa_s->wnm_num_neighbor_report < WNM_MAX_NEIGHBOR_REPORT) |
| 1103 | { |
| 1104 | u8 tag = *pos++; |
| 1105 | u8 len = *pos++; |
| 1106 | |
| 1107 | wpa_printf(MSG_DEBUG, "WNM: Neighbor report tag %u", |
| 1108 | tag); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1109 | if (len > end - pos) { |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1110 | wpa_printf(MSG_DEBUG, "WNM: Truncated request"); |
| 1111 | return; |
| 1112 | } |
Dmitry Shmidt | f940fbd | 2014-04-10 10:23:13 -0700 | [diff] [blame] | 1113 | if (tag == WLAN_EID_NEIGHBOR_REPORT) { |
| 1114 | struct neighbor_report *rep; |
| 1115 | rep = &wpa_s->wnm_neighbor_report_elements[ |
| 1116 | wpa_s->wnm_num_neighbor_report]; |
| 1117 | wnm_parse_neighbor_report(wpa_s, pos, len, rep); |
| 1118 | } |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1119 | |
| 1120 | pos += len; |
| 1121 | wpa_s->wnm_num_neighbor_report++; |
| 1122 | } |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1123 | wnm_sort_cand_list(wpa_s); |
| 1124 | wnm_dump_cand_list(wpa_s); |
| 1125 | valid_ms = valid_int * beacon_int * 128 / 125; |
| 1126 | wpa_printf(MSG_DEBUG, "WNM: Candidate list valid for %u ms", |
| 1127 | valid_ms); |
| 1128 | os_get_reltime(&wpa_s->wnm_cand_valid_until); |
| 1129 | wpa_s->wnm_cand_valid_until.sec += valid_ms / 1000; |
| 1130 | wpa_s->wnm_cand_valid_until.usec += (valid_ms % 1000) * 1000; |
| 1131 | wpa_s->wnm_cand_valid_until.sec += |
| 1132 | wpa_s->wnm_cand_valid_until.usec / 1000000; |
| 1133 | wpa_s->wnm_cand_valid_until.usec %= 1000000; |
| 1134 | os_memcpy(wpa_s->wnm_cand_from_bss, wpa_s->bssid, ETH_ALEN); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1135 | |
Dmitry Shmidt | fb45fd5 | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1136 | if (wpa_s->last_scan_res_used > 0) { |
| 1137 | struct os_reltime now; |
| 1138 | |
| 1139 | os_get_reltime(&now); |
| 1140 | if (!os_reltime_expired(&now, &wpa_s->last_scan, 10)) { |
| 1141 | wpa_printf(MSG_DEBUG, |
| 1142 | "WNM: Try to use recent scan results"); |
| 1143 | if (wnm_scan_process(wpa_s, 0) > 0) |
| 1144 | return; |
| 1145 | wpa_printf(MSG_DEBUG, |
| 1146 | "WNM: No match in previous scan results - try a new scan"); |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | wnm_set_scan_freqs(wpa_s); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1151 | wpa_supplicant_req_scan(wpa_s, 0, 0); |
| 1152 | } else if (reply) { |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 1153 | enum bss_trans_mgmt_status_code status; |
| 1154 | if (wpa_s->wnm_mode & WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT) |
| 1155 | status = WNM_BSS_TM_ACCEPT; |
| 1156 | else { |
| 1157 | wpa_msg(wpa_s, MSG_INFO, "WNM: BSS Transition Management Request did not include candidates"); |
| 1158 | status = WNM_BSS_TM_REJECT_UNSPECIFIED; |
| 1159 | } |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1160 | wnm_send_bss_transition_mgmt_resp(wpa_s, |
| 1161 | wpa_s->wnm_dialog_token, |
Dmitry Shmidt | f7e0a99 | 2013-05-23 11:03:10 -0700 | [diff] [blame] | 1162 | status, 0, NULL); |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1163 | } |
| 1164 | } |
| 1165 | |
| 1166 | |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1167 | int wnm_send_bss_transition_mgmt_query(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame^] | 1168 | u8 query_reason, int cand_list) |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1169 | { |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame^] | 1170 | u8 buf[2000], *pos; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1171 | struct ieee80211_mgmt *mgmt; |
| 1172 | size_t len; |
| 1173 | int ret; |
| 1174 | |
| 1175 | wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Query to " |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame^] | 1176 | MACSTR " query_reason=%u%s", |
| 1177 | MAC2STR(wpa_s->bssid), query_reason, |
| 1178 | cand_list ? " candidate list" : ""); |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1179 | |
| 1180 | mgmt = (struct ieee80211_mgmt *) buf; |
| 1181 | os_memset(&buf, 0, sizeof(buf)); |
| 1182 | os_memcpy(mgmt->da, wpa_s->bssid, ETH_ALEN); |
| 1183 | os_memcpy(mgmt->sa, wpa_s->own_addr, ETH_ALEN); |
| 1184 | os_memcpy(mgmt->bssid, wpa_s->bssid, ETH_ALEN); |
| 1185 | mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 1186 | WLAN_FC_STYPE_ACTION); |
| 1187 | mgmt->u.action.category = WLAN_ACTION_WNM; |
| 1188 | mgmt->u.action.u.bss_tm_query.action = WNM_BSS_TRANS_MGMT_QUERY; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1189 | mgmt->u.action.u.bss_tm_query.dialog_token = 1; |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1190 | mgmt->u.action.u.bss_tm_query.query_reason = query_reason; |
| 1191 | pos = mgmt->u.action.u.bss_tm_query.variable; |
| 1192 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame^] | 1193 | if (cand_list) |
| 1194 | pos += wnm_add_cand_list(wpa_s, pos, buf + sizeof(buf) - pos); |
| 1195 | |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1196 | len = pos - (u8 *) &mgmt->u.action.category; |
| 1197 | |
| 1198 | ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, |
| 1199 | wpa_s->own_addr, wpa_s->bssid, |
| 1200 | &mgmt->u.action.category, len, 0); |
| 1201 | |
| 1202 | return ret; |
| 1203 | } |
| 1204 | |
| 1205 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1206 | static void ieee802_11_rx_wnm_notif_req_wfa(struct wpa_supplicant *wpa_s, |
| 1207 | const u8 *sa, const u8 *data, |
| 1208 | int len) |
| 1209 | { |
| 1210 | const u8 *pos, *end, *next; |
| 1211 | u8 ie, ie_len; |
| 1212 | |
| 1213 | pos = data; |
| 1214 | end = data + len; |
| 1215 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1216 | while (end - pos > 1) { |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1217 | ie = *pos++; |
| 1218 | ie_len = *pos++; |
| 1219 | wpa_printf(MSG_DEBUG, "WNM: WFA subelement %u len %u", |
| 1220 | ie, ie_len); |
| 1221 | if (ie_len > end - pos) { |
| 1222 | wpa_printf(MSG_DEBUG, "WNM: Not enough room for " |
| 1223 | "subelement"); |
| 1224 | break; |
| 1225 | } |
| 1226 | next = pos + ie_len; |
| 1227 | if (ie_len < 4) { |
| 1228 | pos = next; |
| 1229 | continue; |
| 1230 | } |
| 1231 | wpa_printf(MSG_DEBUG, "WNM: Subelement OUI %06x type %u", |
| 1232 | WPA_GET_BE24(pos), pos[3]); |
| 1233 | |
| 1234 | #ifdef CONFIG_HS20 |
| 1235 | if (ie == WLAN_EID_VENDOR_SPECIFIC && ie_len >= 5 && |
| 1236 | WPA_GET_BE24(pos) == OUI_WFA && |
| 1237 | pos[3] == HS20_WNM_SUB_REM_NEEDED) { |
| 1238 | /* Subscription Remediation subelement */ |
| 1239 | const u8 *ie_end; |
| 1240 | u8 url_len; |
| 1241 | char *url; |
| 1242 | u8 osu_method; |
| 1243 | |
| 1244 | wpa_printf(MSG_DEBUG, "WNM: Subscription Remediation " |
| 1245 | "subelement"); |
| 1246 | ie_end = pos + ie_len; |
| 1247 | pos += 4; |
| 1248 | url_len = *pos++; |
| 1249 | if (url_len == 0) { |
| 1250 | wpa_printf(MSG_DEBUG, "WNM: No Server URL included"); |
| 1251 | url = NULL; |
| 1252 | osu_method = 1; |
| 1253 | } else { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1254 | if (url_len + 1 > ie_end - pos) { |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1255 | wpa_printf(MSG_DEBUG, "WNM: Not enough room for Server URL (len=%u) and Server Method (left %d)", |
| 1256 | url_len, |
| 1257 | (int) (ie_end - pos)); |
| 1258 | break; |
| 1259 | } |
| 1260 | url = os_malloc(url_len + 1); |
| 1261 | if (url == NULL) |
| 1262 | break; |
| 1263 | os_memcpy(url, pos, url_len); |
| 1264 | url[url_len] = '\0'; |
| 1265 | osu_method = pos[url_len]; |
| 1266 | } |
| 1267 | hs20_rx_subscription_remediation(wpa_s, url, |
| 1268 | osu_method); |
| 1269 | os_free(url); |
| 1270 | pos = next; |
| 1271 | continue; |
| 1272 | } |
| 1273 | |
| 1274 | if (ie == WLAN_EID_VENDOR_SPECIFIC && ie_len >= 8 && |
| 1275 | WPA_GET_BE24(pos) == OUI_WFA && |
| 1276 | pos[3] == HS20_WNM_DEAUTH_IMMINENT_NOTICE) { |
| 1277 | const u8 *ie_end; |
| 1278 | u8 url_len; |
| 1279 | char *url; |
| 1280 | u8 code; |
| 1281 | u16 reauth_delay; |
| 1282 | |
| 1283 | ie_end = pos + ie_len; |
| 1284 | pos += 4; |
| 1285 | code = *pos++; |
| 1286 | reauth_delay = WPA_GET_LE16(pos); |
| 1287 | pos += 2; |
| 1288 | url_len = *pos++; |
| 1289 | wpa_printf(MSG_DEBUG, "WNM: HS 2.0 Deauthentication " |
| 1290 | "Imminent - Reason Code %u " |
| 1291 | "Re-Auth Delay %u URL Length %u", |
| 1292 | code, reauth_delay, url_len); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1293 | if (url_len > ie_end - pos) |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1294 | break; |
| 1295 | url = os_malloc(url_len + 1); |
| 1296 | if (url == NULL) |
| 1297 | break; |
| 1298 | os_memcpy(url, pos, url_len); |
| 1299 | url[url_len] = '\0'; |
| 1300 | hs20_rx_deauth_imminent_notice(wpa_s, code, |
| 1301 | reauth_delay, url); |
| 1302 | os_free(url); |
| 1303 | pos = next; |
| 1304 | continue; |
| 1305 | } |
| 1306 | #endif /* CONFIG_HS20 */ |
| 1307 | |
| 1308 | pos = next; |
| 1309 | } |
| 1310 | } |
| 1311 | |
| 1312 | |
| 1313 | static void ieee802_11_rx_wnm_notif_req(struct wpa_supplicant *wpa_s, |
| 1314 | const u8 *sa, const u8 *frm, int len) |
| 1315 | { |
| 1316 | const u8 *pos, *end; |
| 1317 | u8 dialog_token, type; |
| 1318 | |
| 1319 | /* Dialog Token [1] | Type [1] | Subelements */ |
| 1320 | |
| 1321 | if (len < 2 || sa == NULL) |
| 1322 | return; |
| 1323 | end = frm + len; |
| 1324 | pos = frm; |
| 1325 | dialog_token = *pos++; |
| 1326 | type = *pos++; |
| 1327 | |
| 1328 | wpa_dbg(wpa_s, MSG_DEBUG, "WNM: Received WNM-Notification Request " |
| 1329 | "(dialog_token %u type %u sa " MACSTR ")", |
| 1330 | dialog_token, type, MAC2STR(sa)); |
| 1331 | wpa_hexdump(MSG_DEBUG, "WNM-Notification Request subelements", |
| 1332 | pos, end - pos); |
| 1333 | |
| 1334 | if (wpa_s->wpa_state != WPA_COMPLETED || |
| 1335 | os_memcmp(sa, wpa_s->bssid, ETH_ALEN) != 0) { |
| 1336 | wpa_dbg(wpa_s, MSG_DEBUG, "WNM: WNM-Notification frame not " |
| 1337 | "from our AP - ignore it"); |
| 1338 | return; |
| 1339 | } |
| 1340 | |
| 1341 | switch (type) { |
| 1342 | case 1: |
| 1343 | ieee802_11_rx_wnm_notif_req_wfa(wpa_s, sa, pos, end - pos); |
| 1344 | break; |
| 1345 | default: |
| 1346 | wpa_dbg(wpa_s, MSG_DEBUG, "WNM: Ignore unknown " |
| 1347 | "WNM-Notification type %u", type); |
| 1348 | break; |
| 1349 | } |
| 1350 | } |
| 1351 | |
| 1352 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1353 | void ieee802_11_rx_wnm_action(struct wpa_supplicant *wpa_s, |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1354 | const struct ieee80211_mgmt *mgmt, size_t len) |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1355 | { |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1356 | const u8 *pos, *end; |
| 1357 | u8 act; |
| 1358 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1359 | if (len < IEEE80211_HDRLEN + 2) |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1360 | return; |
| 1361 | |
Dmitry Shmidt | 623d63a | 2014-06-13 11:05:14 -0700 | [diff] [blame] | 1362 | pos = ((const u8 *) mgmt) + IEEE80211_HDRLEN + 1; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1363 | act = *pos++; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1364 | end = ((const u8 *) mgmt) + len; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1365 | |
| 1366 | wpa_printf(MSG_DEBUG, "WNM: RX action %u from " MACSTR, |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1367 | act, MAC2STR(mgmt->sa)); |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1368 | if (wpa_s->wpa_state < WPA_ASSOCIATED || |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1369 | os_memcmp(mgmt->sa, wpa_s->bssid, ETH_ALEN) != 0) { |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1370 | wpa_printf(MSG_DEBUG, "WNM: Ignore unexpected WNM Action " |
| 1371 | "frame"); |
| 1372 | return; |
| 1373 | } |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1374 | |
| 1375 | switch (act) { |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1376 | case WNM_BSS_TRANS_MGMT_REQ: |
| 1377 | ieee802_11_rx_bss_trans_mgmt_req(wpa_s, pos, end, |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1378 | !(mgmt->da[0] & 0x01)); |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1379 | break; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1380 | case WNM_SLEEP_MODE_RESP: |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1381 | ieee802_11_rx_wnmsleep_resp(wpa_s, pos, end - pos); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1382 | break; |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1383 | case WNM_NOTIFICATION_REQ: |
| 1384 | ieee802_11_rx_wnm_notif_req(wpa_s, mgmt->sa, pos, end - pos); |
| 1385 | break; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1386 | default: |
Dmitry Shmidt | 44c9578 | 2013-05-17 09:51:35 -0700 | [diff] [blame] | 1387 | wpa_printf(MSG_ERROR, "WNM: Unknown request"); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1388 | break; |
| 1389 | } |
| 1390 | } |