////////////////////////////////////////////////////////////////////////////////
// Server: call through proxies (Record-Route / Route)
//
// Counterpart of Record_route_client.
//
// It saves the Record-Route headers of the INVITE and copies them, in the same
// order, into the 200 OK (RFC 3261 12.1.1). After the ACK it saves the dialog
// identifiers and the client's Contact, waits a second and ends the call with a
// BYE addressed to that Contact, with the saved Route headers.
//
// Messages with ;retrans are sent again over UDP until they are answered, and a copy
// of one that comes again is answered as before (RFC 3261; -t1, -t2).
//
// SIP Messages
//  <--- INVITE ;retrans
//  ---> 100 Trying
//  ---> 180 Ringing
//  ---> 200 OK ;retrans (SDP, Record-Route)
//  <--- ACK
//  ---- pause 1 s
//  ---> BYE ;retrans (Route headers)
//  <--- 200 OK
////////////////////////////////////////////////////////////////////////////////

<----------;retrans
INVITE

----------
set_Variable=route1 "Record-Route-1:" "*"

----------
set_Variable=route2 "Record-Route-2:" "*"

----------
set_Variable=route3 "Record-Route-3:" "*"

---------->
SIP/2.0 100 Trying
[last_Via:]
[last_From:]
[last_To:]
[last_Call-ID:]
[last_CSeq:]
User-Agent: SIPInspector_v_[ver]
Content-Length: 0


---------->
SIP/2.0 180 Ringing
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
User-Agent: SIPInspector_v_[ver]
Content-Length: 0


---------->;retrans
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:];tag=[call_number]
[last_Call-ID:]
[last_CSeq:]
Record-Route: [$route1]
Record-Route: [$route2]
Record-Route: [$route3]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
User-Agent: SIPInspector_v_[ver]
Content-Type: application/sdp
Content-Length: [len]

v=0
o=111 843670094 843670094 IN [IP_ver] [local_ip_sdp]
s=-
c=IN [IP_ver] [local_ip_sdp]
t=0 0
a=sendrecv
m=audio [media_port] RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20

<----------
ACK

// The BYE goes out in the dialog created by the INVITE, so remember its identifiers.
// Taken from the ACK because only the ACK's To header carries the tag this side added.
----------
set_Variable=cid "Call-ID:" "*"

----------
set_Variable=contactRem "Contact:" "<*>"

----------
set_Variable=to "To:" "*"

----------
set_Variable=from "From:" "*"

----------
cmd_Pause=1000

---------->;retrans
BYE [$contactRem] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: [$to]
To: [$from]
Call-ID: [$cid]
CSeq: [cseq+1] BYE
Max-Forwards: 70
Route: [$route1]
Route: [$route2]
Route: [$route3]
Contact: <sip:[fromUsername]@[local_ip]:[local_port];transport=[transport]>
User-Agent: SIPInspector_v_[ver]
Content-Length: 0


<----------
200 OK
