eap_common.c File Reference

EAP common peer/server definitions. More...

#include "includes.h"
#include "common.h"
#include "eap_defs.h"
#include "eap_common.h"
Include dependency graph for eap_common.c:

Go to the source code of this file.

Functions

const u8 * eap_hdr_validate (int vendor, EapType eap_type, const struct wpabuf *msg, size_t *plen)
 Validate EAP header.
struct wpabufeap_msg_alloc (int vendor, EapType type, size_t payload_len, u8 code, u8 identifier)
 Allocate a buffer for an EAP message.
void eap_update_len (struct wpabuf *msg)
 Update EAP header length.
u8 eap_get_id (const struct wpabuf *msg)
 Get EAP Identifier from wpabuf.
EapType eap_get_type (const struct wpabuf *msg)
 Get EAP Type from wpabuf.

Detailed Description

EAP common peer/server definitions.

Copyright
Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

Alternatively, this software may be distributed under the terms of BSD license.

See README and COPYING for more details.

Definition in file eap_common.c.


Function Documentation

u8 eap_get_id ( const struct wpabuf msg  ) 

Get EAP Identifier from wpabuf.

Parameters:
msg Buffer starting with an EAP header
Returns:
The Identifier field from the EAP header

Definition at line 166 of file eap_common.c.

EapType eap_get_type ( const struct wpabuf msg  ) 

Get EAP Type from wpabuf.

Parameters:
msg Buffer starting with an EAP header
Returns:
The EAP Type after the EAP header

Definition at line 184 of file eap_common.c.

const u8* eap_hdr_validate ( int  vendor,
EapType  eap_type,
const struct wpabuf msg,
size_t *  plen 
)

Validate EAP header.

Parameters:
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
Returns:
Pointer to EAP payload (after type field), or NULL on failure

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.

Definition at line 39 of file eap_common.c.

Here is the call graph for this function:

struct wpabuf* eap_msg_alloc ( int  vendor,
EapType  type,
size_t  payload_len,
u8  code,
u8  identifier 
) [read]

Allocate a buffer for an EAP message.

Parameters:
vendor Vendor-Id (0 = IETF)
type EAP type
payload_len Payload length in bytes (data after Type)
code Message Code (EAP_CODE_*)
identifier Identifier
Returns:
Pointer to the allocated message buffer or NULL on error

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.

Definition at line 110 of file eap_common.c.

Here is the call graph for this function:

void eap_update_len ( struct wpabuf msg  ) 

Update EAP header length.

Parameters:
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).

Definition at line 150 of file eap_common.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Sat Nov 21 23:20:49 2009 for hostapd by  doxygen 1.6.1