wpa_supplicant / hostapd
2.5
|
EAP common peer/server definitions. More...
Functions | |
int | eap_hdr_len_valid (const struct wpabuf *msg, size_t min_payload) |
Validate EAP header length field. More... | |
const u8 * | eap_hdr_validate (int vendor, EapType eap_type, const struct wpabuf *msg, size_t *plen) |
Validate EAP header. More... | |
struct wpabuf * | eap_msg_alloc (int vendor, EapType type, size_t payload_len, u8 code, u8 identifier) |
Allocate a buffer for an EAP message. More... | |
void | eap_update_len (struct wpabuf *msg) |
Update EAP header length. More... | |
u8 | eap_get_id (const struct wpabuf *msg) |
Get EAP Identifier from wpabuf. More... | |
EapType | eap_get_type (const struct wpabuf *msg) |
Get EAP Type from wpabuf. More... | |
EAP common peer/server definitions.
u8 eap_get_id | ( | const struct wpabuf * | msg | ) |
Get EAP Identifier from wpabuf.
msg | Buffer starting with an EAP header |
EapType eap_get_type | ( | const struct wpabuf * | msg | ) |
Get EAP Type from wpabuf.
msg | Buffer starting with an EAP header |
int eap_hdr_len_valid | ( | const struct wpabuf * | msg, |
size_t | min_payload | ||
) |
Validate EAP header length field.
msg | EAP frame (starting with EAP header) |
min_payload | Minimum payload length needed |
This is a helper function that does minimal validation of EAP messages. The length field is verified to be large enough to include the header and not too large to go beyond the end of the buffer.
const u8* eap_hdr_validate | ( | int | vendor, |
EapType | eap_type, | ||
const struct wpabuf * | msg, | ||
size_t * | plen | ||
) |
Validate EAP header.
vendor | Expected EAP Vendor-Id (0 = IETF) |
eap_type | Expected EAP type number |
msg | EAP frame (starting with EAP header) |
plen | Pointer to variable to contain the returned payload length |
This is a helper function for EAP method implementations. This is usually called in the beginning of struct eap_method::process() function to verify that the received EAP request packet has a valid header. This function is able to process both legacy and expanded EAP headers and in most cases, the caller can just use the returned payload pointer (into *plen) for processing the payload regardless of whether the packet used the expanded EAP header or not.
struct wpabuf* eap_msg_alloc | ( | int | vendor, |
EapType | type, | ||
size_t | payload_len, | ||
u8 | code, | ||
u8 | identifier | ||
) |
Allocate a buffer for an EAP message.
vendor | Vendor-Id (0 = IETF) |
type | EAP type |
payload_len | Payload length in bytes (data after Type) |
code | Message Code (EAP_CODE_*) |
identifier | Identifier |
This function can be used to allocate a buffer for an EAP message and fill in the EAP header. This function is automatically using expanded EAP header if the selected Vendor-Id is not IETF. In other words, most EAP methods do not need to separately select which header type to use when using this function to allocate the message buffers. The returned buffer has room for payload_len bytes and has the EAP header and Type field already filled in.
void eap_update_len | ( | struct wpabuf * | msg | ) |
Update EAP header length.
msg | EAP message from eap_msg_alloc |
This function updates the length field in the EAP header to match with the current length for the buffer. This allows eap_msg_alloc() to be used to allocate a larger buffer than the exact message length (e.g., if exact message length is not yet known).