### Home Classes Methods

### In Files

- lib/packetfu/protos/eth.rb

### Parent

PacketFu::Packet

### Methods

- ::can_parse?
- ::new
- #read
- #recalc

### Included Modules

- PacketFu::EthHeaderMixin

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

EthPacket is used to construct Ethernet packets. They contain an Ethernet header, and that's about it.

## Example

    require 'packetfu'
    eth_pkt = PacketFu::EthPacket.new
    eth_pkt.eth_saddr="00:1c:23:44:55:66"
    eth_pkt.eth_daddr="00:1c:24:aa:bb:cc"

    eth_pkt.to_w('eth0') # Inject on the wire. (require root)

### Attributes

eth_header[RW]

### Public Class Methods

can_parse?(str) click to toggle source

    # File lib/packetfu/protos/eth.rb, line 22
    def self.can_parse?(str)
            # XXX Temporary fix. Need to extend the EthHeader class to handle more.
            valid_eth_types = [0x0800, 0x0806, 0x86dd, 0x88cc]
            return false unless str.size >= 14
            type = str[12,2].unpack("n").first rescue nil
            return false unless valid_eth_types.include? type
            true
    end

new(args={}) click to toggle source

    # File lib/packetfu/protos/eth.rb, line 44
    def initialize(args={})
            @eth_header = EthHeader.new(args).read(args[:eth])
            @headers = [@eth_header]
            super
    end

### Public Instance Methods

read(str=nil,args={}) click to toggle source

    # File lib/packetfu/protos/eth.rb, line 31
    def read(str=nil,args={})
            raise "Cannot parse `#{str}'" unless self.class.can_parse?(str)
            @eth_header.read(str)
            super(args)
            return self
    end

recalc(args={}) click to toggle source

Does nothing, really, since there's no length or checksum to calculate for a straight Ethernet packet.

    # File lib/packetfu/protos/eth.rb, line 40
    def recalc(args={})
            @headers[0].inspect
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.