### Home Classes Methods

### In Files

- lib/packetfu/pcap.rb

### Parent

Object

### Methods

- ::a2f
- ::append
- ::array_to_file
- ::format_packets

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

Write is largely deprecated. It was current in PacketFu 0.2.0, but isn't all that useful in 0.3.0 and beyond. Expect it to go away completely by version 1.0, as working with PacketFu::PcapFile directly is generally going to be more rewarding.

### Public Class Methods

a2f(args={}) click to toggle source
Alias for: array_to_file
append(args={}) click to toggle source

Shorthand method for appending to a file. Also shouldn't use.

    # File lib/packetfu/pcap.rb, line 599
    def append(args={})
            array_to_file(args.merge(:append => true))
    end

array_to_file(args={}) click to toggle source

array_to_file is a largely deprecated function for writing arrays of pcaps to a file. Use PcapFile#array_to_file instead.

    # File lib/packetfu/pcap.rb, line 570
    def array_to_file(args={})
            filename = args[:filename] || args[:file] || args[:out] || :nowrite
            arr = args[:arr] || args[:array] || []
            ts = args[:ts] || args[:timestamp] || args[:time_stamp] || Time.now.to_f
            ts_inc = args[:ts_inc] || args[:timestamp_increment] || args[:time_stamp_increment]
            byte_order = args[:byte_order] || args[:byteorder] || args[:endian] || args[:endianness] || :little
            append = args[:append]
            Read.set_byte_order(byte_order) if [:big, :little].include? byte_order
            pf = PcapFile.new
            pf.array_to_file(:endian => PacketFu.instance_variable_get(:@byte_order),
                                                                             :arr => arr,
                                                                             :ts => ts,
                                                                             :ts_inc => ts_inc)
            if filename && filename != :nowrite
                    if append
                            pf.append(filename)
                    else
                            pf.write(filename)
                    end
                    return [filename,pf.to_s.size,arr.size,ts,ts_inc]
            else
                    return [nil,pf.to_s.size,arr.size,ts,ts_inc]
            end

    end

Also aliased as: a2f
format_packets(args={}) click to toggle source

format_packets: Pretty much totally deprecated.

    # File lib/packetfu/pcap.rb, line 557
    def format_packets(args={})
            arr = args[:arr] || args[:array] || []
            ts = args[:ts] || args[:timestamp] || Time.now.to_i
            ts_inc = args[:ts_inc] || args[:timestamp_increment]
            pkts = PcapFile.new.array_to_file(:endian => PacketFu.instance_variable_get(:@byte_order),
                                                                                                                                                    :arr => arr,
                                                                                                                                                    :ts => ts,
                                                                                                                                                    :ts_inc => ts_inc)
            pkts.body
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.