libtins 4.5
Loading...
Searching...
No Matches
Tins::Utils::RadioTapParser Class Reference

Allows parsing RadioTap options. More...

#include <radiotap_parser.h>

Classes

struct  FieldMetadata
 

Public Types

enum  NamespaceType { RADIOTAP_NS , VENDOR_NS , UNKNOWN_NS }
 

Public Member Functions

 RadioTapParser (const std::vector< uint8_t > &buffer)
 Constructs a RadioTap parser around a payload.
 
NamespaceType current_namespace () const
 
uint32_t current_namespace_index () const
 Gets a 0 index based namespace index.
 
RadioTap::PresentFlags current_field () const
 
RadioTap::option current_option ()
 
const uint8_t * current_option_ptr () const
 Gets the pointer at which the current option is located.
 
bool advance_field ()
 Advances to the next option.
 
bool advance_namespace ()
 Advances to the next namespace.
 
RadioTap::PresentFlags namespace_flags () const
 
bool skip_to_field (RadioTap::PresentFlags flag)
 Skips all fields until the provided one is found.
 
bool has_fields () const
 
bool has_field (RadioTap::PresentFlags flag) const
 Indicates whether the provided field is set.
 

Static Public Attributes

static const FieldMetadata RADIOTAP_METADATA []
 
static const uint32_t MAX_RADIOTAP_FIELD
 

Detailed Description

Allows parsing RadioTap options.

RadioTap is a somehow tricky protocol to be parsed, as it has ordered flags, alignment between options, etc. This class allows parsing options in a RadioTap header without much trouble.

Member Enumeration Documentation

◆ NamespaceType

Represents the RadioTap namespace currently being parsed

Constructor & Destructor Documentation

◆ RadioTapParser()

Tins::Utils::RadioTapParser::RadioTapParser ( const std::vector< uint8_t > & buffer)

Constructs a RadioTap parser around a payload.

Note that the payload is not copied, hence it must be kept in scope while the parser is still being used.

The buffer should contain an entire RadioTap header, with optionally extra data at the end, which will be ignored.

Parameters
bufferThe buffer to be parsed

Member Function Documentation

◆ advance_field()

bool Tins::Utils::RadioTapParser::advance_field ( )

Advances to the next option.

If there's a namespace change, this will handle that as well.

Returns
true iff advancing was successfull (e.g. false if we reached the end of the header)

◆ advance_namespace()

bool Tins::Utils::RadioTapParser::advance_namespace ( )

Advances to the next namespace.

Returns
true iff advancing was successfull (e.g. false if we're currently in the last namespace)

◆ current_field()

RadioTap::PresentFlags Tins::Utils::RadioTapParser::current_field ( ) const

Gets the current field being parsed

◆ current_namespace()

RadioTapParser::NamespaceType Tins::Utils::RadioTapParser::current_namespace ( ) const

Gets the current namespace being parsed

◆ current_namespace_index()

uint32_t Tins::Utils::RadioTapParser::current_namespace_index ( ) const

Gets a 0 index based namespace index.

This index will be incremented every time a new namespace is found

◆ current_option()

RadioTap::option Tins::Utils::RadioTapParser::current_option ( )

Gets the option the parsed is currently pointing at

◆ current_option_ptr()

const uint8_t * Tins::Utils::RadioTapParser::current_option_ptr ( ) const

Gets the pointer at which the current option is located.

A past-the-end pointer may be returned in case of malformed input or end of data. Its validity must be checked (e.g. using RadioTapParser::has_fields) before dereference.

◆ has_field()

bool Tins::Utils::RadioTapParser::has_field ( RadioTap::PresentFlags flag) const

Indicates whether the provided field is set.

This will look the field up in all flag sets and not just the current one

◆ has_fields()

bool Tins::Utils::RadioTapParser::has_fields ( ) const

Indicates whether this RadioTap options buffer contains any fields set

◆ namespace_flags()

RadioTap::PresentFlags Tins::Utils::RadioTapParser::namespace_flags ( ) const

Gets the current namespace's flags

◆ skip_to_field()

bool Tins::Utils::RadioTapParser::skip_to_field ( RadioTap::PresentFlags flag)

Skips all fields until the provided one is found.

This will effectively move the current option pointer until the field is found or the end of the options list is reached

Returns
true iff the field was foudn

Member Data Documentation

◆ MAX_RADIOTAP_FIELD

const uint32_t Tins::Utils::RadioTapParser::MAX_RADIOTAP_FIELD
static
Initial value:
= sizeof(RADIOTAP_METADATA) /
sizeof(FieldMetadata)
static const FieldMetadata RADIOTAP_METADATA[]
Definition radiotap_parser.h:74

Represents the maximum bit we have information for

◆ RADIOTAP_METADATA

const RadioTapParser::FieldMetadata Tins::Utils::RadioTapParser::RADIOTAP_METADATA
static
Initial value:
= {
{ 8, 8 },
{ 1, 1 },
{ 1, 1 },
{ 4, 2 },
{ 2, 2 },
{ 1, 1 },
{ 1, 1 },
{ 2, 2 },
{ 2, 2 },
{ 2, 2 },
{ 1, 1 },
{ 1, 1 },
{ 1, 1 },
{ 1, 1 },
{ 2, 2 },
{ 2, 2 },
{ 1, 1 },
{ 1, 1 },
{ 8, 4 },
{ 3, 1 },
{ 8, 4 },
{ 12, 2 }
}

Contains metadata for each data field in RadioTap


The documentation for this class was generated from the following files: