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)


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

define_field :body, Types::String

#lengthInteger

Returns 16-bit RadioTap header length.

Returns:

  • (Integer)

    16-bit RadioTap header length



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

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

#padInteger

Returns 8-bit pad.

Returns:

  • (Integer)

    8-bit pad



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

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

#present_flagsInteger

Returns 32-bit integer.

Returns:

  • (Integer)

    32-bit integer



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

define_field :present_flags, Types::Int32le

#radio_fieldsType::String

Returns concatenation of RadioTap fields.

Returns:

  • (Type::String)

    concatenation of RadioTap fields



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

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



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

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

Instance Method Details

#calc_lengthInteger

Calculate header length

Returns:

  • (Integer)

    calculated length

Since:

  • 2.1.3



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

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



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

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



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

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