lib/sippy_cup/scenario.rb in sippy_cup-0.6.0 vs lib/sippy_cup/scenario.rb in sippy_cup-0.7.0

- old
+ new

@@ -81,11 +81,12 @@ # @option options [String] :source The source IP/hostname with which to invoke SIPp. # @option options [String, Numeric] :source_port The source port to bind SIPp to (defaults to 8836). # @option options [String] :destination The target system at which to direct traffic. # @option options [String] :advertise_address The IP address to advertise in SIP and SDP if different from the bind IP (defaults to the bind IP). # @option options [String] :from_user The SIP user from which traffic should appear. - # @option options [String] :to_user The SIP user to send requests to. + # @option options [String] :to_user The SIP user to send requests to. Alias for `:to` and deprecated in favour of the same. + # @option options [String] :to The SIP user / address to send requests to. # @option options [Integer] :media_port The RTCP (media) port to bind to locally. # @option options [String, Numeric] :max_concurrent The maximum number of concurrent calls to execute. # @option options [String, Numeric] :number_of_calls The maximum number of calls to execute in the test run. # @option options [String, Numeric] :calls_per_second The rate at which to initiate calls. # @option options [String] :stats_file The path at which to dump statistics. @@ -153,14 +154,13 @@ def invite(opts = {}) opts[:retrans] ||= 500 # FIXME: The DTMF mapping (101) is hard-coded. It would be better if we could # get this from the DTMF payload generator from_addr = "#{@from_user}@#{@adv_ip}:[local_port]" - to_addr = "[service]@[remote_ip]:[remote_port]" msg = <<-MSG -INVITE sip:#{to_addr} SIP/2.0 +INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0 Via: SIP/2.0/[transport] #{@adv_ip}:[local_port];branch=[branch] From: "#{@from_user}" <sip:#{from_addr}>;tag=[call_number] To: <sip:#{to_addr}> Call-ID: [call_id] CSeq: [cseq] INVITE @@ -323,11 +323,11 @@ Content-Type: application/sdp [routes] Content-Length: [len] v=0 -o=user1 53655765 2353687637 IN IP[local_ip_type] #{@adv_ip} +o=user1 53655765 2353687637 IN IP[local_ip_type] #{@adv_ip} s=- c=IN IP[media_ip_type] [media_ip] t=0 0 m=audio [media_port] RTP/AVP 0 a=rtpmap:0 PCMU/8000 @@ -446,11 +446,11 @@ msg = <<-BODY ACK [next_url] SIP/2.0 Via: SIP/2.0/[transport] #{@adv_ip}:[local_port];branch=[branch] From: "#{@from_user}" <sip:#{@from_user}@#{@adv_ip}:[local_port]>;tag=[call_number] -To: <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param] +To: <sip:#{to_addr}>[peer_tag_param] Call-ID: [call_id] CSeq: [cseq] ACK Contact: <sip:[$local_addr];transport=[transport]> Max-Forwards: 100 User-Agent: #{USER_AGENT} @@ -497,11 +497,11 @@ info = <<-INFO INFO [next_url] SIP/2.0 Via: SIP/2.0/[transport] #{@adv_ip}:[local_port];branch=[branch] From: "#{@from_user}" <sip:#{@from_user}@#{@adv_ip}:[local_port]>;tag=[call_number] -To: <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param] +To: <sip:#{to_addr}>[peer_tag_param] Call-ID: [call_id] CSeq: [cseq] INFO Contact: <sip:[$local_addr];transport=[transport]> Max-Forwards: 100 User-Agent: #{USER_AGENT} @@ -734,10 +734,14 @@ {scenario: scenario_file, media: media_file} end private + def to_addr + @to_addr ||= "[service]@#{@to_domain}:[remote_port]" + end + #TODO: SIPS support? def parse_user(user) user.slice! 0, 4 if user =~ /sip:/ user = user.split(":")[0] user, domain = user.split("@") @@ -772,12 +776,16 @@ raise ArgumentError, "dtmf_mode must be rfc2833 or info" unless [:rfc2833, :info].include?(@dtmf_mode) else @dtmf_mode = :rfc2833 end - @from_addr, @from_port = args[:source].split ':' if args[:source] - @to_addr, @to_port = args[:destination].split ':' if args[:destination] @from_user = args[:from_user] || "sipp" + + args[:to] ||= args[:to_user] if args.has_key?(:to_user) + if args[:to] + @to_user, @to_domain = args[:to].to_s.split('@') + end + @to_domain ||= "[remote_ip]" end def compile_media raise "Media not started" unless @media @media.compile!