Class: PacketGen::Header::Dot1x

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

Overview

IEEE 802.1X / EAPOL

A IEEE 802.1X header consists of:

Create a Dot1x header

pkt1 = PacketGen.gen('Eth').add('Dot1x', type: 1)
pkt2 = PacketGen.gen('Eth').add('Dot1x')
pkt2.dot1x.type = 'EAP Packet'
pkt2.dot1x.body.read 'body'

Author:

  • Sylvain Daubert

Since:

  • 1.4.0

Constant Summary collapse

ETHERTYPE =

IEEE 802.1x Ether type

Since:

  • 1.4.0

0x888e
TYPES =

IEEE 802.1X packet types

Since:

  • 1.4.0

{
  'EAP Packet' => 0,
  'Start' => 1,
  'Logoff' => 2,
  'Key' => 3,
  'Encap-ASF-Alert' => 4
}.freeze

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=, #parse?, #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

#bodyTypes::String, Header::Base


48
# File 'lib/packetgen/header/dot1x.rb', line 48

define_field :body, Types::String, builder: ->(h, t) { t.new(length_from: h[:length]) }

#lengthInteger

Returns 16-bit body length.

Returns:

  • (Integer)

    16-bit body length


45
# File 'lib/packetgen/header/dot1x.rb', line 45

define_field :length, Types::Int16

#typeInteger

Returns 8-bit Packet Type.

Returns:

  • (Integer)

    8-bit Packet Type


42
# File 'lib/packetgen/header/dot1x.rb', line 42

define_field :type, Types::Int8Enum, enum: TYPES

#versionInteger

Returns 8-bit Protocol Version.

Returns:

  • (Integer)

    8-bit Protocol Version


39
# File 'lib/packetgen/header/dot1x.rb', line 39

define_field :version, Types::Int8, default: 1

Instance Method Details

#calc_lengthInteger

Calculate and set body length

Returns:

  • (Integer)

Since:

  • 2.1.4


59
60
61
# File 'lib/packetgen/header/dot1x.rb', line 59

def calc_length
  Base.calculate_and_set_length self, header_in_size: false
end

#human_typeString

Get human readable type

Returns:

  • (String)

Since:

  • 1.4.0


52
53
54
# File 'lib/packetgen/header/dot1x.rb', line 52

def human_type
  self[:type].to_human
end