Class: PacketGen::Header::PPI

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

Overview

PPI (Per-Packet Information) packet

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

#alignBoolean

Returns align flag from #flags attribute.

Returns:

  • (Boolean)

    align flag from #flags attribute



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

define_bit_fields_on :flags, :reserved, 7, :align

#bodyType::String

Returns:

  • (Type::String)


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

define_field :body, Types::String

#dltInteger

Returns 32-bit PPI data link type.

Returns:

  • (Integer)

    32-bit PPI data link type



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

define_field :dlt, Types::Int32le

#flagsInteger

Returns 8-bit PPI flags.

Returns:

  • (Integer)

    8-bit PPI flags



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

define_field :flags, Types::Int8

#lengthInteger

Returns 16-bit PPI header length.

Returns:

  • (Integer)

    16-bit PPI header length



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

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

#ppi_fieldsType::String

Returns concatenation of PPI fields.

Returns:

  • (Type::String)

    concatenation of PPI fields



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

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

#versionInteger

Returns 8-bit PPI version.

Returns:

  • (Integer)

    8-bit PPI version



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

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

Instance Method Details

#calc_lengthInteger

Calculate header length

Returns:

  • (Integer)

    calculated length

Since:

  • 2.1.3



49
50
51
# File 'lib/packetgen/header/dot11.rb', line 49

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

#parse?Boolean

Check version field

Returns:

  • (Boolean)

See Also:

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

Since:

  • 1.4.0



42
43
44
# File 'lib/packetgen/header/dot11.rb', line 42

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

#to_w(iface) ⇒ void

This method returns an undefined value.

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

Parameters:

  • iface (String)

    interface name

Since:

  • 1.4.0



56
57
58
# File 'lib/packetgen/header/dot11.rb', line 56

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