summaryrefslogtreecommitdiffstats
path: root/contrib/wpa_supplicant/eap_tlv.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2006-03-07 05:26:33 +0000
committersam <sam@FreeBSD.org>2006-03-07 05:26:33 +0000
commit840099f34d8de1ca769f02fae379c4d8e5d6688a (patch)
tree0c0ff34569d807e7bceb062a6210ce68490a8764 /contrib/wpa_supplicant/eap_tlv.c
parent34dbcde8dfa5b3d152d250b6d69965e001238e49 (diff)
downloadFreeBSD-src-840099f34d8de1ca769f02fae379c4d8e5d6688a.zip
FreeBSD-src-840099f34d8de1ca769f02fae379c4d8e5d6688a.tar.gz
Import of WPA supplicant 0.4.8
Diffstat (limited to 'contrib/wpa_supplicant/eap_tlv.c')
-rw-r--r--contrib/wpa_supplicant/eap_tlv.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/contrib/wpa_supplicant/eap_tlv.c b/contrib/wpa_supplicant/eap_tlv.c
index 5571d8b..4070c6f 100644
--- a/contrib/wpa_supplicant/eap_tlv.c
+++ b/contrib/wpa_supplicant/eap_tlv.c
@@ -22,7 +22,7 @@
#include "eap_tlv.h"
-u8 * eap_tlv_build_nak(int id, int nak_type, size_t *resp_len)
+u8 * eap_tlv_build_nak(int id, u16 nak_type, size_t *resp_len)
{
struct eap_hdr *hdr;
u8 *pos;
@@ -48,14 +48,13 @@ u8 * eap_tlv_build_nak(int id, int nak_type, size_t *resp_len)
*pos++ = 0;
*pos++ = 0;
/* NAK-Type */
- *pos++ = nak_type >> 8;
- *pos++ = nak_type & 0xff;
+ WPA_PUT_BE16(pos, nak_type);
return (u8 *) hdr;
}
-u8 * eap_tlv_build_result(int id, int status, size_t *resp_len)
+u8 * eap_tlv_build_result(int id, u16 status, size_t *resp_len)
{
struct eap_hdr *hdr;
u8 *pos;
@@ -76,33 +75,32 @@ u8 * eap_tlv_build_result(int id, int status, size_t *resp_len)
*pos++ = 0;
*pos++ = 2;
/* Status */
- *pos++ = status >> 8;
- *pos++ = status & 0xff;
+ WPA_PUT_BE16(pos, status);
return (u8 *) hdr;
}
int eap_tlv_process(struct eap_sm *sm, struct eap_method_ret *ret,
- struct eap_hdr *hdr, u8 **resp, size_t *resp_len)
+ const struct eap_hdr *hdr, u8 **resp, size_t *resp_len)
{
size_t left;
- u8 *pos;
- u8 *result_tlv = NULL;
+ const u8 *pos;
+ const u8 *result_tlv = NULL;
size_t result_tlv_len = 0;
int tlv_type, mandatory, tlv_len;
/* Parse TLVs */
left = be_to_host16(hdr->length) - sizeof(struct eap_hdr) - 1;
- pos = (u8 *) (hdr + 1);
+ pos = (const u8 *) (hdr + 1);
pos++;
wpa_hexdump(MSG_DEBUG, "EAP-TLV: Received TLVs", pos, left);
while (left >= 4) {
mandatory = !!(pos[0] & 0x80);
- tlv_type = pos[0] & 0x3f;
- tlv_type = (tlv_type << 8) | pos[1];
- tlv_len = ((int) pos[2] << 8) | pos[3];
- pos += 4;
+ tlv_type = WPA_GET_BE16(pos) & 0x3fff;
+ pos += 2;
+ tlv_len = WPA_GET_BE16(pos);
+ pos += 2;
left -= 4;
if (tlv_len > left) {
wpa_printf(MSG_DEBUG, "EAP-TLV: TLV underrun "
@@ -150,7 +148,7 @@ int eap_tlv_process(struct eap_sm *sm, struct eap_method_ret *ret,
(unsigned long) result_tlv_len);
return -1;
}
- status = ((int) result_tlv[0] << 8) | result_tlv[1];
+ status = WPA_GET_BE16(result_tlv);
if (status == EAP_TLV_RESULT_SUCCESS) {
wpa_printf(MSG_INFO, "EAP-TLV: TLV Result - Success "
"- EAP-TLV/Phase2 Completed");
OpenPOWER on IntegriCloud