Class: PacketFu::TcpOption::WS

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

Returns a new instance of WS.



367
368
369
370
371
372
373
374
# File 'lib/packetfu/protos/tcp.rb', line 367

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.



379
380
381
382
383
384
385
# File 'lib/packetfu/protos/tcp.rb', line 379

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

#value=(i) ⇒ Object



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

def value=(i); typecast i; end