Class: PacketGen::Plugin::IKE::Payload
- Inherits:
-
Header::Base
- Object
- Header::Base
- PacketGen::Plugin::IKE::Payload
- Defined in:
- lib/packetgen/plugin/ike/payload.rb
Overview
PacketGen::Header::Base class for IKE payloads. This class may also be used for unknown payloads.
This class handles generic IKE payload Plugin:
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Payload |C| RESERVED | Payload Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
to which a #content field is added to handle content of unknown payload types.
Instance Attribute Summary collapse
-
#content ⇒ String
Payload content.
-
#critical ⇒ Boolean
critical flag.
-
#flags ⇒ Integer
8-bit flags.
-
#hreserved ⇒ Integer
reserved part of #flags field.
-
#length ⇒ Integer
16-bit payload total length, including generic payload Plugin.
-
#next ⇒ Integer
8-bit next payload.
Class Method Summary collapse
-
.protocol_name ⇒ String
Give protocol name.
Instance Method Summary collapse
-
#calc_length ⇒ Integer
Compute length and set #length field.
-
#initialize(options = {}) ⇒ Payload
constructor
A new instance of Payload.
Constructor Details
#initialize(options = {}) ⇒ Payload
Returns a new instance of Payload.
58 59 60 61 62 63 64 65 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 58 def initialize(={}) super if [:content] self[:content] = PacketGen::Types::String.new self[:content].read [:content] end calc_length unless [:length] end |
Instance Attribute Details
#content ⇒ String
Payload content. Depends on payload. Variable length.
45 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 45 define_field :content, PacketGen::Types::String, builder: ->(h, t) { t.new(length_from: -> { h.length - h.offset_of(:content) }) } |
#critical ⇒ Boolean
critical flag
56 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 56 define_bit_fields_on :flags, :critical, :hreserved, 7 |
#flags ⇒ Integer
8-bit flags
37 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 37 define_field :flags, PacketGen::Types::Int8 |
#hreserved ⇒ Integer
reserved part of #flags field
56 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 56 define_bit_fields_on :flags, :critical, :hreserved, 7 |
#length ⇒ Integer
16-bit payload total length, including generic payload Plugin
41 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 41 define_field :length, PacketGen::Types::Int16 |
#next ⇒ Integer
8-bit next payload
33 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 33 define_field :next, PacketGen::Types::Int8 |
Class Method Details
.protocol_name ⇒ String
Give protocol name
23 24 25 26 27 28 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 23 def self.protocol_name return @protocol_name if defined? @protocol_name basename = to_s.sub(/.*::/, '') @protocol_name = "IKE::#{basename}" end |
Instance Method Details
#calc_length ⇒ Integer
Compute length and set #length field
69 70 71 72 73 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 69 def calc_length # Here, #body is next payload, so body size should not be taken in # account (payload's real body is #content). self.length = sz - self[:body].sz end |