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.
56 57 58 59 60 61 62 63 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 56 def initialize(={}) super if [:content] self[:content] = BinStruct::String.new self[:content].read [:content] end calc_length unless [:length] end |
Instance Attribute Details
#content ⇒ String
Payload content. Depends on payload. Variable length.
51 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 51 define_attr :content, BinStruct::String, builder: ->(h, t) { t.new(length_from: -> { h.length - h.offset_of(:content) }) } |
#critical ⇒ Boolean
critical flag
43 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 43 define_bit_attr :flags, critical: 1, hreserved: 7 |
#flags ⇒ Integer
8-bit flags
43 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 43 define_bit_attr :flags, critical: 1, hreserved: 7 |
#hreserved ⇒ Integer
reserved part of #flags field
43 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 43 define_bit_attr :flags, critical: 1, hreserved: 7 |
#length ⇒ Integer
16-bit payload total length, including generic payload Plugin
47 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 47 define_attr :length, BinStruct::Int16 |
#next ⇒ Integer
8-bit next payload
33 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 33 define_attr :next, BinStruct::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
67 68 69 70 71 |
# File 'lib/packetgen/plugin/ike/payload.rb', line 67 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 |