Home | History | Annotate | Download | only in eapol_supp

Lines Matching refs:sm

152 static void eapol_sm_txLogoff(struct eapol_sm *sm);
153 static void eapol_sm_txStart(struct eapol_sm *sm);
154 static void eapol_sm_processKey(struct eapol_sm *sm);
155 static void eapol_sm_getSuppRsp(struct eapol_sm *sm);
156 static void eapol_sm_txSuppRsp(struct eapol_sm *sm);
157 static void eapol_sm_abortSupp(struct eapol_sm *sm);
158 static void eapol_sm_abort_cached(struct eapol_sm *sm);
160 static void eapol_sm_set_port_authorized(struct eapol_sm *sm);
161 static void eapol_sm_set_port_unauthorized(struct eapol_sm *sm);
168 struct eapol_sm *sm = timeout_ctx;
170 if (sm->authWhile > 0) {
171 sm->authWhile--;
172 if (sm->authWhile == 0)
175 if (sm->heldWhile > 0) {
176 sm->heldWhile--;
177 if (sm->heldWhile == 0)
180 if (sm->startWhen > 0) {
181 sm->startWhen--;
182 if (sm->startWhen == 0)
185 if (sm->idleWhile > 0) {
186 sm->idleWhile--;
187 if (sm->idleWhile == 0)
191 if (sm->authWhile | sm->heldWhile | sm->startWhen | sm->idleWhile) {
193 sm);
196 sm->timer_tick_enabled = 0;
198 eapol_sm_step(sm);
202 static void eapol_enable_timer_tick(struct eapol_sm *sm)
204 if (sm->timer_tick_enabled)
207 sm->timer_tick_enabled = 1;
208 eloop_cancel_timeout(eapol_port_timers_tick, NULL, sm);
209 eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm);
216 eapol_sm_txLogoff(sm);
217 sm->logoffSent = TRUE;
218 eapol_sm_set_port_unauthorized(sm);
225 sm->sPortMode = Auto;
226 sm->startCount = 0;
227 sm->eapTriggerStart = FALSE;
228 sm->logoffSent = FALSE;
229 eapol_sm_set_port_unauthorized(sm);
230 sm->suppAbort = TRUE;
232 sm->unicast_key_received = FALSE;
233 sm->broadcast_key_received = FALSE;
242 sm->heldWhile = 0;
248 int send_start = sm->SUPP_PAE_state == SUPP_PAE_CONNECTING ||
249 sm->SUPP_PAE_state == SUPP_PAE_HELD;
252 if (sm->eapTriggerStart)
254 if (sm->ctx->preauth)
256 sm->eapTriggerStart = FALSE;
259 sm->startWhen = sm->startPeriod;
260 sm->startCount++;
269 if (sm->conf.wps && !(sm->conf.wps & EAPOL_PEER_IS_WPS20_AP)) {
273 sm->startWhen = 1;
275 sm->startWhen = 2;
278 eapol_enable_timer_tick(sm);
279 sm->eapolEap = FALSE;
281 eapol_sm_txStart(sm);
288 sm->startCount = 0;
289 sm->suppSuccess = FALSE;
290 sm->suppFail = FALSE;
291 sm->suppTimeout = FALSE;
292 sm->keyRun = FALSE;
293 sm->keyDone = FALSE;
294 sm->suppStart = TRUE;
301 sm->heldWhile = sm->heldPeriod;
302 eapol_enable_timer_tick(sm);
303 eapol_sm_set_port_unauthorized(sm);
304 sm->cb_status = EAPOL_CB_FAILURE;
311 eapol_sm_set_port_authorized(sm);
312 sm->cb_status = EAPOL_CB_SUCCESS;
319 sm->eapRestart = TRUE;
320 if (sm->altAccept) {
327 sm->eapSuccess = FALSE;
328 sm->altAccept = FALSE;
336 eapol_sm_set_port_authorized(sm);
337 sm->sPortMode = ForceAuthorized;
344 eapol_sm_set_port_unauthorized(sm);
345 sm->sPortMode = ForceUnauthorized;
346 eapol_sm_txLogoff(sm);
352 if ((sm->userLogoff && !sm->logoffSent) &&
353 !(sm->initialize || !sm->portEnabled))
355 else if (((sm->portControl == Auto) &&
356 (sm->sPortMode != sm->portControl)) ||
357 sm->initialize || !sm->portEnabled)
359 else if ((sm->portControl == ForceAuthorized) &&
360 (sm->sPortMode != sm->portControl) &&
361 !(sm->initialize || !sm->portEnabled))
363 else if ((sm->portControl == ForceUnauthorized) &&
364 (sm->sPortMode != sm->portControl) &&
365 !(sm->initialize || !sm->portEnabled))
367 else switch (sm->SUPP_PAE_state) {
371 if (!sm->userLogoff)
378 if (sm->startWhen == 0 && sm->startCount < sm->maxStart)
380 else if (sm->startWhen == 0 &&
381 sm->startCount >= sm->maxStart &&
382 sm->portValid)
384 else if (sm->eapSuccess || sm->eapFail)
386 else if (sm->eapolEap)
388 else if (sm->startWhen == 0 &&
389 sm->startCount >= sm->maxStart &&
390 !sm->portValid)
394 if (sm->eapSuccess && !sm->portValid &&
395 sm->conf.accept_802_1x_keys &&
396 sm->conf.required_keys == 0) {
400 sm->portValid = TRUE;
401 if (sm->ctx->eapol_done_cb)
402 sm->ctx->eapol_done_cb(sm->ctx->ctx);
404 if (sm->eapSuccess && sm->portValid)
406 else if (sm->eapFail || (sm->keyDone && !sm->portValid))
408 else if (sm->suppTimeout)
410 else if (sm->eapTriggerStart)
414 if (sm->heldWhile == 0)
416 else if (sm->eapolEap)
420 if (sm->eapolEap && sm->portValid)
422 else if (!sm->portValid)
426 if (!sm->eapRestart)
446 eapol_sm_processKey(sm);
447 sm->rxKey = FALSE;
453 if (sm->initialize || !sm->portEnabled)
455 switch (sm->KEY_RX_state) {
459 if (sm->rxKey)
463 if (sm->rxKey)
473 sm->authWhile = 0;
474 sm->eapReq = TRUE;
475 eapol_sm_getSuppRsp(sm);
482 eapol_sm_txSuppRsp(sm);
483 sm->eapResp = FALSE;
490 sm->keyRun = TRUE;
491 sm->suppSuccess = TRUE;
494 if (sm->use_eap_proxy) {
495 if (eap_proxy_key_available(sm->eap_proxy)) {
501 sm->replay_counter_valid = FALSE;
504 sm->eap_proxy, &session_id_len);
505 emsk = eap_proxy_get_emsk(sm->eap_proxy, &emsk_len);
506 if (sm->config->erp && session_id && emsk)
507 eap_peer_erp_init(sm->eap, session_id,
515 if (eap_key_available(sm->eap)) {
518 sm->replay_counter_valid = FALSE;
526 sm->suppFail = TRUE;
533 sm->suppTimeout = TRUE;
540 sm->suppStart = FALSE;
541 sm->initial_req = TRUE;
548 eapol_sm_abortSupp(sm);
549 sm->suppAbort = FALSE;
558 sm->authWhile = 0;
565 sm->authWhile = sm->authPeriod;
566 eapol_enable_timer_tick(sm);
567 sm->eapolEap = FALSE;
568 sm->eapNoResp = FALSE;
569 sm->initial_req = FALSE;
575 if (sm->initialize || sm->suppAbort)
577 else switch (sm->SUPP_BE_state) {
595 if (sm->eapResp && sm->eapNoResp) {
599 if (sm->eapResp)
601 else if (sm->eapNoResp)
603 else if (sm->eapFail)
605 else if (sm->eapSuccess)
621 if (sm->eapFail && sm->suppStart)
623 else if (sm->eapolEap && sm->suppStart)
625 else if (sm->eapSuccess && sm->suppStart)
632 if (sm->eapolEap)
634 else if (sm->eapFail)
636 else if (sm->authWhile == 0)
638 else if (sm->eapSuccess)
645 static void eapol_sm_txLogoff(struct eapol_sm *sm)
648 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
650 sm->dot1xSuppEapolLogoffFramesTx++;
651 sm->dot1xSuppEapolFramesTx++;
655 sm)
658 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
660 sm->dot1xSuppEapolStartFramesTx++;
661 sm->dot1xSuppEapolFramesTx++;
674 static void eapol_sm_processKey(struct eapol_sm *sm)
689 if (sm->last_rx_key == NULL)
692 if (!sm->conf.accept_802_1x_keys) {
699 if (sm->last_rx_key_len < sizeof(*hdr) + sizeof(*key))
701 hdr = (struct ieee802_1x_hdr *) sm->last_rx_key;
704 if (sizeof(*hdr) + plen > sm->last_rx_key_len || plen < sizeof(*key)) {
714 eapol_sm_notify_lower_layer_success(sm, 1);
717 res = eapol_sm_get_key(sm, (u8 *) &keydata, sizeof(keydata));
725 res = eapol_sm_get_key(sm, (u8 *) &keydata, 16);
741 if (sm->replay_counter_valid &&
742 os_memcmp(sm->last_replay_counter, key->replay_counter,
747 sm->last_replay_counter,
758 sm->last_rx_key, sizeof(*hdr) + be_to_host16(hdr->length),
814 sm->replay_counter_valid = TRUE;
815 os_memcpy(sm->last_replay_counter, key->replay_counter,
824 if (sm->ctx->set_wep_key &&
825 sm->ctx->set_wep_key(sm->ctx->ctx,
833 sm->unicast_key_received = TRUE;
835 sm->broadcast_key_received = TRUE;
837 if ((sm->unicast_key_received ||
838 !(sm->conf.required_keys & EAPOL_REQUIRE_KEY_UNICAST)) &&
839 (sm->broadcast_key_received ||
840 !(sm->conf.required_keys & EAPOL_REQUIRE_KEY_BROADCAST)))
844 sm->portValid = TRUE;
845 if (sm->ctx->eapol_done_cb)
846 sm->ctx->eapol_done_cb(sm->ctx->ctx);
853 static void eapol_sm_getSuppRsp(struct eapol_sm *sm)
863 static void eapol_sm_txSuppRsp(struct eapol_sm *sm)
870 if (sm->use_eap_proxy) {
872 resp = eap_proxy_get_eapRespData(sm->eap_proxy);
881 resp = eap_get_eapRespData(sm->eap);
889 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
896 if (sm->initial_req)
897 sm->dot1xSuppEapolReqIdFramesRx++;
899 sm->dot1xSuppEapolReqFramesRx++;
900 sm->dot1xSuppEapolRespFramesTx++;
901 sm->dot1xSuppEapolFramesTx++;
905 static void eapol_sm_abortSupp(struct eapol_sm *sm)
909 os_free(sm->last_rx_key);
910 sm->last_rx_key = NULL;
911 wpabuf_free(sm->eapReqData);
912 sm->eapReqData = NULL;
913 eap_sm_abort(sm->eap);
915 eap_proxy_sm_abort(sm->eap_proxy);
926 static void eapol_sm_set_port_authorized(struct eapol_sm *sm)
930 cb = sm->suppPortStatus != Authorized || sm->force_authorized_update;
931 sm->force_authorized_update = FALSE;
932 sm->suppPortStatus = Authorized;
933 if (cb && sm->ctx->port_cb)
934 sm->ctx->port_cb(sm->ctx->ctx, 1);
938 static void eapol_sm_set_port_unauthorized(struct eapol_sm *sm)
942 cb = sm->suppPortStatus != Unauthorized || sm->force_authorized_update;
943 sm->force_authorized_update = FALSE;
944 sm->suppPortStatus = Unauthorized;
945 if (cb && sm->ctx->port_cb)
946 sm->ctx->port_cb(sm->ctx->ctx, 0);
952 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
958 void eapol_sm_step(struct eapol_sm *sm)
967 sm->changed = FALSE;
972 if (sm->use_eap_proxy) {
974 if (eap_proxy_sm_step(sm->eap_proxy, sm->eap))
975 sm->changed = TRUE;
978 if (eap_peer_sm_step(sm->eap))
979 sm->changed = TRUE;
980 if (!sm->changed)
984 if (sm->changed) {
987 eloop_cancel_timeout(eapol_sm_step_timeout, NULL, sm);
988 eloop_register_timeout(0, 0, eapol_sm_step_timeout, NULL, sm);
991 if (sm->ctx->cb && sm->cb_status != EAPOL_CB_IN_PROGRESS) {
993 if (sm->cb_status == EAPOL_CB_SUCCESS)
995 else if (eap_peer_was_failure_expected(sm->eap))
999 sm->cb_status = EAPOL_CB_IN_PROGRESS;
1000 sm->ctx->cb(sm, result, sm->ctx->cb_ctx);
1083 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1092 void eapol_sm_configure(struct eapol_sm *sm, int heldPeriod, int authPeriod,
1095 if (sm == NULL)
1098 sm->heldPeriod = heldPeriod;
1100 sm->authPeriod = authPeriod;
1102 sm->startPeriod = startPeriod;
1104 sm->maxStart = maxStart;
1110 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1113 const char * eapol_sm_get_method_name(struct eapol_sm *sm)
1115 if (sm->SUPP_PAE_state != SUPP_PAE_AUTHENTICATED ||
1116 sm->suppPortStatus != Authorized)
1119 return eap_sm_get_method_name(sm->eap);
1126 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1137 int eapol_sm_get_status(struct eapol_sm *sm, char *buf, size_t buflen,
1141 if (sm == NULL)
1147 eapol_supp_pae_state(sm->SUPP_PAE_state),
1148 eapol_port_status(sm->suppPortStatus));
1160 sm->heldPeriod,
1161 sm->authPeriod,
1162 sm->startPeriod,
1163 sm->maxStart,
1164 eapol_port_control(sm->portControl),
1165 eapol_supp_be_state(sm->SUPP_BE_state));
1172 if (sm->use_eap_proxy)
1173 len += eap_proxy_sm_get_status(sm->eap_proxy,
1178 len += eap_sm_get_status(sm->eap, buf + len, buflen - len, verbose);
1186 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1196 int eapol_sm_get_mib(struct eapol_sm *sm, char *buf, size_t buflen)
1201 if (sm == NULL)
1211 sm->SUPP_PAE_state,
1212 sm->heldPeriod,
1213 sm->authPeriod,
1214 sm->startPeriod,
1215 sm->maxStart,
1216 sm->suppPortStatus == Authorized ?
1218 sm->SUPP_BE_state);
1236 sm->dot1xSuppEapolFramesRx,
1237 sm->dot1xSuppEapolFramesTx,
1238 sm->dot1xSuppEapolStartFramesTx,
1239 sm->dot1xSuppEapolLogoffFramesTx,
1240 sm->dot1xSuppEapolRespFramesTx,
1241 sm->dot1xSuppEapolReqIdFramesRx,
1242 sm->dot1xSuppEapolReqFramesRx,
1243 sm->dot1xSuppInvalidEapolFramesRx,
1244 sm->dot1xSuppEapLengthErrorFramesRx,
1245 sm->dot1xSuppLastEapolFrameVersion,
1246 MAC2STR(sm->dot1xSuppLastEapolFrameSource));
1259 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1266 int eapol_sm_rx_eapol(struct eapol_sm *sm, const u8 *src, const u8 *buf,
1275 if (sm == NULL)
1277 sm->dot1xSuppEapolFramesRx++;
1279 sm->dot1xSuppInvalidEapolFramesRx++;
1283 sm->dot1xSuppLastEapolFrameVersion = hdr->version;
1284 os_memcpy(sm->dot1xSuppLastEapolFrameSource, src, ETH_ALEN);
1290 sm->dot1xSuppEapLengthErrorFramesRx++;
1294 if (sm->conf.wps && sm->conf.workaround &&
1322 if (sm->conf.workaround) {
1340 if (sm->cached_pmk) {
1345 eapol_sm_abort_cached(sm);
1347 wpabuf_free(sm->eapReqData);
1348 sm->eapReqData = wpabuf_alloc_copy(hdr + 1, plen);
1349 if (sm->eapReqData) {
1352 sm->eapolEap = TRUE;
1354 if (sm->use_eap_proxy) {
1356 sm->eap_proxy,
1357 wpabuf_mhead_u8(sm->eapReqData),
1358 wpabuf_len(sm->eapReqData));
1363 eapol_sm_step(sm);
1386 os_free(sm->last_rx_key);
1387 sm->last_rx_key = os_malloc(data_len);
1388 if (sm->last_rx_key) {
1391 os_memcpy(sm->last_rx_key, buf, data_len);
1392 sm->last_rx_key_len = data_len;
1393 sm->rxKey = TRUE;
1394 eapol_sm_step(sm);
1407 sm->dot1xSuppInvalidEapolFramesRx++;
1417 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1422 void eapol_sm_notify_tx_eapol_key(struct eapol_sm *sm)
1424 if (sm)
1425 sm->dot1xSuppEapolFramesTx++;
1431 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1436 void eapol_sm_notify_portEnabled(struct eapol_sm *sm, Boolean enabled)
1438 if (sm == NULL)
1442 if (sm->portEnabled != enabled)
1443 sm->force_authorized_update = TRUE;
1444 sm->portEnabled = enabled;
1445 eapol_sm_step(sm);
1451 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1456 void eapol_sm_notify_portValid(struct eapol_sm *sm, Boolean valid)
1458 if (sm == NULL)
1462 sm->portValid = valid;
1463 eapol_sm_step(sm);
1469 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1478 void eapol_sm_notify_eap_success(struct eapol_sm *sm, Boolean success)
1480 if (sm == NULL)
1484 sm->eapSuccess = success;
1485 sm->altAccept = success;
1487 eap_notify_success(sm->eap);
1488 eapol_sm_step(sm);
1494 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1500 void eapol_sm_notify_eap_fail(struct eapol_sm *sm, Boolean fail)
1502 if (sm == NULL)
1506 sm->eapFail = fail;
1507 sm->altReject = fail;
1508 eapol_sm_step(sm);
1514 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1524 void eapol_sm_notify_config(struct eapol_sm *sm,
1528 if (sm == NULL)
1531 sm->config = config;
1533 sm->use_eap_proxy = eap_proxy_notify_config(sm->eap_proxy, config) > 0;
1539 sm->conf.accept_802_1x_keys = conf->accept_802_1x_keys;
1540 sm->conf.required_keys = conf->required_keys;
1541 sm->conf.fast_reauth = conf->fast_reauth;
1542 sm->conf.workaround = conf->workaround;
1543 sm->conf.wps = conf->wps;
1545 if (sm->use_eap_proxy) {
1550 if (sm->eap) {
1551 eap_set_fast_reauth(sm->eap, conf->fast_reauth);
1552 eap_set_workaround(sm->eap, conf->workaround);
1553 eap_set_force_disabled(sm->eap, conf->eap_disabled);
1554 eap_set_external_sim(sm->eap, conf->external_sim);
1561 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1570 int eapol_sm_get_key(struct eapol_sm *sm, u8 *key, size_t len)
1576 if (sm && sm->use_eap_proxy) {
1578 if (sm == NULL || !eap_proxy_key_available(sm->eap_proxy)) {
1582 eap_key = eap_proxy_get_eapKeyData(sm->eap_proxy, &eap_len);
1591 if (sm == NULL || !eap_key_available(sm->eap)) {
1595 eap_key = eap_get_eapKeyData(sm->eap, &eap_len);
1618 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1624 const u8 * eapol_sm_get_session_id(struct eapol_sm *sm, size_t *len)
1626 if (sm == NULL || !eap_key_available(sm->eap)) {
1630 return eap_get_eapSessionId(sm->eap, len);
1636 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1641 void eapol_sm_notify_logoff(struct eapol_sm *sm, Boolean logoff)
1643 if (sm) {
1644 sm->userLogoff = logoff;
1647 sm->startWhen = 0;
1649 eapol_sm_step(sm);
1656 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1661 void eapol_sm_notify_cached(struct eapol_sm *sm)
1663 if (sm == NULL)
1666 sm->eapSuccess = TRUE;
1667 eap_notify_success(sm->eap);
1668 eapol_sm_step(sm);
1674 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1678 void eapol_sm_notify_pmkid_attempt(struct eapol_sm *sm)
1680 if (sm == NULL)
1683 sm->cached_pmk = TRUE;
1687 static void eapol_sm_abort_cached(struct eapol_sm *sm)
1691 if (sm == NULL)
1693 sm->cached_pmk = FALSE;
1694 sm->SUPP_PAE_state = SUPP_PAE_CONNECTING;
1695 eapol_sm_set_port_unauthorized(sm);
1699 sm->startWhen = 3;
1700 eapol_enable_timer_tick(sm);
1702 if (sm->ctx->aborted_cached)
1703 sm->ctx->aborted_cached(sm->ctx->ctx);
1709 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1715 void eapol_sm_register_scard_ctx(struct eapol_sm *sm, void *ctx)
1717 if (sm) {
1718 sm->ctx->scard_ctx = ctx;
1719 eap_register_scard_ctx(sm->eap, ctx);
1726 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1731 void eapol_sm_notify_portControl(struct eapol_sm *sm, PortControl portControl)
1733 if (sm == NULL)
1737 sm->portControl = portControl;
1738 eapol_sm_step(sm);
1744 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1749 void eapol_sm_notify_ctrl_attached(struct eapol_sm *sm)
1751 if (sm == NULL)
1753 eap_sm_notify_ctrl_attached(sm->eap);
1759 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1764 void eapol_sm_notify_ctrl_response(struct eapol_sm *sm)
1766 if (sm == NULL)
1768 if (sm->eapReqData && !sm->eapReq) {
1772 sm->eapolEap = TRUE;
1773 sm->eapReq = TRUE;
1774 eapol_sm_step(sm);
1781 * @sm
1786 void eapol_sm_request_reauth(struct eapol_sm *sm)
1788 if (sm == NULL || sm->SUPP_PAE_state != SUPP_PAE_AUTHENTICATED)
1790 eapol_sm_txStart(sm);
1796 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1804 void eapol_sm_notify_lower_layer_success(struct eapol_sm *sm, int in_eapol_sm)
1806 if (sm == NULL)
1808 eap_notify_lower_layer_success(sm->eap);
1810 eapol_sm_step(sm);
1816 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1818 void eapol_sm_invalidate_cached_session(struct eapol_sm *sm)
1820 if (sm)
1821 eap_invalidate_cached_session(sm->eap);
1827 struct eapol_sm *sm = ctx;
1828 return sm ? sm->config : NULL;
1834 struct eapol_sm *sm = ctx;
1835 if (sm == NULL || sm->eapReqData == NULL)
1838 return sm->eapReqData;
1844 struct eapol_sm *sm = ctx;
1845 if (sm == NULL)
1849 return sm->eapSuccess;
1851 return sm->eapRestart;
1853 return sm->eapFail;
1855 return sm->eapResp;
1857 return sm->eapNoResp;
1859 return sm->eapReq;
1861 return sm->portEnabled;
1863 return sm->altAccept;
1865 return sm->altReject;
1867 return sm->eapTriggerStart;
1876 struct eapol_sm *sm = ctx;
1877 if (sm == NULL)
1881 sm->eapSuccess = value;
1884 sm->eapRestart = value;
1887 sm->eapFail = value;
1890 sm->eapResp = value;
1893 sm->eapNoResp = value;
1896 sm->eapReq = value;
1899 sm->portEnabled = value;
1902 sm->altAccept = value;
1905 sm->altReject = value;
1908 sm->eapTriggerStart = value;
1916 struct eapol_sm *sm = ctx;
1917 if (sm == NULL)
1921 return sm->idleWhile;
1930 struct eapol_sm *sm = ctx;
1931 if (sm == NULL)
1935 sm->idleWhile = value;
1936 if (sm->idleWhile > 0)
1937 eapol_enable_timer_tick(sm);
1946 struct eapol_sm *sm = ctx;
1947 if (sm && sm->ctx && sm->ctx->set_config_blob)
1948 sm->ctx->set_config_blob(sm->ctx->ctx, blob);
1957 struct eapol_sm *sm = ctx;
1958 if (sm && sm->ctx && sm->ctx->get_config_blob)
1959 return sm->ctx->get_config_blob(sm->ctx->ctx, name);
1970 struct eapol_sm *sm = ctx;
1971 if (sm == NULL)
1973 if (sm->eapReqData && !sm->eapReq) {
1976 sm->eapolEap = TRUE;
1977 sm->eapReq = TRUE;
1978 eapol_sm_step(sm);
1987 struct eapol_sm *sm = ctx;
1989 if (sm->ctx->eap_param_needed)
1990 sm->ctx->eap_param_needed(sm->ctx->ctx, field, txt);
2001 struct eapol_sm *sm = ctx;
2002 if (sm->ctx->cert_cb)
2003 sm->ctx->cert_cb(sm->ctx->ctx, depth, subject, altsubject,
2011 struct eapol_sm *sm = ctx;
2013 if (sm->ctx->status_cb)
2014 sm->ctx->status_cb(sm->ctx->ctx, status, parameter);
2019 struct eapol_sm *sm = ctx;
2021 if (sm->ctx->eap_error_cb)
2022 sm->ctx->eap_error_cb(sm->ctx->ctx, error_code);
2029 struct eapol_sm *sm = ctx;
2031 if (sm->ctx->eap_proxy_cb)
2032 sm->ctx->eap_proxy_cb(sm->ctx->ctx);
2040 struct eapol_sm *sm = ctx;
2042 if (sm->ctx->eap_proxy_notify_sim_status)
2043 sm->ctx->eap_proxy_notify_sim_status(sm->ctx->ctx, sim_state);
2051 struct eapol_sm *sm = ctx;
2053 if (sm->ctx->set_anon_id)
2054 sm->ctx->set_anon_id(sm->ctx->ctx, id, len);
2092 struct eapol_sm *sm;
2094 sm = os_zalloc(sizeof(*sm));
2095 if (sm == NULL)
2097 sm->ctx = ctx;
2099 sm->portControl = Auto;
2102 sm->heldPeriod = 60;
2103 sm->startPeriod = 30;
2104 sm->maxStart = 3;
2107 sm->authPeriod = 30;
2117 sm->eap = eap_peer_sm_init(sm, &eapol_cb, sm->ctx->msg_ctx, &conf);
2118 if (sm->eap == NULL) {
2119 os_free(sm);
2124 sm->use_eap_proxy = FALSE;
2125 sm->eap_proxy = eap_proxy_init(sm, &eapol_cb, sm->ctx->msg_ctx);
2126 if (sm->eap_proxy == NULL) {
2132 sm->force_authorized_update = TRUE;
2133 sm->initialize = TRUE;
2134 eapol_sm_step(sm);
2135 sm->initialize = FALSE;
2136 eapol_sm_step(sm);
2138 sm->timer_tick_enabled = 1;
2139 eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm);
2141 return sm;
2147 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
2151 void eapol_sm_deinit(struct eapol_sm *sm)
2153 if (sm == NULL)
2155 eloop_cancel_timeout(eapol_sm_step_timeout, NULL, sm);
2156 eloop_cancel_timeout(eapol_port_timers_tick, NULL, sm);
2157 eap_peer_sm_deinit(sm->eap);
2159 eap_proxy_deinit(sm->eap_proxy);
2161 os_free(sm->last_rx_key);
2162 wpabuf_free(sm->eapReqData);
2163 os_free(sm->ctx);
2164 os_free(sm);
2168 void eapol_sm_set_ext_pw_ctx(struct eapol_sm *sm,
2171 if (sm && sm->eap)
2172 eap_sm_set_ext_pw_ctx(sm->eap, ext);
2176 int eapol_sm_failed(struct eapol_sm *sm)
2178 if (sm == NULL)
2180 return !sm->eapSuccess && sm->eapFail;
2187 struct eapol_sm *sm = ctx;
2189 if (sm->eap_proxy == NULL)
2191 return eap_proxy_get_imsi(sm->eap_proxy, sim_num, imsi, len);
2196 void eapol_sm_erp_flush(struct eapol_sm *sm)
2198 if (sm)
2199 eap_peer_erp_free_keys(sm->eap);
2203 struct wpabuf * eapol_sm_build_erp_reauth_start(struct eapol_sm *sm)
2206 if (!sm)
2208 return eap_peer_build_erp_reauth_start(sm->eap, 0);
2215 void eapol_sm_process_erp_finish(struct eapol_sm *sm, const u8 *buf,
2219 if (!sm)
2221 eap_peer_finish(sm->eap, (const struct eap_hdr *) buf, len);
2226 int eapol_sm_update_erp_next_seq_num(struct eapol_sm *sm, u16 next_seq_num)
2229 if (!sm)
2231 return eap_peer_update_erp_next_seq_num(sm->eap, next_seq_num);
2238 int eapol_sm_get_erp_info(struct eapol_sm *sm, struct eap_peer_config *config,
2245 if (!sm)
2247 return eap_peer_get_erp_info(sm->eap, config, username, username_len,