Sha256: 410ca74d653d3d6482f2f66f22751b458db5a491c7986686794246720728f054

Contents?: true

Size: 1.33 KB

Versions: 17

Compression:

Stored size: 1.33 KB

Contents

# http://www.mudynamics.com
# http://labs.mudynamics.com
# http://www.pcapr.net

module Mu
class Pcap

class Reader
    attr_accessor :pcap2scenario

    FAMILY_TO_READER = {}

    # Returns a reader instance of specified family. Returns nil when family is :none.
    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

    # Returns family name 
    def family
        raise NotImplementedError
    end

    # Notify parser of bytes written. Parser may update state
    # to serve as a hint for subsequent reads.
    def record_write bytes, state=nil
        begin
            do_record_write bytes, state
        rescue
            nil
        end
    end

    # Returns next complete message from byte stream or nil. 
    def read_message bytes, state=nil
        read_message! bytes.dup, state
    end

    # Mutating form of read_message. Removes a complete message
    # from input stream. Returns the message or nil if there. 
    # is not a complete message.
    def read_message! bytes, state=nil
        begin
            do_read_message! bytes, state
        rescue
            nil
        end
    end

end
end
end

require 'mu/pcap/reader/http_family'

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
DIY-pcap-0.4.1 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.3.8 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.3.6 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.3.5 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.3.4 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.3.3 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.3.2 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.3.1 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.3.0 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.2.8 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.2.7 lib/diy/parser/mu/pcap/reader.rb
DIY-pcap-0.2.6 lib/diy/parser/mu/pcap/reader.rb
pcapr-local-0.2.0 lib/mu/pcap/reader.rb
pcapr-local-0.1.13 lib/mu/pcap/reader.rb
pcapr-local-0.1.12 lib/mu/pcap/reader.rb
pcapr-local-0.1.11 lib/mu/pcap/reader.rb
pcapr-local-0.1.10 lib/mu/pcap/reader.rb