Class: PacketGen::Header::IPv6::HopByHop

Inherits:
Extension
  • Object
show all
Defined in:
lib/packetgen/header/ipv6/hop_by_hop.rb

Overview

Hop-by-hop IPv6 extension

 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
|                                                               |
.                                                               .
.                            Options                            .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Hop-by-hop IPv6 extension header consists of:

Examples:

pkt = PacketGen.gen('Eth').add('IPv6').add('IPv6::HopByHop').add('ICMPv6')
pkt.ipv6_hopbyhop.options << { type: 'router_alert', value: "\x00\x00".b }

Since:

  • 2.4.0

Instance Attribute Summary collapse

Attributes inherited from Extension

#body, #length, #next

Instance Method Summary collapse

Methods inherited from Extension

#calc_length, #real_length

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

Constructor Details

This class inherits a constructor from PacketGen::Header::Base

Instance Attribute Details

#optionsOptions

Specific HopByHop options

Returns:



120
# File 'lib/packetgen/header/ipv6/hop_by_hop.rb', line 120

define_attr_before :body, :options, Options, builder: ->(h, t) { t.new(length_from: -> { h.real_length - 2 }) }

Instance Method Details

#to_sString

Generate binary string. Add padding if needed in #options, and update Extension#length accordingly.

Returns:

  • (String)

Since:



126
127
128
129
# File 'lib/packetgen/header/ipv6/hop_by_hop.rb', line 126

def to_s
  calc_length
  super
end