Class: PacketFu::TcpOption::WS

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 = {}) ⇒ WS

Returns a new instance of WS.



160
161
162
163
164
165
166
167
# File 'lib/packetfu/protos/tcp/option.rb', line 160

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

Instance Method Details

#decodeObject

WS options with lengths other than 3 are malformed.



172
173
174
175
176
177
178
# File 'lib/packetfu/protos/tcp/option.rb', line 172

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

#value=(i) ⇒ Object



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

def value=(i); typecast i; end