Pcap::Capture
Inherits Iterator / Enumerable / Reference / Object
Constants
DEFAULT_NETMASK = 4294967040_u32
DEFAULT_OPTIMIZE = 1
DEFAULT_PROMISC = 1
DEFAULT_SNAPLEN = 1500
DEFAULT_TIMEOUT_MS = 1000
Constructors
new(pcap : LibPcap::PcapT)
SourceClass methods
open_dead(linktype : Int32 = DEFAULT_LINKTYPE, snaplen : Int32 = DEFAULT_SNAPLEN)
Sourceopen_live(device : String, snaplen : Int32 = DEFAULT_SNAPLEN, promisc : Int32 = DEFAULT_PROMISC, timeout_ms : Int32 = DEFAULT_TIMEOUT_MS)
Sourceopen_offline(file : String)
SourceInstance methods
callback
Sourcecallback=(callback : Pcap::Packet -> _)
Sourcecallback?
Sourceclose
Sourcecompile(filter, optimize = DEFAULT_OPTIMIZE, netmask = DEFAULT_NETMASK)
Sourceget?
reads the next packet, and
- trys again if read timeouted
- returns
Pcap::Packetif exists - returns
nilif EOF reached (maybe read in offline mode) - raises
Pcap::Erroron error
calls pcap_loop that fetches all packets in the next buffer, and loop forever.
next_ex
calls pcap_next_ex that reads the next packet and returns a success/failure indication.
set_promisc(flag : Bool)
Sourcesetfilter(filter : String, optimize : Int32 = DEFAULT_OPTIMIZE, netmask : UInt32 = DEFAULT_NETMASK)
Source