Class: PacketGen::Header::OSPFv3::Hello

Inherits:
Base
  • Object
show all
Defined in:
lib/packetgen/header/ospfv3/hello.rb

Overview

This class handles OSPFv3 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Interface ID                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Rtr Priority  |             Options                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|        HelloInterval          |       RouterDeadInterval      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   Designated Router ID                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                Backup Designated Router ID                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Neighbor ID                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        ...                                    |

A HELLO payload consists of:

Examples:

Create a HELLO payload

# standalone
hello = PacketGen::Header::OSPFv3::Hello.new
# in a packet
pkt = PacketGen.gen('IPv6').add('OSPFv3').add('OSPFv3::Hello')
# make IPv6 header correct for OSPF
pkt.ospfize
# access to Hello payload
pkt.ospfv3_hello.class    # => PacketGen::Header::OSPFv3::Hello

HELLO attributes

hello = PacketGen::Header::OSPFv3::Hello.new
hello.interface_id = 1
hello.priority = 1
# set options. Options may also be set one by one with #v6_opt, #e_opt,
# #n_opt, #r_opt and #dc_opt
hello.options = 0x33
hello.hello_interval = 10
hello.dead_interval = 300
hello.designated_router = '0.0.0.1'
hello.backup_designated_router = '0.0.0.2'
# set neighbors identifiers
hello.neighbors << '1.1.1.1'
hello.neighbors << '2.2.2.2'

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, #to_s

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)


94
# File 'lib/packetgen/header/ospfv3/hello.rb', line 94

define_attr :backup_designated_router, IP::Addr

#dc_optInteger

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

Returns:

  • (Integer)


76
# File 'lib/packetgen/header/ospfv3/hello.rb', line 76

OSPFv3.define_options(self)

#dead_intervalInteger

The number of seconds before declaring a silent router down.

Returns:

  • (Integer)


84
# File 'lib/packetgen/header/ospfv3/hello.rb', line 84

define_attr :dead_interval, BinStruct::Int16

#designated_routerString

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

Returns:

  • (String)


89
# File 'lib/packetgen/header/ospfv3/hello.rb', line 89

define_attr :designated_router, IP::Addr

#e_optInteger

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

Returns:

  • (Integer)


76
# File 'lib/packetgen/header/ospfv3/hello.rb', line 76

OSPFv3.define_options(self)

#hello_intervalInteger

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

Returns:

  • (Integer)


80
# File 'lib/packetgen/header/ospfv3/hello.rb', line 80

define_attr :hello_interval, BinStruct::Int16

#interface_idString

The network mask associated with this interface.

Returns:

  • (String)


69
# File 'lib/packetgen/header/ospfv3/hello.rb', line 69

define_attr :interface_id, BinStruct::Int32

#n_optInteger

This bit indicates whether or not the router is attached to an NSSA.

Returns:

  • (Integer)


76
# File 'lib/packetgen/header/ospfv3/hello.rb', line 76

OSPFv3.define_options(self)

#neighborsIP::ArrayOfAddr

Array of neighbors

Returns:



98
# File 'lib/packetgen/header/ospfv3/hello.rb', line 98

define_attr :neighbors, IP::ArrayOfAddr

#optionsInteger

24-bit options field. Handle #v6_opt, #e_opt, #x_opt, #n_opt, #r_opt and #dc_opt.

Returns:

  • (Integer)


76
# File 'lib/packetgen/header/ospfv3/hello.rb', line 76

OSPFv3.define_options(self)

#priorityInteger

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

Returns:

  • (Integer)


74
# File 'lib/packetgen/header/ospfv3/hello.rb', line 74

define_attr :priority, BinStruct::Int8

#r_optInteger

This bit indicates whether the originator is an active router.

Returns:

  • (Integer)


76
# File 'lib/packetgen/header/ospfv3/hello.rb', line 76

OSPFv3.define_options(self)

#v6_optInteger

If this bit is clear, the router/link should be excluded from IPv6 routing calculations.

Returns:

  • (Integer)


76
# File 'lib/packetgen/header/ospfv3/hello.rb', line 76

OSPFv3.define_options(self)

#x_optInteger

This bit should be set to 0, and ignored when received.

Returns:

  • (Integer)


76
# File 'lib/packetgen/header/ospfv3/hello.rb', line 76

OSPFv3.define_options(self)