/* big enough to have even a single attribute */
if (attrlen < 5) {
- ERROR("eap: EAP-Sim attribute too short: %d < 5", attrlen);
+ fr_strerror_printf("EAP-Sim attribute too short: %d < 5", attrlen);
return 0;
}
newvp = fr_pair_afrom_num(r, PW_EAP_SIM_SUBTYPE, 0);
if (!newvp) {
+ fr_strerror_printf("Failed creating EAP-SIM-Subtype");
return 0;
}
uint8_t *p;
if(attrlen < 2) {
- ERROR("eap: EAP-Sim attribute %d too short: %d < 2", es_attribute_count, attrlen);
+ fr_strerror_printf("EAP-Sim attribute %d too short: %d < 2", es_attribute_count, attrlen);
return 0;
}
eapsim_len = attr[1] * 4;
if (eapsim_len > attrlen) {
- ERROR("eap: EAP-Sim attribute %d (no.%d) has length longer than data (%d > %d)",
- eapsim_attribute, es_attribute_count, eapsim_len, attrlen);
-
+ fr_strerror_printf("EAP-Sim attribute %d (no.%d) has length longer than data (%d > %d)",
+ eapsim_attribute, es_attribute_count, eapsim_len, attrlen);
return 0;
}
eapsim_len = MAX_STRING_LEN;
}
if (eapsim_len < 2) {
- ERROR("eap: EAP-Sim attribute %d (no.%d) has length too small", eapsim_attribute,
- es_attribute_count);
- return 0;
+ fr_strerror_printf("EAP-Sim attribute %d (no.%d) has length too small", eapsim_attribute,
+ es_attribute_count);
+ return 0;
}
newvp = fr_pair_afrom_num(r, eapsim_attribute+PW_EAP_SIM_BASE, 0);
attrlen -= eapsim_len;
es_attribute_count++;
}
+
return 1;
}
/*
* build a reply to be sent.
*/
-static int eap_sim_compose(eap_handler_t *handler)
+static void eap_sim_compose(REQUEST *request, eap_handler_t *handler)
{
/* we will set the ID on requests, since we have to HMAC it */
handler->eap_ds->set_request_id = 1;
- return map_eapsim_basictypes(handler->request->reply,
- handler->eap_ds->request);
+ if (!map_eapsim_basictypes(handler->request->reply,
+ handler->eap_ds->request)) {
+ REDEBUG("Failed decoding EAP-SIM packet: %s", fr_strerror());
+ }
}
static int eap_sim_sendstart(eap_handler_t *handler)
/** Run the server state machine
*
*/
-static void eap_sim_stateenter(eap_handler_t *handler,
- eap_sim_state_t *ess,
- enum eapsim_serverstates newstate)
+static void eap_sim_state_enter(REQUEST *request, eap_handler_t *handler,
+ eap_sim_state_t *ess,
+ enum eapsim_serverstates newstate)
{
switch (newstate) {
/*
ess->state = newstate;
/* build the target packet */
- eap_sim_compose(handler);
+ eap_sim_compose(request, handler);
}
/*
if (!eap_sim_get_challenge(handler, request->config, 0, ess) ||
!eap_sim_get_challenge(handler, request->config, 1, ess) ||
!eap_sim_get_challenge(handler, request->config, 2, ess)) {
- return 0;
+ return 0; /* already printed error */
}
/*
time(&n);
ess->sim_id = (n & 0xff);
- eap_sim_stateenter(handler, ess, EAPSIM_SERVER_START);
+ eap_sim_state_enter(request, handler, ess, EAPSIM_SERVER_START);
return 1;
}
selectedversion_vp = fr_pair_find_by_num(vps, PW_EAP_SIM_SELECTED_VERSION, 0, TAG_ANY);
if (!nonce_vp || !selectedversion_vp) {
RDEBUG2("Client did not select a version and send a NONCE");
- eap_sim_stateenter(handler, ess, EAPSIM_SERVER_START);
-
+ eap_sim_state_enter(request, handler, ess, EAPSIM_SERVER_START);
return 1;
}
*/
if (selectedversion_vp->vp_length < 2) {
REDEBUG("EAP-SIM version field is too short");
-
return 0;
}
memcpy(&simversion, selectedversion_vp->vp_strvalue, sizeof(simversion));
/*
* Everything looks good, change states
*/
- eap_sim_stateenter(handler, ess, EAPSIM_SERVER_CHALLENGE);
+ eap_sim_state_enter(request, handler, ess, EAPSIM_SERVER_CHALLENGE);
return 1;
}
}
/* everything looks good, change states */
- eap_sim_stateenter(handler, ess, EAPSIM_SERVER_SUCCESS);
+ eap_sim_state_enter(request, handler, ess, EAPSIM_SERVER_SUCCESS);
return 1;
}
handler->eap_ds->response->type.data,
handler->eap_ds->response->type.length);
- if (!success) return 0;
+ if (!success) {
+ REDEBUG("Failed decoding EAP-SIM packet: %s", fr_strerror());
+ return 0;
+ }
/*
* See what kind of message we have gotten
*/
default:
- eap_sim_stateenter(handler, ess, EAPSIM_SERVER_START);
+ eap_sim_state_enter(request, handler, ess, EAPSIM_SERVER_START);
return 1;
/*
* A response to our EAP-Sim/Request/Start!
* Pretty much anything else here is illegal, so we will retransmit the request.
*/
default:
- eap_sim_stateenter(handler, ess, EAPSIM_SERVER_CHALLENGE);
+ eap_sim_state_enter(request, handler, ess, EAPSIM_SERVER_CHALLENGE);
return 1;
/*
* A response to our EAP-Sim/Request/Challenge!