Class: PacketGen::Header::IPv6::Extension Abstract
- Defined in:
- lib/packetgen/header/ipv6/extension.rb
Overview
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:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ String, Headerable
Next header in IPv6 packet.
-
#length ⇒ Integer
8-bit extension length, in 8-octets units, not including the first 8 octets.
-
#next ⇒ Integer
8-bit Next header field.
-
#options ⇒ String
Specific options of extension header.
Instance Method Summary collapse
-
#calc_length ⇒ Integer
Compute length and set #length+ attribute.
-
#real_length ⇒ Integer
Get real extension header 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, #to_s
Constructor Details
This class inherits a constructor from PacketGen::Header::Base
Instance Attribute Details
#body ⇒ String, Headerable
Next header in IPv6 packet
52 |
# File 'lib/packetgen/header/ipv6/extension.rb', line 52 define_attr :body, BinStruct::String |
#length ⇒ Integer
8-bit extension length, in 8-octets units, not including the first 8 octets.
43 |
# File 'lib/packetgen/header/ipv6/extension.rb', line 43 define_attr :length, BinStruct::Int8 |
#next ⇒ Integer
8-bit Next header field
38 |
# File 'lib/packetgen/header/ipv6/extension.rb', line 38 define_attr :next, BinStruct::Int8 |
#options ⇒ String
Specific options of extension header
47 48 |
# File 'lib/packetgen/header/ipv6/extension.rb', line 47 define_attr :options, BinStruct::String, builder: ->(h, t) { t.new(length_from: -> { h.real_length - 2}) } |
Instance Method Details
#calc_length ⇒ Integer
Compute length and set #length+ attribute
62 63 64 |
# File 'lib/packetgen/header/ipv6/extension.rb', line 62 def calc_length self.length = (.sz + 2) / 8 - 1 end |
#real_length ⇒ Integer
Get real extension header length
56 57 58 |
# File 'lib/packetgen/header/ipv6/extension.rb', line 56 def real_length (length + 1) * 8 end |