Class: PacketGen::Plugin::IKE::TSi

Inherits:
Payload
  • Object
show all
Defined in:
lib/packetgen/plugin/ike/ts.rb

Overview

This class handles Traffic Selector - Initiator payloads, denoted TSi.

A TSi 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        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Number of TSs |                 RESERVED                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
~                       <Traffic Selectors>                     ~
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

These specific fields are:

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' }

Author:

  • Sylvain Daubert

Direct Known Subclasses

TSr

Constant Summary collapse

PAYLOAD_TYPE =

Payload type number

44

Instance Attribute Summary collapse

Attributes inherited from Payload

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

Instance Method Summary collapse

Methods inherited from Payload

#initialize, protocol_name

Constructor Details

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

Instance Attribute Details

#num_tsInteger

8-bit Number of TSs

Returns:

  • (Integer)


231
# File 'lib/packetgen/plugin/ike/ts.rb', line 231

define_field_before :body, :num_ts, PacketGen::Types::Int8

#rsvInteger

24-bit RESERVED field

Returns:

  • (Integer)


235
# File 'lib/packetgen/plugin/ike/ts.rb', line 235

define_field_before :body, :rsv, PacketGen::Types::Int24

#traffic_selectorsTrafficSelectors Also known as: selectors

Returns:



240
241
# File 'lib/packetgen/plugin/ike/ts.rb', line 240

define_field_before :body, :traffic_selectors, TrafficSelectors,
builder: ->(h, t) { t.new(counter: h[:num_ts]) }

Instance Method Details

#calc_lengthInteger

Compute length and set Payload#length field

Returns:

  • (Integer)

    new length



246
247
248
249
# File 'lib/packetgen/plugin/ike/ts.rb', line 246

def calc_length
  selectors.each(&:calc_length)
  super
end