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


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

define_bit_fields_on :flags, :reserved, 7, :align

#bodyType::String

Returns:

  • (Type::String)

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

define_field :body, Types::String

#dltInteger

Returns 32-bit PPI data link type.

Returns:

  • (Integer)

    32-bit PPI data link type


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

define_field :dlt, Types::Int32le

#flagsInteger

Returns 8-bit PPI flags.

Returns:

  • (Integer)

    8-bit PPI flags


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

define_field :flags, Types::Int8

#lengthInteger

Returns 16-bit PPI header length.

Returns:

  • (Integer)

    16-bit PPI header length


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

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

#ppi_fieldsType::String

Returns concatenation of PPI fields.

Returns:

  • (Type::String)

    concatenation of PPI fields


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

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


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

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

Instance Method Details

#calc_lengthInteger

Calculate header length

Returns:

  • (Integer)

    calculated length

Since:

  • 2.1.3


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

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


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

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


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

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