Class: PacketFu::TcpOption::SACK

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

Overview

Selective Acknowledgement option.

www.networksorcery.com/enp/protocol/tcp/option004.htm

Note that SACK always takes its optlen from the size of the string.

Instance Attribute Summary

Attributes inherited from PacketFu::TcpOption

#kind, #optlen, #value

Instance Method Summary collapse

Methods inherited from PacketFu::TcpOption

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

Returns a new instance of SACK.



210
211
212
213
214
215
216
# File 'lib/packetfu/protos/tcp/option.rb', line 210

def initialize(args={})
  super(
    args.merge(:kind => 5,
               :optlen => ((args[:value] || "").size + 2)
              )
  )
end

Instance Method Details

#decodeObject



225
226
227
# File 'lib/packetfu/protos/tcp/option.rb', line 225

def decode
    "SACK:#{self[:value]}"
end

#encode(str) ⇒ Object



229
230
231
232
233
234
# File 'lib/packetfu/protos/tcp/option.rb', line 229

def encode(str)
  temp_obj = self.class.new(:value => str)
  self[:value] = temp_obj.value
  self[:optlen] = temp_obj.optlen.value
  self
end

#optlen=(i) ⇒ Object



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

def optlen=(i); typecast i; end

#value=(i) ⇒ Object



220
221
222
223
# File 'lib/packetfu/protos/tcp/option.rb', line 220

def value=(i)
  self[:optlen] = Int8.new(i.to_s.size + 2)
  self[:value] = StructFu::String.new(i)
end