libtins  4.0
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
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. More...
 
NamespaceType current_namespace () const
 
uint32_t current_namespace_index () const
 Gets a 0 index based namespace index. More...
 
RadioTap::PresentFlags current_field () const
 
RadioTap::option current_option ()
 
const uint8_t * current_option_ptr () const
 
bool advance_field ()
 Advances to the next option. More...
 
bool advance_namespace ()
 Advances to the next namespace. More...
 
RadioTap::PresentFlags namespace_flags () const
 
bool skip_to_field (RadioTap::PresentFlags flag)
 Skips all fields until the provided one is found. More...
 
bool has_fields () const
 
bool has_field (RadioTap::PresentFlags flag) const
 Indicates whether the provided field is set. More...
 

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

Represents the RadioTap namespace currently being parsed

Constructor & Destructor Documentation

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

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)
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)
RadioTap::PresentFlags Tins::Utils::RadioTapParser::current_field ( ) const

Gets the current field being parsed

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

Gets the current namespace being parsed

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

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

Gets the option the parsed is currently pointing at

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

Gets the pointer at which the current option is located

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

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

Indicates whether this RadioTap options buffer contains any fields set

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

Gets the current namespace's flags

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

const uint32_t Tins::Utils::RadioTapParser::MAX_RADIOTAP_FIELD
static
Initial value:
= sizeof(RADIOTAP_METADATA) /
sizeof(FieldMetadata) + 1

Represents the maximum bit we have information for

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: