* packet that it is sent in response
* to.
*/
- case FR_EAP_SUCCESS:
- case FR_EAP_FAILURE:
+ case FR_EAP_CODE_SUCCESS:
+ case FR_EAP_CODE_FAILURE:
break;
/*
* that the TTLS and PEAP modules can call it to do most
* of their dirty work.
*/
- if (((eap_round->request->code == FR_EAP_REQUEST) ||
- (eap_round->request->code == FR_EAP_RESPONSE)) &&
+ if (((eap_round->request->code == FR_EAP_CODE_REQUEST) ||
+ (eap_round->request->code == FR_EAP_CODE_RESPONSE)) &&
(eap_round->request->type.num == 0)) {
rad_assert(eap_session->type >= FR_EAP_MD5);
rad_assert(eap_session->type < FR_EAP_MAX_TYPES);
/* Set request reply code, but only if it's not already set. */
rcode = RLM_MODULE_OK;
if (!request->reply->code) switch (reply->code) {
- case FR_EAP_RESPONSE:
+ case FR_EAP_CODE_RESPONSE:
request->reply->code = FR_CODE_ACCESS_ACCEPT;
rcode = RLM_MODULE_HANDLED; /* leap weirdness */
break;
- case FR_EAP_SUCCESS:
+ case FR_EAP_CODE_SUCCESS:
request->reply->code = FR_CODE_ACCESS_ACCEPT;
rcode = RLM_MODULE_OK;
break;
- case FR_EAP_FAILURE:
+ case FR_EAP_CODE_FAILURE:
request->reply->code = FR_CODE_ACCESS_REJECT;
rcode = RLM_MODULE_REJECT;
break;
- case FR_EAP_REQUEST:
+ case FR_EAP_CODE_REQUEST:
request->reply->code = FR_CODE_ACCESS_CHALLENGE;
rcode = RLM_MODULE_HANDLED;
break;
/* Should never enter here */
REDEBUG("Reply code %d is unknown, rejecting the request", reply->code);
request->reply->code = FR_CODE_ACCESS_REJECT;
- reply->code = FR_EAP_FAILURE;
+ reply->code = FR_EAP_CODE_FAILURE;
rcode = RLM_MODULE_REJECT;
break;
}
* Manually create an EAP Identity request
*/
p = talloc_array(vp, uint8_t, 5);
- p[0] = FR_EAP_REQUEST;
+ p[0] = FR_EAP_CODE_REQUEST;
p[1] = 0; /* ID */
p[2] = 0;
p[3] = 5; /* length */
* server, but they're not forbidden from doing so.
* This behaviour was observed with a Spirent Avalanche test server.
*/
- if ((eap_msg->vp_length == EAP_HEADER_LEN) && (eap_msg->vp_octets[0] == FR_EAP_FAILURE)) {
+ if ((eap_msg->vp_length == EAP_HEADER_LEN) && (eap_msg->vp_octets[0] == FR_EAP_CODE_FAILURE)) {
REDEBUG("Peer sent EAP %s (code %i) ID %d length %zu",
eap_codes[eap_msg->vp_octets[0]],
eap_msg->vp_octets[0],
* Success, or Failure.
*/
if ((eap_msg->vp_octets[0] == 0) ||
- (eap_msg->vp_octets[0] >= FR_EAP_MAX_CODES)) {
+ (eap_msg->vp_octets[0] >= FR_EAP_CODE_MAX)) {
RDEBUG2("Peer sent EAP packet with unknown code %i", eap_msg->vp_octets[0]);
} else {
RDEBUG2("Peer sent EAP %s (code %i) ID %d length %zu",
* sending success/fail packets to us, as it doesn't make
* sense.
*/
- if ((eap_msg->vp_octets[0] != FR_EAP_REQUEST) &&
- (eap_msg->vp_octets[0] != FR_EAP_RESPONSE)) {
+ if ((eap_msg->vp_octets[0] != FR_EAP_CODE_REQUEST) &&
+ (eap_msg->vp_octets[0] != FR_EAP_CODE_RESPONSE)) {
RDEBUG2("Ignoring EAP packet which we don't know how to handle");
return RLM_MODULE_FAIL;
}
talloc_free(eap_session->this_round->request);
eap_session->this_round->request = talloc_zero(eap_session->this_round, eap_packet_t);
- eap_session->this_round->request->code = FR_EAP_FAILURE;
+ eap_session->this_round->request->code = FR_EAP_CODE_FAILURE;
eap_session->finished = true;
eap_compose(eap_session);
}
*/
void eap_success(eap_session_t *eap_session)
{
- eap_session->this_round->request->code = FR_EAP_SUCCESS;
+ eap_session->this_round->request->code = FR_EAP_CODE_SUCCESS;
eap_session->finished = true;
eap_compose(eap_session);
}
* High level EAP packet checks
*/
if ((len <= EAP_HEADER_LEN) ||
- ((eap_packet->code != FR_EAP_RESPONSE) &&
- (eap_packet->code != FR_EAP_REQUEST))) {
+ ((eap_packet->code != FR_EAP_CODE_RESPONSE) &&
+ (eap_packet->code != FR_EAP_CODE_REQUEST))) {
REDEBUG("Badly formatted EAP Message: Ignoring the packet");
return -1;
}
uint16_t len;
if (!eap_packet ||
- (eap_packet->code != FR_EAP_RESPONSE) ||
+ (eap_packet->code != FR_EAP_CODE_RESPONSE) ||
(eap_packet->data[0] != FR_EAP_IDENTITY)) return NULL;
memcpy(&len, eap_packet->length, sizeof(uint16_t));
case EAP_TLS_ACK_SEND:
case EAP_TLS_START_SEND:
case EAP_TLS_RECORD_SEND:
- eap_round->request->code = FR_EAP_REQUEST;
+ eap_round->request->code = FR_EAP_CODE_REQUEST;
break;
case EAP_TLS_ESTABLISHED:
- eap_round->request->code = FR_EAP_SUCCESS;
+ eap_round->request->code = FR_EAP_CODE_SUCCESS;
break;
case EAP_TLS_FAIL:
- eap_round->request->code = FR_EAP_FAILURE;
+ eap_round->request->code = FR_EAP_CODE_FAILURE;
break;
default:
#define EAP_HEADER_LEN 4
typedef enum eap_code {
- FR_EAP_REQUEST = 1,
- FR_EAP_RESPONSE,
- FR_EAP_SUCCESS,
- FR_EAP_FAILURE,
- FR_EAP_MAX_CODES
+ FR_EAP_CODE_REQUEST = 1,
+ FR_EAP_CODE_RESPONSE,
+ FR_EAP_CODE_SUCCESS,
+ FR_EAP_CODE_FAILURE,
+ FR_EAP_CODE_MAX
} eap_code_t;
typedef enum eap_method {
/*
* Request and Response packets are special.
*/
- if ((reply->code == FR_EAP_REQUEST) ||
- (reply->code == FR_EAP_RESPONSE)) {
+ if ((reply->code == FR_EAP_CODE_REQUEST) ||
+ (reply->code == FR_EAP_CODE_RESPONSE)) {
header->data[0] = (reply->type.num & 0xFF);
/*
/* Set request reply code, but only if it's not already set. */
rcode = RLM_MODULE_OK;
if (!packet->code) switch (reply->code) {
- case FR_EAP_RESPONSE:
- case FR_EAP_SUCCESS:
+ case FR_EAP_CODE_RESPONSE:
+ case FR_EAP_CODE_SUCCESS:
packet->code = FR_CODE_ACCESS_ACCEPT;
rcode = RLM_MODULE_HANDLED;
break;
- case FR_EAP_FAILURE:
+ case FR_EAP_CODE_FAILURE:
packet->code = FR_CODE_ACCESS_REJECT;
rcode = RLM_MODULE_REJECT;
break;
- case FR_EAP_REQUEST:
+ case FR_EAP_CODE_REQUEST:
packet->code = FR_CODE_ACCESS_CHALLENGE;
rcode = RLM_MODULE_HANDLED;
break;
id = vp ? vp->vp_uint32 : ((int)getpid() & 0xff);
vp = fr_pair_find_by_num(to_encode, 0, FR_EAP_CODE, TAG_ANY);
- eap_code = vp ? vp->vp_uint32 : FR_EAP_REQUEST;
+ eap_code = vp ? vp->vp_uint32 : FR_EAP_CODE_REQUEST;
/*
* Fill in some bits in the EAP packet
*
* These are needed even if we're sending an almost empty packet.
*/
- if (eap_packet->code != FR_EAP_SUCCESS) eap_packet->code = eap_code;
+ if (eap_packet->code != FR_EAP_CODE_SUCCESS) eap_packet->code = eap_code;
eap_packet->id = (id & 0xff);
eap_packet->type.num = type;
* Add to the list only if it is EAP-Request, OR if
* it's LEAP, and a response.
*/
- if (((eap_session->this_round->request->code == FR_EAP_REQUEST) &&
+ if (((eap_session->this_round->request->code == FR_EAP_CODE_REQUEST) &&
(eap_session->this_round->request->type.num >= FR_EAP_MD5)) ||
/*
* At stage 6, LEAP sends an EAP-Response, which
* isn't put into the list.
*/
- ((eap_session->this_round->response->code == FR_EAP_RESPONSE) &&
+ ((eap_session->this_round->response->code == FR_EAP_CODE_RESPONSE) &&
(eap_session->this_round->response->type.num == FR_EAP_LEAP) &&
- (eap_session->this_round->request->code == FR_EAP_SUCCESS) &&
+ (eap_session->this_round->request->code == FR_EAP_CODE_SUCCESS) &&
(eap_session->this_round->request->type.num == 0))) {
talloc_free(eap_session->prev_round);
eap_session->prev_round = eap_session->this_round;
* Add to the list only if it is EAP-Request, OR if
* it's LEAP, and a response.
*/
- if ((eap_session->this_round->request->code == FR_EAP_REQUEST) &&
+ if ((eap_session->this_round->request->code == FR_EAP_CODE_REQUEST) &&
(eap_session->this_round->request->type.num >= FR_EAP_MD5)) {
talloc_free(eap_session->prev_round);
eap_session->prev_round = eap_session->this_round;
VALUE_PAIR *vp;
RADIUS_PACKET *packet;
- eap_session->this_round->request->code = FR_EAP_SUCCESS;
+ eap_session->this_round->request->code = FR_EAP_CODE_SUCCESS;
eap_session->finished = true;
/* to_client is the data to the client. */
RDEBUG("Sending EAP-Identity");
- eap_packet.code = FR_EAP_REQUEST;
+ eap_packet.code = FR_EAP_CODE_REQUEST;
eap_packet.id = eap_session->this_round->response->id + 1;
eap_packet.length[0] = 0;
eap_packet.length[1] = EAP_HEADER_LEN + 1;
vp = fr_pair_find_by_num(fake->packet->vps, 0, FR_EAP_MESSAGE, TAG_ANY);
if (vp &&
(vp->vp_length >= EAP_HEADER_LEN + 2) &&
- (vp->vp_strvalue[0] == FR_EAP_RESPONSE) &&
+ (vp->vp_strvalue[0] == FR_EAP_CODE_RESPONSE) &&
(vp->vp_strvalue[EAP_HEADER_LEN] == FR_EAP_IDENTITY) &&
(vp->vp_strvalue[EAP_HEADER_LEN + 1] != 0)) {
/*
if (rcode == RLM_MODULE_YIELD) return rcode;
if (rcode != RLM_MODULE_OK) {
- eap_round->request->code = FR_EAP_FAILURE;
+ eap_round->request->code = FR_EAP_CODE_FAILURE;
return rcode;
}
- eap_round->request->code = FR_EAP_SUCCESS;
+ eap_round->request->code = FR_EAP_CODE_SUCCESS;
return RLM_MODULE_OK;
}
*/
if (eap_round->response->length <= 4) {
ERROR("Corrupted data");
- eap_round->request->code = FR_EAP_FAILURE;
+ eap_round->request->code = FR_EAP_CODE_FAILURE;
return RLM_MODULE_INVALID;
}
*/
if (eap_round->response->type.length > 128) {
ERROR("Response is too large to understand");
- eap_round->request->code = FR_EAP_FAILURE;
+ eap_round->request->code = FR_EAP_CODE_FAILURE;
return RLM_MODULE_INVALID;
}
*/
rcode = process_authenticate(inst->auth_type, request);
if (rcode != RLM_MODULE_OK) {
- eap_round->request->code = FR_EAP_FAILURE;
+ eap_round->request->code = FR_EAP_CODE_FAILURE;
return rcode;
}
- eap_round->request->code = FR_EAP_SUCCESS;
+ eap_round->request->code = FR_EAP_CODE_SUCCESS;
return RLM_MODULE_OK;
}
/*
* We're sending a request...
*/
- eap_round->request->code = FR_EAP_REQUEST;
+ eap_round->request->code = FR_EAP_CODE_REQUEST;
eap_round->request->type.data = talloc_array(eap_round->request, uint8_t, length);
if (!eap_round->request->type.data) return RLM_MODULE_FAIL;
* messages sent to it.
*/
if (!eap_round || !eap_round->response ||
- ((eap_round->response->code != FR_EAP_RESPONSE) && (eap_round->response->code != FR_EAP_REQUEST)) ||
+ ((eap_round->response->code != FR_EAP_CODE_RESPONSE) && (eap_round->response->code != FR_EAP_CODE_REQUEST)) ||
(eap_round->response->type.num != FR_EAP_LEAP) || !eap_round->response->type.data ||
(eap_round->response->length < LEAP_HEADER_LEN) ||
(eap_round->response->type.data[0] != 0x01)) { /* version 1 */
* of the stages.
*/
switch (eap_round->response->code) {
- case FR_EAP_RESPONSE:
+ case FR_EAP_CODE_RESPONSE:
if (data->count != 24) {
REDEBUG("Bad NTChallengeResponse in LEAP stage 3");
return NULL;
}
break;
- case FR_EAP_REQUEST:
+ case FR_EAP_CODE_REQUEST:
if (data->count != 8) {
REDEBUG("Bad AP Challenge in LEAP stage 5");
return NULL;
reply = talloc(session, leap_packet_t);
if (!reply) return NULL;
- reply->code = FR_EAP_RESPONSE;
+ reply->code = FR_EAP_CODE_RESPONSE;
reply->length = LEAP_HEADER_LEN + 24 + user_name->vp_length;
reply->count = 24;
return NULL;
}
- reply->code = FR_EAP_REQUEST;
+ reply->code = FR_EAP_CODE_REQUEST;
reply->length = LEAP_HEADER_LEN + 8 + user_name->vp_length;
reply->count = 8; /* random challenge */
* We need the name and the challenge.
*/
switch (reply->code) {
- case FR_EAP_REQUEST:
- case FR_EAP_RESPONSE:
+ case FR_EAP_CODE_REQUEST:
+ case FR_EAP_CODE_RESPONSE:
eap_round->request->type.num = FR_EAP_LEAP;
eap_round->request->type.length = reply->length;
* EAP-Success packets don't contain any data
* other than the header.
*/
- case FR_EAP_SUCCESS:
+ case FR_EAP_CODE_SUCCESS:
eap_round->request->type.length = 0;
break;
* any LEAP packet. So we return here.
*/
if (!rcode) {
- eap_session->this_round->request->code = FR_EAP_FAILURE;
+ eap_session->this_round->request->code = FR_EAP_CODE_FAILURE;
talloc_free(packet);
return 0;
}
- eap_session->this_round->request->code = FR_EAP_SUCCESS;
+ eap_session->this_round->request->code = FR_EAP_CODE_SUCCESS;
/*
* Do this only for Success.
eap_round_t *eap_round = eap_session->this_round;
REQUEST *request = eap_session->request;
- eap_round->request->code = FR_EAP_REQUEST;
+ eap_round->request->code = FR_EAP_CODE_REQUEST;
eap_round->request->type.num = FR_EAP_MSCHAPV2;
/*
failure:
request->options &= ~RAD_REQUEST_OPTION_PROXY_EAP;
- eap_round->request->code = FR_EAP_FAILURE;
+ eap_round->request->code = FR_EAP_CODE_FAILURE;
return RLM_MODULE_REJECT;
case FR_EAP_MSCHAPV2_SUCCESS:
switch (ccode) {
case FR_EAP_MSCHAPV2_SUCCESS:
- eap_round->request->code = FR_EAP_SUCCESS;
+ eap_round->request->code = FR_EAP_CODE_SUCCESS;
fr_pair_list_mcopy_by_num(request->reply, &request->reply->vps, &data->mppe_keys, 0, 0, TAG_ANY);
/* FALL-THROUGH */
}
data->code = FR_EAP_MSCHAPV2_FAILURE;
} else {
- eap_round->request->code = FR_EAP_FAILURE;
+ eap_round->request->code = FR_EAP_CODE_FAILURE;
return RLM_MODULE_REJECT;
}
#define EAP_TLV_FAILURE (2)
#define EAP_TLV_ACK_RESULT (3)
-#define FR_EAP_TLV 33
+#define FR_PEAP_EXTENSIONS_METHOD 33
/*
* Process the PEAP portion of an EAP-PEAP request.
RDEBUG2("FAILURE");
- tlv_packet[0] = FR_EAP_REQUEST;
+ tlv_packet[0] = FR_EAP_CODE_REQUEST;
tlv_packet[1] = eap_session->this_round->response->id +1;
tlv_packet[2] = 0;
tlv_packet[3] = 11; /* length of this packet */
RDEBUG2("SUCCESS");
- tlv_packet[0] = FR_EAP_REQUEST;
+ tlv_packet[0] = FR_EAP_CODE_REQUEST;
tlv_packet[1] = eap_session->this_round->response->id +1;
tlv_packet[2] = 0;
tlv_packet[3] = 11; /* length of this packet */
{
eap_packet_raw_t eap_packet;
- eap_packet.code = FR_EAP_REQUEST;
+ eap_packet.code = FR_EAP_CODE_REQUEST;
eap_packet.id = eap_session->this_round->response->id + 1;
eap_packet.length[0] = 0;
eap_packet.length[1] = EAP_HEADER_LEN + 1;
static int eap_peap_verify(REQUEST *request,
uint8_t const *data, unsigned int data_len)
{
- eap_packet_raw_t const *eap_packet = (eap_packet_raw_t const *) data;
- eap_type_t eap_method;
+ eap_packet_raw_t const *eap_packet = (eap_packet_raw_t const *) data;
+ eap_type_t eap_method;
/*
* No data, OR only 1 byte of EAP type.
*/
- if (!data || (data_len == 0) ||
- ((data_len <= 1) && (data[0] != FR_EAP_IDENTITY))) {
- return 0;
- }
+ if (!data || (data_len == 0) || ((data_len <= 1) && (data[0] != FR_EAP_IDENTITY))) return 0;
- if (eap_packet->code == FR_EAP_RESPONSE) {
+ if (eap_packet->code == FR_EAP_CODE_RESPONSE) {
if (eap_packet->data[0] == FR_EAP_TLV) {
RDEBUG2("Received EAP-TLV response");
return 1;
}
}
- eap_method = *data;
+ eap_method = data[0]; /* Inner EAP header misses off code and identifier */
switch (eap_method) {
case FR_EAP_IDENTITY:
RDEBUG2("Received EAP-Identity-Response");
return 1;
}
- return 0;
}
/*
* Hand-build an EAP packet from the crap in PEAP version 0.
*/
p = talloc_array(vp, uint8_t, EAP_HEADER_LEN + total);
- p[0] = FR_EAP_RESPONSE;
+ p[0] = FR_EAP_CODE_RESPONSE;
p[1] = eap_round->response->id;
p[2] = (data_len + EAP_HEADER_LEN) >> 8;
p[3] = (data_len + EAP_HEADER_LEN) & 0xff;
/*
* Look for success or failure.
*/
- if ((eap_packet->code == FR_EAP_RESPONSE) &&
+ if ((eap_packet->code == FR_EAP_CODE_RESPONSE) &&
(eap_packet->data[0] == FR_EAP_TLV)) {
if (data[10] == EAP_TLV_SUCCESS) {
return 1;
vp = fr_pair_afrom_num(fake->packet, 0, FR_EAP_MESSAGE);
q = talloc_array(vp, uint8_t, len);
- q[0] = FR_EAP_RESPONSE;
+ q[0] = FR_EAP_CODE_RESPONSE;
q[1] = eap_round->response->id;
q[2] = (len >> 8) & 0xff;
q[3] = len & 0xff;
len = (session->out_len - session->out_pos) + sizeof(pwd_hdr);
rad_assert(len > 0);
- eap_round->request->code = FR_EAP_REQUEST;
+ eap_round->request->code = FR_EAP_CODE_REQUEST;
eap_round->request->type.num = FR_EAP_PWD;
eap_round->request->type.length = (len > session->mtu) ? session->mtu : len;
eap_round->request->type.data = talloc_zero_array(eap_round->request, uint8_t, eap_round->request->type.length);
* send back an ACK for this fragment
*/
exch = EAP_PWD_GET_EXCHANGE(hdr);
- eap_round->request->code = FR_EAP_REQUEST;
+ eap_round->request->code = FR_EAP_CODE_REQUEST;
eap_round->request->type.num = FR_EAP_PWD;
eap_round->request->type.length = sizeof(pwd_hdr);
REDEBUG("Failed generating (E)MSK");
return RLM_MODULE_FAIL;
}
- eap_round->request->code = FR_EAP_SUCCESS;
+ eap_round->request->code = FR_EAP_CODE_SUCCESS;
/*
* Return the MSK (in halves).
VALUE_PAIR *vp;
RADIUS_PACKET *packet;
- eap_session->this_round->request->code = FR_EAP_SUCCESS;
+ eap_session->this_round->request->code = FR_EAP_CODE_SUCCESS;
eap_session->finished = true;
/* to_client is the data to the client. */
vp = fr_pair_find_by_num(fake->packet->vps, 0, FR_EAP_MESSAGE, TAG_ANY);
if (vp &&
(vp->vp_length >= EAP_HEADER_LEN + 2) &&
- (vp->vp_strvalue[0] == FR_EAP_RESPONSE) &&
+ (vp->vp_strvalue[0] == FR_EAP_CODE_RESPONSE) &&
(vp->vp_strvalue[EAP_HEADER_LEN] == FR_EAP_IDENTITY) &&
(vp->vp_strvalue[EAP_HEADER_LEN + 1] != 0)) {
/*