class Mu::Scenario::Pcap::Fields

Constants

FIELDS
FIELD_COUNT
SEPARATOR
TSHARK_OPTS

Public Class Methods

next_from_io(io) click to toggle source
# File lib/woolen_common/pcap/mu/scenario/pcap/fields.rb, line 32
def self.next_from_io io
    if line = readline(io)
        fields = line.split SEPARATOR, FIELD_COUNT
        hash = {}
        FIELDS.each do |key|
            val = fields.shift
            hash[key] = val.empty? ? nil : val
        end
        return hash
    end
rescue Exception => e
    Pcap.warning e.message
    return nil
end
readline(io) click to toggle source
# File lib/woolen_common/pcap/mu/scenario/pcap/fields.rb, line 24
def self.readline io
    if ::IO.select [io], nil, nil, Pcap::TSHARK_READ_TIMEOUT
        return io.readline.chomp
    end

    raise Errno::ETIMEDOUT, "read timed out"
end