Class: PacketGen::Header::OSPFv2::Hello

Inherits:
Base show all
Defined in:
lib/packetgen/header/ospfv2/hello.rb

Overview

This class handles OSPFv2 HELLO packets payload. The HELLO 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Network Mask                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         HelloInterval         |    Options    |    Rtr Pri    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     RouterDeadInterval                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      Designated Router                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   Backup Designated Router                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          Neighbor                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                              ...                              |

A HELLO payload consists of:

Create a HELLO payload

# standalone
hello = PacketGen::Header::OSPFv2::Hello.new
# in a packet
pkt = PacketGen.gen('IP', src: source_ip).add('OSPFv2').add('OSPFv2::Hello')
# make IP header correct for OSPF
pkt.ospfize
# access to Hello payload
pkt.ospfv2_hello    # => PacketGen::Header::OSPFv2::Hello

HELLO attributes

hello.network_mask = '255.255.255.0'
hello.hello_interval = 10
hello.options = 0
hello.priority = 1
hello.dead_interval = 300
hello.designated_router = '10.0.0.1'
hello.backup_designated_router = '0.0.0.0'
# set neighbors identifiers
hello.neighbors << '10.0.1.1'
hello.neighbors << '10.0.2.1'

Author:

  • Sylvain Daubert

Since:

  • 2.5.0

Instance Attribute Summary collapse

Method Summary

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

#backup_designated_routerString

The identity of the Backup Designated Router for this network, in the view of the sending router.

Returns:

  • (String)


93
# File 'lib/packetgen/header/ospfv2/hello.rb', line 93

define_field :backup_designated_router, IP::Addr

#dc_optBoolean

This bit describes the router’s handling of demand circuits.

Returns:

  • (Boolean)


73
# File 'lib/packetgen/header/ospfv2/hello.rb', line 73

OSPFv2.define_options(self)

#dead_intervalInteger

The number of seconds before declaring a silent router down.

Returns:

  • (Integer)


83
# File 'lib/packetgen/header/ospfv2/hello.rb', line 83

define_field :dead_interval, Types::Int32

#designated_routerString

The identity of the Designated Router for this network, in the view of the sending router.

Returns:

  • (String)


88
# File 'lib/packetgen/header/ospfv2/hello.rb', line 88

define_field :designated_router, IP::Addr

#dn_optBoolean

Returns:

  • (Boolean)


73
# File 'lib/packetgen/header/ospfv2/hello.rb', line 73

OSPFv2.define_options(self)

#e_optBoolean

This bit describes the way AS-external-LSAs are flooded.

Returns:

  • (Boolean)


73
# File 'lib/packetgen/header/ospfv2/hello.rb', line 73

OSPFv2.define_options(self)

#hello_intervalInteger

The number of seconds between this router’s Hello packets.

Returns:

  • (Integer)


70
# File 'lib/packetgen/header/ospfv2/hello.rb', line 70

define_field :hello_interval, Types::Int16

#l_optBoolean

This specifies if a LLS Data block is present.

Returns:

  • (Boolean)


73
# File 'lib/packetgen/header/ospfv2/hello.rb', line 73

OSPFv2.define_options(self)

#mc_optBoolean

This bit describes whether IP multicast datagrams are forwarded.

Returns:

  • (Boolean)


73
# File 'lib/packetgen/header/ospfv2/hello.rb', line 73

OSPFv2.define_options(self)

#mt_optBoolean

Returns:

  • (Boolean)


73
# File 'lib/packetgen/header/ospfv2/hello.rb', line 73

OSPFv2.define_options(self)

#n_optBoolean

This bit specifies if NSSA is supported.

Returns:

  • (Boolean)


73
# File 'lib/packetgen/header/ospfv2/hello.rb', line 73

OSPFv2.define_options(self)

#neighborsIP::ArrayOfAddr

Array of neighbors

Returns:



97
# File 'lib/packetgen/header/ospfv2/hello.rb', line 97

define_field :neighbors, IP::ArrayOfAddr

#network_maskString

The network mask associated with this interface.

Returns:

  • (String)


66
# File 'lib/packetgen/header/ospfv2/hello.rb', line 66

define_field :network_mask, IP::Addr

#o_optBoolean

Returns:

  • (Boolean)


73
# File 'lib/packetgen/header/ospfv2/hello.rb', line 73

OSPFv2.define_options(self)

#optionsInteger

8-bit options field. Handle #mt_opt, #e_opt, #mc_opt, #n_opt, #l_opt, #dc_opt, #o_opt and #dn_opt.

Returns:

  • (Integer)


73
# File 'lib/packetgen/header/ospfv2/hello.rb', line 73

OSPFv2.define_options(self)

#priorityInteger

This router’s Router Priority. Used in (Backup) Designated Router election.

Returns:

  • (Integer)


79
# File 'lib/packetgen/header/ospfv2/hello.rb', line 79

define_field :priority, Types::Int8