/* Process the RADIUS frames from Authentication Server */ static RadiusRxResult ieee802_1x_receive_auth(struct wpa_supplicant *wpa_s, struct radius_msg *msg, struct radius_msg *req, u8 *shared_secret, size_t shared_secret_len, void *data) { /* RFC 2869, Ch. 5.13: valid Message-Authenticator attribute MUST be * present when packet contains an EAP-Message attribute */ if (msg->hdr->code == RADIUS_CODE_ACCESS_REJECT && radius_msg_get_attr(msg, RADIUS_ATTR_MESSAGE_AUTHENTICATOR, NULL, 0) < 0 && radius_msg_get_attr(msg, RADIUS_ATTR_EAP_MESSAGE, NULL, 0) < 0) { wpa_printf(MSG_DEBUG, "Allowing RADIUS " "Access-Reject without Message-Authenticator " "since it does not include EAP-Message\n"); } else if (radius_msg_verify(msg, shared_secret, shared_secret_len, req)) { printf("Incoming RADIUS packet did not have correct " "Message-Authenticator - dropped\n"); return RADIUS_RX_UNKNOWN; } if (msg->hdr->code != RADIUS_CODE_ACCESS_ACCEPT && msg->hdr->code != RADIUS_CODE_ACCESS_REJECT && msg->hdr->code != RADIUS_CODE_ACCESS_CHALLENGE) { printf("Unknown RADIUS message code\n"); return RADIUS_RX_UNKNOWN; } wpa_s->radius_identifier = -1; wpa_printf(MSG_DEBUG, "RADIUS packet matching with station"); if (wpa_s->last_recv_radius) { radius_msg_free(wpa_s->last_recv_radius); free(wpa_s->last_recv_radius); } wpa_s->last_recv_radius = msg; switch (msg->hdr->code) { case RADIUS_CODE_ACCESS_ACCEPT: wpa_s->radius_access_accept_received = 1; ieee802_1x_get_keys(wpa_s, msg, req, shared_secret, shared_secret_len); break; case RADIUS_CODE_ACCESS_REJECT: wpa_s->radius_access_reject_received = 1; break; } ieee802_1x_decapsulate_radius(wpa_s); if ((msg->hdr->code == RADIUS_CODE_ACCESS_ACCEPT && eapol_test_num_reauths < 0) || msg->hdr->code == RADIUS_CODE_ACCESS_REJECT) { eloop_terminate(); } return RADIUS_RX_QUEUED; }
/* Process the RADIUS frames from Authentication Server */ static RadiusRxResult ieee802_1x_receive_auth(struct wpa_supplicant *wpa_s, struct radius_msg *msg, struct radius_msg *req, u8 *shared_secret, size_t shared_secret_len, void *data) { #if 0 u32 session_timeout, termination_action; int session_timeout_set; int acct_interim_interval; #endif #if 0 sta = ap_get_sta_radius_identifier(hapd, msg->hdr->identifier); if (sta == NULL) { wpa_printf(MSG_DEBUG, "IEEE 802.1X: Could not " "find matching station for this RADIUS " "message\n"); return RADIUS_RX_UNKNOWN; } #endif /* RFC 2869, Ch. 5.13: valid Message-Authenticator attribute MUST be * present when packet contains an EAP-Message attribute */ if (msg->hdr->code == RADIUS_CODE_ACCESS_REJECT && radius_msg_get_attr(msg, RADIUS_ATTR_MESSAGE_AUTHENTICATOR, NULL, 0) < 0 && radius_msg_get_attr(msg, RADIUS_ATTR_EAP_MESSAGE, NULL, 0) < 0) { wpa_printf(MSG_DEBUG, "Allowing RADIUS " "Access-Reject without Message-Authenticator " "since it does not include EAP-Message\n"); } else if (radius_msg_verify(msg, shared_secret, shared_secret_len, req)) { printf("Incoming RADIUS packet did not have correct " "Message-Authenticator - dropped\n"); return RADIUS_RX_UNKNOWN; } if (msg->hdr->code != RADIUS_CODE_ACCESS_ACCEPT && msg->hdr->code != RADIUS_CODE_ACCESS_REJECT && msg->hdr->code != RADIUS_CODE_ACCESS_CHALLENGE) { printf("Unknown RADIUS message code\n"); return RADIUS_RX_UNKNOWN; } wpa_s->radius_identifier = -1; wpa_printf(MSG_DEBUG, "RADIUS packet matching with station"); if (wpa_s->last_recv_radius) { radius_msg_free(wpa_s->last_recv_radius); free(wpa_s->last_recv_radius); } wpa_s->last_recv_radius = msg; #if 0 session_timeout_set = !radius_msg_get_attr_int32(msg, RADIUS_ATTR_SESSION_TIMEOUT, &session_timeout); if (radius_msg_get_attr_int32(msg, RADIUS_ATTR_TERMINATION_ACTION, &termination_action)) termination_action = RADIUS_TERMINATION_ACTION_DEFAULT; if (hapd->conf->radius_acct_interim_interval == 0 && msg->hdr->code == RADIUS_CODE_ACCESS_ACCEPT && radius_msg_get_attr_int32(msg, RADIUS_ATTR_ACCT_INTERIM_INTERVAL, &acct_interim_interval) == 0) { if (acct_interim_interval < 60) { hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X, HOSTAPD_LEVEL_INFO, "ignored too small " "Acct-Interim-Interval %d", acct_interim_interval); } else sta->acct_interim_interval = acct_interim_interval; } switch (msg->hdr->code) { case RADIUS_CODE_ACCESS_ACCEPT: /* draft-congdon-radius-8021x-22.txt, Ch. 3.17 */ if (session_timeout_set && termination_action == RADIUS_TERMINATION_ACTION_RADIUS_REQUEST) { sta->eapol_sm->reauth_timer.reAuthPeriod = session_timeout; } else if (session_timeout_set) ap_sta_session_timeout(hapd, sta, session_timeout); sta->eapol_sm->be_auth.aSuccess = TRUE; ieee802_1x_get_keys(hapd, sta, msg, req, shared_secret, shared_secret_len); if (sta->eapol_sm->keyAvailable) { pmksa_cache_add(hapd, sta, sta->eapol_key_crypt, session_timeout_set ? session_timeout : -1); } break; case RADIUS_CODE_ACCESS_REJECT: sta->eapol_sm->be_auth.aFail = TRUE; break; case RADIUS_CODE_ACCESS_CHALLENGE: if (session_timeout_set) { /* RFC 2869, Ch. 2.3.2 * draft-congdon-radius-8021x-22.txt, Ch. 3.17 */ sta->eapol_sm->be_auth.suppTimeout = session_timeout; } sta->eapol_sm->be_auth.aReq = TRUE; break; } #else switch (msg->hdr->code) { case RADIUS_CODE_ACCESS_ACCEPT: wpa_s->radius_access_accept_received = 1; ieee802_1x_get_keys(wpa_s, msg, req, shared_secret, shared_secret_len); break; case RADIUS_CODE_ACCESS_REJECT: wpa_s->radius_access_reject_received = 1; break; } #endif ieee802_1x_decapsulate_radius(wpa_s); /* eapol_sm_step(sta->eapol_sm); */ if (msg->hdr->code == RADIUS_CODE_ACCESS_ACCEPT || msg->hdr->code == RADIUS_CODE_ACCESS_REJECT) { eloop_terminate(); } return RADIUS_RX_QUEUED; }