int eap_example_peer_step(void) { int res; res = eap_peer_sm_step(eap_ctx.eap); if (eap_ctx.eapResp) { struct wpabuf *resp; printf("==> Response\n"); eap_ctx.eapResp = FALSE; resp = eap_get_eapRespData(eap_ctx.eap); if (resp) { /* Send EAP response to the server */ eap_example_server_rx(wpabuf_head(resp), wpabuf_len(resp)); wpabuf_free(resp); } } if (eap_ctx.eapSuccess) { res = 0; if (eap_key_available(eap_ctx.eap)) { const u8 *key; size_t key_len; key = eap_get_eapKeyData(eap_ctx.eap, &key_len); wpa_hexdump(MSG_DEBUG, "EAP keying material", key, key_len); } } return res; }
static void eapol_sm_txSuppRsp(struct eapol_sm *sm) { struct wpabuf *resp; wpa_printf(MSG_DEBUG, "EAPOL: txSuppRsp"); resp = eap_get_eapRespData(sm->eap); if (resp == NULL) { wpa_printf(MSG_WARNING, "EAPOL: txSuppRsp - EAP response data " "not available"); return; } /* Send EAP-Packet from the EAP layer to the Authenticator */ sm->ctx->eapol_send(sm->ctx->eapol_send_ctx, IEEE802_1X_TYPE_EAP_PACKET, wpabuf_head(resp), wpabuf_len(resp)); /* eapRespData is not used anymore, so free it here */ wpabuf_free(resp); if (sm->initial_req) sm->dot1xSuppEapolReqIdFramesRx++; else sm->dot1xSuppEapolReqFramesRx++; sm->dot1xSuppEapolRespFramesTx++; sm->dot1xSuppEapolFramesTx++; }
int eap_peer_step(void) { unsigned char data[0x4000]; int res; res = eap_peer_sm_step(eap_ctx.eap); /* This part was not tested properly */ if( !eap_ctx.eapSuccess && !eap_ctx.eapRestart && !eap_ctx.eapFail && !eap_ctx.eapResp && !eap_ctx.eapNoResp && !eap_ctx.eapReq ) { struct wpabuf *resp; resp = eap_sm_buildIdentity( eap_ctx.eap, 0, 0 ); if (resp) { // Send EAP response to the server memcpy(data,wpabuf_head(resp),wpabuf_len(resp)); // memcpy Maybe useless!!!! eap_server_rx(data, wpabuf_len(resp)); wpabuf_free(resp); } } if (eap_ctx.eapResp) { struct wpabuf *resp; eap_ctx.eapResp = FALSE; resp = eap_get_eapRespData(eap_ctx.eap); if (resp) { /* Send EAP response to the server */ memcpy(data,wpabuf_head(resp),wpabuf_len(resp)); // memcpy Maybe useless!!!! eap_server_rx(data, wpabuf_len(resp)); //eap_server_rx(wpabuf_head(resp), // wpabuf_len(resp)); wpabuf_free(resp); } } if (eap_ctx.eapSuccess) { res = 0; if (eap_key_available(eap_ctx.eap)) { const u8 *key; size_t key_len; key = eap_get_eapKeyData(eap_ctx.eap, &key_len); memcpy(data,key,key_len); eap_key(data, key_len); wpa_hexdump(MSG_DEBUG, "EAP keying material", key, key_len); } } if (eap_ctx.eapFail) { res = -1; } return res; }