class Pcap::Capture
- Pcap::Capture
- Reference
- Object
Included Modules
- Iterator(Pcap::Packet)
Defined in:
pcap/capture.crConstant Summary
-
DEFAULT_NETMASK =
4294967040_u32
-
DEFAULT_OPTIMIZE =
1
-
DEFAULT_PROMISC =
1
-
DEFAULT_SNAPLEN =
1500
-
DEFAULT_TIMEOUT_MS =
1000
Constructors
Class Method Summary
- .open_dead(linktype : Int32 = DEFAULT_LINKTYPE, snaplen : Int32 = DEFAULT_SNAPLEN)
- .open_live(device : String, snaplen : Int32 = DEFAULT_SNAPLEN, promisc : Int32 = DEFAULT_PROMISC, timeout_ms : Int32 = DEFAULT_TIMEOUT_MS)
- .open_offline(file : String)
Instance Method Summary
- #callback
- #callback=(callback : Pcap::Packet -> _)
- #callback? : Pcap::Packet -> Nil
- #close
- #compile(filter, optimize = DEFAULT_OPTIMIZE, netmask = DEFAULT_NETMASK)
-
#get? : Packet | Nil
reads the next packet, and - trys again if read timeouted - returns
Pcap::Packet
if exists - returnsnil
if EOF reached (maybe read in offline mode) - raisesPcap::Error
on error -
#loop(count : Int32 = -1, &callback : Pcap::Packet -> )
calls
pcap_loop
that fetches all packets in the next buffer, and loop forever. -
#next
called via
iterator
-
#next_ex : NextError | Packet
calls
pcap_next_ex
that reads the next packet and returns a success/failure indication. - #set_promisc(flag : Bool)
- #setfilter(filter : String, optimize : Int32 = DEFAULT_OPTIMIZE, netmask : UInt32 = DEFAULT_NETMASK)
Constructor Detail
Class Method Detail
def self.open_live(device : String, snaplen : Int32 = DEFAULT_SNAPLEN, promisc : Int32 = DEFAULT_PROMISC, timeout_ms : Int32 = DEFAULT_TIMEOUT_MS)
#
Instance Method Detail
reads the next packet, and
- trys again if read timeouted
- returns
Pcap::Packet
if exists - returns
nil
if EOF reached (maybe read in offline mode) - raises
Pcap::Error
on error
calls pcap_loop
that fetches all packets in the next buffer, and loop forever.
calls pcap_next_ex
that reads the next packet and returns a success/failure indication.
def setfilter(filter : String, optimize : Int32 = DEFAULT_OPTIMIZE, netmask : UInt32 = DEFAULT_NETMASK)
#