@@ -72,6 +72,7 @@ tm Module
72
72
73
73
1.4.21. t_flush_flags()
74
74
1.4.22. t_anycast_replicate()
75
+ 1.4.23 t_reply_by_callid()
75
76
76
77
1.5. Exported Pseudo-Variables
77
78
@@ -180,6 +181,7 @@ tm Module
180
181
1.42. t_write_req/unix usage
181
182
1.43. t_flush_flags usage
182
183
1.44. t_anycast_replicate usage
184
+ 1.45. t_reply_by_callid usage
183
185
184
186
Chapter 1. Admin Guide
185
187
@@ -1381,6 +1383,58 @@ if (is_method("ACK|CANCEL") && !t_check_trans()) {
1381
1383
}
1382
1384
...
1383
1385
1386
+ 1.4.23. t_reply_by_callid(code, reason_phrase, [callid], [cseq])
1387
+
1388
+ This function is used to send a reply to
1389
+ an existing INVITE transaction.
1390
+ The usual use case is when opensips is used as an UAS
1391
+ and when an INVITE is receveid, it is "parked" locally on
1392
+ opensips by replying to it with
1393
+ t_reply(180, "Ringing" or t_reply(183, "Session Progress")
1394
+ and later we need to handle CANCEL or BYE for it and send
1395
+ '487 Request Terminated' to the original INVITE transaction.
1396
+
1397
+ The callid and cseq used to identify the transaction
1398
+ will be obtained from the current messsage being processed.
1399
+ But they can be passed explicitly so that for example we can
1400
+ handle a BYE where the cseq must be the cseq
1401
+ of the INVITE minus one.
1402
+
1403
+ This function can be used from REQUEST_ROUTE.
1404
+
1405
+ Example 1.45. t_reply_by_callid usage
1406
+ ...
1407
+
1408
+ route{
1409
+ if($rU == "LOCAL_PARK") {
1410
+ if(is_method("INVITE")) {
1411
+ $T_fr_timeout = 10;
1412
+ $T_fr_inv_timeout = 10;
1413
+ append_to_reply("Contact: sip:LOCAL_PARK@$socket_in(ip):$socket_in(port)\r\n");
1414
+ t_reply(180, "Ringing");
1415
+ t_wait_for_new_branches();
1416
+ } else if(is_method("CANCEL")) {
1417
+ if(!t_reply_by_callid(487, "Request Terminated")) {
1418
+ sl_send_reply(481, "Call Leg/Transaction Does Not Exist");
1419
+ } else {
1420
+ sl_send_reply(200, "OK");
1421
+ }
1422
+ } else if(is_method("BYE")) {
1423
+ $var(prev_cseq) = ($(cs{s.int}) - 1);
1424
+ if(!t_reply_by_callid(487, "Request Terminated", , $var(prev_cseq))) {
1425
+ sl_send_reply(481, "Call Leg/Transaction Does Not Exist");
1426
+ } else {
1427
+ sl_send_reply(200, "OK");
1428
+ }
1429
+ } else if(is_method("ACK")) {
1430
+ t_relay();
1431
+ }
1432
+ exit;
1433
+ }
1434
+ }
1435
+
1436
+ ...
1437
+
1384
1438
1.5. Exported Pseudo-Variables
1385
1439
1386
1440
Exported variables are listed in the next sections.
0 commit comments