libwifi 0.0.3
An 802.11 Frame Parsing and Generation library in C
crc.c File Reference
#include "crc.h"
#include "../misc/byteswap.h"
#include <stdint.h>
#include <sys/types.h>

Go to the source code of this file.

Functions

uint32_t libwifi_crc32 (const unsigned char *message, int message_len)
 Calculate the CRC32 sum of a given buffer. More...
 
uint32_t libwifi_calculate_fcs (const unsigned char *frame, size_t frame_len)
 Calculate the frame checksum for an 802.11 frame. More...
 
int libwifi_frame_verify (void *frame, size_t frame_len)
 Check if the given raw 802.11 frame has a valid FCS. More...
 

Function Documentation

◆ libwifi_calculate_fcs()

uint32_t libwifi_calculate_fcs ( const unsigned char *  frame,
size_t  frame_len 
)

Calculate the frame checksum for an 802.11 frame.

Parameters
frameAn 802.11 frame
frame_lenLength of the frame
Returns
frame checksum of the frame

Definition at line 47 of file crc.c.

◆ libwifi_crc32()

uint32_t libwifi_crc32 ( const unsigned char *  message,
int  message_len 
)

Calculate the CRC32 sum of a given buffer.

Parameters
messageBuffer of data
message_lenLength of the data buffer
Returns
CRC32 sum of the given buffer

Definition at line 26 of file crc.c.

◆ libwifi_frame_verify()

int libwifi_frame_verify ( void *  frame,
size_t  frame_len 
)

Check if the given raw 802.11 frame has a valid FCS.

This function relies on an assumption that the last 4 bytes of the supplied frame is the CRC, as stated in the Radiotap specification.

You can check if the frame data has this field by using libwifi_get_wifi_frame() and then checking if the libwifi_frame's flags has the LIBWIFI_FLAGS_FCS_PRESENT bit set.

Parameters
frameAn 802.11 frame with an FCS
frame_lenLength of the frame
Returns
1 if verified, 0 if not

Definition at line 55 of file crc.c.