Skip to content

Commit

Permalink
Fix [routes] keyword in UAS scenario.
Browse files Browse the repository at this point in the history
The strrchr-logic did not do what was intended at all.

Closes #262.
  • Loading branch information
wdoekes committed Apr 9, 2017
1 parent f6c26d2 commit b6c7b20
Show file tree
Hide file tree
Showing 7 changed files with 298 additions and 92 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
@@ -1,3 +1,10 @@
Bugs fixed in 3.6.0
===================

* Fix `[routes]` header in UAS scenario's. (Issue #262, reported by
Stefan Mititelu (@smititelu).)


Changes in 3.6.0
================

Expand Down
4 changes: 2 additions & 2 deletions docs/scenarios/keywords.rst
Expand Up @@ -133,7 +133,7 @@ Keyword list
``[routes]``
=============
:Description: If the "rrs" attribute in a recv command is set to "true", then the "Record-Route:"
header of the message received is stored and can be recalled using the [routes] keyword
header of the message received is stored and can be recalled using the [routes] keyword.

``[next_url]``
==============
Expand Down Expand Up @@ -187,4 +187,4 @@ Keyword list
=============
:Description: If the -users command line option is specified, then this keyword
containst he integer identifier of the current user (starting at zero
and ending at [users-1]).
and ending at [users-1]).
28 changes: 28 additions & 0 deletions regress/github-#0262/run
@@ -0,0 +1,28 @@
#!/bin/sh
# This regression test is a part of SIPp.
# Author: Walter Doekes, OSSO B.V., 2016
#
# Test Record-Route and [routes].
#
. "`dirname "$0"`/../functions"; init

sippbg -sf uas.xml -p 5070 -trace_msg -message_file uas.log
sippfg -m 1 -sf uac.xml 127.0.0.1:5070 -trace_msg -message_file uac.log \
-timeout 5 -timeout_error >/dev/null 2>&1
status=$?

test $status -ne 0 && fail "SIPp UAC job failed"

uac_route=`sed -e '/^ACK /,/^$/!d;/^Route:/!d;s/[[:cntrl:]]//g' uac.log`
uac_expected='Route: <sip:127.0.1.1:2;lr>, <sip:127.0.1.1:3;lr>, <sip:127.0.1.1:5060;lr>'

uas_route=`sed -e '/^BYE /,/^$/!d;/^Route:/!d;s/[[:cntrl:]]//g' uas.log`
uas_expected='Route: <sip:127.0.1.1:5060;lr>, <sip:127.0.1.1:3;lr>, <sip:127.0.1.1:2;lr>'

if test "$uac_route" != "$uac_expected"; then
fail "UAC Route unexpected, got: $uac_route"
elif test "$uas_route" != "$uas_expected"; then
fail "UAS Route unexpected, got: $uas_route"
else
ok
fi
81 changes: 81 additions & 0 deletions regress/github-#0262/uac.xml
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="UAC that pretends to be a proxy">

<send retrans="500" start_txn="invite">
<![CDATA[
INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
Via: SIP/2.0/[transport] [local_ip]:3;branch=[branch]-proxy2
Via: SIP/2.0/[transport] [local_ip]:2;branch=[branch]-proxy1
Via: SIP/2.0/[transport] [local_ip]:1;branch=[branch]-uac
Record-Route: <sip:[local_ip]:[local_port];lr>
Record-Route: <sip:[local_ip]:3;lr>
Record-Route: <sip:[local_ip]:2;lr>
From: sip:[service]@[local_ip]:[local_port];tag=[pid]SIPpTag00[call_number]
To: sip:[service]@[remote_ip]:[remote_port]
Call-ID: [call_id]
CSeq: [cseq] INVITE
Contact: <sip:[service]@[local_ip]:1;transport=[transport]>
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [rtpstream_audio_port] RTP/AVP 8 0
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
]]>
</send>

<recv response="100" optional="true" response_txn="invite"/>

<recv response="180" optional="true" response_txn="invite"/>

<recv response="183" optional="true" response_txn="invite"/>

<recv response="200" rrs="true" response_txn="invite"/>

<send ack_txn="invite">
<![CDATA[
ACK [next_url] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
Via: SIP/2.0/[transport] [local_ip]:3;branch=[branch]-proxy2
Via: SIP/2.0/[transport] [local_ip]:2;branch=[branch]-proxy1
Via: SIP/2.0/[transport] [local_ip]:1;branch=[branch]-uac
[routes]
From: sip:[service]@[local_ip]:[local_port];tag=[pid]SIPpTag00[call_number]
To: sip:[service]@[remote_ip]:[remote_port][peer_tag_param]
Call-ID: [call_id]
CSeq: [cseq] ACK
Contact: <sip:[service]@[local_ip]:1;transport=[transport]>
Content-Length: 0
]]>
</send>

<recv request="BYE"/>

<send>
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:]
[last_Call-ID:]
[last_CSeq:]
Content-Length: 0
]]>
</send>

<timewait milliseconds="1000"/><!-- retransmit 200's for a while -->

</scenario>
75 changes: 75 additions & 0 deletions regress/github-#0262/uas.xml
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="iinv-o200-obye.xml -- wjd 2014">

<recv request="INVITE" rrs="true"/>

<send>
<![CDATA[
SIP/2.0 180 Ringing
[last_Via:]
[last_Record-Route:]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[service]@[local_ip]:[local_port];transport=[transport]>
Content-Length: 0
]]>
</send>

<send retrans="500">
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_Record-Route:]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[service]@[local_ip]:[local_port];transport=[transport]>
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 8 0
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
]]>
</send>

<recv request="ACK">
<action>
<ereg regexp=": *(.*)" search_in="hdr" header="To" assign_to="_,us"/><!-- with tag -->
<ereg regexp=": *(.*)" search_in="hdr" header="From" assign_to="_,them"/>
</action>
</recv>
<Reference variables="_"/>

<send start_txn="bye" retrans="500">
<![CDATA[
BYE [next_url] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
[routes]
From: [$us]
To: [$them]
[last_Call-ID:]
CSeq: [cseq] BYE
Contact: <sip:[service]@[local_ip]:[local_port];transport=[transport]>
Content-Length: 0
]]>
</send>

<recv response="200" response_txn="bye"/>

</scenario><!-- vim: set ts=8 sw=2 sts=2 et ai: -->

0 comments on commit b6c7b20

Please sign in to comment.