libwifi 0.0.3
An 802.11 Frame Parsing and Generation library in C
eapol.c File Reference
#include "eapol.h"
#include "../../core/frame/frame.h"
#include "../../core/misc/byteswap.h"
#include "../../core/misc/llc.h"
#include "../../core/misc/security.h"
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

int libwifi_check_wpa_handshake (struct libwifi_frame *frame)
 A libwifi_frame is deemed to be an EAPOL handshake if the following criteria is met: More...
 
int libwifi_check_wpa_message (struct libwifi_frame *frame)
 Check what message of the WPA1/2 handshake is in the given frame. More...
 
const char * libwifi_get_wpa_message_string (struct libwifi_frame *frame)
 Get a string describing the WPA handshake message inside a supplied libwifi_frame. More...
 
int libwifi_get_wpa_key_data_length (struct libwifi_frame *frame)
 Get the length of the key data, if any, present at the end of an EAPOL frame. More...
 
int libwifi_get_wpa_data (struct libwifi_frame *frame, struct libwifi_wpa_auth_data *data)
 Get the EAPOL/WPA information from a given libwifi_frame. More...
 
void libwifi_free_wpa_data (struct libwifi_wpa_auth_data *data)
 Free any memory allocated inside of a libwifi_wpa_auth data, such as a buffer for WPA key data allocated by the library. More...
 

Function Documentation

◆ libwifi_check_wpa_handshake()

int libwifi_check_wpa_handshake ( struct libwifi_frame frame)

A libwifi_frame is deemed to be an EAPOL handshake if the following criteria is met:

Check if a libwifi_frame contains a WPA1/2 handshake message.

  • The frame is of type TYPE_DATA, and
  • The frame contains a logical link control layer, and
  • There is enough data in the frame body to fill a libwifi_wpa_auth_data struct.

Definition at line 34 of file eapol.c.

◆ libwifi_check_wpa_message()

int libwifi_check_wpa_message ( struct libwifi_frame frame)

Check what message of the WPA1/2 handshake is in the given frame.

The returned value can be used with the WPA_HANDSHAKE_PART enum, such as:

part = libwifi_check_wpa_message(frame); if (part & HANDSHAKE_M1) { // This is EAPOL Message 1 }

Parameters
libwifi_frameA libwifi_frame
Returns
A bitmask of parts.

Definition at line 74 of file eapol.c.

◆ libwifi_free_wpa_data()

void libwifi_free_wpa_data ( struct libwifi_wpa_auth_data data)

Free any memory allocated inside of a libwifi_wpa_auth data, such as a buffer for WPA key data allocated by the library.

Parameters
dataA pointer to a libwifi_wpa_auth_data struct

Definition at line 186 of file eapol.c.

◆ libwifi_get_wpa_data()

int libwifi_get_wpa_data ( struct libwifi_frame frame,
struct libwifi_wpa_auth_data data 
)

Get the EAPOL/WPA information from a given libwifi_frame.

As the values in the frame below and including the logical link control layer will be in network byte order, the values will be automatically byte swapped if necessary to match the host systems byte order.

Parameters
libwifi_frameA libwifi_frame
dataA pointer to a libwifi_wpa_auth_data struct
Returns
0 on success, -1 on failure

Definition at line 147 of file eapol.c.

◆ libwifi_get_wpa_key_data_length()

int libwifi_get_wpa_key_data_length ( struct libwifi_frame frame)

Get the length of the key data, if any, present at the end of an EAPOL frame.

Parameters
libwifi_frameA libwifi_frame
Returns
The length of the key data

Definition at line 127 of file eapol.c.

◆ libwifi_get_wpa_message_string()

const char * libwifi_get_wpa_message_string ( struct libwifi_frame frame)

Get a string describing the WPA handshake message inside a supplied libwifi_frame.

Parameters
libwifi_frameA libwifi_frame
Returns
A string describing the WPA handshake message found

Definition at line 105 of file eapol.c.