| Class | PacketFu::PcapFile |
| In: |
lib/packetfu/pcap.rb
|
| Parent: | Struct.new(:endian, :head, :body) |
PcapFile is a complete libpcap file struct, made up of two elements, a PcapHeader and PcapPackets.
Shorthand method for appending to a file. Can take either :file => ‘name.pcap’ or simply ‘name.pcap‘
Takes an array of packets (as generated by file_to_array), and writes them to a file. Valid arguments are:
:filename :array # Can either be an array of packet data, or a hash-value pair of timestamp => data. :timestamp # Sets an initial timestamp :ts_inc # Sets the increment between timestamps. Defaults to 1 second. :append # If true, then the packets are appended to the end of a file.
file_to_array() translates a libpcap file into an array of packets. Note that this strips out pcap timestamps — if you‘d like to retain timestamps and other libpcap file information, you will want to use read() instead.
Note, invoking this requires the somewhat clumsy sytax of, PcapFile.new.file_to_array(:f => ‘filename.pcap’)
A shorthand method for opening a file and reading in the packets. Note that readfile clears any existing packets, since that seems to be the typical use.
Writes the PcapFile to a file. Takes the following arguments:
:filename # The file to write to. :append # If set to true, the packets are appended to the file, rather than overwriting.