Use helper functions to handle (non-)skippable attributes
This commit is contained in:
@@ -843,6 +843,33 @@ static eap_payload_t *build_aka_payload(private_eap_aka_t *this, eap_code_t code
|
|||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if an unknown attribute is skippable
|
||||||
|
*/
|
||||||
|
static bool attribute_skippable(aka_attribute_t attribute)
|
||||||
|
{
|
||||||
|
if (attribute >= 0 && attribute <= 127)
|
||||||
|
{
|
||||||
|
DBG1(DBG_IKE, "ignoring skippable attribute %N",
|
||||||
|
aka_attribute_names, attribute);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* build the error response if we received an unknown non-skippable attribute
|
||||||
|
*/
|
||||||
|
static eap_payload_t *build_non_skippable_error(private_eap_aka_t *this,
|
||||||
|
aka_attribute_t attribute, u_char identifier)
|
||||||
|
{
|
||||||
|
DBG1(DBG_IKE, "found non skippable attribute %N, sending %N %d",
|
||||||
|
aka_attribute_names, attribute,
|
||||||
|
aka_attribute_names, AT_CLIENT_ERROR_CODE, 0);
|
||||||
|
return build_aka_payload(this, EAP_RESPONSE, identifier, AKA_CLIENT_ERROR,
|
||||||
|
AT_CLIENT_ERROR_CODE, client_error_code, AT_END);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate a new non-zero identifier
|
* generate a new non-zero identifier
|
||||||
*/
|
*/
|
||||||
@@ -976,15 +1003,13 @@ static status_t server_process_synchronize(private_eap_aka_t *this,
|
|||||||
auts = attr;
|
auts = attr;
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
if (attribute >= 0 && attribute <= 127)
|
if (attribute_skippable(attribute))
|
||||||
{
|
{
|
||||||
DBG1(DBG_IKE, "found non skippable attribute %N",
|
continue;
|
||||||
aka_attribute_names, attribute);
|
|
||||||
return FAILED;
|
|
||||||
}
|
}
|
||||||
DBG1(DBG_IKE, "ignoring skippable attribute %N",
|
DBG1(DBG_IKE, "found non skippable attribute %N",
|
||||||
aka_attribute_names, attribute);
|
aka_attribute_names, attribute);
|
||||||
continue;
|
return FAILED;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1060,15 +1085,13 @@ static status_t server_process_challenge(private_eap_aka_t *this, eap_payload_t
|
|||||||
memset(attr.ptr, 0, attr.len);
|
memset(attr.ptr, 0, attr.len);
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
if (attribute >= 0 && attribute <= 127)
|
if (attribute_skippable(attribute))
|
||||||
{
|
{
|
||||||
DBG1(DBG_IKE, "found non skippable attribute %N",
|
continue;
|
||||||
aka_attribute_names, attribute);
|
|
||||||
return FAILED;
|
|
||||||
}
|
}
|
||||||
DBG1(DBG_IKE, "ignoring skippable attribute %N",
|
DBG1(DBG_IKE, "found non skippable attribute %N",
|
||||||
aka_attribute_names, attribute);
|
aka_attribute_names, attribute);
|
||||||
continue;
|
return FAILED;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1179,19 +1202,12 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
|
|||||||
memset(attr.ptr, 0, attr.len);
|
memset(attr.ptr, 0, attr.len);
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
if (attribute >= 0 && attribute <= 127)
|
if (attribute_skippable(attribute))
|
||||||
{
|
{
|
||||||
/* non skippable attribute, abort */
|
continue;
|
||||||
*out = build_aka_payload(this, EAP_RESPONSE, identifier, AKA_CLIENT_ERROR,
|
|
||||||
AT_CLIENT_ERROR_CODE, client_error_code, AT_END);
|
|
||||||
DBG1(DBG_IKE, "found non skippable attribute %N, sending %N %d",
|
|
||||||
aka_attribute_names, attribute,
|
|
||||||
aka_attribute_names, AT_CLIENT_ERROR_CODE, 0);
|
|
||||||
return NEED_MORE;
|
|
||||||
}
|
}
|
||||||
DBG1(DBG_IKE, "ignoring skippable attribute %N",
|
*out = build_non_skippable_error(this, attribute, identifier);
|
||||||
aka_attribute_names, attribute);
|
return NEED_MORE;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1347,19 +1363,12 @@ static status_t peer_process_identity(private_eap_aka_t *this,
|
|||||||
aka_attribute_names, attribute, this->peer);
|
aka_attribute_names, attribute, this->peer);
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
if (attribute >= 0 && attribute <= 127)
|
if (attribute_skippable(attribute))
|
||||||
{
|
{
|
||||||
/* non skippable attribute, abort */
|
continue;
|
||||||
*out = build_aka_payload(this, EAP_RESPONSE, identifier, AKA_CLIENT_ERROR,
|
|
||||||
AT_CLIENT_ERROR_CODE, client_error_code, AT_END);
|
|
||||||
DBG1(DBG_IKE, "found non skippable attribute %N, sending %N %d",
|
|
||||||
aka_attribute_names, attribute,
|
|
||||||
aka_attribute_names, AT_CLIENT_ERROR_CODE, 0);
|
|
||||||
return NEED_MORE;
|
|
||||||
}
|
}
|
||||||
DBG1(DBG_IKE, "ignoring skippable attribute %N",
|
*out = build_non_skippable_error(this, attribute, identifier);
|
||||||
aka_attribute_names, attribute);
|
return NEED_MORE;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1433,16 +1442,11 @@ static status_t peer_process_notification(private_eap_aka_t *this,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if (attribute >= 0 && attribute <= 127)
|
if (!attribute_skippable(attribute))
|
||||||
{
|
{
|
||||||
DBG1(DBG_IKE, "ignoring non-skippable attribute %N in %N",
|
DBG1(DBG_IKE, "ignoring non-skippable attribute %N in %N",
|
||||||
aka_attribute_names, attribute, aka_subtype_names,
|
aka_attribute_names, attribute, aka_subtype_names,
|
||||||
AKA_NOTIFICATION);
|
AKA_NOTIFICATION);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DBG1(DBG_IKE, "ignoring skippable attribute %N",
|
|
||||||
aka_attribute_names, attribute);
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user