Class: PacketGen::Header::TCP::Options

Inherits:
BinStruct::Array
  • Object
show all
Defined in:
lib/packetgen/header/tcp/options.rb

Overview

Container for TCP options in TCP header.

Examples:

Add an option from a hash

opts = PacketGen::Header::TCP::Options.new
# Option kind may be set using :opt
opts << { opt: 'MSS', value: 1250 }
# It may aldo be set using :kind
opts << { kind: 'EOL' }

Author:

  • Sylvain Daubert

Since:

  • 1.0.0

  • 4.1.0 #<< accepts :kind parameter in hash

Class Method Summary collapse

Class Method Details

.option_classesArray<Class>

Returns:

  • (Array<Class>)

Since:

  • 1.0.0

  • 4.1.0 #<< accepts :kind parameter in hash



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/packetgen/header/tcp/options.rb', line 29

def self.option_classes
  return @klasses if defined? @klasses

  @klasses = []
  Option.constants.each do |cst|
    next unless cst.to_s.end_with?('_KIND')

    optname = cst.to_s.sub('_KIND', '')
    @klasses[Option.const_get(cst)] = TCP.const_get(optname)
  end
  @klasses
end