Home | History | Annotate | Download | only in wpa_supplicant

Lines Matching defs:sm

188 static void eapol_sm_txLogoff(struct eapol_sm *sm);
189 static void eapol_sm_txStart(struct eapol_sm *sm);
190 static void eapol_sm_processKey(struct eapol_sm *sm);
191 static void eapol_sm_getSuppRsp(struct eapol_sm *sm);
192 static void eapol_sm_txSuppRsp(struct eapol_sm *sm);
193 static void eapol_sm_abortSupp(struct eapol_sm *sm);
194 static void eapol_sm_abort_cached(struct eapol_sm *sm);
202 struct eapol_sm *sm = timeout_ctx;
204 if (sm->authWhile > 0) {
205 sm->authWhile--;
206 if (sm->authWhile == 0)
209 if (sm->heldWhile > 0) {
210 sm->heldWhile--;
211 if (sm->heldWhile == 0)
214 if (sm->startWhen > 0) {
215 sm->startWhen--;
216 if (sm->startWhen == 0)
219 if (sm->idleWhile > 0) {
220 sm->idleWhile--;
221 if (sm->idleWhile == 0)
225 eloop_register_timeout(1, 0, eapol_port_timers_tick, eloop_ctx, sm);
226 eapol_sm_step(sm);
233 eapol_sm_txLogoff(sm);
234 sm->logoffSent = TRUE;
235 sm->suppPortStatus = Unauthorized;
242 sm->sPortMode = Auto;
243 sm->startCount = 0;
244 sm->logoffSent = FALSE;
245 sm->suppPortStatus = Unauthorized;
246 sm->suppAbort = TRUE;
248 sm->unicast_key_received = FALSE;
249 sm->broadcast_key_received = FALSE;
255 int send_start = sm->SUPP_PAE_state == SUPP_PAE_CONNECTING;
258 sm->startWhen = sm->startPeriod;
259 sm->startCount++;
268 sm->startWhen = 3;
270 sm->eapolEap = FALSE;
272 eapol_sm_txStart(sm);
279 sm->startCount = 0;
280 sm->suppSuccess = FALSE;
281 sm->suppFail = FALSE;
282 sm->suppTimeout = FALSE;
283 sm->keyRun = FALSE;
284 sm->keyDone = FALSE;
285 sm->suppStart = TRUE;
292 sm->heldWhile = sm->heldPeriod;
293 sm->suppPortStatus = Unauthorized;
294 sm->cb_status = EAPOL_CB_FAILURE;
301 sm->suppPortStatus = Authorized;
302 sm->cb_status = EAPOL_CB_SUCCESS;
309 sm->eapRestart = TRUE;
316 sm->suppPortStatus = Authorized;
317 sm->sPortMode = ForceAuthorized;
324 sm->suppPortStatus = Unauthorized;
325 sm->sPortMode = ForceUnauthorized;
326 eapol_sm_txLogoff(sm);
332 if ((sm->userLogoff && !sm->logoffSent) &&
333 !(sm->initialize || !sm->portEnabled))
335 else if (((sm->portControl == Auto) &&
336 (sm->sPortMode != sm->portControl)) ||
337 sm->initialize || !sm->portEnabled)
339 else if ((sm->portControl == ForceAuthorized) &&
340 (sm->sPortMode != sm->portControl) &&
341 !(sm->initialize || !sm->portEnabled))
343 else if ((sm->portControl == ForceUnauthorized) &&
344 (sm->sPortMode != sm->portControl) &&
345 !(sm->initialize || !sm->portEnabled))
347 else switch (sm->SUPP_PAE_state) {
351 if (!sm->userLogoff)
358 if (sm->startWhen == 0 && sm->startCount < sm->maxStart)
360 else if (sm->startWhen == 0 &&
361 sm->startCount >= sm->maxStart &&
362 sm->portValid)
364 else if (sm->eapSuccess || sm->eapFail)
366 else if (sm->eapolEap)
368 else if (sm->startWhen == 0 &&
369 sm->startCount >= sm->maxStart &&
370 !sm->portValid)
374 if (sm->eapSuccess && !sm->portValid &&
375 sm->conf.accept_802_1x_keys &&
376 sm->conf.required_keys == 0) {
380 sm->portValid = TRUE;
381 if (sm->ctx->eapol_done_cb)
382 sm->ctx->eapol_done_cb(sm->ctx->ctx);
384 if (sm->eapSuccess && sm->portValid)
386 else if (sm->eapFail || (sm->keyDone && !sm->portValid))
388 else if (sm->suppTimeout)
392 if (sm->heldWhile == 0)
394 else if (sm->eapolEap)
398 if (sm->eapolEap && sm->portValid)
400 else if (!sm->portValid)
404 if (!sm->eapRestart)
424 eapol_sm_processKey(sm);
425 sm->rxKey = FALSE;
431 if (sm->initialize || !sm->portEnabled)
433 switch (sm->KEY_RX_state) {
437 if (sm->rxKey)
441 if (sm->rxKey)
451 sm->authWhile = 0;
452 sm->eapReq = TRUE;
453 eapol_sm_getSuppRsp(sm);
460 eapol_sm_txSuppRsp(sm);
461 sm->eapResp = FALSE;
468 sm->keyRun = TRUE;
469 sm->suppSuccess = TRUE;
471 if (eap_key_available(sm->eap)) {
474 sm->replay_counter_valid = FALSE;
482 sm->suppFail = TRUE;
489 sm->suppTimeout = TRUE;
496 sm->suppStart = FALSE;
497 sm->initial_req = TRUE;
504 eapol_sm_abortSupp(sm);
505 sm->suppAbort = FALSE;
512 sm->authWhile = sm->authPeriod;
513 sm->eapolEap = FALSE;
514 sm->eapNoResp = FALSE;
515 sm->initial_req = FALSE;
521 if (sm->initialize || sm->suppAbort)
523 else switch (sm->SUPP_BE_state) {
541 if (sm->eapResp && sm->eapNoResp) {
545 if (sm->eapResp)
547 else if (sm->eapNoResp)
549 else if (sm->eapFail)
551 else if (sm->eapSuccess)
567 if (sm->eapFail && sm->suppStart)
569 else if (sm->eapolEap && sm->suppStart)
571 else if (sm->eapSuccess && sm->suppStart)
578 if (sm->eapolEap)
580 else if (sm->eapFail)
582 else if (sm->authWhile == 0)
584 else if (sm->eapSuccess)
591 static void eapol_sm_txLogoff(struct eapol_sm *sm)
594 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
596 sm->dot1xSuppEapolLogoffFramesTx++;
597 sm->dot1xSuppEapolFramesTx++;
601 static void eapol_sm_txStart(struct eapol_sm *sm)
604 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
606 sm->dot1xSuppEapolStartFramesTx++;
607 sm->dot1xSuppEapolFramesTx++;
620 static void eapol_sm_processKey(struct eapol_sm *sm)
631 if (sm->last_rx_key == NULL)
634 if (!sm->conf.accept_802_1x_keys) {
641 hdr = (struct ieee802_1x_hdr *) sm->last_rx_key;
643 if (sizeof(*hdr) + be_to_host16(hdr->length) > sm->last_rx_key_len) {
653 eapol_sm_notify_lower_layer_success(sm);
656 res = eapol_sm_get_key(sm, (u8 *) &keydata, sizeof(keydata));
664 res = eapol_sm_get_key(sm, (u8 *) &keydata, 16);
680 if (sm->replay_counter_valid &&
681 os_memcmp(sm->last_replay_counter, key->replay_counter,
686 sm->last_replay_counter,
697 sm->last_rx_key, sizeof(*hdr) + be_to_host16(hdr->length),
745 sm->replay_counter_valid = TRUE;
746 os_memcpy(sm->last_replay_counter, key->replay_counter,
755 if (sm->ctx->set_wep_key &&
756 sm->ctx->set_wep_key(sm->ctx->ctx,
764 sm->unicast_key_received = TRUE;
766 sm->broadcast_key_received = TRUE;
768 if ((sm->unicast_key_received ||
769 !(sm->conf.required_keys & EAPOL_REQUIRE_KEY_UNICAST)) &&
770 (sm->broadcast_key_received ||
771 !(sm->conf.required_keys & EAPOL_REQUIRE_KEY_BROADCAST)))
775 sm->portValid = TRUE;
776 if (sm->ctx->eapol_done_cb)
777 sm->ctx->eapol_done_cb(sm->ctx->ctx);
783 static void eapol_sm_getSuppRsp(struct eapol_sm *sm)
793 static void eapol_sm_txSuppRsp(struct eapol_sm *sm)
799 resp = eap_get_eapRespData(sm->eap, &resp_len);
807 sm->ctx->eapol_send(sm->ctx->eapol_send_ctx,
813 if (sm->initial_req)
814 sm->dot1xSuppEapolReqIdFramesRx++;
816 sm->dot1xSuppEapolReqFramesRx++;
817 sm->dot1xSuppEapolRespFramesTx++;
818 sm->dot1xSuppEapolFramesTx++;
822 static void eapol_sm_abortSupp(struct eapol_sm *sm)
826 os_free(sm->last_rx_key);
827 sm->last_rx_key = NULL;
828 os_free(sm->eapReqData);
829 sm->eapReqData = NULL;
830 eap_sm_abort(sm->eap);
842 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
848 void eapol_sm_step(struct eapol_sm *sm)
857 sm->changed = FALSE;
861 if (eap_sm_step(sm->eap))
862 sm->changed = TRUE;
863 if (!sm->changed)
867 if (sm->changed) {
870 eloop_cancel_timeout(eapol_sm_step_timeout, NULL, sm);
871 eloop_register_timeout(0, 0, eapol_sm_step_timeout, NULL, sm);
874 if (sm->ctx->cb && sm->cb_status != EAPOL_CB_IN_PROGRESS) {
875 int success = sm->cb_status == EAPOL_CB_SUCCESS ? 1 : 0;
876 sm->cb_status = EAPOL_CB_IN_PROGRESS;
877 sm->ctx->cb(sm, success, sm->ctx->cb_ctx);
960 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
969 void eapol_sm_configure(struct eapol_sm *sm, int heldPeriod, int authPeriod,
972 if (sm == NULL)
975 sm->heldPeriod = heldPeriod;
977 sm->authPeriod = authPeriod;
979 sm->startPeriod = startPeriod;
981 sm->maxStart = maxStart;
988 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
999 int eapol_sm_get_status(struct eapol_sm *sm, char *buf, size_t buflen,
1003 if (sm == NULL)
1009 eapol_supp_pae_state(sm->SUPP_PAE_state),
1010 eapol_port_status(sm->suppPortStatus));
1022 sm->heldPeriod,
1023 sm->authPeriod,
1024 sm->startPeriod,
1025 sm->maxStart,
1026 eapol_port_control(sm->portControl),
1027 eapol_supp_be_state(sm->SUPP_BE_state));
1033 len += eap_sm_get_status(sm->eap, buf + len, buflen - len, verbose);
1041 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1051 int eapol_sm_get_mib(struct eapol_sm *sm, char *buf, size_t buflen)
1056 if (sm == NULL)
1066 sm->SUPP_PAE_state,
1067 sm->heldPeriod,
1068 sm->authPeriod,
1069 sm->startPeriod,
1070 sm->maxStart,
1071 sm->suppPortStatus == Authorized ?
1073 sm->SUPP_BE_state);
1091 sm->dot1xSuppEapolFramesRx,
1092 sm->dot1xSuppEapolFramesTx,
1093 sm->dot1xSuppEapolStartFramesTx,
1094 sm->dot1xSuppEapolLogoffFramesTx,
1095 sm->dot1xSuppEapolRespFramesTx,
1096 sm->dot1xSuppEapolReqIdFramesRx,
1097 sm->dot1xSuppEapolReqFramesRx,
1098 sm->dot1xSuppInvalidEapolFramesRx,
1099 sm->dot1xSuppEapLengthErrorFramesRx,
1100 sm->dot1xSuppLastEapolFrameVersion,
1101 MAC2STR(sm->dot1xSuppLastEapolFrameSource));
1114 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1121 int eapol_sm_rx_eapol(struct eapol_sm *sm, const u8 *src, const u8 *buf,
1130 if (sm == NULL)
1132 sm->dot1xSuppEapolFramesRx++;
1134 sm->dot1xSuppInvalidEapolFramesRx++;
1138 sm->dot1xSuppLastEapolFrameVersion = hdr->version;
1139 os_memcpy(sm->dot1xSuppLastEapolFrameSource, src, ETH_ALEN);
1145 sm->dot1xSuppEapLengthErrorFramesRx++;
1152 if (sm->cached_pmk) {
1157 eapol_sm_abort_cached(sm);
1159 os_free(sm->eapReqData);
1160 sm->eapReqDataLen = plen;
1161 sm->eapReqData = os_malloc(sm->eapReqDataLen);
1162 if (sm->eapReqData) {
1165 os_memcpy(sm->eapReqData, (u8 *) (hdr + 1),
1166 sm->eapReqDataLen);
1167 sm->eapolEap = TRUE;
1168 eapol_sm_step(sm);
1191 os_free(sm->last_rx_key);
1192 sm->last_rx_key = os_malloc(data_len);
1193 if (sm->last_rx_key) {
1196 os_memcpy(sm->last_rx_key, buf, data_len);
1197 sm->last_rx_key_len = data_len;
1198 sm->rxKey = TRUE;
1199 eapol_sm_step(sm);
1205 sm->dot1xSuppInvalidEapolFramesRx++;
1215 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1220 void eapol_sm_notify_tx_eapol_key(struct eapol_sm *sm)
1222 if (sm)
1223 sm->dot1xSuppEapolFramesTx++;
1229 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1234 void eapol_sm_notify_portEnabled(struct eapol_sm *sm, Boolean enabled)
1236 if (sm == NULL)
1240 sm->portEnabled = enabled;
1241 eapol_sm_step(sm);
1247 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1252 void eapol_sm_notify_portValid(struct eapol_sm *sm, Boolean valid)
1254 if (sm == NULL)
1258 sm->portValid = valid;
1259 eapol_sm_step(sm);
1265 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1274 void eapol_sm_notify_eap_success(struct eapol_sm *sm, Boolean success)
1276 if (sm == NULL)
1280 sm->eapSuccess = success;
1281 sm->altAccept = success;
1283 eap_notify_success(sm->eap);
1284 eapol_sm_step(sm);
1290 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1296 void eapol_sm_notify_eap_fail(struct eapol_sm *sm, Boolean fail)
1298 if (sm == NULL)
1302 sm->eapFail = fail;
1303 sm->altReject = fail;
1304 eapol_sm_step(sm);
1310 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1320 void eapol_sm_notify_config(struct eapol_sm *sm, struct wpa_ssid *config,
1323 if (sm == NULL)
1326 sm->config = config;
1331 sm->conf.accept_802_1x_keys = conf->accept_802_1x_keys;
1332 sm->conf.required_keys = conf->required_keys;
1333 sm->conf.fast_reauth = conf->fast_reauth;
1334 if (sm->eap) {
1335 eap_set_fast_reauth(sm->eap, conf->fast_reauth);
1336 eap_set_workaround(sm->eap, conf->workaround);
1337 eap_set_force_disabled(sm->eap, conf->eap_disabled);
1344 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1353 int eapol_sm_get_key(struct eapol_sm *sm, u8 *key, size_t len)
1358 if (sm == NULL || !eap_key_available(sm->eap))
1360 eap_key = eap_get_eapKeyData(sm->eap, &eap_len);
1372 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1377 void eapol_sm_notify_logoff(struct eapol_sm *sm, Boolean logoff)
1379 if (sm) {
1380 sm->userLogoff = logoff;
1381 eapol_sm_step(sm);
1388 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1393 void eapol_sm_notify_cached(struct eapol_sm *sm)
1395 if (sm == NULL)
1397 sm->SUPP_PAE_state = SUPP_PAE_AUTHENTICATED;
1398 sm->suppPortStatus = Authorized;
1399 eap_notify_success(sm->eap);
1405 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1410 void eapol_sm_notify_pmkid_attempt(struct eapol_sm *sm, int attempt)
1412 if (sm == NULL)
1416 sm->cached_pmk = TRUE;
1419 sm->cached_pmk = FALSE;
1424 static void eapol_sm_abort_cached(struct eapol_sm *sm)
1428 if (sm == NULL)
1430 sm->cached_pmk = FALSE;
1431 sm->SUPP_PAE_state = SUPP_PAE_CONNECTING;
1432 sm->suppPortStatus = Unauthorized;
1436 sm->startWhen = 3;
1438 if (sm->ctx->aborted_cached)
1439 sm->ctx->aborted_cached(sm->ctx->ctx);
1445 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1451 void eapol_sm_register_scard_ctx(struct eapol_sm *sm, void *ctx)
1453 if (sm) {
1454 sm->ctx->scard_ctx = ctx;
1455 eap_register_scard_ctx(sm->eap, ctx);
1462 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1467 void eapol_sm_notify_portControl(struct eapol_sm *sm, PortControl portControl)
1469 if (sm == NULL)
1473 sm->portControl = portControl;
1474 eapol_sm_step(sm);
1480 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1485 void eapol_sm_notify_ctrl_attached(struct eapol_sm *sm)
1487 if (sm == NULL)
1489 eap_sm_notify_ctrl_attached(sm->eap);
1495 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1500 void eapol_sm_notify_ctrl_response(struct eapol_sm *sm)
1502 if (sm == NULL)
1504 if (sm->eapReqData && !sm->eapReq) {
1508 sm->eapolEap = TRUE;
1509 sm->eapReq = TRUE;
1510 eapol_sm_step(sm);
1517 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1522 void eapol_sm_request_reauth(struct eapol_sm *sm)
1524 if (sm == NULL || sm->SUPP_PAE_state != SUPP_PAE_AUTHENTICATED)
1526 eapol_sm_txStart(sm);
1532 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1538 void eapol_sm_notify_lower_layer_success(struct eapol_sm *sm)
1540 if (sm == NULL)
1542 eap_notify_lower_layer_success(sm->eap);
1548 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1550 void eapol_sm_invalidate_cached_session(struct eapol_sm *sm)
1552 if (sm)
1553 eap_invalidate_cached_session(sm->eap);
1559 struct eapol_sm *sm = ctx;
1560 return sm ? sm->config : NULL;
1566 struct eapol_sm *sm = ctx;
1567 if (sm == NULL || sm->eapReqData == NULL) {
1572 *len = sm->eapReqDataLen;
1573 return sm->eapReqData;
1579 struct eapol_sm *sm = ctx;
1580 if (sm == NULL)
1584 return sm->eapSuccess;
1586 return sm->eapRestart;
1588 return sm->eapFail;
1590 return sm->eapResp;
1592 return sm->eapNoResp;
1594 return sm->eapReq;
1596 return sm->portEnabled;
1598 return sm->altAccept;
1600 return sm->altReject;
1609 struct eapol_sm *sm = ctx;
1610 if (sm == NULL)
1614 sm->eapSuccess = value;
1617 sm->eapRestart = value;
1620 sm->eapFail = value;
1623 sm->eapResp = value;
1626 sm->eapNoResp = value;
1629 sm->eapReq = value;
1632 sm->portEnabled = value;
1635 sm->altAccept = value;
1638 sm->altReject = value;
1646 struct eapol_sm *sm = ctx;
1647 if (sm == NULL)
1651 return sm->idleWhile;
1660 struct eapol_sm *sm = ctx;
1661 if (sm == NULL)
1665 sm->idleWhile = value;
1673 struct eapol_sm *sm = ctx;
1674 if (sm && sm->ctx && sm->ctx->set_config_blob)
1675 sm->ctx->set_config_blob(sm->ctx->ctx, blob);
1682 struct eapol_sm *sm = ctx;
1683 if (sm && sm->ctx && sm->ctx->get_config_blob)
1684 return sm->ctx->get_config_blob(sm->ctx->ctx, name);
1692 struct eapol_sm *sm = ctx;
1693 if (sm == NULL)
1695 if (sm->eapReqData && !sm->eapReq) {
1698 sm->eapolEap = TRUE;
1699 sm->eapReq = TRUE;
1700 eapol_sm_step(sm);
1729 struct eapol_sm *sm;
1731 sm = os_zalloc(sizeof(*sm));
1732 if (sm == NULL)
1734 sm->ctx = ctx;
1736 sm->portControl = Auto;
1739 sm->heldPeriod = 60;
1740 sm->startPeriod = 30;
1741 sm->maxStart = 3;
1744 sm->authPeriod = 30;
1751 sm->eap = eap_sm_init(sm, &eapol_cb, sm->ctx->msg_ctx, &conf);
1752 if (sm->eap == NULL) {
1753 os_free(sm);
1758 sm->initialize = TRUE;
1759 eapol_sm_step(sm);
1760 sm->initialize = FALSE;
1761 eapol_sm_step(sm);
1763 eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm);
1765 return sm;
1771 * @sm: Pointer to EAPOL state machine allocated with eapol_sm_init()
1775 void eapol_sm_deinit(struct eapol_sm *sm)
1777 if (sm == NULL)
1779 eloop_cancel_timeout(eapol_sm_step_timeout, NULL, sm);
1780 eloop_cancel_timeout(eapol_port_timers_tick, NULL, sm);
1781 eap_sm_deinit(sm->eap);
1782 os_free(sm->last_rx_key);
1783 os_free(sm->eapReqData);
1784 os_free(sm->ctx);
1785 os_free(sm);