### Home Classes Methods

### In Files

- lib/packetfu/pcap.rb

### Parent

Struct.new(:endian, :timestamp, :incl_len, :orig_len, :data)

### Methods

- ::new
- #init_fields
- #read
- #to_s

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

PcapPacket defines how individual packets are stored in a libpcap-formatted file.

#### Header Definition

Timestamp :timestamp Int32 :incl_len Int32 :orig_len String :data

### Public Class Methods

new(args={}) click to toggle source

    # File lib/packetfu/pcap.rb, line 150
    def initialize(args={})
            set_endianness(args[:endian] ||= :little)
            init_fields(args)
            super(args[:endian], args[:timestamp], args[:incl_len],
                             args[:orig_len], args[:data])
    end

### Public Instance Methods

init_fields(args={}) click to toggle source

Called by initialize to set the initial fields.

    # File lib/packetfu/pcap.rb, line 158
    def init_fields(args={})
            args[:timestamp] = Timestamp.new(:endian => args[:endian]).read(args[:timestamp])
            args[:incl_len] = args[:incl_len].nil? ? @int32.new(args[:data].to_s.size) : @int32.new(args[:incl_len])
            args[:orig_len] = @int32.new(args[:orig_len])
            args[:data] = StructFu::String.new.read(args[:data])
    end

read(str) click to toggle source

Reads a string to populate the object.

    # File lib/packetfu/pcap.rb, line 171
    def read(str)
            return unless str
            force_binary(str)
            self[:timestamp].read str[0,8]
            self[:incl_len].read str[8,4]
            self[:orig_len].read str[12,4]
            self[:data].read str[16,self[:incl_len].to_i]
            self
    end

to_s() click to toggle source

Returns the object in string form.

    # File lib/packetfu/pcap.rb, line 166
    def to_s
            self.to_a[1,4].map {|x| x.to_s}.join
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.