libtins  4.0
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Tins::RadioTap Class Reference

Class that represents the IEEE 802.11 radio tap header. More...

#include <radiotap.h>

Inheritance diagram for Tins::RadioTap:
Tins::PDU

Classes

struct  mcs_type
 The type used to represent the MCS flags field. More...
 
struct  xchannel_type
 The type used to represent the XChannel field. More...
 

Public Types

enum  ChannelType {
  TURBO = 0x10, CCK = 0x20, OFDM = 0x40, TWO_GZ = 0x80,
  FIVE_GZ = 0x100, PASSIVE = 0x200, DYN_CCK_OFDM = 0x400, GFSK = 0x800
}
 Enumeration of the different channel type flags. More...
 
enum  PresentFlags {
  TSFT = 1 << 0, TSTF = 1 << 0, FLAGS = 1 << 1, RATE = 1 << 2,
  CHANNEL = 1 << 3, FHSS = 1 << 4, DBM_SIGNAL = 1 << 5, DBM_NOISE = 1 << 6,
  LOCK_QUALITY = 1 << 7, TX_ATTENUATION = 1 << 8, DB_TX_ATTENUATION = 1 << 9, DBM_TX_ATTENUATION = 1 << 10,
  ANTENNA = 1 << 11, DB_SIGNAL = 1 << 12, DB_NOISE = 1 << 13, RX_FLAGS = 1 << 14,
  TX_FLAGS = 1 << 15, DATA_RETRIES = 1 << 17, XCHANNEL = 1 << 18, CHANNEL_PLUS = 1 << 18,
  MCS = 1 << 19
}
 Flags used in the present field. More...
 
enum  FrameFlags {
  CFP = 1, PREAMBLE = 2, WEP = 4, FRAGMENTATION = 8,
  FCS = 16, PADDING = 32, FAILED_FCS = 64, SHORT_GI = 128
}
 Flags used in the RadioTap::flags() method.
 
typedef PDUOption< RadioTap::PresentFlags, RadioTapoption
 
typedef std::vector< uint8_t > options_payload_type
 
- Public Types inherited from Tins::PDU
enum  endian_type { BE, LE }
 
enum  PDUType {
  RAW, ETHERNET_II, IEEE802_3, DOT3 = IEEE802_3,
  RADIOTAP, DOT11, DOT11_ACK, DOT11_ASSOC_REQ,
  DOT11_ASSOC_RESP, DOT11_AUTH, DOT11_BEACON, DOT11_BLOCK_ACK,
  DOT11_BLOCK_ACK_REQ, DOT11_CF_END, DOT11_DATA, DOT11_CONTROL,
  DOT11_DEAUTH, DOT11_DIASSOC, DOT11_END_CF_ACK, DOT11_MANAGEMENT,
  DOT11_PROBE_REQ, DOT11_PROBE_RESP, DOT11_PS_POLL, DOT11_REASSOC_REQ,
  DOT11_REASSOC_RESP, DOT11_RTS, DOT11_QOS_DATA, LLC,
  SNAP, IP, ARP, TCP,
  UDP, ICMP, BOOTP, DHCP,
  EAPOL, RC4EAPOL, RSNEAPOL, DNS,
  LOOPBACK, IPv6, ICMPv6, SLL,
  DHCPv6, DOT1Q, PPPOE, STP,
  PPI, IPSEC_AH, IPSEC_ESP, PKTAP,
  MPLS, UNKNOWN = 999, USER_DEFINED_PDU = 1000
}
 Enum which identifies each type of PDU. More...
 
typedef byte_array serialization_type
 

Public Member Functions

 RadioTap ()
 Default constructor.
 
 RadioTap (const uint8_t *buffer, uint32_t total_sz)
 Constructs a RadioTap object from a buffer and adds all identifiable PDUs found in the buffer as children of this one. More...
 
void send (PacketSender &sender, const NetworkInterface &iface)
 
void version (uint8_t new_version)
 Setter for the version field. More...
 
void padding (uint8_t new_padding)
 Setter for the padding field. More...
 
void length (uint16_t new_length)
 Setter for the length field. More...
 
void tsft (uint64_t new_tsft)
 Setter for the TSFT field. More...
 
void flags (FrameFlags new_flags)
 Setter for the flags field. More...
 
void rate (uint8_t new_rate)
 Setter for the rate field. More...
 
void channel (uint16_t new_freq, uint16_t new_type)
 Setter for the channel frequency and type field. More...
 
void dbm_signal (int8_t new_dbm_signal)
 Setter for the dbm signal field. More...
 
void dbm_noise (int8_t new_dbm_noise)
 Setter for the dbm noise field. More...
 
void signal_quality (uint8_t new_signal_quality)
 Setter for the signal quality field. More...
 
void antenna (uint8_t new_antenna)
 Setter for the antenna field. More...
 
void db_signal (uint8_t new_db_signal)
 Setter for the db signal field. More...
 
void rx_flags (uint16_t new_rx_flag)
 Setter for the rx flag field. More...
 
void tx_flags (uint16_t new_tx_flag)
 Setter for the tx flag field. More...
 
void xchannel (xchannel_type new_xchannel)
 Setter for the xchannel field. More...
 
void data_retries (uint8_t new_data_retries)
 Setter for the data retries field. More...
 
void mcs (const mcs_type &new_mcs)
 Setter for the MCS field. More...
 
uint8_t version () const
 Getter for the version field. More...
 
uint8_t padding () const
 Getter for the padding field. More...
 
uint16_t length () const
 Getter for the length field. More...
 
uint64_t tsft () const
 Getter for the tsft field. More...
 
FrameFlags flags () const
 Getter for the flags field. More...
 
uint8_t rate () const
 Getter for the rate field. More...
 
uint16_t channel_freq () const
 Getter for the channel frequency field. More...
 
uint16_t channel_type () const
 Getter for the channel type field. More...
 
int8_t dbm_signal () const
 Getter for the dbm signal field. More...
 
int8_t dbm_noise () const
 Getter for the dbm noise field. More...
 
uint16_t signal_quality () const
 Getter for the signal quality field. More...
 
uint8_t antenna () const
 Getter for the antenna field. More...
 
uint8_t db_signal () const
 Getter for the db signal field. More...
 
xchannel_type xchannel () const
 Getter for the XChannel field. More...
 
uint8_t data_retries () const
 Getter for the data retries field. More...
 
uint16_t rx_flags () const
 Getter for the rx flags field. More...
 
uint16_t tx_flags () const
 Getter for the tx flags field. More...
 
mcs_type mcs () const
 Getter for the MCS field. More...
 
PresentFlags present () const
 Getter for the present bit fields. More...
 
bool matches_response (const uint8_t *ptr, uint32_t total_sz) const
 Check whether ptr points to a valid response for this PDU. More...
 
uint32_t header_size () const
 Returns the RadioTap frame's header length. More...
 
uint32_t trailer_size () const
 Returns the frame's trailer size. More...
 
void add_option (const option &opt)
 
const options_payload_typeoptions_payload () const
 Gets the options payload. More...
 
RadioTapclone () const
 
PDUType pdu_type () const
 Getter for the PDU's type. More...
 
- Public Member Functions inherited from Tins::PDU
 PDU ()
 Default constructor.
 
 PDU (PDU &&rhs) TINS_NOEXCEPT
 Move constructor. More...
 
PDUoperator= (PDU &&rhs) TINS_NOEXCEPT
 Move assignment operator. More...
 
virtual ~PDU ()
 PDU destructor. More...
 
uint32_t size () const
 The whole chain of PDU's size, including this one. More...
 
PDUinner_pdu () const
 Getter for the inner PDU. More...
 
PDUparent_pdu () const
 
PDUrelease_inner_pdu ()
 Releases the inner PDU. More...
 
void inner_pdu (PDU *next_pdu)
 Sets the child PDU. More...
 
void inner_pdu (const PDU &next_pdu)
 Sets the child PDU. More...
 
serialization_type serialize ()
 Serializes the whole chain of PDU's, including this one. More...
 
template<typename T >
T * find_pdu (PDUType type=T::pdu_flag)
 Finds and returns the first PDU that matches the given flag. More...
 
template<typename T >
const T * find_pdu (PDUType type=T::pdu_flag) const
 Finds and returns the first PDU that matches the given flag. More...
 
template<typename T >
T & rfind_pdu (PDUType type=T::pdu_flag)
 Finds and returns the first PDU that matches the given flag. More...
 
template<typename T >
const T & rfind_pdu (PDUType type=T::pdu_flag) const
 Finds and returns the first PDU that matches the given flag. More...
 
virtual PDUrecv_response (PacketSender &sender, const NetworkInterface &iface)
 Receives a matching response for this packet. More...
 
virtual bool matches_flag (PDUType flag) const
 Check whether this PDU matches the specified flag. More...
 

Public Attributes

TINS_BEGIN_PACK struct Tins::RadioTap::mcs_type TINS_END_PACK
 
TINS_BEGIN_PACK struct Tins::RadioTap::xchannel_type TINS_END_PACK
 

Static Public Attributes

static const PDU::PDUType pdu_flag = PDU::RADIOTAP
 This PDU's flag.
 
static const endian_type endianness = LE
 
- Static Public Attributes inherited from Tins::PDU
static const endian_type endianness = BE
 

Additional Inherited Members

- Protected Member Functions inherited from Tins::PDU
 PDU (const PDU &other)
 Copy constructor.
 
PDUoperator= (const PDU &other)
 Copy assignment operator.
 
void copy_inner_pdu (const PDU &pdu)
 Copy other PDU's inner PDU(if any). More...
 
virtual void prepare_for_serialize ()
 Prepares this PDU for serialization. More...
 
void serialize (uint8_t *buffer, uint32_t total_sz)
 Serializes this PDU and propagates this action to child PDUs. More...
 

Detailed Description

Class that represents the IEEE 802.11 radio tap header.

By default, RadioTap PDUs set the necesary fields to send an 802.11 PDU as its inner pdu, avoiding packet drops. As a consequence, the FCS-at-end flag is on, the channel is set to 1, TSFT is set to 0, dbm_signal is set to -50, and the rx_flag and antenna fields to 0.

Member Typedef Documentation

The type used to store RadioTap options

typedef std::vector<uint8_t> Tins::RadioTap::options_payload_type

The type used to store the options payload

Member Enumeration Documentation

Enumeration of the different channel type flags.

These channel type flags can be OR'd and set using the RadioTap::channel() method.

Flags used in the present field.

See also
RadioTap::present()
Enumerator
TSTF 

Deprecated (typo), use TSFT.

Constructor & Destructor Documentation

Tins::RadioTap::RadioTap ( const uint8_t *  buffer,
uint32_t  total_sz 
)

Constructs a RadioTap object from a buffer and adds all identifiable PDUs found in the buffer as children of this one.

If there is not enough size for a RadioTap header, a malformed_packet exception is thrown.

Parameters
bufferThe buffer from which this PDU will be constructed.
total_szThe total size of the buffer.

Member Function Documentation

void Tins::RadioTap::add_option ( const option opt)

Adds the given option

Parameters
optionThe option to be added.
void Tins::RadioTap::antenna ( uint8_t  new_antenna)

Setter for the antenna field.

Parameters
new_antennaThe antenna signal.
uint8_t Tins::RadioTap::antenna ( ) const

Getter for the antenna field.

Returns
The antenna field.
void Tins::RadioTap::channel ( uint16_t  new_freq,
uint16_t  new_type 
)

Setter for the channel frequency and type field.

Parameters
new_freqThe new channel frequency.
new_typeThe new channel type.
uint16_t Tins::RadioTap::channel_freq ( ) const

Getter for the channel frequency field.

Returns
The channel frequency field.
uint16_t Tins::RadioTap::channel_type ( ) const

Getter for the channel type field.

Returns
The channel type field.
RadioTap* Tins::RadioTap::clone ( ) const
inlinevirtual
See also
PDU::clone

Implements Tins::PDU.

void Tins::RadioTap::data_retries ( uint8_t  new_data_retries)

Setter for the data retries field.

Parameters
new_rx_flagThe data retries.
uint8_t Tins::RadioTap::data_retries ( ) const

Getter for the data retries field.

Returns
The data retries field.
void Tins::RadioTap::db_signal ( uint8_t  new_db_signal)

Setter for the db signal field.

Parameters
new_antennaThe db signal signal.
uint8_t Tins::RadioTap::db_signal ( ) const

Getter for the db signal field.

Returns
The db signal field.
void Tins::RadioTap::dbm_noise ( int8_t  new_dbm_noise)

Setter for the dbm noise field.

Parameters
new_dbm_noiseThe new dbm noise.
int8_t Tins::RadioTap::dbm_noise ( ) const

Getter for the dbm noise field.

Returns
The dbm noise field.
void Tins::RadioTap::dbm_signal ( int8_t  new_dbm_signal)

Setter for the dbm signal field.

Parameters
new_dbm_signalThe new dbm signal.
int8_t Tins::RadioTap::dbm_signal ( ) const

Getter for the dbm signal field.

Returns
The dbm signal field.
void Tins::RadioTap::flags ( FrameFlags  new_flags)

Setter for the flags field.

Parameters
new_flagsThe new flags.
RadioTap::FrameFlags Tins::RadioTap::flags ( ) const

Getter for the flags field.

Returns
The flags field.
uint32_t Tins::RadioTap::header_size ( ) const
virtual

Returns the RadioTap frame's header length.

Returns
An uint32_t with the header's size.
See also
PDU::header_size()

Implements Tins::PDU.

void Tins::RadioTap::length ( uint16_t  new_length)

Setter for the length field.

Parameters
new_lengthThe new length.
uint16_t Tins::RadioTap::length ( ) const

Getter for the length field.

Returns
The length field.
bool Tins::RadioTap::matches_response ( const uint8_t *  ptr,
uint32_t  total_sz 
) const
virtual

Check whether ptr points to a valid response for this PDU.

See also
PDU::matches_response
Parameters
ptrThe pointer to the buffer.
total_szThe size of the buffer.

Reimplemented from Tins::PDU.

void Tins::RadioTap::mcs ( const mcs_type new_mcs)

Setter for the MCS field.

Parameters
new_rx_flagThe MCS retries.
RadioTap::mcs_type Tins::RadioTap::mcs ( ) const

Getter for the MCS field.

Returns
The MCS field.
const RadioTap::options_payload_type & Tins::RadioTap::options_payload ( ) const

Gets the options payload.

Use Utils::RadioTapParser to iterate these options and extract fields manually, in case you want to have deeper access into the option types/values stored in a RadioTap frame.

void Tins::RadioTap::padding ( uint8_t  new_padding)

Setter for the padding field.

Parameters
new_paddingThe new padding.
uint8_t Tins::RadioTap::padding ( ) const

Getter for the padding field.

Returns
The padding field.
PDUType Tins::RadioTap::pdu_type ( ) const
inlinevirtual

Getter for the PDU's type.

See also
PDU::pdu_type

Implements Tins::PDU.

RadioTap::PresentFlags Tins::RadioTap::present ( ) const

Getter for the present bit fields.

Use this method and masks created from the values taken from the PresentFlags enum to find out which fields are set. Accessing non-initialized fields, the behaviour is undefined will be undefined. It is only safe to use the getter of a field if its corresponding bit flag is set in the present field.

void Tins::RadioTap::rate ( uint8_t  new_rate)

Setter for the rate field.

Parameters
new_rateThe new rate.
uint8_t Tins::RadioTap::rate ( ) const

Getter for the rate field.

Returns
The rate field.
void Tins::RadioTap::rx_flags ( uint16_t  new_rx_flag)

Setter for the rx flag field.

Parameters
new_rx_flagThe rx flags.
uint16_t Tins::RadioTap::rx_flags ( ) const

Getter for the rx flags field.

Returns
The rx flags field.
void Tins::RadioTap::send ( PacketSender sender,
const NetworkInterface iface 
)
virtual
See also
PDU::send()

Reimplemented from Tins::PDU.

void Tins::RadioTap::signal_quality ( uint8_t  new_signal_quality)

Setter for the signal quality field.

Parameters
new_antennaThe signal quality signal.
uint16_t Tins::RadioTap::signal_quality ( ) const

Getter for the signal quality field.

Returns
The signal quality field.
uint32_t Tins::RadioTap::trailer_size ( ) const
virtual

Returns the frame's trailer size.

Returns
The trailer's size.

Reimplemented from Tins::PDU.

void Tins::RadioTap::tsft ( uint64_t  new_tsft)

Setter for the TSFT field.

Parameters
new_tsftThe new TSFT
uint64_t Tins::RadioTap::tsft ( ) const

Getter for the tsft field.

Returns
The tsft field.
void Tins::RadioTap::tx_flags ( uint16_t  new_tx_flag)

Setter for the tx flag field.

Parameters
new_tx_flagThe tx flags.
uint16_t Tins::RadioTap::tx_flags ( ) const

Getter for the tx flags field.

Returns
The tx flags field.
void Tins::RadioTap::version ( uint8_t  new_version)

Setter for the version field.

Parameters
new_versionThe new version.
uint8_t Tins::RadioTap::version ( ) const

Getter for the version field.

Returns
The version field.
void Tins::RadioTap::xchannel ( xchannel_type  new_xchannel)

Setter for the xchannel field.

Parameters
new_xchannelThe xchannel field
RadioTap::xchannel_type Tins::RadioTap::xchannel ( ) const

Getter for the XChannel field.

Returns
The XChannel field.

Member Data Documentation

const endian_type Tins::RadioTap::endianness = LE
static

RadioTap is little endian


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