Class: Dap::Filter::FilterDecodeSIPOptionsReply
- Inherits:
-
Object
- Object
- Dap::Filter::FilterDecodeSIPOptionsReply
- Includes:
- BaseDecoder
- Defined in:
- lib/dap/filter/udp.rb
Overview
Decode a SIP OPTIONS Reply
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
Methods included from BaseDecoder
Methods included from Base
Instance Method Details
#decode(data) ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/dap/filter/udp.rb', line 287 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 |