@@ -1881,6 +1881,66 @@ if (is_method("ACK|CANCEL") && !t_check_trans()) {
1881
1881
</example >
1882
1882
</section >
1883
1883
1884
+ <section id =" func_t_reply_by_callid" xreflabel =" t_reply_by_callid()" >
1885
+ <title >
1886
+ <function moreinfo =" none" >t_reply_by_callid(code, reason_phrase, [callid], [cseq])</function >
1887
+ </title >
1888
+ <para >
1889
+ This function is used to send a reply to an existing INVITE
1890
+ transaction. The usual use case is when OpenSIPS is used as an UAS
1891
+ and when an INVITE is receveid, it is "parked" locally on
1892
+ OpenSIPS by replying to it with
1893
+ <quote >t_reply(180, "Ringing")</quote > or
1894
+ <quote >t_reply(183, "Session Progress")</quote >
1895
+ and later we need to handle CANCEL or BYE for it and send
1896
+ '487 Request Terminated' to the original INVITE transaction.
1897
+ </para >
1898
+ <para >
1899
+ The callid and cseq used to identify the transaction
1900
+ will be obtained from the current messsage being processed.
1901
+ But they can be passed explicitly so that for example we can
1902
+ handle a BYE where the cseq must be the cseq
1903
+ of the INVITE minus one.
1904
+ </para >
1905
+ <para >
1906
+ This function can be used from REQUEST_ROUTE.
1907
+ </para >
1908
+ <example >
1909
+ <title ><function >t_reply_by_callid</function > usage</title >
1910
+ <programlisting format =" linespecific" >
1911
+ ...
1912
+ route{
1913
+ if($rU == "LOCAL_PARK") {
1914
+ if(is_method("INVITE")) {
1915
+ $T_fr_timeout = 10;
1916
+ $T_fr_inv_timeout = 10;
1917
+ append_to_reply("Contact: sip:LOCAL_PARK@$socket_in(ip):$socket_in(port)\r\n");
1918
+ t_reply(180, "Ringing");
1919
+ t_wait_for_new_branches();
1920
+ } else if(is_method("CANCEL")) {
1921
+ if(!t_reply_by_callid(487, "Request Terminated")) {
1922
+ sl_send_reply(481, "Call Leg/Transaction Does Not Exist");
1923
+ } else {
1924
+ sl_send_reply(200, "OK");
1925
+ }
1926
+ } else if(is_method("BYE")) {
1927
+ $var(prev_cseq) = ($(cs{s.int}) - 1);
1928
+ if(!t_reply_by_callid(487, "Request Terminated", , $var(prev_cseq))) {
1929
+ sl_send_reply(481, "Call Leg/Transaction Does Not Exist");
1930
+ } else {
1931
+ sl_send_reply(200, "OK");
1932
+ }
1933
+ } else if(is_method("ACK")) {
1934
+ t_relay();
1935
+ }
1936
+ exit;
1937
+ }
1938
+ }
1939
+ ...
1940
+ </programlisting >
1941
+ </example >
1942
+ </section >
1943
+
1884
1944
</section >
1885
1945
1886
1946
<section id =" exported_pseudo_variables" xreflabel =" Exported Pseudo-Variables" >
0 commit comments