Line data Source code
1 : /*
2 : * hostapd - WNM
3 : * Copyright (c) 2011-2013, Qualcomm Atheros, Inc.
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 "utils/eloop.h"
13 : #include "common/ieee802_11_defs.h"
14 : #include "ap/hostapd.h"
15 : #include "ap/sta_info.h"
16 : #include "ap/ap_config.h"
17 : #include "ap/ap_drv_ops.h"
18 : #include "ap/wpa_auth.h"
19 : #include "wnm_ap.h"
20 :
21 : #define MAX_TFS_IE_LEN 1024
22 :
23 :
24 : /* get the TFS IE from driver */
25 0 : static int ieee80211_11_get_tfs_ie(struct hostapd_data *hapd, const u8 *addr,
26 : u8 *buf, u16 *buf_len, enum wnm_oper oper)
27 : {
28 0 : wpa_printf(MSG_DEBUG, "%s: TFS get operation %d", __func__, oper);
29 :
30 0 : return hostapd_drv_wnm_oper(hapd, oper, addr, buf, buf_len);
31 : }
32 :
33 :
34 : /* set the TFS IE to driver */
35 0 : static int ieee80211_11_set_tfs_ie(struct hostapd_data *hapd, const u8 *addr,
36 : u8 *buf, u16 *buf_len, enum wnm_oper oper)
37 : {
38 0 : wpa_printf(MSG_DEBUG, "%s: TFS set operation %d", __func__, oper);
39 :
40 0 : return hostapd_drv_wnm_oper(hapd, oper, addr, buf, buf_len);
41 : }
42 :
43 :
44 : /* MLME-SLEEPMODE.response */
45 0 : static int ieee802_11_send_wnmsleep_resp(struct hostapd_data *hapd,
46 : const u8 *addr, u8 dialog_token,
47 : u8 action_type, u16 intval)
48 : {
49 : struct ieee80211_mgmt *mgmt;
50 : int res;
51 : size_t len;
52 0 : size_t gtk_elem_len = 0;
53 0 : size_t igtk_elem_len = 0;
54 : struct wnm_sleep_element wnmsleep_ie;
55 : u8 *wnmtfs_ie;
56 : u8 wnmsleep_ie_len;
57 : u16 wnmtfs_ie_len;
58 : u8 *pos;
59 : struct sta_info *sta;
60 0 : enum wnm_oper tfs_oper = action_type == WNM_SLEEP_MODE_ENTER ?
61 : WNM_SLEEP_TFS_RESP_IE_ADD : WNM_SLEEP_TFS_RESP_IE_NONE;
62 :
63 0 : sta = ap_get_sta(hapd, addr);
64 0 : if (sta == NULL) {
65 0 : wpa_printf(MSG_DEBUG, "%s: station not found", __func__);
66 0 : return -EINVAL;
67 : }
68 :
69 : /* WNM-Sleep Mode IE */
70 0 : os_memset(&wnmsleep_ie, 0, sizeof(struct wnm_sleep_element));
71 0 : wnmsleep_ie_len = sizeof(struct wnm_sleep_element);
72 0 : wnmsleep_ie.eid = WLAN_EID_WNMSLEEP;
73 0 : wnmsleep_ie.len = wnmsleep_ie_len - 2;
74 0 : wnmsleep_ie.action_type = action_type;
75 0 : wnmsleep_ie.status = WNM_STATUS_SLEEP_ACCEPT;
76 0 : wnmsleep_ie.intval = host_to_le16(intval);
77 :
78 : /* TFS IE(s) */
79 0 : wnmtfs_ie = os_zalloc(MAX_TFS_IE_LEN);
80 0 : if (wnmtfs_ie == NULL)
81 0 : return -1;
82 0 : if (ieee80211_11_get_tfs_ie(hapd, addr, wnmtfs_ie, &wnmtfs_ie_len,
83 : tfs_oper)) {
84 0 : wnmtfs_ie_len = 0;
85 0 : os_free(wnmtfs_ie);
86 0 : wnmtfs_ie = NULL;
87 : }
88 :
89 : #define MAX_GTK_SUBELEM_LEN 45
90 : #define MAX_IGTK_SUBELEM_LEN 26
91 0 : mgmt = os_zalloc(sizeof(*mgmt) + wnmsleep_ie_len +
92 : MAX_GTK_SUBELEM_LEN + MAX_IGTK_SUBELEM_LEN);
93 0 : if (mgmt == NULL) {
94 0 : wpa_printf(MSG_DEBUG, "MLME: Failed to allocate buffer for "
95 : "WNM-Sleep Response action frame");
96 0 : return -1;
97 : }
98 0 : os_memcpy(mgmt->da, addr, ETH_ALEN);
99 0 : os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
100 0 : os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
101 0 : mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
102 : WLAN_FC_STYPE_ACTION);
103 0 : mgmt->u.action.category = WLAN_ACTION_WNM;
104 0 : mgmt->u.action.u.wnm_sleep_resp.action = WNM_SLEEP_MODE_RESP;
105 0 : mgmt->u.action.u.wnm_sleep_resp.dialogtoken = dialog_token;
106 0 : pos = (u8 *)mgmt->u.action.u.wnm_sleep_resp.variable;
107 : /* add key data if MFP is enabled */
108 0 : if (!wpa_auth_uses_mfp(sta->wpa_sm) ||
109 : action_type != WNM_SLEEP_MODE_EXIT) {
110 0 : mgmt->u.action.u.wnm_sleep_resp.keydata_len = 0;
111 : } else {
112 0 : gtk_elem_len = wpa_wnmsleep_gtk_subelem(sta->wpa_sm, pos);
113 0 : pos += gtk_elem_len;
114 0 : wpa_printf(MSG_DEBUG, "Pass 4, gtk_len = %d",
115 : (int) gtk_elem_len);
116 : #ifdef CONFIG_IEEE80211W
117 0 : res = wpa_wnmsleep_igtk_subelem(sta->wpa_sm, pos);
118 0 : if (res < 0) {
119 0 : os_free(wnmtfs_ie);
120 0 : os_free(mgmt);
121 0 : return -1;
122 : }
123 0 : igtk_elem_len = res;
124 0 : pos += igtk_elem_len;
125 0 : wpa_printf(MSG_DEBUG, "Pass 4 igtk_len = %d",
126 : (int) igtk_elem_len);
127 : #endif /* CONFIG_IEEE80211W */
128 :
129 0 : WPA_PUT_LE16((u8 *)
130 0 : &mgmt->u.action.u.wnm_sleep_resp.keydata_len,
131 : gtk_elem_len + igtk_elem_len);
132 : }
133 0 : os_memcpy(pos, &wnmsleep_ie, wnmsleep_ie_len);
134 : /* copy TFS IE here */
135 0 : pos += wnmsleep_ie_len;
136 0 : if (wnmtfs_ie)
137 0 : os_memcpy(pos, wnmtfs_ie, wnmtfs_ie_len);
138 :
139 0 : len = 1 + sizeof(mgmt->u.action.u.wnm_sleep_resp) + gtk_elem_len +
140 0 : igtk_elem_len + wnmsleep_ie_len + wnmtfs_ie_len;
141 :
142 : /* In driver, response frame should be forced to sent when STA is in
143 : * PS mode */
144 0 : res = hostapd_drv_send_action(hapd, hapd->iface->freq, 0,
145 0 : mgmt->da, &mgmt->u.action.category, len);
146 :
147 0 : if (!res) {
148 0 : wpa_printf(MSG_DEBUG, "Successfully send WNM-Sleep Response "
149 : "frame");
150 :
151 : /* when entering wnmsleep
152 : * 1. pause the node in driver
153 : * 2. mark the node so that AP won't update GTK/IGTK during
154 : * WNM Sleep
155 : */
156 0 : if (wnmsleep_ie.status == WNM_STATUS_SLEEP_ACCEPT &&
157 0 : wnmsleep_ie.action_type == WNM_SLEEP_MODE_ENTER) {
158 0 : sta->flags |= WLAN_STA_WNM_SLEEP_MODE;
159 0 : hostapd_drv_wnm_oper(hapd, WNM_SLEEP_ENTER_CONFIRM,
160 : addr, NULL, NULL);
161 0 : wpa_set_wnmsleep(sta->wpa_sm, 1);
162 : }
163 : /* when exiting wnmsleep
164 : * 1. unmark the node
165 : * 2. start GTK/IGTK update if MFP is not used
166 : * 3. unpause the node in driver
167 : */
168 0 : if ((wnmsleep_ie.status == WNM_STATUS_SLEEP_ACCEPT ||
169 0 : wnmsleep_ie.status ==
170 0 : WNM_STATUS_SLEEP_EXIT_ACCEPT_GTK_UPDATE) &&
171 0 : wnmsleep_ie.action_type == WNM_SLEEP_MODE_EXIT) {
172 0 : sta->flags &= ~WLAN_STA_WNM_SLEEP_MODE;
173 0 : wpa_set_wnmsleep(sta->wpa_sm, 0);
174 0 : hostapd_drv_wnm_oper(hapd, WNM_SLEEP_EXIT_CONFIRM,
175 : addr, NULL, NULL);
176 0 : if (!wpa_auth_uses_mfp(sta->wpa_sm))
177 0 : wpa_wnmsleep_rekey_gtk(sta->wpa_sm);
178 : }
179 : } else
180 0 : wpa_printf(MSG_DEBUG, "Fail to send WNM-Sleep Response frame");
181 :
182 : #undef MAX_GTK_SUBELEM_LEN
183 : #undef MAX_IGTK_SUBELEM_LEN
184 0 : os_free(wnmtfs_ie);
185 0 : os_free(mgmt);
186 0 : return res;
187 : }
188 :
189 :
190 0 : static void ieee802_11_rx_wnmsleep_req(struct hostapd_data *hapd,
191 : const u8 *addr, const u8 *frm, int len)
192 : {
193 : /* Dialog Token [1] | WNM-Sleep Mode IE | TFS Response IE */
194 0 : const u8 *pos = frm;
195 : u8 dialog_token;
196 0 : struct wnm_sleep_element *wnmsleep_ie = NULL;
197 : /* multiple TFS Req IE (assuming consecutive) */
198 0 : u8 *tfsreq_ie_start = NULL;
199 0 : u8 *tfsreq_ie_end = NULL;
200 0 : u16 tfsreq_ie_len = 0;
201 :
202 0 : dialog_token = *pos++;
203 0 : while (pos + 1 < frm + len) {
204 0 : u8 ie_len = pos[1];
205 0 : if (pos + 2 + ie_len > frm + len)
206 0 : break;
207 0 : if (*pos == WLAN_EID_WNMSLEEP)
208 0 : wnmsleep_ie = (struct wnm_sleep_element *) pos;
209 0 : else if (*pos == WLAN_EID_TFS_REQ) {
210 0 : if (!tfsreq_ie_start)
211 0 : tfsreq_ie_start = (u8 *) pos;
212 0 : tfsreq_ie_end = (u8 *) pos;
213 : } else
214 0 : wpa_printf(MSG_DEBUG, "WNM: EID %d not recognized",
215 0 : *pos);
216 0 : pos += ie_len + 2;
217 : }
218 :
219 0 : if (!wnmsleep_ie) {
220 0 : wpa_printf(MSG_DEBUG, "No WNM-Sleep IE found");
221 0 : return;
222 : }
223 :
224 0 : if (wnmsleep_ie->action_type == WNM_SLEEP_MODE_ENTER &&
225 0 : tfsreq_ie_start && tfsreq_ie_end &&
226 0 : tfsreq_ie_end - tfsreq_ie_start >= 0) {
227 0 : tfsreq_ie_len = (tfsreq_ie_end + tfsreq_ie_end[1] + 2) -
228 : tfsreq_ie_start;
229 0 : wpa_printf(MSG_DEBUG, "TFS Req IE(s) found");
230 : /* pass the TFS Req IE(s) to driver for processing */
231 0 : if (ieee80211_11_set_tfs_ie(hapd, addr, tfsreq_ie_start,
232 : &tfsreq_ie_len,
233 : WNM_SLEEP_TFS_REQ_IE_SET))
234 0 : wpa_printf(MSG_DEBUG, "Fail to set TFS Req IE");
235 : }
236 :
237 0 : ieee802_11_send_wnmsleep_resp(hapd, addr, dialog_token,
238 0 : wnmsleep_ie->action_type,
239 0 : le_to_host16(wnmsleep_ie->intval));
240 :
241 0 : if (wnmsleep_ie->action_type == WNM_SLEEP_MODE_EXIT) {
242 : /* clear the tfs after sending the resp frame */
243 0 : ieee80211_11_set_tfs_ie(hapd, addr, tfsreq_ie_start,
244 : &tfsreq_ie_len, WNM_SLEEP_TFS_IE_DEL);
245 : }
246 : }
247 :
248 :
249 0 : static int ieee802_11_send_bss_trans_mgmt_request(struct hostapd_data *hapd,
250 : const u8 *addr,
251 : u8 dialog_token,
252 : const char *url)
253 : {
254 : struct ieee80211_mgmt *mgmt;
255 : size_t url_len, len;
256 : u8 *pos;
257 : int res;
258 :
259 0 : if (url)
260 0 : url_len = os_strlen(url);
261 : else
262 0 : url_len = 0;
263 :
264 0 : mgmt = os_zalloc(sizeof(*mgmt) + (url_len ? 1 + url_len : 0));
265 0 : if (mgmt == NULL)
266 0 : return -1;
267 0 : os_memcpy(mgmt->da, addr, ETH_ALEN);
268 0 : os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
269 0 : os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
270 0 : mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
271 : WLAN_FC_STYPE_ACTION);
272 0 : mgmt->u.action.category = WLAN_ACTION_WNM;
273 0 : mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ;
274 0 : mgmt->u.action.u.bss_tm_req.dialog_token = dialog_token;
275 0 : mgmt->u.action.u.bss_tm_req.req_mode = 0;
276 0 : mgmt->u.action.u.bss_tm_req.disassoc_timer = host_to_le16(0);
277 0 : mgmt->u.action.u.bss_tm_req.validity_interval = 1;
278 0 : pos = mgmt->u.action.u.bss_tm_req.variable;
279 0 : if (url) {
280 0 : *pos++ += url_len;
281 0 : os_memcpy(pos, url, url_len);
282 0 : pos += url_len;
283 : }
284 :
285 0 : wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Request to "
286 : MACSTR " dialog_token=%u req_mode=0x%x disassoc_timer=%u "
287 : "validity_interval=%u",
288 0 : MAC2STR(addr), dialog_token,
289 0 : mgmt->u.action.u.bss_tm_req.req_mode,
290 0 : le_to_host16(mgmt->u.action.u.bss_tm_req.disassoc_timer),
291 0 : mgmt->u.action.u.bss_tm_req.validity_interval);
292 :
293 0 : len = pos - &mgmt->u.action.category;
294 0 : res = hostapd_drv_send_action(hapd, hapd->iface->freq, 0,
295 0 : mgmt->da, &mgmt->u.action.category, len);
296 0 : os_free(mgmt);
297 0 : return res;
298 : }
299 :
300 :
301 0 : static void ieee802_11_rx_bss_trans_mgmt_query(struct hostapd_data *hapd,
302 : const u8 *addr, const u8 *frm,
303 : size_t len)
304 : {
305 : u8 dialog_token, reason;
306 : const u8 *pos, *end;
307 :
308 0 : if (len < 2) {
309 0 : wpa_printf(MSG_DEBUG, "WNM: Ignore too short BSS Transition Management Query from "
310 0 : MACSTR, MAC2STR(addr));
311 0 : return;
312 : }
313 :
314 0 : pos = frm;
315 0 : end = pos + len;
316 0 : dialog_token = *pos++;
317 0 : reason = *pos++;
318 :
319 0 : wpa_printf(MSG_DEBUG, "WNM: BSS Transition Management Query from "
320 : MACSTR " dialog_token=%u reason=%u",
321 0 : MAC2STR(addr), dialog_token, reason);
322 :
323 0 : wpa_hexdump(MSG_DEBUG, "WNM: BSS Transition Candidate List Entries",
324 0 : pos, end - pos);
325 :
326 0 : ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token, NULL);
327 : }
328 :
329 :
330 0 : static void ieee802_11_rx_bss_trans_mgmt_resp(struct hostapd_data *hapd,
331 : const u8 *addr, const u8 *frm,
332 : size_t len)
333 : {
334 : u8 dialog_token, status_code, bss_termination_delay;
335 : const u8 *pos, *end;
336 :
337 0 : if (len < 3) {
338 0 : wpa_printf(MSG_DEBUG, "WNM: Ignore too short BSS Transition Management Response from "
339 0 : MACSTR, MAC2STR(addr));
340 0 : return;
341 : }
342 :
343 0 : pos = frm;
344 0 : end = pos + len;
345 0 : dialog_token = *pos++;
346 0 : status_code = *pos++;
347 0 : bss_termination_delay = *pos++;
348 :
349 0 : wpa_printf(MSG_DEBUG, "WNM: BSS Transition Management Response from "
350 : MACSTR " dialog_token=%u status_code=%u "
351 0 : "bss_termination_delay=%u", MAC2STR(addr), dialog_token,
352 : status_code, bss_termination_delay);
353 :
354 0 : if (status_code == WNM_BSS_TM_ACCEPT) {
355 0 : if (end - pos < ETH_ALEN) {
356 0 : wpa_printf(MSG_DEBUG, "WNM: not enough room for Target BSSID field");
357 0 : return;
358 : }
359 0 : wpa_printf(MSG_DEBUG, "WNM: Target BSSID: " MACSTR,
360 0 : MAC2STR(pos));
361 0 : pos += ETH_ALEN;
362 : }
363 :
364 0 : wpa_hexdump(MSG_DEBUG, "WNM: BSS Transition Candidate List Entries",
365 0 : pos, end - pos);
366 : }
367 :
368 :
369 0 : int ieee802_11_rx_wnm_action_ap(struct hostapd_data *hapd,
370 : const struct ieee80211_mgmt *mgmt, size_t len)
371 : {
372 : u8 action;
373 : const u8 *payload;
374 : size_t plen;
375 :
376 0 : if (len < IEEE80211_HDRLEN + 2)
377 0 : return -1;
378 :
379 0 : payload = &mgmt->u.action.category;
380 0 : payload++;
381 0 : action = *payload++;
382 0 : plen = (((const u8 *) mgmt) + len) - payload;
383 :
384 0 : switch (action) {
385 : case WNM_BSS_TRANS_MGMT_QUERY:
386 0 : ieee802_11_rx_bss_trans_mgmt_query(hapd, mgmt->sa, payload,
387 : plen);
388 0 : return 0;
389 : case WNM_BSS_TRANS_MGMT_RESP:
390 0 : ieee802_11_rx_bss_trans_mgmt_resp(hapd, mgmt->sa, payload,
391 : plen);
392 0 : return 0;
393 : case WNM_SLEEP_MODE_REQ:
394 0 : ieee802_11_rx_wnmsleep_req(hapd, mgmt->sa, payload, plen);
395 0 : return 0;
396 : }
397 :
398 0 : wpa_printf(MSG_DEBUG, "WNM: Unsupported WNM Action %u from " MACSTR,
399 0 : action, MAC2STR(mgmt->sa));
400 0 : return -1;
401 : }
402 :
403 :
404 0 : int wnm_send_disassoc_imminent(struct hostapd_data *hapd,
405 : struct sta_info *sta, int disassoc_timer)
406 : {
407 : u8 buf[1000], *pos;
408 : struct ieee80211_mgmt *mgmt;
409 :
410 0 : os_memset(buf, 0, sizeof(buf));
411 0 : mgmt = (struct ieee80211_mgmt *) buf;
412 0 : mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
413 : WLAN_FC_STYPE_ACTION);
414 0 : os_memcpy(mgmt->da, sta->addr, ETH_ALEN);
415 0 : os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
416 0 : os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
417 0 : mgmt->u.action.category = WLAN_ACTION_WNM;
418 0 : mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ;
419 0 : mgmt->u.action.u.bss_tm_req.dialog_token = 1;
420 0 : mgmt->u.action.u.bss_tm_req.req_mode =
421 : WNM_BSS_TM_REQ_DISASSOC_IMMINENT;
422 0 : mgmt->u.action.u.bss_tm_req.disassoc_timer =
423 0 : host_to_le16(disassoc_timer);
424 0 : mgmt->u.action.u.bss_tm_req.validity_interval = 0;
425 :
426 0 : pos = mgmt->u.action.u.bss_tm_req.variable;
427 :
428 0 : wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Request frame to indicate imminent disassociation (disassoc_timer=%d) to "
429 0 : MACSTR, disassoc_timer, MAC2STR(sta->addr));
430 0 : if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) {
431 0 : wpa_printf(MSG_DEBUG, "Failed to send BSS Transition "
432 : "Management Request frame");
433 0 : return -1;
434 : }
435 :
436 0 : return 0;
437 : }
438 :
439 :
440 0 : int wnm_send_ess_disassoc_imminent(struct hostapd_data *hapd,
441 : struct sta_info *sta, const char *url,
442 : int disassoc_timer)
443 : {
444 : u8 buf[1000], *pos;
445 : struct ieee80211_mgmt *mgmt;
446 : size_t url_len;
447 :
448 0 : os_memset(buf, 0, sizeof(buf));
449 0 : mgmt = (struct ieee80211_mgmt *) buf;
450 0 : mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
451 : WLAN_FC_STYPE_ACTION);
452 0 : os_memcpy(mgmt->da, sta->addr, ETH_ALEN);
453 0 : os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
454 0 : os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
455 0 : mgmt->u.action.category = WLAN_ACTION_WNM;
456 0 : mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ;
457 0 : mgmt->u.action.u.bss_tm_req.dialog_token = 1;
458 0 : mgmt->u.action.u.bss_tm_req.req_mode =
459 : WNM_BSS_TM_REQ_DISASSOC_IMMINENT |
460 : WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT;
461 0 : mgmt->u.action.u.bss_tm_req.disassoc_timer =
462 0 : host_to_le16(disassoc_timer);
463 0 : mgmt->u.action.u.bss_tm_req.validity_interval = 0x01;
464 :
465 0 : pos = mgmt->u.action.u.bss_tm_req.variable;
466 :
467 : /* Session Information URL */
468 0 : url_len = os_strlen(url);
469 0 : if (url_len > 255)
470 0 : return -1;
471 0 : *pos++ = url_len;
472 0 : os_memcpy(pos, url, url_len);
473 0 : pos += url_len;
474 :
475 0 : if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) {
476 0 : wpa_printf(MSG_DEBUG, "Failed to send BSS Transition "
477 : "Management Request frame");
478 0 : return -1;
479 : }
480 :
481 : /* send disassociation frame after time-out */
482 0 : if (disassoc_timer) {
483 : int timeout, beacon_int;
484 :
485 : /*
486 : * Prevent STA from reconnecting using cached PMKSA to force
487 : * full authentication with the authentication server (which may
488 : * decide to reject the connection),
489 : */
490 0 : wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr);
491 :
492 0 : beacon_int = hapd->iconf->beacon_int;
493 0 : if (beacon_int < 1)
494 0 : beacon_int = 100; /* best guess */
495 : /* Calculate timeout in ms based on beacon_int in TU */
496 0 : timeout = disassoc_timer * beacon_int * 128 / 125;
497 0 : wpa_printf(MSG_DEBUG, "Disassociation timer for " MACSTR
498 0 : " set to %d ms", MAC2STR(sta->addr), timeout);
499 :
500 0 : sta->timeout_next = STA_DISASSOC_FROM_CLI;
501 0 : eloop_cancel_timeout(ap_handle_timer, hapd, sta);
502 0 : eloop_register_timeout(timeout / 1000,
503 0 : timeout % 1000 * 1000,
504 : ap_handle_timer, hapd, sta);
505 : }
506 :
507 0 : return 0;
508 : }
|