Class: FFI::PCap::CaptureWrapper
- Inherits:
-
Object
- Object
- FFI::PCap::CaptureWrapper
- Defined in:
- lib/diy/ext/capture_wrapper.rb
Instance Method Summary collapse
-
#dispatch(opts = {}, &block) ⇒ Object
Fix bug: dispatch but call pcap_loop.
Instance Method Details
#dispatch(opts = {}, &block) ⇒ Object
Fix bug: dispatch but call pcap_loop
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/diy/ext/capture_wrapper.rb', line 13 def dispatch(opts={}, &block) cnt = opts[:count] || -1 # default to infinite loop h = opts[:handler] ret = FFI::PCap.pcap_dispatch(_pcap, cnt, _wrap_callback(h, block),nil) if ret == -1 raise(ReadError, "pcap_dispatch(): #{geterr()}") elsif ret -2 return nil elsif ret > -1 return ret else raise(ReadError, "unexpected return from pcap_dispatch() -> #{ret}") end end |