Class: Mu::Pcap::Reader
- Inherits:
-
Object
- Object
- Mu::Pcap::Reader
- Defined in:
- lib/mu/pcap/reader.rb,
lib/mu/pcap/reader/http_family.rb
Direct Known Subclasses
Defined Under Namespace
Classes: HttpFamily
Constant Summary collapse
- FAMILY_TO_READER =
{}
Instance Attribute Summary collapse
-
#pcap2scenario ⇒ Object
Returns the value of attribute pcap2scenario.
Class Method Summary collapse
-
.reader(family) ⇒ Object
Returns a reader instance of specified family.
Instance Method Summary collapse
-
#family ⇒ Object
Returns family name.
-
#read_message(bytes, state = nil) ⇒ Object
Returns next complete message from byte stream or nil.
-
#read_message!(bytes, state = nil) ⇒ Object
Mutating form of read_message.
-
#record_write(bytes, state = nil) ⇒ Object
Notify parser of bytes written.
Instance Attribute Details
#pcap2scenario ⇒ Object
Returns the value of attribute pcap2scenario.
9 10 11 |
# File 'lib/mu/pcap/reader.rb', line 9 def pcap2scenario @pcap2scenario end |
Class Method Details
.reader(family) ⇒ Object
Returns a reader instance of specified family. Returns nil when family is :none.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mu/pcap/reader.rb', line 14 def self.reader family if family == :none return nil end if klass = FAMILY_TO_READER[family] return klass.new end raise ArgumentError, "Unknown protocol family: '#{family}'" end |
Instance Method Details
#family ⇒ Object
Returns family name
27 28 29 |
# File 'lib/mu/pcap/reader.rb', line 27 def family raise NotImplementedError end |
#read_message(bytes, state = nil) ⇒ Object
Returns next complete message from byte stream or nil.
42 43 44 |
# File 'lib/mu/pcap/reader.rb', line 42 def bytes, state=nil bytes.dup, state end |
#read_message!(bytes, state = nil) ⇒ Object
Mutating form of read_message. Removes a complete message from input stream. Returns the message or nil if there. is not a complete message.
49 50 51 52 53 54 55 |
# File 'lib/mu/pcap/reader.rb', line 49 def bytes, state=nil begin bytes, state rescue nil end end |
#record_write(bytes, state = nil) ⇒ Object
Notify parser of bytes written. Parser may update state to serve as a hint for subsequent reads.
33 34 35 36 37 38 39 |
# File 'lib/mu/pcap/reader.rb', line 33 def record_write bytes, state=nil begin do_record_write bytes, state rescue nil end end |