Class: PacketGen::Header::Dot1x
- Inherits:
-
Base
- Object
- Types::Fields
- Base
- PacketGen::Header::Dot1x
- Defined in:
- lib/packetgen/header/dot1x.rb
Overview
IEEE 802.1X / EAPOL
A IEEE 802.1X header consists of:
-
a #version (Types::Int8),
-
a packet #type (Types::Int8),
-
a #length (Types::Int16),
-
and a body (a Types::String or another Header class).
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'
Constant Summary collapse
- ETHERTYPE =
IEEE 802.1x Ether type
0x888e
- TYPES =
IEEE 802.1X packet types
{ 'EAP Packet' => 0, 'Start' => 1, 'Logoff' => 2, 'Key' => 3, 'Encap-ASF-Alert' => 4 }.freeze
Instance Attribute Summary collapse
- #body ⇒ Types::String, Header::Base
-
#length ⇒ Integer
16-bit body length.
-
#type ⇒ Integer
8-bit Packet Type.
-
#version ⇒ Integer
8-bit Protocol Version.
Instance Method Summary collapse
-
#calc_length ⇒ Integer
Calculate and set body length.
-
#human_type ⇒ String
Get human readable type.
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
#body ⇒ Types::String, Header::Base
49 |
# File 'lib/packetgen/header/dot1x.rb', line 49 define_field :body, Types::String, builder: ->(h, t) { t.new(length_from: h[:length]) } |
#length ⇒ Integer
Returns 16-bit body length.
46 |
# File 'lib/packetgen/header/dot1x.rb', line 46 define_field :length, Types::Int16 |
Instance Method Details
#calc_length ⇒ Integer
Calculate and set body length
60 61 62 |
# File 'lib/packetgen/header/dot1x.rb', line 60 def calc_length Base.calculate_and_set_length self, header_in_size: false end |
#human_type ⇒ String
Get human readable type
53 54 55 |
# File 'lib/packetgen/header/dot1x.rb', line 53 def human_type self[:type].to_human end |