Class: PacketGen::Plugin::IKE::IDi
- Defined in:
- lib/packetgen/plugin/ike/id.rb
Overview
This class handles Identification - Initiator payloads, denoted IDi (see RFC 7296, §3.5).
A ID payload consists of the IKE generic payload Plugin (see Payload) and some specific fields:
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 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ID Type | RESERVED |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
~ Identification Data ~
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
These specific fields are:
-
#type (ID type),
-
and Payload#content (Identification Data).
Create a IDi payload
# Create a IKE packet with a IDi payload
pkt = PacketGen.gen('IP').add('UDP').add('IKE').add('IKE::IDi', type: 'FQDN')
pkt.ike_idi.content.read 'fqdn.example.org'
pkt.calc_length
Direct Known Subclasses
Constant Summary collapse
- PAYLOAD_TYPE =
Payload type number
35
- TYPES =
{ 'IPV4_ADDR' => 1, 'FQDN' => 2, 'RFC822_ADDR' => 3, 'IPV6_ADDR' => 5, 'DER_ASN1_DN' => 9, 'DER_ASN1_GN' => 10, 'KEY_ID' => 11 }.freeze
Instance Attribute Summary collapse
-
#reserved ⇒ Integer
24-bit reserved field.
-
#type ⇒ Integer
readonly
8-bit ID type.
Attributes inherited from Payload
#content, #critical, #flags, #hreserved, #length, #next
Instance Method Summary collapse
-
#human_content ⇒ String
Get human readable content, from #type.
-
#human_type ⇒ String
Get ID type name.
Methods inherited from Payload
#calc_length, #initialize, protocol_name
Constructor Details
This class inherits a constructor from PacketGen::Plugin::IKE::Payload
Instance Attribute Details
#reserved ⇒ Integer
24-bit reserved field
60 |
# File 'lib/packetgen/plugin/ike/id.rb', line 60 define_field_before :content, :reserved, PacketGen::Types::Int24 |
Instance Method Details
#human_content ⇒ String
Get human readable content, from #type
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/packetgen/plugin/ike/id.rb', line 70 def human_content case type when TYPES['IPV4_ADDR'], TYPES['IPV4_ADDR'] IPAddr.ntop(content) when TYPES['DER_ASN1_DN'], TYPES['DER_ASN1_GN'] OpenSSL::X509::Name.new(content).to_s else content.inspect end end |
#human_type ⇒ String
Get ID type name
64 65 66 |
# File 'lib/packetgen/plugin/ike/id.rb', line 64 def human_type self[:type].to_human end |