Module: PacketGen::Pcap Private
- Defined in:
- lib/packetgen/pcap.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Module to read/write PCAP files
Class Method Summary collapse
-
.read(filename) ⇒ Array<Packet>
private
Read a PCAP file.
-
.write(filename, packets) ⇒ void
private
Write binary packets to a PCAP file.
Class Method Details
.read(filename) ⇒ Array<Packet>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Read a PCAP file
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/packetgen/pcap.rb', line 20 def self.read(filename) packets = [] PCAPRUBWrapper.read_pcap(filename: filename) do |raw_packet| packet = PacketGen.parse(raw_packet.to_s) next if packet.nil? packets << packet end packets end |
.write(filename, packets) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Write binary packets to a PCAP file
37 38 39 |
# File 'lib/packetgen/pcap.rb', line 37 def self.write(filename, packets) PCAPRUBWrapper.pcap_write(filename, packets.map(&:to_s)) end |