int unmap_eapsim_types(RADIUS_PACKET *r) { VALUE_PAIR *esvp; esvp = pairfind(r->vps, ATTRIBUTE_EAP_BASE+PW_EAP_SIM); if (esvp == NULL) { radlog(L_ERR, "eap: EAP-Sim attribute not found"); return 0; } return unmap_eapsim_basictypes(r, esvp->strvalue, esvp->length); }
static int unmap_eapsim_types(RADIUS_PACKET *r) { VALUE_PAIR *esvp; esvp = pairfind(r->vps, ATTRIBUTE_EAP_BASE+PW_EAP_SIM, 0, TAG_ANY); if (!esvp) { ERROR("eap: EAP-Sim attribute not found"); return 0; } return unmap_eapsim_basictypes(r, esvp->vp_octets, esvp->length); }
static int unmap_eapsim_types(RADIUS_PACKET *r) { VALUE_PAIR *esvp; uint8_t *eap_data; int rcode_unmap; esvp = pairfind(r->vps, ATTRIBUTE_EAP_BASE+PW_EAP_SIM, 0, TAG_ANY); if (!esvp) { ERROR("eap: EAP-Sim attribute not found"); return 0; } eap_data = talloc_memdup(esvp, esvp->vp_octets, esvp->length); talloc_set_type(eap_data, uint8_t); rcode_unmap = unmap_eapsim_basictypes(r, eap_data, esvp->length); talloc_free(eap_data); return rcode_unmap; }
/** Authenticate a previously sent challenge * */ static int mod_authenticate(UNUSED void *arg, eap_handler_t *handler) { REQUEST *request = handler->request; eap_sim_state_t *ess = handler->opaque; VALUE_PAIR *vp, *vps; enum eapsim_subtype subtype; int success; /* * VPS is the data from the client */ vps = handler->request->packet->vps; success = unmap_eapsim_basictypes(handler->request->packet, handler->eap_ds->response->type.data, handler->eap_ds->response->type.length); if (!success) return 0; /* * See what kind of message we have gotten */ vp = pairfind(vps, PW_EAP_SIM_SUBTYPE, 0, TAG_ANY); if (!vp) { REDEBUG2("No subtype attribute was created, message dropped"); return 0; } subtype = vp->vp_integer; /* * Client error supersedes anything else. */ if (subtype == EAPSIM_CLIENT_ERROR) { return 0; } switch (ess->state) { case EAPSIM_SERVER_START: switch (subtype) { /* * Pretty much anything else here is illegal, so we will retransmit the request. */ default: eap_sim_stateenter(handler, ess, EAPSIM_SERVER_START); return 1; /* * A response to our EAP-Sim/Request/Start! */ case EAPSIM_START: return process_eap_sim_start(handler, vps); } break; case EAPSIM_SERVER_CHALLENGE: switch(subtype) { /* * Pretty much anything else here is illegal, so we will retransmit the request. */ default: eap_sim_stateenter(handler, ess, EAPSIM_SERVER_CHALLENGE); return 1; /* * A response to our EAP-Sim/Request/Challenge! */ case EAPSIM_CHALLENGE: return process_eap_sim_challenge(handler, vps); } break; default: rad_assert(0 == 1); } return 0; }
/* * Authenticate a previously sent challenge. */ static int eap_sim_authenticate(void *arg, EAP_HANDLER *handler) { struct eap_sim_server_state *ess; VALUE_PAIR *vp, *vps; enum eapsim_subtype subtype; int success; arg = arg; /* shut up compiler */ ess = (struct eap_sim_server_state *)handler->opaque; /* vps is the data from the client */ vps = handler->request->packet->vps; success= unmap_eapsim_basictypes(handler->request->packet, handler->eap_ds->response->type.data, handler->eap_ds->response->type.length); if(!success) { return 0; } /* see what kind of message we have gotten */ if((vp = pairfind(vps, ATTRIBUTE_EAP_SIM_SUBTYPE, 0, TAG_ANY)) == NULL) { DEBUG2(" no subtype attribute was created, message dropped"); return 0; } subtype = vp->vp_integer; /* * Client error supersedes anything else. */ if (subtype == eapsim_client_error) { return 0; } switch(ess->state) { case eapsim_server_start: switch(subtype) { default: /* * pretty much anything else here is illegal, * so we will retransmit the request. */ eap_sim_stateenter(handler, ess, eapsim_server_start); return 1; case eapsim_start: /* * a response to our EAP-Sim/Request/Start! * */ return process_eap_sim_start(handler, vps); } break; case eapsim_server_challenge: switch(subtype) { default: /* * pretty much anything else here is illegal, * so we will retransmit the request. */ eap_sim_stateenter(handler, ess, eapsim_server_challenge); return 1; case eapsim_challenge: /* * a response to our EAP-Sim/Request/Challenge! * */ return process_eap_sim_challenge(handler, vps); } break; default: /* if we get into some other state, die, as this * is a coding error! */ DEBUG2(" illegal-unknown state reached in eap_sim_authenticate\n"); rad_assert(0 == 1); } return 0; }