Class: PacketGen::Header::RadioTap

Inherits:
Base show all
Defined in:
lib/packetgen/header/dot11.rb

Overview

Radiotap header (see www.radiotap.org/)

Author:

  • Sylvain Daubert

Since:

  • 1.4.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

bind, calculate_and_set_length, #header_id, inherited, #initialize, #ip_header, #ll_header

Methods included from PacketGen::Headerable

#added_to_packet, included, #method_name, #packet, #packet=, #protocol_name, #read

Methods inherited from Types::Fields

#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #initialize, #inspect, #offset_of, #optional?, #optional_fields, #present?, #read, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field

Constructor Details

This class inherits a constructor from PacketGen::Header::Base

Instance Attribute Details

#bodyType::String

Returns:

  • (Type::String)

82
# File 'lib/packetgen/header/dot11.rb', line 82

define_field :body, Types::String

#lengthInteger

Returns 16-bit RadioTap header length.

Returns:

  • (Integer)

    16-bit RadioTap header length


73
# File 'lib/packetgen/header/dot11.rb', line 73

define_field :length, Types::Int16le, default: 8

#padInteger

Returns 8-bit pad.

Returns:

  • (Integer)

    8-bit pad


70
# File 'lib/packetgen/header/dot11.rb', line 70

define_field :pad, Types::Int8, default: 0

#present_flagsInteger

Returns 32-bit integer.

Returns:

  • (Integer)

    32-bit integer


76
# File 'lib/packetgen/header/dot11.rb', line 76

define_field :present_flags, Types::Int32le

#radio_fieldsType::String

Returns concatenation of RadioTap fields.

Returns:

  • (Type::String)

    concatenation of RadioTap fields


79
# File 'lib/packetgen/header/dot11.rb', line 79

define_field :radio_fields, Types::String, builder: ->(h, t) { t.new(length_from: -> { h.length - 8 }) }

#versionInteger

Returns 8-bit version.

Returns:

  • (Integer)

    8-bit version


67
# File 'lib/packetgen/header/dot11.rb', line 67

define_field :version, Types::Int8, default: 0

Instance Method Details

#calc_lengthInteger

Calculate header length

Returns:

  • (Integer)

    calculated length

Since:

  • 2.1.3


93
94
95
# File 'lib/packetgen/header/dot11.rb', line 93

def calc_length
  self[:length].value = self.sz - self[:body].sz
end

#parse?Boolean

Check version field

Returns:

  • (Boolean)

See Also:

  • PacketGen::Header::RadioTap.[Base[Base#parse?]

Since:

  • 1.4.0


86
87
88
# File 'lib/packetgen/header/dot11.rb', line 86

def parse?
  version.zero? && (length >= 8)
end

#to_w(iface) ⇒ void

This method returns an undefined value.

send RadioTap packet on wire. Dot11 FCS trailer should be set.

Parameters:

  • iface (String)

    interface name

Since:

  • 1.4.0


100
101
102
# File 'lib/packetgen/header/dot11.rb', line 100

def to_w(iface)
  Inject.inject(iface: iface, data: self)
end