class Mu::Pcap::Reader

Constants

FAMILY_TO_READER

Attributes

pcap2scenario[RW]

Public Class Methods

reader(family) click to toggle source

Returns a reader instance of specified family. Returns nil when family is :none.

# File lib/woolen_common/pcap/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

Public Instance Methods

family() click to toggle source

Returns family name

# File lib/woolen_common/pcap/mu/pcap/reader.rb, line 27
def family
    raise NotImplementedError
end
read_message(bytes, state=nil) click to toggle source

Returns next complete message from byte stream or nil.

# File lib/woolen_common/pcap/mu/pcap/reader.rb, line 42
def read_message bytes, state=nil
    read_message! bytes.dup, state
end
read_message!(bytes, state=nil) click to toggle source

Mutating form of read_message. Removes a complete message from input stream. Returns the message or nil if there. is not a complete message.

# File lib/woolen_common/pcap/mu/pcap/reader.rb, line 49
def read_message! bytes, state=nil
    begin
        do_read_message! bytes, state
    rescue
        nil
    end
end
record_write(bytes, state=nil) click to toggle source

Notify parser of bytes written. Parser may update state to serve as a hint for subsequent reads.

# File lib/woolen_common/pcap/mu/pcap/reader.rb, line 33
def record_write bytes, state=nil
    begin
        do_record_write bytes, state
    rescue
        nil
    end
end