Class: PacketGen::Plugin::IKE::IDi

Inherits:
Payload
  • Object
show all
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:

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

Author:

  • Sylvain Daubert

Direct Known Subclasses

IDr

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

Attributes inherited from Payload

#content, #critical, #flags, #hreserved, #length, #next

Instance Method Summary collapse

Methods inherited from Payload

#calc_length, #initialize, protocol_name

Constructor Details

This class inherits a constructor from PacketGen::Plugin::IKE::Payload

Instance Attribute Details

#reservedInteger

24-bit reserved field

Returns:

  • (Integer)


60
# File 'lib/packetgen/plugin/ike/id.rb', line 60

define_field_before :content, :reserved, PacketGen::Types::Int24

#typeInteger (readonly)

8-bit ID type

Returns:

  • (Integer)


56
# File 'lib/packetgen/plugin/ike/id.rb', line 56

define_field_before :content, :type, PacketGen::Types::Int8Enum, enum: TYPES

Instance Method Details

#human_contentString

Get human readable content, from #type

Returns:

  • (String)


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_typeString

Get ID type name

Returns:

  • (String)


64
65
66
# File 'lib/packetgen/plugin/ike/id.rb', line 64

def human_type
  self[:type].to_human
end