3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 01:09:35 +01:00

eap: Remove nested function use

This allows building iwd with clang
This commit is contained in:
Marc-Antoine Perennou 2021-11-06 20:34:32 +01:00 committed by Denis Kenzior
parent 09f4bd9210
commit b3991c1a40

View File

@ -416,6 +416,9 @@ static const char *eap_type_to_str(enum eap_type type, uint32_t vendor_id,
#define IS_EXPANDED_RESPONSE(id, t) \ #define IS_EXPANDED_RESPONSE(id, t) \
(type == EAP_TYPE_EXPANDED && vendor_id == (id) && vendor_type == (t)) (type == EAP_TYPE_EXPANDED && vendor_id == (id) && vendor_type == (t))
#define RESPONSE_IS(t) \
(type == (t) || IS_EXPANDED_RESPONSE(0, (t)))
static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt, static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
size_t len) size_t len)
{ {
@ -428,14 +431,6 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
eap->method->vendor_id[2]; eap->method->vendor_id[2];
uint32_t our_vendor_type = eap->method->vendor_type; uint32_t our_vendor_type = eap->method->vendor_type;
bool response_is(enum eap_type wanted)
{
if (type == wanted)
return true;
return IS_EXPANDED_RESPONSE(0, wanted);
}
if (len < 1) if (len < 1)
/* Invalid packets to be ignored */ /* Invalid packets to be ignored */
return; return;
@ -461,7 +456,7 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
return; return;
} }
if (response_is(EAP_TYPE_NAK)) { if (RESPONSE_IS(EAP_TYPE_NAK)) {
l_debug("EAP peer not configured for method: %s", l_debug("EAP peer not configured for method: %s",
eap_type_to_str(our_type, our_vendor_id, eap_type_to_str(our_type, our_vendor_id,
our_vendor_type)); our_vendor_type));
@ -500,7 +495,7 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
*/ */
if (!eap->identity) { if (!eap->identity) {
if (!response_is(EAP_TYPE_IDENTITY)) if (!RESPONSE_IS(EAP_TYPE_IDENTITY))
goto unsupported_method; goto unsupported_method;
/* /*
@ -528,7 +523,7 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
* (with the exception of the Nak) * (with the exception of the Nak)
*/ */
if (our_type != EAP_TYPE_EXPANDED) { if (our_type != EAP_TYPE_EXPANDED) {
if (response_is(our_type)) if (RESPONSE_IS(our_type))
goto handle_response; goto handle_response;
} else if (IS_EXPANDED_RESPONSE(our_vendor_id, our_vendor_type)) } else if (IS_EXPANDED_RESPONSE(our_vendor_id, our_vendor_type))
goto handle_response; goto handle_response;