Class: PacketFu::TcpOption::MSS

Inherits:
PacketFu::TcpOption show all
Defined in:
lib/packetfu/protos/tcp/option.rb

Overview

Instance Attribute Summary

Attributes inherited from PacketFu::TcpOption

#kind, #optlen, #value

Instance Method Summary collapse

Methods inherited from PacketFu::TcpOption

#encode, #has_optlen?, #has_value?, #read, #to_s

Methods included from StructFu

#body=, #clone, #set_endianness, #sz, #typecast

Methods inherited from Struct

#force_binary

Constructor Details

#initialize(args = {}) ⇒ MSS

Returns a new instance of MSS


134
135
136
137
138
139
140
141
# File 'lib/packetfu/protos/tcp/option.rb', line 134

def initialize(args={})
  super(
    args.merge(:kind => 2,
               :optlen => 4
              )
  )
  self[:value] = Int16.new(args[:value])
end

Instance Method Details

#decodeObject

MSS options with lengths other than 4 are malformed.


146
147
148
149
150
151
152
# File 'lib/packetfu/protos/tcp/option.rb', line 146

def decode
  if self[:optlen].to_i == 4
    "MSS:#{self[:value].to_i}"
  else
    "MSS-bad:#{self[:value]}"
  end
end

#value=(i) ⇒ Object


143
# File 'lib/packetfu/protos/tcp/option.rb', line 143

def value=(i); typecast i; end