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 PCAP files

Author:

  • Sylvain Daubert

Since:

  • 3.1.4

Class Method Summary collapse

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

Parameters:

  • filename (String)

Returns:

Author:

  • Kent Gruber

Since:

  • 3.1.4


19
20
21
22
23
24
25
26
27
# File 'lib/packetgen/pcap.rb', line 19

def self.read(filename)
  packets = []
  PCAPRUBWrapper.read_pcap(filename: filename) do |packet|
    next unless (packet = PacketGen.parse(packet.to_s))

    packets << packet
  end
  packets
end