Class: PacketFu::TcpOption::MSS

Inherits:
PacketFu::TcpOption show all
Defined in:
lib/packetfu/protos/tcp.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.



341
342
343
344
345
346
347
348
# File 'lib/packetfu/protos/tcp.rb', line 341

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.



353
354
355
356
357
358
359
# File 'lib/packetfu/protos/tcp.rb', line 353

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

#value=(i) ⇒ Object



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

def value=(i); typecast i; end