class Rex::Proto::SIP::Response

Represents a SIP response message

Attributes

code[RW]
message[RW]
status_line[RW]
version[RW]

Public Class Methods

parse(data) click to toggle source

Parses data, constructs and returns a Response

# File lib/rex/proto/sip/response.rb, line 45
def self.parse(data)
  response = Response.new
  # do some basic sanity checking on this response to ensure that it is SIP
  response.status_line = data.split(/\r\n/)[0]
  unless response.status_line && response.status_line =~ SIP_STATUS_REGEX
    fail(ArgumentError, "Invalid SIP status line: #{response.status_line}")
  end
  response.version = Regexp.last_match(1)
  response.code = Regexp.last_match(2)
  response.message = Regexp.last_match(3)
  response.headers = extract_headers(data)
  response
end