Class: PacketGen::Header::IPv6::Extension Abstract

Inherits:
Base show all
Defined in:
lib/packetgen/header/ipv6/extension.rb

Overview

This class is abstract.

You should not use this class but its subclasses.

Base class to handle IPv6 extensions A IPv6 extension header 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
|                                                               |
.                                                               .
.                            Options                            .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Such a header consists of:

Author:

  • Sylvain Daubert

Direct Known Subclasses

HopByHop

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

#bodyString, Base

Returns:



49
# File 'lib/packetgen/header/ipv6/extension.rb', line 49

define_field :body, Types::String

#lengthInteger

8-bit extension length, in 8-octets units, not including the first 8 octets.

Returns:

  • (Integer)


41
# File 'lib/packetgen/header/ipv6/extension.rb', line 41

define_field :length, Types::Int8

#nextInteger

8-bit Next header field

Returns:

  • (Integer)


36
# File 'lib/packetgen/header/ipv6/extension.rb', line 36

define_field :next, Types::Int8

#optionsString

Specific options of extension header

Returns:

  • (String)


45
46
# File 'lib/packetgen/header/ipv6/extension.rb', line 45

define_field :options, Types::String,
builder: ->(h, t) { t.new(length_from: -> { h.real_length }) }

Instance Method Details

#calc_lengthInteger

Compute length and set len field

Returns:

  • (Integer)


59
60
61
# File 'lib/packetgen/header/ipv6/extension.rb', line 59

def calc_length
  self.length = (options.sz + 2) / 8 - 1
end

#real_lengthInteger

Get real extension header length

Returns:

  • (Integer)


53
54
55
# File 'lib/packetgen/header/ipv6/extension.rb', line 53

def real_length
  (length + 1) * 8
end