Class: PacketGen::Header::IKE::Notify
- Inherits:
-
Payload
- Object
- Types::Fields
- Base
- Payload
- PacketGen::Header::IKE::Notify
- Defined in:
- lib/packetgen/header/ike/notify.rb
Overview
This class handles Notify payloads, as defined in RFC 7296 §3.10.
A Notify payload contains a 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 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Protocol ID | SPI Size | Notify Message Type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
~ Security Parameter Index (SPI) ~
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
~ Notification Data ~
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
These specific fields are:
-
#protocol (type Types::Int8),
-
#spi_size (type Types::Int8),
-
#message_type (type Types::Int16),
-
#spi (type Types::String),
-
Payload#content (type Types::String).
Create a Notify payload
# Create a IKE packet with a Notify payload
pkt = PacketGen.gen('IP').add('UDP').add('IKE').add('IKE::Notify', protocol: 'IKE', type: 'INVALID_SYNTAX')
pkt.ike_notify.spi # => ""
pkt.ike_notify.content # => ""
pkt.calc_length
Create a Notify payload with a SPI
# Create a IKE packet with a Notify payload
pkt = PacketGen.gen('IP').add('UDP').add('IKE').add('IKE::Notify', protocol: 'ESP', spi_size: 4, type: 'INVALID_SYNTAX')
pkt.ike_notify.spi.read PacketGen::Types::Int32.new(0x12345678).to_s
pkt.calc_length
Constant Summary collapse
- PAYLOAD_TYPE =
Payload type number
41- TYPE_UNSUPPORTED_CRITICAL_PAYLOAD =
Unsupported critical payload
1- TYPE_INVALID_IKE_SPI =
Invalid IKE SPI
4- TYPE_INVALID_MAJOR_VERSION =
Invalid major version
5- TYPE_INVALID_SYNTAX =
Invalid syntax
7- TYPE_INVALID_MESSAGE_ID =
Invalid message ID
9- TYPE_INVALID_SPI =
Invalid SPI
11- TYPE_NO_PROPOSAL_CHOSEN =
No proposal chosen (none of the proposed crypto suites was acceptable)
14- TYPE_INVALID_KE_PAYLOAD =
Invalid KE payload
17- TYPE_AUTHENTICATION_FAILED =
Authentication failed
24- TYPE_SINGLE_PAIR_REQUIRED =
Single pair required
34- TYPE_NO_ADDITIONAL_SAS =
No additional SAs
35- TYPE_INTERNAL_ADDRESS_FAILURE =
Internal address failture
36- TYPE_FAILED_CP_REQUIRED =
Failed CP required
37- TYPE_TS_UNACCEPTABLE =
traffic selectors unacceptable
38- TYPE_INVALID_SELECTORS =
invalid selectors
39- TYPE_TEMPORARY_FAILURE =
Temporary failure
43- TYPE_CHILD_SA_NOT_FOUND =
Child SA not found
44- TYPE_INITIAL_CONTACT =
Initial contact
16384- TYPE_SET_WINDOW_SIZE =
Set window size
16385- TYPE_ADDITIONAL_TS_POSSIBLE =
Additional traffic selector possible
16386- TYPE_IPCOMP_SUPPORTED =
IPcomp supported
16387- TYPE_NAT_DETECTION_SOURCE_IP =
NAT detection source IP
16388- TYPE_NAT_DETECTION_DESTINATION_IP =
NAT detection destination IP
16389- TYPE_COOKIE =
Cookie
16390- TYPE_USE_TRANSPORT_MODE =
Use transport mode (tunnel mode is default)
16391- TYPE_HTTP_CERT_LOOKUP_SUPPORTED =
HTTP certificate look up supported
16392- TYPE_REKEY_SA =
Rekey SA
16393- TYPE_ESP_TFC_PADDING_NOT_SUPPORTED =
ESP TFC paddin not supported
16394- TYPE_NON_FIRST_FRAGMENTS_ALSO =
Non-first fragment also
16395
Instance Attribute Summary collapse
-
#message_type ⇒ Integer
(also: #type)
16-bit notify message type.
-
#protocol ⇒ Integer
8-bit protocol ID.
-
#spi ⇒ String
the sending entity’s SPI.
-
#spi_size ⇒ Integer
8-bit SPI size.
Attributes inherited from Payload
#content, #critical, #flags, #hreserved, #length, #next
Attributes inherited from Base
Instance Method Summary collapse
-
#human_message_type ⇒ String
(also: #human_type)
Get message type name.
-
#human_protocol ⇒ String
Get protocol name.
-
#initialize(options = {}) ⇒ Notify
constructor
A new instance of Notify.
- #inspect ⇒ String
Methods inherited from Payload
#base_read, #calc_length, #read
Methods inherited from Base
bind_header, #header_id, inherited, #ip_header, known_headers, #method_name, #parse?, protocol_name, #protocol_name
Methods inherited from Types::Fields
#[], #[]=, #body=, define_bit_fields_on, define_field, define_field_after, define_field_before, delete_field, #fields, #force_binary, inherited, #is_optional?, #is_present?, #optional_fields, #read, #sz, #to_h, #to_s
Constructor Details
#initialize(options = {}) ⇒ Notify
Returns a new instance of Notify.
140 141 142 143 144 145 146 147 148 |
# File 'lib/packetgen/header/ike/notify.rb', line 140 def initialize(={}) if [:spi] and [:spi_size].nil? [:spi_size] = [:spi].size end super self.protocol = [:protocol] if [:protocol] self. = [:message_type] if [:message_type] self.type = [:type] if [:type] end |
Instance Attribute Details
#message_type ⇒ Integer Also known as: type
16-bit notify message type. Specifies the type of notification message.
130 |
# File 'lib/packetgen/header/ike/notify.rb', line 130 define_field_before :content, :message_type, Types::Int16 |
#protocol ⇒ Integer
8-bit protocol ID. If this notification concerns an existing SA whose SPI is given in the SPI field, this field indicates the type of that SA. For notifications concerning Child SAs, this field MUST contain either (2) to indicate AH or (3) to indicate ESP. Of the notifications defined in this document, the SPI is included only with INVALID_SELECTORS, REKEY_SA, and CHILD_SA_NOT_FOUND. If the SPI field is empty, this field MUST be sent as zero and MUST be ignored on receipt.
118 |
# File 'lib/packetgen/header/ike/notify.rb', line 118 define_field_before :content, :protocol, Types::Int8 |
#spi ⇒ String
the sending entity’s SPI. When the #spi_size field is zero, this field is not present in the proposal.
135 136 |
# File 'lib/packetgen/header/ike/notify.rb', line 135 define_field_before :content, :spi, Types::String, builder: ->(t) { Types::String.new('', length_from: t[:spi_size]) } |
#spi_size ⇒ Integer
8-bit SPI size. Give size of SPI field. Length in octets of the SPI as defined by the IPsec protocol ID or zero if no SPI is applicable. For a notification concerning the IKE SA, the SPI Size MUST be zero and the field must be empty.Set to 0 for an initial IKE SA negotiation, as SPI is obtained from outer header.
126 |
# File 'lib/packetgen/header/ike/notify.rb', line 126 define_field_before :content, :spi_size, Types::Int8, default: 0 |
Instance Method Details
#human_message_type ⇒ String Also known as: human_type
Get message type name
192 193 194 195 196 197 |
# File 'lib/packetgen/header/ike/notify.rb', line 192 def name = self.class.constants.grep(/TYPE_/). select { |c| self.class.const_get(c) == type }. first || "type #{type}" name.to_s.sub(/TYPE_/, '') end |
#human_protocol ⇒ String
Get protocol name
183 184 185 186 187 188 |
# File 'lib/packetgen/header/ike/notify.rb', line 183 def human_protocol name = IKE.constants.grep(/PROTO/). select { |c| IKE.const_get(c) == protocol }. first || "proto #{protocol}" name.to_s.sub(/PROTO_/, '') end |
#inspect ⇒ String
201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/packetgen/header/ike/notify.rb', line 201 def inspect str = Inspect.dashed_line(self.class, 2) fields.each do |attr| next if attr == :body if i(protocol ).include? attr str << Inspect.shift_level(2) str << Inspect::FMT_ATTR % [self[attr].class.to_s.sub(/.*::/, ''), attr, send("human_#{attr}")] else str << Inspect.inspect_attribute(attr, self[attr], 2) end end str end |