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 eloop_ctx, sm) < 0)
194 sm->timer_tick_enabled = 0;
197 sm->timer_tick_enabled = 0;
199 eapol_sm_step(sm);
203 static void eapol_enable_timer_tick(struct eapol_sm *sm)
205 if (sm->timer_tick_enabled)
208 eloop_cancel_timeout(eapol_port_timers_tick, NULL, sm);
209 if (eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm) == 0)
210 sm->timer_tick_enabled = 1;
217 eapol_sm_txLogoff(sm);
218 sm->logoffSent = TRUE;
219 eapol_sm_set_port_unauthorized(sm);
226 sm->sPortMode = Auto;
227 sm->startCount = 0;
228 sm->eapTriggerStart = FALSE;
229 sm->logoffSent = FALSE;
230 eapol_sm_set_port_unauthorized(sm);
231 sm->suppAbort = TRUE;
233 sm->unicast_key_received = FALSE;
234 sm->broadcast_key_received = FALSE;
243 sm->heldWhile = 0;
249 int send_start = sm->SUPP_PAE_state == SUPP_PAE_CONNECTING ||
250 sm->SUPP_PAE_state == SUPP_PAE_HELD;
253 if (sm->eapTriggerStart)
255 if (sm->ctx->preauth)
257 sm->eapTriggerStart = FALSE;
260 sm->startWhen = sm->startPeriod;
261 sm->startCount++;
270 if (sm->conf.wps && !(sm->conf.wps & EAPOL_PEER_IS_WPS20_AP)) {
274 sm->startWhen = 1;
276 sm->startWhen = 2;
279 eapol_enable_timer_tick(sm);
280 sm->eapolEap = FALSE;
282 eapol_sm_txStart(sm);
289 sm->startCount = 0;
290 sm->suppSuccess = FALSE;
291 sm->suppFail = FALSE;
292 sm->suppTimeout = FALSE;
293 sm->keyRun = FALSE;
294 sm->keyDone = FALSE;
295 sm->suppStart = TRUE;
302 sm->heldWhile = sm->heldPeriod;
303 eapol_enable_timer_tick(sm);
304 eapol_sm_set_port_unauthorized(sm);
305 sm->cb_status = EAPOL_CB_FAILURE;
312 eapol_sm_set_port_authorized(sm);
313 sm->cb_status = EAPOL_CB_SUCCESS;
320 sm->eapRestart = TRUE;
321 if (sm->altAccept) {
328 sm->eapSuccess = FALSE;
329 sm->altAccept = FALSE;
337 eapol_sm_set_port_authorized(sm);
338 sm->sPortMode = ForceAuthorized;
345 eapol_sm_set_port_unauthorized(sm);
346 sm->sPortMode = ForceUnauthorized;
347 eapol_sm_txLogoff(sm);
353 if ((sm->userLogoff && !sm->logoffSent) &&
354 !(sm->initialize || !sm->portEnabled))
356 else if (((sm->portControl == Auto) &&
357 (sm->sPortMode != sm->portControl)) ||
358 sm->initialize || !sm->portEnabled)
360 else if ((sm->portControl == ForceAuthorized) &&
361 (sm->sPortMode != sm->portControl) &&
362 !(sm->initialize || !sm->portEnabled))
364 else if ((sm->portControl == ForceUnauthorized) &&
365 (sm->sPortMode != sm->portControl) &&
366 !(sm->initialize || !sm->portEnabled))
368 else switch (sm->SUPP_PAE_state) {
372 if (!sm->userLogoff)
379 if (sm->startWhen == 0 && sm->startCount < sm->maxStart)
381 else if (sm->startWhen == 0 &&
382 sm->startCount >= sm->maxStart &&
383 sm->portValid)
385 else if (sm->eapSuccess || sm->eapFail)
387 else if (sm->eapolEap)
389 else if (sm->startWhen == 0 &&
390 sm->startCount >= sm->maxStart &&
391 !sm->portValid)
395 if (sm->eapSuccess && !sm->portValid &&
396 sm->conf.accept_802_1x_keys &&
397 sm->conf.required_keys == 0) {
401 sm->portValid = TRUE;
402 if (sm->ctx->eapol_done_cb)
403 sm->ctx->eapol_done_cb(sm->ctx->ctx);
405 if (sm->eapSuccess && sm->portValid)
407 else if (sm->eapFail || (sm->keyDone && !sm->portValid))
409 else if (sm->suppTimeout)
411 else if (sm->eapTriggerStart)
415 if (sm->heldWhile == 0)
417 else if (sm->eapolEap)
421 if (sm->eapolEap && sm->portValid)
423 else if (!sm->portValid)
427 if (!sm->eapRestart)
447 eapol_sm_processKey(sm);
448 sm->rxKey = FALSE;
454 if (sm->initialize || !sm->portEnabled)
456 switch (sm->KEY_RX_state) {
460 if (sm->rxKey)
464 if (sm->rxKey)
474 sm->authWhile = 0;
475 sm->eapReq = TRUE;
476 eapol_sm_getSuppRsp(sm);
483 eapol_sm_txSuppRsp(sm);
484 sm->eapResp = FALSE;
491 sm->keyRun = TRUE;
492 sm->suppSuccess = TRUE;
495 if (sm->use_eap_proxy) {
496 if (eap_proxy_key_available(sm->eap_proxy)) {
502 sm->replay_counter_valid = FALSE;
505 sm->eap_proxy, &session_id_len);
506 emsk = eap_proxy_get_emsk(sm->eap_proxy, &emsk_len);
507 if (sm->config->erp && session_id && emsk) {
508 eap_peer_erp_init(sm->eap, session_id,
520 if (eap_key_available(sm->eap)) {
523 sm->replay_counter_valid = FALSE;
531 sm->suppFail = TRUE;
538 sm->suppTimeout = TRUE;
545 sm->suppStart = FALSE;
546 sm->initial_req = TRUE;
553 eapol_sm_abortSupp(sm);
554 sm->suppAbort = FALSE;
563 sm->authWhile = 0;
570 sm->authWhile = sm->authPeriod;
571 eapol_enable_timer_tick(sm);
572 sm->eapolEap = FALSE;
573 sm->eapNoResp = FALSE;
574 sm->initial_req = FALSE;
580 if (sm->initialize || sm->suppAbort)
582 else switch (sm->SUPP_BE_state) {
600 if (sm->eapResp && sm->eapNoResp) {
604 if (sm->eapResp)
606 else if (sm->eapNoResp)
608 else if (sm->eapFail)
610 else if (sm->eapSuccess)
626 if (sm->eapFail && sm->suppStart)
628 else if (sm->eapolEap && sm->suppStart)
630 else if (sm->eapSuccess && sm->suppStart)
637 if (sm->eapolEap)
639 else if (sm->eapFail)
641 else if (sm->authWhile == 0)
643 else if (sm->eapSuccess)
650 static void eapol_sm_txLogoff(struct eapol_sm *sm)
653 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
655 sm->dot1xSuppEapolLogoffFramesTx++;
656 sm->dot1xSuppEapolFramesTx++;
660 static void eapol_sm_txStart(struct eapol_sm *sm)
663 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
665 sm->dot1xSuppEapolStartFramesTx++;
666 sm->dot1xSuppEapolFramesTx++;
679 static void eapol_sm_processKey(struct eapol_sm *sm)
694 if (sm->last_rx_key == NULL)
697 if (!sm->conf.accept_802_1x_keys) {
704 if (sm->last_rx_key_len < sizeof(*hdr) + sizeof(*key))
706 hdr = (struct ieee802_1x_hdr *) sm->last_rx_key;
709 if (sizeof(*hdr) + plen > sm->last_rx_key_len || plen < sizeof(*key)) {
719 eapol_sm_notify_lower_layer_success(sm, 1);
722 res = eapol_sm_get_key(sm, (u8 *) &keydata, sizeof(keydata));
730 res = eapol_sm_get_key(sm, (u8 *) &keydata, 16);
746 if (sm->replay_counter_valid &&
747 os_memcmp(sm->last_replay_counter, key->replay_counter,
752 sm->last_replay_counter,
763 sm->last_rx_key, sizeof(*hdr) + be_to_host16(hdr->length),
819 sm->replay_counter_valid = TRUE;
820 os_memcpy(sm->last_replay_counter, key->replay_counter,
829 if (sm->ctx->set_wep_key &&
830 sm->ctx->set_wep_key(sm->ctx->ctx,
838 sm->unicast_key_received = TRUE;
840 sm->broadcast_key_received = TRUE;
842 if ((sm->unicast_key_received ||
843 !(sm->conf.required_keys & EAPOL_REQUIRE_KEY_UNICAST)) &&
844 (sm->broadcast_key_received ||
845 !(sm->conf.required_keys & EAPOL_REQUIRE_KEY_BROADCAST)))
849 sm->portValid = TRUE;
850 if (sm->ctx->eapol_done_cb)
851 sm->ctx->eapol_done_cb(sm->ctx->ctx);
858 static void eapol_sm_getSuppRsp(struct eapol_sm *sm)
868 static void eapol_sm_txSuppRsp(struct eapol_sm *sm)
875 if (sm->use_eap_proxy) {
877 resp = eap_proxy_get_eapRespData(sm->eap_proxy);
886 resp = eap_get_eapRespData(sm->eap);
894 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
901 if (sm->initial_req)
902 sm->dot1xSuppEapolReqIdFramesRx++;
904 sm->dot1xSuppEapolReqFramesRx++;
905 sm->dot1xSuppEapolRespFramesTx++;
906 sm->dot1xSuppEapolFramesTx++;
910 static void eapol_sm_abortSupp(struct eapol_sm *sm)
914 os_free(sm->last_rx_key);
915 sm->last_rx_key = NULL;
916 wpabuf_free(sm->eapReqData);
917 sm->eapReqData = NULL;
918 eap_sm_abort(sm->eap);
920 eap_proxy_sm_abort(sm->eap_proxy);
931 static void eapol_sm_set_port_authorized(struct eapol_sm *sm)
935 cb = sm->suppPortStatus != Authorized || sm->force_authorized_update;
936 sm->force_authorized_update = FALSE;
937 sm->suppPortStatus = Authorized;
938 if (cb && sm->ctx->port_cb)
939 sm->ctx->port_cb(sm->ctx->ctx, 1);
943 static void eapol_sm_set_port_unauthorized(struct eapol_sm *sm)
947 cb = sm->suppPortStatus != Unauthorized || sm->force_authorized_update;
948 sm->force_authorized_update = FALSE;
949 sm->suppPortStatus = Unauthorized;
950 if (cb && sm->ctx->port_cb)
951 sm->ctx->port_cb(sm->ctx->ctx, 0);
957 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
963 void eapol_sm_step(struct eapol_sm *sm)
972 sm->changed = FALSE;
977 if (sm->use_eap_proxy) {
979 if (eap_proxy_sm_step(sm->eap_proxy, sm->eap))
980 sm->changed = TRUE;
983 if (eap_peer_sm_step(sm->eap))
984 sm->changed = TRUE;
985 if (!sm->changed)
989 if (sm->changed) {
992 eloop_cancel_timeout(eapol_sm_step_timeout, NULL, sm);
993 eloop_register_timeout(0, 0, eapol_sm_step_timeout, NULL, sm);
996 if (sm->ctx->cb && sm->cb_status != EAPOL_CB_IN_PROGRESS) {
998 if (sm->cb_status == EAPOL_CB_SUCCESS)
1000 else if (eap_peer_was_failure_expected(sm->eap))
1004 sm->cb_status = EAPOL_CB_IN_PROGRESS;
1005 sm->ctx->cb(sm, result, sm->ctx->cb_ctx);
1088 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1097 void eapol_sm_configure(struct eapol_sm *sm, int heldPeriod, int authPeriod,
1100 if (sm == NULL)
1103 sm->heldPeriod = heldPeriod;
1105 sm->authPeriod = authPeriod;
1107 sm->startPeriod = startPeriod;
1109 sm->maxStart = maxStart;
1115 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1118 const char * eapol_sm_get_method_name(struct eapol_sm *sm)
1120 if (sm->SUPP_PAE_state != SUPP_PAE_AUTHENTICATED ||
1121 sm->suppPortStatus != Authorized)
1124 return eap_sm_get_method_name(sm->eap);
1131 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1142 int eapol_sm_get_status(struct eapol_sm *sm, char *buf, size_t buflen,
1146 if (sm == NULL)
1152 eapol_supp_pae_state(sm->SUPP_PAE_state),
1153 eapol_port_status(sm->suppPortStatus));
1165 sm->heldPeriod,
1166 sm->authPeriod,
1167 sm->startPeriod,
1168 sm->maxStart,
1169 eapol_port_control(sm->portControl),
1170 eapol_supp_be_state(sm->SUPP_BE_state));
1177 if (sm->use_eap_proxy)
1178 len += eap_proxy_sm_get_status(sm->eap_proxy,
1183 len += eap_sm_get_status(sm->eap, buf + len, buflen - len, verbose);
1191 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1201 int eapol_sm_get_mib(struct eapol_sm *sm, char *buf, size_t buflen)
1206 if (sm == NULL)
1216 sm->SUPP_PAE_state,
1217 sm->heldPeriod,
1218 sm->authPeriod,
1219 sm->startPeriod,
1220 sm->maxStart,
1221 sm->suppPortStatus == Authorized ?
1223 sm->SUPP_BE_state);
1241 sm->dot1xSuppEapolFramesRx,
1242 sm->dot1xSuppEapolFramesTx,
1243 sm->dot1xSuppEapolStartFramesTx,
1244 sm->dot1xSuppEapolLogoffFramesTx,
1245 sm->dot1xSuppEapolRespFramesTx,
1246 sm->dot1xSuppEapolReqIdFramesRx,
1247 sm->dot1xSuppEapolReqFramesRx,
1248 sm->dot1xSuppInvalidEapolFramesRx,
1249 sm->dot1xSuppEapLengthErrorFramesRx,
1250 sm->dot1xSuppLastEapolFrameVersion,
1251 MAC2STR(sm->dot1xSuppLastEapolFrameSource));
1264 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1271 int eapol_sm_rx_eapol(struct eapol_sm *sm, const u8 *src, const u8 *buf,
1280 if (sm == NULL)
1282 sm->dot1xSuppEapolFramesRx++;
1284 sm->dot1xSuppInvalidEapolFramesRx++;
1288 sm->dot1xSuppLastEapolFrameVersion = hdr->version;
1289 os_memcpy(sm->dot1xSuppLastEapolFrameSource, src, ETH_ALEN);
1295 sm->dot1xSuppEapLengthErrorFramesRx++;
1299 if (sm->conf.wps && sm->conf.workaround &&
1327 if (sm->conf.workaround) {
1345 if (sm->cached_pmk) {
1350 eapol_sm_abort_cached(sm);
1352 wpabuf_free(sm->eapReqData);
1353 sm->eapReqData = wpabuf_alloc_copy(hdr + 1, plen);
1354 if (sm->eapReqData) {
1357 sm->eapolEap = TRUE;
1359 if (sm->use_eap_proxy) {
1361 sm->eap_proxy,
1362 wpabuf_mhead_u8(sm->eapReqData),
1363 wpabuf_len(sm->eapReqData));
1368 eapol_sm_step(sm);
1391 os_free(sm->last_rx_key);
1392 sm->last_rx_key = os_malloc(data_len);
1393 if (sm->last_rx_key) {
1396 os_memcpy(sm->last_rx_key, buf, data_len);
1397 sm->last_rx_key_len = data_len;
1398 sm->rxKey = TRUE;
1399 eapol_sm_step(sm);
1412 sm->dot1xSuppInvalidEapolFramesRx++;
1422 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1427 void eapol_sm_notify_tx_eapol_key(struct eapol_sm *sm)
1429 if (sm)
1430 sm->dot1xSuppEapolFramesTx++;
1436 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1441 void eapol_sm_notify_portEnabled(struct eapol_sm *sm, Boolean enabled)
1443 if (sm == NULL)
1447 if (sm->portEnabled != enabled)
1448 sm->force_authorized_update = TRUE;
1449 sm->portEnabled = enabled;
1450 eapol_sm_step(sm);
1456 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1461 void eapol_sm_notify_portValid(struct eapol_sm *sm, Boolean valid)
1463 if (sm == NULL)
1467 sm->portValid = valid;
1468 eapol_sm_step(sm);
1474 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1483 void eapol_sm_notify_eap_success(struct eapol_sm *sm, Boolean success)
1485 if (sm == NULL)
1489 sm->eapSuccess = success;
1490 sm->altAccept = success;
1492 eap_notify_success(sm->eap);
1493 eapol_sm_step(sm);
1499 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1505 void eapol_sm_notify_eap_fail(struct eapol_sm *sm, Boolean fail)
1507 if (sm == NULL)
1511 sm->eapFail = fail;
1512 sm->altReject = fail;
1513 eapol_sm_step(sm);
1519 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1529 void eapol_sm_notify_config(struct eapol_sm *sm,
1533 if (sm == NULL)
1536 sm->config = config;
1538 sm->use_eap_proxy = eap_proxy_notify_config(sm->eap_proxy, config) > 0;
1544 sm->conf.accept_802_1x_keys = conf->accept_802_1x_keys;
1545 sm->conf.required_keys = conf->required_keys;
1546 sm->conf.fast_reauth = conf->fast_reauth;
1547 sm->conf.workaround = conf->workaround;
1548 sm->conf.wps = conf->wps;
1550 if (sm->use_eap_proxy) {
1555 if (sm->eap) {
1556 eap_set_fast_reauth(sm->eap, conf->fast_reauth);
1557 eap_set_workaround(sm->eap, conf->workaround);
1558 eap_set_force_disabled(sm->eap, conf->eap_disabled);
1559 eap_set_external_sim(sm->eap, conf->external_sim);
1566 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1575 int eapol_sm_get_key(struct eapol_sm *sm, u8 *key, size_t len)
1581 if (sm && sm->use_eap_proxy) {
1583 if (sm == NULL || !eap_proxy_key_available(sm->eap_proxy)) {
1587 eap_key = eap_proxy_get_eapKeyData(sm->eap_proxy, &eap_len);
1596 if (sm == NULL || !eap_key_available(sm->eap)) {
1600 eap_key = eap_get_eapKeyData(sm->eap, &eap_len);
1623 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1629 const u8 * eapol_sm_get_session_id(struct eapol_sm *sm, size_t *len)
1631 if (sm == NULL || !eap_key_available(sm->eap)) {
1635 return eap_get_eapSessionId(sm->eap, len);
1641 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1646 void eapol_sm_notify_logoff(struct eapol_sm *sm, Boolean logoff)
1648 if (sm) {
1649 sm->userLogoff = logoff;
1652 sm->startWhen = 0;
1654 eapol_sm_step(sm);
1661 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1666 void eapol_sm_notify_cached(struct eapol_sm *sm)
1668 if (sm == NULL)
1671 sm->eapSuccess = TRUE;
1672 eap_notify_success(sm->eap);
1673 eapol_sm_step(sm);
1679 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1683 void eapol_sm_notify_pmkid_attempt(struct eapol_sm *sm)
1685 if (sm == NULL)
1688 sm->cached_pmk = TRUE;
1692 static void eapol_sm_abort_cached(struct eapol_sm *sm)
1696 if (sm == NULL)
1698 sm->cached_pmk = FALSE;
1699 sm->SUPP_PAE_state = SUPP_PAE_CONNECTING;
1700 eapol_sm_set_port_unauthorized(sm);
1704 sm->startWhen = 3;
1705 eapol_enable_timer_tick(sm);
1707 if (sm->ctx->aborted_cached)
1708 sm->ctx->aborted_cached(sm->ctx->ctx);
1714 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1720 void eapol_sm_register_scard_ctx(struct eapol_sm *sm, void *ctx)
1722 if (sm) {
1723 sm->ctx->scard_ctx = ctx;
1724 eap_register_scard_ctx(sm->eap, ctx);
1731 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1736 void eapol_sm_notify_portControl(struct eapol_sm *sm, PortControl portControl)
1738 if (sm == NULL)
1742 sm->portControl = portControl;
1743 eapol_sm_step(sm);
1749 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1754 void eapol_sm_notify_ctrl_attached(struct eapol_sm *sm)
1756 if (sm == NULL)
1758 eap_sm_notify_ctrl_attached(sm->eap);
1764 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1769 void eapol_sm_notify_ctrl_response(struct eapol_sm *sm)
1771 if (sm == NULL)
1773 if (sm->eapReqData && !sm->eapReq) {
1777 sm->eapolEap = TRUE;
1778 sm->eapReq = TRUE;
1779 eapol_sm_step(sm);
1786 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1791 void eapol_sm_request_reauth(struct eapol_sm *sm)
1793 if (sm == NULL || sm->SUPP_PAE_state != SUPP_PAE_AUTHENTICATED)
1795 eapol_sm_txStart(sm);
1801 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1809 void eapol_sm_notify_lower_layer_success(struct eapol_sm *sm, int in_eapol_sm)
1811 if (sm == NULL)
1813 eap_notify_lower_layer_success(sm->eap);
1815 eapol_sm_step(sm);
1821 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1823 void eapol_sm_invalidate_cached_session(struct eapol_sm *sm)
1825 if (sm)
1826 eap_invalidate_cached_session(sm->eap);
1832 struct eapol_sm *sm = ctx;
1833 return sm ? sm->config : NULL;
1839 struct eapol_sm *sm = ctx;
1840 if (sm == NULL || sm->eapReqData == NULL)
1843 return sm->eapReqData;
1849 struct eapol_sm *sm = ctx;
1850 if (sm == NULL)
1854 return sm->eapSuccess;
1856 return sm->eapRestart;
1858 return sm->eapFail;
1860 return sm->eapResp;
1862 return sm->eapNoResp;
1864 return sm->eapReq;
1866 return sm->portEnabled;
1868 return sm->altAccept;
1870 return sm->altReject;
1872 return sm->eapTriggerStart;
1881 struct eapol_sm *sm = ctx;
1882 if (sm == NULL)
1886 sm->eapSuccess = value;
1889 sm->eapRestart = value;
1892 sm->eapFail = value;
1895 sm->eapResp = value;
1898 sm->eapNoResp = value;
1901 sm->eapReq = value;
1904 sm->portEnabled = value;
1907 sm->altAccept = value;
1910 sm->altReject = value;
1913 sm->eapTriggerStart = value;
1921 struct eapol_sm *sm = ctx;
1922 if (sm == NULL)
1926 return sm->idleWhile;
1935 struct eapol_sm *sm = ctx;
1936 if (sm == NULL)
1940 sm->idleWhile = value;
1941 if (sm->idleWhile > 0)
1942 eapol_enable_timer_tick(sm);
1951 struct eapol_sm *sm = ctx;
1952 if (sm && sm->ctx && sm->ctx->set_config_blob)
1953 sm->ctx->set_config_blob(sm->ctx->ctx, blob);
1962 struct eapol_sm *sm = ctx;
1963 if (sm && sm->ctx && sm->ctx->get_config_blob)
1964 return sm->ctx->get_config_blob(sm->ctx->ctx, name);
1975 struct eapol_sm *sm = ctx;
1976 if (sm == NULL)
1978 if (sm->eapReqData && !sm->eapReq) {
1981 sm->eapolEap = TRUE;
1982 sm->eapReq = TRUE;
1983 eapol_sm_step(sm);
1992 struct eapol_sm *sm = ctx;
1994 if (sm->ctx->eap_param_needed)
1995 sm->ctx->eap_param_needed(sm->ctx->ctx, field, txt);
2006 struct eapol_sm *sm = ctx;
2007 if (sm->ctx->cert_cb)
2008 sm->ctx->cert_cb(sm->ctx->ctx, depth, subject, altsubject,
2016 struct eapol_sm *sm = ctx;
2018 if (sm->ctx->status_cb)
2019 sm->ctx->status_cb(sm->ctx->ctx, status, parameter);
2025 struct eapol_sm *sm = ctx;
2027 if (sm->ctx->eap_error_cb)
2028 sm->ctx->eap_error_cb(sm->ctx->ctx, error_code);
2036 struct eapol_sm *sm = ctx;
2038 if (sm->ctx->eap_proxy_cb)
2039 sm->ctx->eap_proxy_cb(sm->ctx->ctx);
2047 struct eapol_sm *sm = ctx;
2049 if (sm->ctx->eap_proxy_notify_sim_status)
2050 sm->ctx->eap_proxy_notify_sim_status(sm->ctx->ctx, sim_state);
2058 struct eapol_sm *sm = ctx;
2060 if (sm->ctx->set_anon_id)
2061 sm->ctx->set_anon_id(sm->ctx->ctx, id, len);
2099 struct eapol_sm *sm;
2101 sm = os_zalloc(sizeof(*sm));
2102 if (sm == NULL)
2104 sm->ctx = ctx;
2106 sm->portControl = Auto;
2109 sm->heldPeriod = 60;
2110 sm->startPeriod = 30;
2111 sm->maxStart = 3;
2114 sm->authPeriod = 30;
2124 sm->eap = eap_peer_sm_init(sm, &eapol_cb, sm->ctx->msg_ctx, &conf);
2125 if (sm->eap == NULL) {
2126 os_free(sm);
2131 sm->use_eap_proxy = FALSE;
2132 sm->eap_proxy = eap_proxy_init(sm, &eapol_cb, sm->ctx->msg_ctx);
2133 if (sm->eap_proxy == NULL) {
2139 sm->force_authorized_update = TRUE;
2140 sm->initialize = TRUE;
2141 eapol_sm_step(sm);
2142 sm->initialize = FALSE;
2143 eapol_sm_step(sm);
2145 if (eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm) == 0)
2146 sm->timer_tick_enabled = 1;
2148 return sm;
2154 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
2158 void eapol_sm_deinit(struct eapol_sm *sm)
2160 if (sm == NULL)
2162 eloop_cancel_timeout(eapol_sm_step_timeout, NULL, sm);
2163 eloop_cancel_timeout(eapol_port_timers_tick, NULL, sm);
2164 eap_peer_sm_deinit(sm->eap);
2166 eap_proxy_deinit(sm->eap_proxy);
2168 os_free(sm->last_rx_key);
2169 wpabuf_free(sm->eapReqData);
2170 os_free(sm->ctx);
2171 os_free(sm);
2175 void eapol_sm_set_ext_pw_ctx(struct eapol_sm *sm,
2178 if (sm && sm->eap)
2179 eap_sm_set_ext_pw_ctx(sm->eap, ext);
2183 int eapol_sm_failed(struct eapol_sm *sm)
2185 if (sm == NULL)
2187 return !sm->eapSuccess && sm->eapFail;
2194 struct eapol_sm *sm = ctx;
2196 if (sm->eap_proxy == NULL)
2198 return eap_proxy_get_imsi(sm->eap_proxy, sim_num, imsi, len);
2203 void eapol_sm_erp_flush(struct eapol_sm *sm)
2205 if (sm)
2206 eap_peer_erp_free_keys(sm->eap);
2210 struct wpabuf * eapol_sm_build_erp_reauth_start(struct eapol_sm *sm)
2213 if (!sm)
2215 return eap_peer_build_erp_reauth_start(sm->eap, 0);
2222 void eapol_sm_process_erp_finish(struct eapol_sm *sm, const u8 *buf,
2226 if (!sm)
2228 eap_peer_finish(sm->eap, (const struct eap_hdr *) buf, len);
2233 int eapol_sm_update_erp_next_seq_num(struct eapol_sm *sm, u16 next_seq_num)
2236 if (!sm)
2238 return eap_peer_update_erp_next_seq_num(sm->eap, next_seq_num);
2245 int eapol_sm_get_erp_info(struct eapol_sm *sm, struct eap_peer_config *config,
2252 if (!sm)
2254 return eap_peer_get_erp_info(sm->eap, config, username, username_len,