Class: PacketGen::Header::IKE::TSi
- Inherits:
-
Payload
- Object
- Types::Fields
- Base
- Payload
- PacketGen::Header::IKE::TSi
- Defined in:
- lib/packetgen/header/ike/ts.rb
Overview
This class handles Traffic Selector - Initiator payloads, denoted TSi.
A TSi 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 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Number of TSs | RESERVED |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
~ <Traffic Selectors> ~
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
These specific fields are:
-
and #traffic_selectors.
Create a TSi payload
# Create a IKE packet with a TSi payload
pkt = PacketGen.gen('IP').add('UDP').add('IKE').add('IKE::TSi')
# add a traffic selector to this payload
pkt.ike_tsi.traffic_selectors << { protocol: 'tcp', ports: 1..1024, start_addr: '20.0.0.1', end_addr: '21.255.255.254' }
# add another traffic selector (IPv6, all protocols)
pkt.ike_tsi.traffic_selectors << { start_addr: '2001::1', end_addr: '200a:ffff:ffff:ffff:ffff:ffff:ffff:ffff' }
Direct Known Subclasses
Constant Summary collapse
- PAYLOAD_TYPE =
Payload type number
44
Instance Attribute Summary collapse
-
#num_ts ⇒ Integer
8-bit Number of TSs.
-
#rsv ⇒ Integer
24-bit RESERVED field.
-
#traffic_selectors ⇒ TrafficSelectors
(also: #selectors)
Set of TrafficSelector.
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
#num_ts ⇒ Integer
8-bit Number of TSs
228 |
# File 'lib/packetgen/header/ike/ts.rb', line 228 define_field_before :body, :num_ts, Types::Int8 |
#rsv ⇒ Integer
24-bit RESERVED field
232 |
# File 'lib/packetgen/header/ike/ts.rb', line 232 define_field_before :body, :rsv, Types::Int24 |
#traffic_selectors ⇒ TrafficSelectors Also known as: selectors
237 238 |
# File 'lib/packetgen/header/ike/ts.rb', line 237 define_field_before :body, :traffic_selectors, TrafficSelectors, builder: ->(h, t) { t.new(counter: h[:num_ts]) } |
Instance Method Details
#calc_length ⇒ Integer
Compute length and set Payload#length field
255 256 257 258 |
# File 'lib/packetgen/header/ike/ts.rb', line 255 def calc_length selectors.each(&:calc_length) super end |
#read(str) ⇒ self
Populate object from a string
244 245 246 247 248 249 250 251 |
# File 'lib/packetgen/header/ike/ts.rb', line 244 def read(str) super(str[0, 8]) hlen = self.class.new.sz tslen = length - hlen selectors.read str[hlen, tslen] body.read str[hlen + tslen..-1] self end |