Return wpabuf from radius_msg_get_eap()
This simplifies the implementation by using the buffer type to which the returned data will be converted anyway. This avoids one memory allocation for each processed RADIUS message. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
95ac3bf49f
commit
e100828b76
5 changed files with 38 additions and 50 deletions
|
@ -1039,9 +1039,8 @@ void ieee802_1x_free_station(struct sta_info *sta)
|
|||
static void ieee802_1x_decapsulate_radius(struct hostapd_data *hapd,
|
||||
struct sta_info *sta)
|
||||
{
|
||||
u8 *eap;
|
||||
size_t len;
|
||||
struct eap_hdr *hdr;
|
||||
struct wpabuf *eap;
|
||||
const struct eap_hdr *hdr;
|
||||
int eap_type = -1;
|
||||
char buf[64];
|
||||
struct radius_msg *msg;
|
||||
|
@ -1055,7 +1054,7 @@ static void ieee802_1x_decapsulate_radius(struct hostapd_data *hapd,
|
|||
|
||||
msg = sm->last_recv_radius;
|
||||
|
||||
eap = radius_msg_get_eap(msg, &len);
|
||||
eap = radius_msg_get_eap(msg);
|
||||
if (eap == NULL) {
|
||||
/* RFC 3579, Chap. 2.6.3:
|
||||
* RADIUS server SHOULD NOT send Access-Reject/no EAP-Message
|
||||
|
@ -1067,19 +1066,19 @@ static void ieee802_1x_decapsulate_radius(struct hostapd_data *hapd,
|
|||
return;
|
||||
}
|
||||
|
||||
if (len < sizeof(*hdr)) {
|
||||
if (wpabuf_len(eap) < sizeof(*hdr)) {
|
||||
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
|
||||
HOSTAPD_LEVEL_WARNING, "too short EAP packet "
|
||||
"received from authentication server");
|
||||
os_free(eap);
|
||||
wpabuf_free(eap);
|
||||
sm->eap_if->aaaEapNoReq = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (len > sizeof(*hdr))
|
||||
eap_type = eap[sizeof(*hdr)];
|
||||
if (wpabuf_len(eap) > sizeof(*hdr))
|
||||
eap_type = (wpabuf_head_u8(eap))[sizeof(*hdr)];
|
||||
|
||||
hdr = (struct eap_hdr *) eap;
|
||||
hdr = wpabuf_head(eap);
|
||||
switch (hdr->code) {
|
||||
case EAP_CODE_REQUEST:
|
||||
if (eap_type >= 0)
|
||||
|
@ -1114,7 +1113,7 @@ static void ieee802_1x_decapsulate_radius(struct hostapd_data *hapd,
|
|||
sm->eap_if->aaaEapReq = TRUE;
|
||||
|
||||
wpabuf_free(sm->eap_if->aaaEapReqData);
|
||||
sm->eap_if->aaaEapReqData = wpabuf_alloc_ext_data(eap, len);
|
||||
sm->eap_if->aaaEapReqData = eap;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue