### Home Classes Methods

### In Files

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

### Parent

Struct.new(:n, :c, :e)

### Methods

- ::new
- #read
- #to_i

### Included Modules

- StructFu

### 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::TcpEcn

Implements the Explict Congestion Notification for TCPHeader.

#### Header Definition

    Fixnum (1 bit)  :n
    Fixnum (1 bit)  :c
    Fixnum (1 bit)  :e

### Public Class Methods

new(args={}) click to toggle source

    # File lib/packetfu/protos/tcp/ecn.rb, line 14
    def initialize(args={})
      super(args[:n], args[:c], args[:e]) if args
    end

### Public Instance Methods

read(str) click to toggle source

Reads a string to populate the object.

    # File lib/packetfu/protos/tcp/ecn.rb, line 25
    def read(str)
      force_binary(str)
      return self if str.nil? || str.size < 2
      if 1.respond_to? :ord
        byte1 = str[0].ord
        byte2 = str[1].ord
      else
        byte1 = str[0]
        byte2 = str[1]
      end
      self[:n] = byte1 & 0b00000001 == 0b00000001 ? 1 : 0
      self[:c] = byte2 & 0b10000000 == 0b10000000 ? 1 : 0
      self[:e] = byte2 & 0b01000000 == 0b01000000 ? 1 : 0
      self
    end

to_i() click to toggle source

Returns the TcpEcn field as an integer... even though it's going to be split across a byte boundary.

    # File lib/packetfu/protos/tcp/ecn.rb, line 20
    def to_i
      (n.to_i << 2) + (c.to_i << 1) + e.to_i
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.