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