Class: PacketGen::Header::OSPFv3::LSUpdate

Inherits:
Base show all
Defined in:
lib/packetgen/header/ospfv3/ls_update.rb

Overview

This class handles OSPFv3 Link State Update packets payload. The LSU payload has the following format:

 0                   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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            # LSAs                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+-                                                            +-+
|                             LSAs                              |
+-                                                            +-+
|                              ...                              |

This paylod is implemented with two fields:

Create a LSUpdate payload

# standalone
lsu = PacketGen::Header::OSPFv3::LSUpdate.new
# in a packet
pkt = PacketGen.gen('IPv6', src: source_ip).add('OSPFv3').add('OSPFv3::LSUpdate')
# make IPv6 header correct for OSPF
pkt.ospfize
# access to LSUpdate payload
lsu = pkt.ospfv3_lsupdate    # => PacketGen::Header::OSPFv3::LSUpdate

Add LSAs to a LSUpdate payload

Adding LSAs with ArrayOfLSA#<< automagically update #lsas_count. To not update it, use ArrayOfLSA#push.

lsu.lsas << { type: 'Router', age: 40, link_state_id: '0.0.0.1', advertising_router: '1.1.1.1', sequence_number: 42 }
lsu.lsas_count     #=> 1
# add a link to Router LSA
lsu.lsas.first.links << { type: 1, metric: 10, interface_id: 1, neighbor_interface_id: 2, neighbor_router_id: '2.2.2.2'}

Author:

  • Sylvain Daubert

Since:

  • 2.5.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

bind, calculate_and_set_length, #header_id, inherited, #initialize, #ip_header, #ll_header

Methods included from PacketGen::Headerable

#added_to_packet, included, #method_name, #packet, #packet=, #parse?, #protocol_name, #read

Methods inherited from Types::Fields

#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #initialize, #inspect, #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::Base

Instance Attribute Details

#lsasArrayOfLSA

Array of LSAs

Returns:



54
55
# File 'lib/packetgen/header/ospfv3/ls_update.rb', line 54

define_field :lsas, ArrayOfLSA,
builder: ->(h, t) { t.new(counter: h[:lsas_count]) }

#lsas_countInteger

Count of LSAs included in this update

Returns:

  • (Integer)


50
# File 'lib/packetgen/header/ospfv3/ls_update.rb', line 50

define_field :lsas_count, Types::Int32

Instance Method Details

#calc_checksumvoid

This method returns an undefined value.

Calculate checksums of all LSAs

Since:

  • 2.5.0



59
60
61
# File 'lib/packetgen/header/ospfv3/ls_update.rb', line 59

def calc_checksum
  lsas.each(&:calc_checksum)
end

#calc_lengthObject

Calculate length of all LSAs

Since:

  • 2.5.0



64
65
66
# File 'lib/packetgen/header/ospfv3/ls_update.rb', line 64

def calc_length
  lsas.each(&:calc_length)
end