SIP Redirection Script Contacts Parameters
Applies to version(s): v2.8 and above
This pages show an example of multiple SIP redirect in term of how the routing script is executed and with which params[:contacts]
parameters.
1. Incoming call
The routing script is executed when an incoming call is received. The routing script executes its logic to find the matching route(s) from the routing table and provides the outgoing call parameters for each route found. The outgoing call is placed to A. The params[:contacts]
parameter is empty with :index=0:
contacts = params[ :contacts ] contacts = {:index=>"0", :source_indexes=>"nil"}
Note: The params[:contacts]
parameter above is provisioned for any call type.
2. Redirect to 6661
"A" requests to redirect the call (302 Moved Temporarily). The call is directed to contact 6661. The routing script is executed a 2nd time with the params[:call]
hash filled with the information from the inbound call.
call = params[ :call ] -> Information from original inbound call, with exception of call[ :called ]
call[ :called ] -> Replaced by the contact number (6661).
params[:contacts]
parameter is filled with the contact list and index=1:
contacts = params[ :contacts ] contacts = { :index=>"1", :list=>[ {:called_number=>"6660", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"", :raw_data=>"", :expiration=>"3600"}, {:called_number=>"6661", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6661@192.168.215.127", :raw_data=>"<sip:6661@192.168.215.127>", :expiration=>"3600"} {:called_number=>"6662", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6662@192.168.215.128", :raw_data=>"<sip:6662@192.168.215.128>", :expiration=>"3600"}, {:called_number=>"6663", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6663@192.168.215.129", :raw_data=>"<sip:6663@192.168.215.129>", :expiration=>"3600"} ], :source_indexes=>"nil,0,0,0" }
3. Redirect to 6662
The call is rejected by "B" with "480 Temporarily unavailable". The call is directed to contact 6662. The routing script is executed a third time with the params[:call]
hash filled with the information from the inbound call.
call = params[ :call ] -> Information from original inbound call, with exception of call[ :called ]
call[ :called ] -> Replaced by the contact number (6662).
params[:contacts]
parameter is filled with the contact list and index=2:
contacts = params[ :contacts ] contacts = { :index=>"2", :list=>[ {:called_number=>"6660", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"", :raw_data=>"", :expiration=>"3600"}, {:called_number=>"6661", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6661@192.168.215.127", :raw_data=>"<sip:6661@192.168.215.127>", :expiration=>"3600"} {:called_number=>"6662", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6662@192.168.215.128", :raw_data=>"<sip:6662@192.168.215.128>", :expiration=>"3600"}, {:called_number=>"6663", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6663@192.168.215.129", :raw_data=>"<sip:6663@192.168.215.129>", :expiration=>"3600"} ], :source_indexes=>"nil,0,0,0" }
4. Redirect to 6664
"C" requests to redirect the call (second redirection). The call is directed to contact 6664. The routing script is executed a fourth time with the params[:call]
hash filled with the information from the inbound call.
call = params[ :call ] -> Information from original inbound call, with exception of call[ :called ]
call[ :called ] -> Replaced by the contact number (6664).
A new contact is added to params[:contacts]
parameter and 'index=3 is set':
contacts = params[ :contacts ] contacts = { :index=>"3", :list=>[ {:called_number=>"6660", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"", :raw_data=>"", :expiration=>"3600"}, {:called_number=>"6661", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6661@192.168.215.127", :raw_data=>"<sip:6661@192.168.215.127>", :expiration=>"3600"} {:called_number=>"6662", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6662@192.168.215.128", :raw_data=>"<sip:6662@192.168.215.128>", :expiration=>"3600"}, {:called_number=>"6664", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6664@192.168.215.150", :raw_data=>"<sip:6664@192.168.215.150>", :expiration=>"3600"} {:called_number=>"6663", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6663@192.168.215.129", :raw_data=>"<sip:6663@192.168.215.129>", :expiration=>"3600"}, ], :source_indexes=>"nil,0,0,2,0" }
params[:contacts][:source_indexes]
is set to:
:source_indexes=>"nil,0,0,0,2
"2" means that the 5th contact from the contact list was requested by the contact index 2 (sip:6662@192.168.215.128)
5. Redirect to 6663
The call is rejected by "D" with "480 Temporarily unavailable". The call is directed to contact 6663. The routing script is executed a fifth time with the params[:call]
hash filled with the information from the inbound call.
call = params[ :call ] -> Information from original inbound call, with exception of call[ :called ]
call[ :called ] -> Replaced by the contact number (6663).
params[:contacts]
parameter is filled with the contact list and index=4:
contacts = params[ :contacts ] contacts = { :index=>"4", :list=>[ {:called_number=>"6660", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"", :raw_data=>"", :expiration=>"3600"}, {:called_number=>"6661", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6661@192.168.215.127", :raw_data=>"<sip:6661@192.168.215.127>", :expiration=>"3600"} {:called_number=>"6662", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6662@192.168.215.128", :raw_data=>"<sip:6662@192.168.215.128>", :expiration=>"3600"}, {:called_number=>"6664", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6664@192.168.215.150", ':raw_data=>"<sip:6664@192.168.215.150>", :expiration=>"3600"} {:called_number=>"6663", :priority=>"1000", :is_number_ported=>"0", :sip_uri=>"sip:6663@192.168.215.129", :raw_data=>"<sip:6663@192.168.215.129>", :expiration=>"3600"}, ], :source_indexes=>"nil,0,0,2,0" }