Class: Mu::Scenario::Pcap::Fields

Inherits:
Object
  • Object
show all
Defined in:
lib/diy/parser/mu/scenario/pcap/fields.rb

Constant Summary collapse

FIELDS =
[
    :rtp,
    :"rtp.setup-frame"
].freeze
FIELD_COUNT =
FIELDS.length
SEPARATOR =
"\xff".freeze
TSHARK_OPTS =
"-Eseparator='#{SEPARATOR}'"

Class Method Summary collapse

Class Method Details

.next_from_io(io) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/diy/parser/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) ⇒ Object

Raises:

  • (Errno::ETIMEDOUT)


24
25
26
27
28
29
30
# File 'lib/diy/parser/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