Class: Dap::Filter::FilterDecodeSIPOptionsReply

Inherits:
Object
  • Object
show all
Includes:
BaseDecoder
Defined in:
lib/dap/filter/udp.rb

Overview

Decode a SIP OPTIONS Reply

Instance Attribute Summary

Attributes included from Base

#name, #opts

Instance Method Summary collapse

Methods included from BaseDecoder

#process

Methods included from Base

#initialize, #process

Instance Method Details

#decode(data) ⇒ Object



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/dap/filter/udp.rb', line 320

def decode(data)
  info = {}

  return info unless (data and data.length > 0)

  head,body = data.to_s.split(/\r?\n\r?\n/, 2)

  head.split(/\r?\n/).each do |line|
    case line
    when /^SIP\/(\d+\.\d+) (\d+)(.*)/
      info['sip_version'] = $1
      info['sip_code']    = $2
      if $3.length > 0
        info['sip_message'] = $3.strip
      end
    when /^([a-zA-z0-9][^:]+):(.*)/
      var = $1.strip
      val = $2.strip
      var = var.downcase.gsub(/[^a-zA-Z0-9_]/, '_').gsub(/_+/, '_')
      info["sip_#{var}"] = val
    end
  end

  if body and body.length > 0
    info['sip_data'] = body
  end

  info
end