libwifi 0.0.3
An 802.11 Frame Parsing and Generation library in C
tag.c File Reference
#include "tag.h"
#include "tag_iterator.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

int libwifi_add_tag (struct libwifi_tagged_parameters *tags, struct libwifi_tagged_parameter *tag)
 Add a tagged parameter to a list of frame tagged parameters. More...
 
int libwifi_remove_tag (struct libwifi_tagged_parameters *tags, int tag_number)
 Remove a tagged parameter from a list of frame tagged parameters. More...
 
size_t libwifi_create_tag (struct libwifi_tagged_parameter *tagged_parameter, int tag_number, const unsigned char *tag_data, size_t tag_length)
 Create a tagged parameter from a tag number, length and data. More...
 
void libwifi_free_tag (struct libwifi_tagged_parameter *tagged_parameter)
 Free a tagged parameters body. More...
 
size_t libwifi_dump_tag (struct libwifi_tagged_parameter *tag, unsigned char *buf, size_t buf_len)
 Dump a tagged parameter into a raw buffer, for use with other buffers or injection. More...
 
int libwifi_quick_add_tag (struct libwifi_tagged_parameters *tags, int tag_number, const unsigned char *tag_data, size_t tag_length)
 Add a tagged parameter via tag number and data to a management frame. More...
 
int libwifi_check_tag (struct libwifi_tagged_parameters *tags, int tag_number)
 Check if a tagged parameter is present via tag number. More...
 
char * libwifi_get_tag_name (int tag_number)
 Get the name of a tagged parameter via a supplied tag number. More...
 

Function Documentation

◆ libwifi_add_tag()

int libwifi_add_tag ( struct libwifi_tagged_parameters tagged_parameters,
struct libwifi_tagged_parameter tagged_parameter 
)

Add a tagged parameter to a list of frame tagged parameters.

Parameters
tagged_parametersA management frame's tagged parameters
tagged_parameterThe new tagged parameter

Definition at line 25 of file tag.c.

◆ libwifi_check_tag()

int libwifi_check_tag ( struct libwifi_tagged_parameters tags,
int  tag_number 
)

Check if a tagged parameter is present via tag number.

Parameters
tagsA tagged parameters list
tag_numberThe number of the tagged parameter to find
Returns
The number of times the supplied tag_number was found in tags

Definition at line 133 of file tag.c.

◆ libwifi_create_tag()

size_t libwifi_create_tag ( struct libwifi_tagged_parameter tagged_parameter,
int  tag_number,
const unsigned char *  tag_data,
size_t  tag_length 
)

Create a tagged parameter from a tag number, length and data.

This can be useful when generating tags on their own, for use with action frame body's.

Parameters
tagged_parameterA new tagged parameter struct
tag_numberTagged parameter number
tag_dataThe tag body
tag_lengthLength of the tag body
Returns
length of the created tag

Definition at line 81 of file tag.c.

◆ libwifi_dump_tag()

size_t libwifi_dump_tag ( struct libwifi_tagged_parameter tag,
unsigned char *  buf,
size_t  buf_len 
)

Dump a tagged parameter into a raw buffer, for use with other buffers or injection.

Parameters
tagA used tagged parameter struct
bufA buffer for the raw data
buf_lenLength of buf

Definition at line 103 of file tag.c.

◆ libwifi_free_tag()

void libwifi_free_tag ( struct libwifi_tagged_parameter tagged_parameter)

Free a tagged parameters body.

Parameters
tagged_parameterA used tagged parameter

Definition at line 99 of file tag.c.

◆ libwifi_get_tag_name()

char * libwifi_get_tag_name ( int  tag_number)

Get the name of a tagged parameter via a supplied tag number.

Parameters
tag_numberThe number of the tagged parameter to name
Returns
The name of the tag

Definition at line 149 of file tag.c.

◆ libwifi_quick_add_tag()

int libwifi_quick_add_tag ( struct libwifi_tagged_parameters tagged_parameters,
int  tag_number,
const unsigned char *  tag_data,
size_t  tag_length 
)

Add a tagged parameter via tag number and data to a management frame.

Parameters
tagged_parametersA management frame's tagged parameters
tag_numberTagged parameter to add
tag_dataData to copy into new tag
tag_lengthLength of the new tag
Returns
0 on success, negative number on error

Definition at line 118 of file tag.c.

◆ libwifi_remove_tag()

int libwifi_remove_tag ( struct libwifi_tagged_parameters tagged_parameters,
int  tag_number 
)

Remove a tagged parameter from a list of frame tagged parameters.

Parameters
tagged_parametersA management frame's tagged parameters
tag_numberNumber of the tag to remove

Definition at line 55 of file tag.c.