libwifi 0.0.3
An 802.11 Frame Parsing and Generation library in C
beacon.c File Reference
#include "beacon.h"
#include "../../core/frame/tag.h"
#include "../../core/frame/tag_iterator.h"
#include "../../core/misc/byteswap.h"
#include "../../core/misc/epoch.h"
#include "common.h"
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

Go to the source code of this file.

Functions

size_t libwifi_get_beacon_length (struct libwifi_beacon *beacon)
 The length of a beacon frame is the sum of the header length, the fixed parameters length, and the tagged parameters length. More...
 
int libwifi_set_beacon_ssid (struct libwifi_beacon *beacon, const char *ssid)
 Simple helper to set the beacon SSID tag by removing it and then adding it back with the new value. More...
 
int libwifi_set_beacon_channel (struct libwifi_beacon *beacon, uint8_t channel)
 Simple helper to set the beacon DS tag by removing it and then adding it back with the new value. More...
 
int libwifi_create_beacon (struct libwifi_beacon *beacon, const unsigned char receiver[6], const unsigned char transmitter[6], const unsigned char address3[6], const char *ssid, uint8_t channel)
 The generated beacon frame is made with sane defaults defined in common.h. More...
 
size_t libwifi_dump_beacon (struct libwifi_beacon *beacon, unsigned char *buf, size_t buf_len)
 Copy a libwifi_beacon into a regular unsigned char buffer. More...
 
void libwifi_free_beacon (struct libwifi_beacon *beacon)
 Because the tagged parameters memory is managed inside of the library, the library must be the one to free it, too. More...
 

Function Documentation

◆ libwifi_create_beacon()

int libwifi_create_beacon ( struct libwifi_beacon beacon,
const unsigned char  receiver[6],
const unsigned char  transmitter[6],
const unsigned char  address3[6],
const char *  ssid,
uint8_t  channel 
)

The generated beacon frame is made with sane defaults defined in common.h.

Generate a populated libwifi beacon.

Two tagged parameters are also added to the beacon: SSID and Channel.

Definition at line 81 of file beacon.c.

◆ libwifi_dump_beacon()

size_t libwifi_dump_beacon ( struct libwifi_beacon beacon,
unsigned char *  buf,
size_t  buf_len 
)

Copy a libwifi_beacon into a regular unsigned char buffer.

Dump a struct libwifi_beacon into a raw format for packet injection.

This is useful when injecting generated libwifi frames.

Definition at line 114 of file beacon.c.

◆ libwifi_free_beacon()

void libwifi_free_beacon ( struct libwifi_beacon beacon)

Because the tagged parameters memory is managed inside of the library, the library must be the one to free it, too.

Free any memory claimed by a struct libwifi_beacon back to the system.

Definition at line 137 of file beacon.c.

◆ libwifi_get_beacon_length()

size_t libwifi_get_beacon_length ( struct libwifi_beacon beacon)

The length of a beacon frame is the sum of the header length, the fixed parameters length, and the tagged parameters length.

Calculate the length of a given struct libwifi_beacon.

Definition at line 33 of file beacon.c.

◆ libwifi_set_beacon_channel()

int libwifi_set_beacon_channel ( struct libwifi_beacon beacon,
uint8_t  channel 
)

Simple helper to set the beacon DS tag by removing it and then adding it back with the new value.

Set the channel of a struct libwifi_beacon.

Definition at line 60 of file beacon.c.

◆ libwifi_set_beacon_ssid()

int libwifi_set_beacon_ssid ( struct libwifi_beacon beacon,
const char *  ssid 
)

Simple helper to set the beacon SSID tag by removing it and then adding it back with the new value.

Set the SSID of a struct libwifi_beacon.

Definition at line 42 of file beacon.c.