### Home Classes Methods

### In Files

- lib/packetfu/protos/eth/header.rb

### Parent

Struct.new(:b5, :b4, :b3, :b2, :b1, :b0, :local, :multicast, :oui)

### Methods

- ::new
- #read
- #to_s

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

EthOui is the Organizationally Unique Identifier portion of a MAC address, used in EthHeader.

See the OUI list at standards.ieee.org/regauth/oui/oui.txt

#### Header Definition

    Fixnum   :b0
    Fixnum   :b1
    Fixnum   :b2
    Fixnum   :b3
    Fixnum   :b4
    Fixnum   :b5
    Fixnum   :local
    Fixnum   :multicast
    Int16    :oui,       Default: 0x1ac5 :)

### Public Class Methods

new(args={}) click to toggle source

EthOui is unusual in that the bit values do not enjoy StructFu typing.

    # File lib/packetfu/protos/eth/header.rb, line 20
    def initialize(args={})
            args[:local] ||= 0
            args[:oui] ||= 0x1ac # :)
            args.each_pair {|k,v| args[k] = 0 unless v}
            super(args[:b5], args[:b4], args[:b3], args[:b2],
                                    args[:b1], args[:b0], args[:local], args[:multicast],
                                    args[:oui])
    end

### Public Instance Methods

read(str) click to toggle source

Reads a string to populate the object.

    # File lib/packetfu/protos/eth/header.rb, line 44
    def read(str)
            force_binary(str)
            return self if str.nil?
            if 1.respond_to? :ord
                    byte = str[0].ord
            else
                    byte = str[0]
            end
            self[:b5] =        byte & 0b10000000 == 0b10000000 ? 1 : 0
            self[:b4] =        byte & 0b01000000 == 0b01000000 ? 1 : 0
            self[:b3] =        byte & 0b00100000 == 0b00100000 ? 1 : 0
            self[:b2] =        byte & 0b00010000 == 0b00010000 ? 1 : 0
            self[:b1] =        byte & 0b00001000 == 0b00001000 ? 1 : 0
            self[:b0] =        byte & 0b00000100 == 0b00000100 ? 1 : 0
            self[:local] =     byte & 0b00000010 == 0b00000010 ? 1 : 0
            self[:multicast] = byte & 0b00000001 == 0b00000001 ? 1 : 0
            self[:oui] =       str[1,2].unpack("n").first
            self
    end

to_s() click to toggle source

Returns the object in string form.

    # File lib/packetfu/protos/eth/header.rb, line 30
    def to_s
            byte = 0
            byte += 0b10000000 if b5.to_i == 1
            byte += 0b01000000 if b4.to_i == 1
            byte += 0b00100000 if b3.to_i == 1
            byte += 0b00010000 if b2.to_i == 1
            byte += 0b00001000 if b1.to_i == 1
            byte += 0b00000100 if b0.to_i == 1
            byte += 0b00000010 if local.to_i == 1
            byte += 0b00000001 if multicast.to_i == 1
            [byte,oui].pack("Cn")
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.