Class: PacketGen::Plugin::IKE::SA
- Defined in:
- lib/packetgen/plugin/ike/sa.rb
Overview
This class handles Security Assocation payloads, as defined in RFC 7296 §3.3.
A SA payload contains a generic payload Plugin (see Payload) and a set of SAProposal (#proposals field, which is a SAProposals object):
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 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
~ <Proposals> ~
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Create a SA payload
# Create a IKE packet with a SA payload
pkt = PacketGen.gen('IP').add('UDP').add('IKE').add('IKE::SA')
# add a proposal. Protocol name is taken from SAProposal::PROTO_* constants
pkt.ike_sa.proposals << { num: 1, protocol: 'ESP' }
# add a transform to this proposal.
# type name is taken from Transform::TYPE_* constants.
# ID is taken from Transform::<TYPE>_* constants.
pkt.ike_sa.proposals.first.transforms << { type: 'ENCR', id: 'AES_CTR' }
# and finally, add an attribute to this transform (here, KEY_SIZE = 128 bits)
pkt.ike_sa.proposals[0].transforms[0].attributes << { type: 0x800e, value: 128 }
pkt.calc_length
Constant Summary collapse
- PAYLOAD_TYPE =
Payload type number
33
Instance Attribute Summary collapse
-
#proposals ⇒ SAProposals
Set of SA proposals.
Attributes inherited from Payload
#content, #critical, #flags, #hreserved, #length, #next
Instance Method Summary collapse
-
#calc_length ⇒ Integer
Compute length and set Payload#length field.
Methods inherited from Payload
Constructor Details
This class inherits a constructor from PacketGen::Plugin::IKE::Payload
Instance Attribute Details
#proposals ⇒ SAProposals
Set of SA proposals
545 |
# File 'lib/packetgen/plugin/ike/sa.rb', line 545 define_field_before :body, :proposals, SAProposals, builder: ->(h, t) { t.new(length_from: -> { h.length - h.offset_of(:proposals) }) } |
Instance Method Details
#calc_length ⇒ Integer
Compute length and set Payload#length field
549 550 551 552 |
# File 'lib/packetgen/plugin/ike/sa.rb', line 549 def calc_length proposals.each(&:calc_length) super end |