Class: Caper::Dumper
- Inherits:
-
Object
- Object
- Caper::Dumper
- Defined in:
- lib/caper/dumper.rb
Overview
See pcap_dumper_t in pcap.h
A pcap_dumper, or Caper::Dumper is handled opaquely so that it can be implemented differently on different platforms. In Caper, we simply wrap the pcap_dumper_t pointer with a ruby interface.
Instance Method Summary collapse
- #_write(header, bytes) ⇒ Object
- #close ⇒ Object
- #flush ⇒ Object
-
#initialize(dumper) ⇒ Dumper
constructor
A new instance of Dumper.
- #tell ⇒ Object
- #write(*args) ⇒ Object
- #write_pkt(pkt) ⇒ Object
Constructor Details
#initialize(dumper) ⇒ Dumper
Returns a new instance of Dumper.
11 12 13 |
# File 'lib/caper/dumper.rb', line 11 def initialize(dumper) @dumper = dumper end |
Instance Method Details
#_write(header, bytes) ⇒ Object
15 16 17 |
# File 'lib/caper/dumper.rb', line 15 def _write(header, bytes) Caper.pcap_dump(@dumper, header, bytes) end |
#close ⇒ Object
39 40 41 |
# File 'lib/caper/dumper.rb', line 39 def close Caper.pcap_dump_close(@dumper) end |
#flush ⇒ Object
35 36 37 |
# File 'lib/caper/dumper.rb', line 35 def flush Caper.pcap_dump_flush(@dumper) end |
#tell ⇒ Object
31 32 33 |
# File 'lib/caper/dumper.rb', line 31 def tell Caper.pcap_dump_ftell(@dumper) end |
#write(*args) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/caper/dumper.rb', line 19 def write(*args) if args.first.is_a? Packet write_pkt(*args) else _write(*args) end end |
#write_pkt(pkt) ⇒ Object
27 28 29 |
# File 'lib/caper/dumper.rb', line 27 def write_pkt(pkt) _write(pkt.header, pkt.body_ptr) end |