Home | History | Annotate | Download | only in eapol_supp

Lines Matching refs:sm

142 static void eapol_sm_txLogoff(struct eapol_sm *sm);
143 static void eapol_sm_txStart(struct eapol_sm *sm);
144 static void eapol_sm_processKey(struct eapol_sm *sm);
145 static void eapol_sm_getSuppRsp(struct eapol_sm *sm);
146 static void eapol_sm_txSuppRsp(struct eapol_sm *sm);
147 static void eapol_sm_abortSupp(struct eapol_sm *sm);
148 static void eapol_sm_abort_cached(struct eapol_sm *sm);
150 static void eapol_sm_set_port_authorized(struct eapol_sm *sm);
151 static void eapol_sm_set_port_unauthorized(struct eapol_sm *sm);
158 struct eapol_sm *sm = timeout_ctx;
160 if (sm->authWhile > 0) {
161 sm->authWhile--;
162 if (sm->authWhile == 0)
165 if (sm->heldWhile > 0) {
166 sm->heldWhile--;
167 if (sm->heldWhile == 0)
170 if (sm->startWhen > 0) {
171 sm->startWhen--;
172 if (sm->startWhen == 0)
175 if (sm->idleWhile > 0) {
176 sm->idleWhile--;
177 if (sm->idleWhile == 0)
181 if (sm->authWhile | sm->heldWhile | sm->startWhen | sm->idleWhile) {
183 sm);
186 sm->timer_tick_enabled = 0;
188 eapol_sm_step(sm);
192 static void eapol_enable_timer_tick(struct eapol_sm *sm)
194 if (sm->timer_tick_enabled)
197 sm->timer_tick_enabled = 1;
198 eloop_cancel_timeout(eapol_port_timers_tick, NULL, sm);
199 eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm);
206 eapol_sm_txLogoff(sm);
207 sm->logoffSent = TRUE;
208 sm->suppPortStatus = Unauthorized;
209 eapol_sm_set_port_unauthorized(sm);
216 sm->sPortMode = Auto;
217 sm->startCount = 0;
218 sm->logoffSent = FALSE;
219 sm->suppPortStatus = Unauthorized;
220 eapol_sm_set_port_unauthorized(sm);
221 sm->suppAbort = TRUE;
223 sm->unicast_key_received = FALSE;
224 sm->broadcast_key_received = FALSE;
233 sm->heldWhile = 0;
239 int send_start = sm->SUPP_PAE_state == SUPP_PAE_CONNECTING;
242 sm->startWhen = sm->startPeriod;
243 sm->startCount++;
254 sm->startWhen = 1;
256 sm->startWhen = 3;
259 eapol_enable_timer_tick(sm);
260 sm->eapolEap = FALSE;
262 eapol_sm_txStart(sm);
269 sm->startCount = 0;
270 sm->suppSuccess = FALSE;
271 sm->suppFail = FALSE;
272 sm->suppTimeout = FALSE;
273 sm->keyRun = FALSE;
274 sm->keyDone = FALSE;
275 sm->suppStart = TRUE;
282 sm->heldWhile = sm->heldPeriod;
283 eapol_enable_timer_tick(sm);
284 sm->suppPortStatus = Unauthorized;
285 eapol_sm_set_port_unauthorized(sm);
286 sm->cb_status = EAPOL_CB_FAILURE;
293 sm->suppPortStatus = Authorized;
294 eapol_sm_set_port_authorized(sm);
295 sm->cb_status = EAPOL_CB_SUCCESS;
302 sm->eapRestart = TRUE;
309 sm->suppPortStatus = Authorized;
310 eapol_sm_set_port_authorized(sm);
311 sm->sPortMode = ForceAuthorized;
318 sm->suppPortStatus = Unauthorized;
319 eapol_sm_set_port_unauthorized(sm);
320 sm->sPortMode = ForceUnauthorized;
321 eapol_sm_txLogoff(sm);
327 if ((sm->userLogoff && !sm->logoffSent) &&
328 !(sm->initialize || !sm->portEnabled))
330 else if (((sm->portControl == Auto) &&
331 (sm->sPortMode != sm->portControl)) ||
332 sm->initialize || !sm->portEnabled)
334 else if ((sm->portControl == ForceAuthorized) &&
335 (sm->sPortMode != sm->portControl) &&
336 !(sm->initialize || !sm->portEnabled))
338 else if ((sm->portControl == ForceUnauthorized) &&
339 (sm->sPortMode != sm->portControl) &&
340 !(sm->initialize || !sm->portEnabled))
342 else switch (sm->SUPP_PAE_state) {
346 if (!sm->userLogoff)
353 if (sm->startWhen == 0 && sm->startCount < sm->maxStart)
355 else if (sm->startWhen == 0 &&
356 sm->startCount >= sm->maxStart &&
357 sm->portValid)
359 else if (sm->eapSuccess || sm->eapFail)
361 else if (sm->eapolEap)
363 else if (sm->startWhen == 0 &&
364 sm->startCount >= sm->maxStart &&
365 !sm->portValid)
369 if (sm->eapSuccess && !sm->portValid &&
370 sm->conf.accept_802_1x_keys &&
371 sm->conf.required_keys == 0) {
375 sm->portValid = TRUE;
376 if (sm->ctx->eapol_done_cb)
377 sm->ctx->eapol_done_cb(sm->ctx->ctx);
379 if (sm->eapSuccess && sm->portValid)
381 else if (sm->eapFail || (sm->keyDone && !sm->portValid))
383 else if (sm->suppTimeout)
387 if (sm->heldWhile == 0)
389 else if (sm->eapolEap)
393 if (sm->eapolEap && sm->portValid)
395 else if (!sm->portValid)
399 if (!sm->eapRestart)
419 eapol_sm_processKey(sm);
420 sm->rxKey = FALSE;
426 if (sm->initialize || !sm->portEnabled)
428 switch (sm->KEY_RX_state) {
432 if (sm->rxKey)
436 if (sm->rxKey)
446 sm->authWhile = 0;
447 sm->eapReq = TRUE;
448 eapol_sm_getSuppRsp(sm);
455 eapol_sm_txSuppRsp(sm);
456 sm->eapResp = FALSE;
463 sm->keyRun = TRUE;
464 sm->suppSuccess = TRUE;
466 if (eap_key_available(sm->eap)) {
469 sm->replay_counter_valid = FALSE;
477 sm->suppFail = TRUE;
484 sm->suppTimeout = TRUE;
491 sm->suppStart = FALSE;
492 sm->initial_req = TRUE;
499 eapol_sm_abortSupp(sm);
500 sm->suppAbort = FALSE;
509 sm->authWhile = 0;
516 sm->authWhile = sm->authPeriod;
517 eapol_enable_timer_tick(sm);
518 sm->eapolEap = FALSE;
519 sm->eapNoResp = FALSE;
520 sm->initial_req = FALSE;
526 if (sm->initialize || sm->suppAbort)
528 else switch (sm->SUPP_BE_state) {
546 if (sm->eapResp && sm->eapNoResp) {
550 if (sm->eapResp)
552 else if (sm->eapNoResp)
554 else if (sm->eapFail)
556 else if (sm->eapSuccess)
572 if (sm->eapFail && sm->suppStart)
574 else if (sm->eapolEap && sm->suppStart)
576 else if (sm->eapSuccess && sm->suppStart)
583 if (sm->eapolEap)
585 else if (sm->eapFail)
587 else if (sm->authWhile == 0)
589 else if (sm->eapSuccess)
596 static void eapol_sm_txLogoff(struct eapol_sm *sm)
599 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
601 sm->dot1xSuppEapolLogoffFramesTx++;
602 sm->dot1xSuppEapolFramesTx++;
606 static void eapol_sm_txStart(struct eapol_sm *sm)
609 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
611 sm->dot1xSuppEapolStartFramesTx++;
612 sm->dot1xSuppEapolFramesTx++;
625 static void eapol_sm_processKey(struct eapol_sm *sm)
638 if (sm->last_rx_key == NULL)
641 if (!sm->conf.accept_802_1x_keys) {
648 if (sm->last_rx_key_len < sizeof(*hdr) + sizeof(*key))
650 hdr = (struct ieee802_1x_hdr *) sm->last_rx_key;
653 if (sizeof(*hdr) + plen > sm
663 eapol_sm_notify_lower_layer_success(sm, 1);
666 res = eapol_sm_get_key(sm, (u8 *) &keydata, sizeof(keydata));
674 res = eapol_sm_get_key(sm, (u8 *) &keydata, 16);
690 if (sm->replay_counter_valid &&
691 os_memcmp(sm->last_replay_counter, key->replay_counter,
696 sm->last_replay_counter,
707 sm->last_rx_key, sizeof(*hdr) + be_to_host16(hdr->length),
755 sm->replay_counter_valid = TRUE;
756 os_memcpy(sm->last_replay_counter, key->replay_counter,
765 if (sm->ctx->set_wep_key &&
766 sm->ctx->set_wep_key(sm->ctx->ctx,
774 sm->unicast_key_received = TRUE;
776 sm->broadcast_key_received = TRUE;
778 if ((sm->unicast_key_received ||
779 !(sm->conf.required_keys & EAPOL_REQUIRE_KEY_UNICAST)) &&
780 (sm->broadcast_key_received ||
781 !(sm->conf.required_keys & EAPOL_REQUIRE_KEY_BROADCAST)))
785 sm->portValid = TRUE;
786 if (sm->ctx->eapol_done_cb)
787 sm->ctx->eapol_done_cb(sm->ctx->ctx);
794 static void eapol_sm_getSuppRsp(struct eapol_sm *sm)
804 static void eapol_sm_txSuppRsp(struct eapol_sm *sm)
809 resp = eap_get_eapRespData(sm->eap);
817 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
824 if (sm->initial_req)
825 sm->dot1xSuppEapolReqIdFramesRx++;
827 sm->dot1xSuppEapolReqFramesRx++;
828 sm->dot1xSuppEapolRespFramesTx++;
829 sm->dot1xSuppEapolFramesTx++;
833 static void eapol_sm_abortSupp(struct eapol_sm *sm)
837 os_free(sm->last_rx_key);
838 sm->last_rx_key = NULL;
839 wpabuf_free(sm->eapReqData);
840 sm->eapReqData = NULL;
841 eap_sm_abort(sm->eap);
851 static void eapol_sm_set_port_authorized(struct eapol_sm *sm)
853 if (sm->ctx->port_cb)
854 sm->ctx->port_cb(sm->ctx->ctx, 1);
858 static void eapol_sm_set_port_unauthorized(struct eapol_sm *sm)
860 if (sm->ctx->port_cb)
861 sm->ctx->port_cb(sm->ctx->ctx, 0);
867 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
873 void eapol_sm_step(struct eapol_sm *sm)
882 sm->changed = FALSE;
886 if (eap_peer_sm_step(sm->eap))
887 sm->changed = TRUE;
888 if (!sm->changed)
892 if (sm->changed) {
895 eloop_cancel_timeout(eapol_sm_step_timeout, NULL, sm);
896 eloop_register_timeout(0, 0, eapol_sm_step_timeout, NULL, sm);
899 if (sm->ctx->cb && sm->cb_status != EAPOL_CB_IN_PROGRESS) {
900 int success = sm->cb_status == EAPOL_CB_SUCCESS ? 1 : 0;
901 sm->cb_status = EAPOL_CB_IN_PROGRESS;
902 sm->ctx->cb(sm, success, sm->ctx->cb_ctx);
985 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
994 void eapol_sm_configure(struct eapol_sm *sm, int heldPeriod, int authPeriod,
997 if (sm == NULL)
1000 sm->heldPeriod = heldPeriod;
1002 sm->authPeriod = authPeriod;
1004 sm->startPeriod = startPeriod;
1006 sm->maxStart = maxStart;
1012 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1015 const char * eapol_sm_get_method_name(struct eapol_sm *sm)
1017 if (sm->SUPP_PAE_state != SUPP_PAE_AUTHENTICATED ||
1018 sm->suppPortStatus != Authorized)
1021 return eap_sm_get_method_name(sm->eap);
1028 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1039 int eapol_sm_get_status(struct eapol_sm *sm, char *buf, size_t buflen,
1043 if (sm == NULL)
1049 eapol_supp_pae_state(sm->SUPP_PAE_state),
1050 eapol_port_status(sm->suppPortStatus));
1062 sm->heldPeriod,
1063 sm->authPeriod,
1064 sm->startPeriod,
1065 sm->maxStart,
1066 eapol_port_control(sm->portControl),
1067 eapol_supp_be_state(sm->SUPP_BE_state));
1073 len += eap_sm_get_status(sm->eap, buf + len, buflen - len, verbose);
1081 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1091 int eapol_sm_get_mib(struct eapol_sm *sm, char *buf, size_t buflen)
1096 if (sm == NULL)
1106 sm->SUPP_PAE_state,
1107 sm->heldPeriod,
1108 sm->authPeriod,
1109 sm->startPeriod,
1110 sm->maxStart,
1111 sm->suppPortStatus == Authorized ?
1113 sm->SUPP_BE_state);
1131 sm->dot1xSuppEapolFramesRx,
1132 sm->dot1xSuppEapolFramesTx,
1133 sm->dot1xSuppEapolStartFramesTx,
1134 sm->dot1xSuppEapolLogoffFramesTx,
1135 sm->dot1xSuppEapolRespFramesTx,
1136 sm->dot1xSuppEapolReqIdFramesRx,
1137 sm->dot1xSuppEapolReqFramesRx,
1138 sm->dot1xSuppInvalidEapolFramesRx,
1139 sm->dot1xSuppEapLengthErrorFramesRx,
1140 sm->dot1xSuppLastEapolFrameVersion,
1141 MAC2STR(sm->dot1xSuppLastEapolFrameSource));
1154 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1161 int eapol_sm_rx_eapol(struct eapol_sm *sm, const u8 *src, const u8 *buf,
1170 if (sm == NULL)
1172 sm->dot1xSuppEapolFramesRx++;
1174 sm->dot1xSuppInvalidEapolFramesRx++;
1178 sm->dot1xSuppLastEapolFrameVersion = hdr->version;
1179 os_memcpy(sm->dot1xSuppLastEapolFrameSource, src, ETH_ALEN);
1185 sm->dot1xSuppEapLengthErrorFramesRx++;
1189 if (sm->conf.workaround &&
1217 if (sm
1222 eapol_sm_abort_cached(sm);
1224 wpabuf_free(sm->eapReqData);
1225 sm->eapReqData = wpabuf_alloc_copy(hdr + 1, plen);
1226 if (sm->eapReqData) {
1229 sm->eapolEap = TRUE;
1230 eapol_sm_step(sm);
1253 os_free(sm->last_rx_key);
1254 sm->last_rx_key = os_malloc(data_len);
1255 if (sm->last_rx_key) {
1258 os_memcpy(sm->last_rx_key, buf, data_len);
1259 sm->last_rx_key_len = data_len;
1260 sm->rxKey = TRUE;
1261 eapol_sm_step(sm);
1267 sm->dot1xSuppInvalidEapolFramesRx++;
1277 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1282 void eapol_sm_notify_tx_eapol_key(struct eapol_sm *sm)
1284 if (sm)
1285 sm->dot1xSuppEapolFramesTx++;
1291 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1296 void eapol_sm_notify_portEnabled(struct eapol_sm *sm, Boolean enabled)
1298 if (sm == NULL)
1302 sm->portEnabled = enabled;
1303 eapol_sm_step(sm);
1309 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1314 void eapol_sm_notify_portValid(struct eapol_sm *sm, Boolean valid)
1316 if (sm == NULL)
1320 sm->portValid = valid;
1321 eapol_sm_step(sm);
1327 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1336 void eapol_sm_notify_eap_success(struct eapol_sm *sm, Boolean success)
1338 if (sm == NULL)
1342 sm->eapSuccess = success;
1343 sm->altAccept = success;
1345 eap_notify_success(sm->eap);
1346 eapol_sm_step(sm);
1352 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1358 void eapol_sm_notify_eap_fail(struct eapol_sm *sm, Boolean fail)
1360 if (sm == NULL)
1364 sm->eapFail = fail;
1365 sm->altReject = fail;
1366 eapol_sm_step(sm);
1372 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1382 void eapol_sm_notify_config(struct eapol_sm *sm,
1386 if (sm == NULL)
1389 sm->config = config;
1394 sm->conf.accept_802_1x_keys = conf->accept_802_1x_keys;
1395 sm->conf.required_keys = conf->required_keys;
1396 sm->conf.fast_reauth = conf->fast_reauth;
1397 sm->conf.workaround = conf->workaround;
1398 if (sm->eap) {
1399 eap_set_fast_reauth(sm->eap, conf->fast_reauth);
1400 eap_set_workaround(sm->eap, conf->workaround);
1401 eap_set_force_disabled(sm->eap, conf->eap_disabled);
1408 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1417 int eapol_sm_get_key(struct eapol_sm *sm, u8 *key, size_t len)
1422 if (sm == NULL || !eap_key_available(sm->eap)) {
1426 eap_key = eap_get_eapKeyData(sm->eap, &eap_len);
1446 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1451 void eapol_sm_notify_logoff(struct eapol_sm *sm, Boolean logoff)
1453 if (sm) {
1454 sm->userLogoff = logoff;
1455 eapol_sm_step(sm);
1462 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1467 void eapol_sm_notify_cached(struct eapol_sm *sm)
1469 if (sm == NULL)
1472 sm->SUPP_PAE_state = SUPP_PAE_AUTHENTICATED;
1473 sm->suppPortStatus = Authorized;
1474 eapol_sm_set_port_authorized(sm);
1475 sm->portValid = TRUE;
1476 eap_notify_success(sm->eap);
1477 eapol_sm_step(sm);
1483 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1488 void eapol_sm_notify_pmkid_attempt(struct eapol_sm *sm, int attempt)
1490 if (sm == NULL)
1494 sm->cached_pmk = TRUE;
1497 sm->cached_pmk = FALSE;
1502 static void eapol_sm_abort_cached(struct eapol_sm *sm)
1506 if (sm == NULL)
1508 sm->cached_pmk = FALSE;
1509 sm->SUPP_PAE_state = SUPP_PAE_CONNECTING;
1510 sm->suppPortStatus = Unauthorized;
1511 eapol_sm_set_port_unauthorized(sm);
1515 sm->startWhen = 3;
1516 eapol_enable_timer_tick(sm);
1518 if (sm->ctx->aborted_cached)
1519 sm->ctx->aborted_cached(sm->ctx->ctx);
1525 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1531 void eapol_sm_register_scard_ctx(struct eapol_sm *sm, void *ctx)
1533 if (sm) {
1534 sm->ctx->scard_ctx = ctx;
1535 eap_register_scard_ctx(sm->eap, ctx);
1542 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1547 void eapol_sm_notify_portControl(struct eapol_sm *sm, PortControl portControl)
1549 if (sm == NULL)
1553 sm->portControl = portControl;
1554 eapol_sm_step(sm);
1560 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1565 void eapol_sm_notify_ctrl_attached(struct eapol_sm *sm)
1567 if (sm == NULL)
1569 eap_sm_notify_ctrl_attached(sm->eap);
1575 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1580 void eapol_sm_notify_ctrl_response(struct eapol_sm *sm)
1582 if (sm == NULL)
1584 if (sm->eapReqData && !sm->eapReq) {
1588 sm->eapolEap = TRUE;
1589 sm->eapReq = TRUE;
1590 eapol_sm_step(sm);
1597 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1602 void eapol_sm_request_reauth(struct eapol_sm *sm)
1604 if (sm == NULL || sm->SUPP_PAE_state != SUPP_PAE_AUTHENTICATED)
1606 eapol_sm_txStart(sm);
1612 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1620 void eapol_sm_notify_lower_layer_success(struct eapol_sm *sm, int in_eapol_sm)
1622 if (sm == NULL)
1624 eap_notify_lower_layer_success(sm->eap);
1626 eapol_sm_step(sm);
1632 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1634 void eapol_sm_invalidate_cached_session(struct eapol_sm *sm)
1636 if (sm)
1637 eap_invalidate_cached_session(sm->eap);
1643 struct eapol_sm *sm = ctx;
1644 return sm ? sm->config : NULL;
1650 struct eapol_sm *sm = ctx;
1651 if (sm == NULL || sm->eapReqData == NULL)
1654 return sm->eapReqData;
1660 struct eapol_sm *sm = ctx;
1661 if (sm == NULL)
1665 return sm->eapSuccess;
1667 return sm->eapRestart;
1669 return sm->eapFail;
1671 return sm->eapResp;
1673 return sm->eapNoResp;
1675 return sm->eapReq;
1677 return sm->portEnabled;
1679 return sm->altAccept;
1681 return sm->altReject;
1690 struct eapol_sm *sm = ctx;
1691 if (sm == NULL)
1695 sm->eapSuccess = value;
1698 sm->eapRestart = value;
1701 sm->eapFail = value;
1704 sm->eapResp = value;
1707 sm->eapNoResp = value;
1710 sm->eapReq = value;
1713 sm->portEnabled = value;
1716 sm->altAccept = value;
1719 sm->altReject = value;
1727 struct eapol_sm *sm = ctx;
1728 if (sm == NULL)
1732 return sm->idleWhile;
1741 struct eapol_sm *sm = ctx;
1742 if (sm == NULL)
1746 sm->idleWhile = value;
1747 if (sm->idleWhile > 0)
1748 eapol_enable_timer_tick(sm);
1757 struct eapol_sm *sm = ctx;
1758 if (sm && sm->ctx && sm->ctx->set_config_blob)
1759 sm->ctx->set_config_blob(sm->ctx->ctx, blob);
1768 struct eapol_sm *sm = ctx;
1769 if (sm && sm->ctx && sm->ctx->get_config_blob)
1770 return sm->ctx->get_config_blob(sm->ctx->ctx, name);
1781 struct eapol_sm *sm = ctx;
1782 if (sm == NULL)
1784 if (sm->eapReqData && !sm->eapReq) {
1787 sm->eapolEap = TRUE;
1788 sm->eapReq = TRUE;
1789 eapol_sm_step(sm);
1798 struct eapol_sm *sm = ctx;
1800 if (sm->ctx->eap_param_needed)
1801 sm->ctx->eap_param_needed(sm->ctx->ctx, field, txt);
1811 struct eapol_sm *sm = ctx;
1812 if (sm->ctx->cert_cb)
1813 sm->ctx->cert_cb(sm->ctx->ctx, depth, subject,
1821 struct eapol_sm *sm = ctx;
1823 if (sm->ctx->status_cb)
1824 sm->ctx->status_cb(sm->ctx->ctx, status, parameter);
1830 struct eapol_sm *sm = ctx;
1832 if (sm->ctx->set_anon_id)
1833 sm->ctx->set_anon_id(sm->ctx->ctx, id, len);
1865 struct eapol_sm *sm;
1867 sm = os_zalloc(sizeof(*sm));
1868 if (sm == NULL)
1870 sm->ctx = ctx;
1872 sm->portControl = Auto;
1875 sm->heldPeriod = 60;
1876 sm->startPeriod = 30;
1877 sm->maxStart = 3;
1880 sm->authPeriod = 30;
1889 sm->eap = eap_peer_sm_init(sm, &eapol_cb, sm->ctx->msg_ctx, &conf);
1890 if (sm->eap == NULL) {
1891 os_free(sm);
1896 sm->initialize = TRUE;
1897 eapol_sm_step(sm);
1898 sm->initialize = FALSE;
1899 eapol_sm_step(sm);
1901 sm->timer_tick_enabled = 1;
1902 eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm);
1904 return sm;
1910 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1914 void eapol_sm_deinit(struct eapol_sm *sm)
1916 if (sm == NULL)
1918 eloop_cancel_timeout(eapol_sm_step_timeout, NULL, sm);
1919 eloop_cancel_timeout(eapol_port_timers_tick, NULL, sm);
1920 eap_peer_sm_deinit(sm->eap);
1921 os_free(sm->last_rx_key);
1922 wpabuf_free(sm->eapReqData);
1923 os_free(sm->ctx);
1924 os_free(sm);
1928 void eapol_sm_set_ext_pw_ctx(struct eapol_sm *sm,
1931 if (sm && sm->eap)
1932 eap_sm_set_ext_pw_ctx(sm->eap, ext);
1936 int eapol_sm_failed(struct eapol_sm *sm)
1938 if (sm == NULL)
1940 return !sm->eapSuccess && sm->eapFail;