Class: Pcapz::Capture::Linux
- Inherits:
-
Object
- Object
- Pcapz::Capture::Linux
- Defined in:
- lib/pcapz/capture_types/linux.rb
Instance Method Summary collapse
- #file ⇒ Object
-
#initialize(interface = Interfacez.default) ⇒ Linux
constructor
A new instance of Linux.
- #next_packet ⇒ Object
- #packets ⇒ Object
- #stop! ⇒ Object
- #stopped? ⇒ Boolean
Constructor Details
#initialize(interface = Interfacez.default) ⇒ Linux
Returns a new instance of Linux.
4 5 6 7 8 9 |
# File 'lib/pcapz/capture_types/linux.rb', line 4 def initialize(interface = Interfacez.default) @interface = interface @buffer_size = 0 @file = nil configure_socket end |
Instance Method Details
#file ⇒ Object
26 27 28 |
# File 'lib/pcapz/capture_types/linux.rb', line 26 def file @file end |
#next_packet ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/pcapz/capture_types/linux.rb', line 17 def next_packet @file.recvfrom_nonblock(@buffer_size)[0] rescue IO::WaitReadable IO.select([@file]) retry rescue Interrupt exit end |
#packets ⇒ Object
11 12 13 14 15 |
# File 'lib/pcapz/capture_types/linux.rb', line 11 def packets until @file.closed? yield next_packet end end |
#stop! ⇒ Object
30 31 32 33 34 |
# File 'lib/pcapz/capture_types/linux.rb', line 30 def stop! return nil if stopped? @file.close stopped? end |
#stopped? ⇒ Boolean
36 37 38 |
# File 'lib/pcapz/capture_types/linux.rb', line 36 def stopped? @file.closed? end |