Class PacketFu::TcpOption
In: lib/packetfu/tcp.rb
Parent: Struct.new(:kind, :optlen, :value)

TcpOption is the base class for all TCP options. Note that TcpOption#len returns the size of the entire option, while TcpOption#optlen is the struct for the TCP Option Length field.

Subclassed options should set the correct TcpOption#kind by redefining initialize. They should also deal with various value types there by setting them explicitly with an accompanying StructFu#typecast for the setter.

By default, values are presumed to be strings, unless they are Numeric, in which case a guess is made to the width of the Numeric based on the given optlen.

Note that normally, optlen is /not/ enforced for directly setting values, so the user is perfectly capable of setting incorrect lengths.

Methods

decode   encode   has_optlen?   has_value?   kind=   new   optlen=   read   to_s   value=  

Included Modules

StructFu

Classes and Modules

Class PacketFu::TcpOption::ECHO
Class PacketFu::TcpOption::ECHOREPLY
Class PacketFu::TcpOption::EOL
Class PacketFu::TcpOption::MSS
Class PacketFu::TcpOption::NOP
Class PacketFu::TcpOption::SACK
Class PacketFu::TcpOption::SACKOK
Class PacketFu::TcpOption::TS
Class PacketFu::TcpOption::WS

Public Class methods

Public Instance methods

The default decode for an unknown option. Known options should redefine this.

Generally, encoding a value is going to be just a read. Some options will treat things a little differently; TS for example, takes two values and concatenates them.

Returns true if this option has an optlen. Some don‘t.

Returns true if this option has a value. Some don‘t.

Setter for the "kind" byte of this option.

Setter for the "option length" byte for this option.

Reads a string to populate the object.

Returns the object in string form.

Setter for the value of this option.

[Validate]