Class: PacketGen::Header::IKE::SA
- Inherits:
-
Payload
- Object
- Types::Fields
- Base
- Payload
- PacketGen::Header::IKE::SA
- Defined in:
- lib/packetgen/header/ike/sa.rb
Overview
This class handles Security Assocation payloads, as defined in RFC 7296 §3.3.
A SA payload contains a generic payload header (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
Attributes inherited from Base
Instance Method Summary collapse
-
#calc_length ⇒ Integer
Compute length and set Payload#length field.
-
#read(str) ⇒ self
Populate object from a string.
Methods inherited from Payload
Methods inherited from Base
#added_to_packet, bind, bind_header, calculate_and_set_length, #header_id, inherited, #initialize, #ip_header, known_headers, #ll_header, #method_name, #parse?, #protocol_name, protocol_name
Methods inherited from Types::Fields
#[], #[]=, #bits_on, #body=, define_bit_fields_on, define_field, define_field_after, define_field_before, delete_field, #fields, fields, #force_binary, inherited, #initialize, #inspect, #is_optional?, #is_present?, #offset_of, #optional?, #optional_fields, #present?, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field
Constructor Details
This class inherits a constructor from PacketGen::Header::IKE::Payload
Instance Attribute Details
#proposals ⇒ SAProposals
Set of SA proposals
536 |
# File 'lib/packetgen/header/ike/sa.rb', line 536 define_field_before :body, :proposals, SAProposals |
Instance Method Details
#calc_length ⇒ Integer
Compute length and set Payload#length field
552 553 554 555 |
# File 'lib/packetgen/header/ike/sa.rb', line 552 def calc_length proposals.each(&:calc_length) super end |
#read(str) ⇒ self
Populate object from a string
541 542 543 544 545 546 547 548 |
# File 'lib/packetgen/header/ike/sa.rb', line 541 def read(str) super hlen = self.class.new.sz plen = length - hlen proposals.read str[hlen, plen] body.read str[hlen + plen..-1] self end |