### Home Classes Methods

### In Files

- lib/packetfu/protos/tcp/option.rb

### Parent

PacketFu::TcpOption

### Methods

- ::new
- #decode
- #encode

### Files

- .document
- README.rdoc

### Class/Module Index

Quicksearch

- PacketFu
- PacketFu::ARPHeader
- PacketFu::ARPHeaderMixin
- PacketFu::ARPPacket
- PacketFu::AddrIpv6
- PacketFu::Capture
- PacketFu::Config
- PacketFu::EthHeader
- PacketFu::EthHeaderMixin
- PacketFu::EthMac
- PacketFu::EthNic
- PacketFu::EthOui
- PacketFu::EthPacket
- PacketFu::HSRPHeader
- PacketFu::HSRPHeaderMixin
- PacketFu::HSRPPacket
- PacketFu::ICMPHeader
- PacketFu::ICMPHeaderMixin
- PacketFu::ICMPPacket
- PacketFu::IPHeader
- PacketFu::IPHeaderMixin
- PacketFu::IPPacket
- PacketFu::IPv6Header
- PacketFu::IPv6HeaderMixin
- PacketFu::IPv6Packet
- PacketFu::Inject
- PacketFu::InvalidHeader
- PacketFu::InvalidPacket
- PacketFu::LLDPHeader
- PacketFu::LLDPHeaderMixin
- PacketFu::LLDPPacket
- PacketFu::Octets
- PacketFu::Packet
- PacketFu::PcapFile
- PacketFu::PcapHeader
- PacketFu::PcapPacket
- PacketFu::PcapPackets
- PacketFu::Read
- PacketFu::TCPHeader
- PacketFu::TCPHeaderMixin
- PacketFu::TCPPacket
- PacketFu::TcpEcn
- PacketFu::TcpFlags
- PacketFu::TcpHlen
- PacketFu::TcpOption
- PacketFu::TcpOption::ECHO
- PacketFu::TcpOption::ECHOREPLY
- PacketFu::TcpOption::EOL
- PacketFu::TcpOption::MSS
- PacketFu::TcpOption::NOP
- PacketFu::TcpOption::SACK
- PacketFu::TcpOption::SACKOK
- PacketFu::TcpOption::TS
- PacketFu::TcpOption::WS
- PacketFu::TcpOptions
- PacketFu::TcpReserved
- PacketFu::Timestamp
- PacketFu::UDPHeader
- PacketFu::UDPHeaderMixin
- PacketFu::UDPPacket
- PacketFu::Utils
- PacketFu::Write
- StructFu
- StructFu::Int
- StructFu::Int16
- StructFu::Int16be
- StructFu::Int16le
- StructFu::Int32
- StructFu::Int32be
- StructFu::Int32le
- StructFu::Int8
- StructFu::IntString
- StructFu::String
- Struct

No matching classes.

# PacketFu::TcpOption::TS

Timestamp option

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

### Public Class Methods

new(args={}) click to toggle source

    # File lib/packetfu/protos/tcp/option.rb, line 287
    def initialize(args={})
            super(
                    args.merge(:kind => 8,
                                                             :optlen => 10
                                                            )
            )
            self[:value] = StructFu::String.new.read(args[:value] || "\x00" * 8)
    end

### Public Instance Methods

decode() click to toggle source

TS options with lengths other than 10 are malformed.

    # File lib/packetfu/protos/tcp/option.rb, line 297
    def decode
            if self[:optlen].to_i == 10
                    val1,val2 = self[:value].unpack("NN")
                    "TS:#{val1};#{val2}"
            else
                    "TS-bad:#{self[:value]}"
            end
    end

encode(str) click to toggle source

TS options are in the format of "TS:[timestamp value];[timestamp secret]" Both should be written as decimal numbers.

    # File lib/packetfu/protos/tcp/option.rb, line 308
    def encode(str)
            if str =~ /^([0-9]+);([0-9]+)$/
                    tsval,tsecr = str.split(";").map {|x| x.to_i}
                    if tsval <= 0xffffffff && tsecr <= 0xffffffff
                            self[:value] = StructFu::String.new([tsval,tsecr].pack("NN"))
                    else
                            self[:value] = StructFu::String.new(str)
                    end
            else
                    self[:value] = StructFu::String.new(str)
            end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.