Class: PacketGen::Header::IKE::IDi
- Inherits:
-
Payload
- Object
- Types::Fields
- Base
- Payload
- PacketGen::Header::IKE::IDi
- Defined in:
- lib/packetgen/header/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 header (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
Attributes inherited from Base
Instance Method Summary collapse
-
#human_content ⇒ String
Get human readable content, from #type.
-
#human_type ⇒ String
Get ID type name.
Methods inherited from Payload
#base_read, #calc_length, #initialize, #read
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?, #read, 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
#reserved ⇒ Integer
24-bit reserved field
60 |
# File 'lib/packetgen/header/ike/id.rb', line 60 define_field_before :content, :reserved, Types::Int24 |
#type ⇒ Integer (readonly)
8-bit ID type
56 |
# File 'lib/packetgen/header/ike/id.rb', line 56 define_field_before :content, :type, Types::Int8Enum, enum: TYPES |
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/header/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/header/ike/id.rb', line 64 def human_type self[:type].to_human end |