File: functions.xml

package info (click to toggle)
kamailio 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 56,100 kB
  • sloc: ansic: 552,832; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (1727 lines) | stat: -rw-r--r-- 49,788 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 
   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<section id="tm.functions" xmlns:xi="http://www.w3.org/2001/XInclude">
    <sectioninfo>
    </sectioninfo>

    <title>Functions</title>

    <section id="tm.f.t_relay">
	<title>
	    <function>t_relay([host, port])</function>
	</title>
	<para>
	    Relay a message statefully either to the destination indicated in the
		current URI (if called without any parameters) or to the specified 
		host and port. In the later case (host and port specified) the protocol
		used is the same protocol on which the message was received.
	</para>
	<para>
		<function>t_relay()</function> is the statefull version for 
		<function>forward()</function>
		while <function>t_relay(host, port)</function> is similar to 
		<function>forward(host, port)</function>.
	</para>
	<para>
		In the forward to uri case (<function>t_relay()</function>), if the
	    original URI was rewritten (by UsrLoc, RR, strip/prefix, etc.) the new
		URI will be taken). The destination (including the protocol) is 
		determined from the uri, using SIP specific DNS resolving if needed
		(NAPTR, SRV a.s.o depending also on the dns options).
	</para>
	<para>
		Returns a negative value on failure -- you may still want to send a
	    negative reply upstream statelessly not to leave upstream UAC in lurch.
	</para>
	<example>
	    <title><function>t_relay</function> usage</title>
	    <programlisting>
...
if (!t_relay()) 
{ 
    sl_reply_error(); 
    break; 
};
...
	    </programlisting>
	</example>
    </section>

    <section id="tm.f.t_relay_to_udp">
	<title>
	    <function>t_relay_to_udp([ip, port])</function>
	</title>
	<para>
	    Relay a message statefully using a fixed protocol either to the 
		 specified fixed destination or to a destination derived from the 
		 message uri (if the host address and port are not specified).
		 These along with
	    <function>t_relay</function> are the functions most users want to
	    use--all other are mostly for programming. Programmers interested
	    in writing <acronym>TM</acronym> logic should review how t_relay is
	    implemented in tm.c and how <acronym>TM</acronym> callbacks work.
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>ip</emphasis> - IP address where the message should be sent.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>port</emphasis> - Port number.
		</para>
	    </listitem>
	</itemizedlist>
	<para>If no parameters are specified the message is sent to a destination
	 derived from the message uri (using sip sepcific DNS lookups), but with 
	 the protocol corresponding to the function name.</para>
	<example>
	    <title><function>t_relay_to_udp</function> usage</title>
	    <programlisting>
...
if (src_ip==10.0.0.0/8)
	t_relay_to_udp("1.2.3.4", "5060"); # sent to 1.2.3.4:5060 over udp
else
	t_relay_to_tcp(); # relay to msg. uri, but over tcp
...
	    </programlisting>
	</example>
    </section>

    <section id="tm.f.t_relay_to_tcp">
	<title>
	    <function>t_relay_to_tcp([ip, port])</function>
	</title>
	<para>
		See function <function>t_relay_to_udp([ip, port])</function>.
	</para>
    </section>

    <section id="tm.f.t_relay_to_tls">
	<title>
	    <function>t_relay_to_tls([ip, port])</function>
	</title>
	<para>
		See function <function>t_relay_to_udp([ip, port])</function>.
	</para>
    </section>

    <section id="tm.f.t_relay_to_sctp">
	<title>
	    <function>t_relay_to_sctp([ip, port])</function>
	</title>
	<para>
		See function <function>t_relay_to_udp([ip, port])</function>.
	</para>
    </section>

    <section id="tm.f.t_on_failure">
	<title>
	    <function>t_on_failure(failure_route)</function>
	</title>
	<para>
	    Sets failure routing block, to which control is passed after a
	    transaction completed with a negative result but before sending a
	    final reply. In the referred block, you can either start a new
	    branch (good for services such as forward_on_no_reply) or send a
	    final reply on your own (good for example for message silo, which
	    received a negative reply from upstream and wants to tell upstream
	    "202 I will take care of it"). Note that the set of
	    commands which are usable within failure_routes is strictly limited to
	    rewriting URI, initiating new branches, logging, and sending
	    stateful replies (<function>t_reply</function>). Any other commands
	    may result in unpredictable behavior and possible server
	    failure. Note that whenever failure_route is entered, uri is reset to
	    value which it had on relaying. If it temporarily changed during a
	    reply_route processing, subsequent reply_route will ignore the
	    changed value and use again the original one.
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>failure_route</emphasis> - Failure route block to be called.
		</para>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function>t_on_failure</function> usage</title>
	    <programlisting>
...
route { 
    t_on_failure("1"); 
    t_relay(); 
} 

failure_route[1] {
    revert_uri(); 
    setuser("voicemail"); 
    append_branch(); 
}
...
	    </programlisting>
	</example>
	<para>
	    See <filename>test/onr.cfg</filename> for a more complex example of
	    combination of serial with parallel forking.
	</para>
    </section>
     <section id="tm.f.t_on_branch_failure">
	<title>
	    <function>t_on_branch_failure(branch_failure_route)</function>
	</title>
	<para>
	    Sets the branch_failure routing block, to which control is passed on each
	    negative response to a transaction. This route is run before deciding if
	    the transaction is complete. In the referred block, you can start a new
	    branch which is required for failover of multiple outbound flows (RFC 5626).
	    Note that the set of commands which are usable within a branch_failure route
	    is limited to a subset of the failure_rotue commands including logging,
	    rewriting URI and initiating new branches. Any other commands may generate
	    errors or result in unpredictable behavior.
	    Note that whenever failure_route is entered, uri is reset to
	    value which it had on relaying. If it temporarily changed during a
	    reply_route processing, subsequent reply_route will ignore the
	    changed value and use again the original one.
	</para>
	<para>Function Parameters:</para>
	<itemizedlist>
	    <listitem>
			<para><emphasis>branch_failure_route</emphasis> - Name of the branch_failure route
			block to be called (it is prefixed internally with 'tm:branch-failure:').
		</para>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function>t_on_branch_failure</function> usage</title>
	    <programlisting>
...
route {
    t_on_branch_failure("myroute");
    t_relay();
}

event_route[tm:branch-failure:myroute] {
    if (t_check_status("430|403") {
        unregister("location", "$tu", "$T_reply_ruid");
    }
}
...
	    </programlisting>
	</example>
    </section>
 
	 <section id="tm.f.t_on_reply">
	<title>
	    <function>t_on_reply(onreply_route)</function>
	</title>
	<para>
	    Sets the reply routing block, to which control is passed when a
	    reply for the current transaction is received.
	    Note that the set of commands which are usable within onreply_routes is
	     limited.
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>onreply_route</emphasis> - Onreply route block to be
			called.
		</para>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function>t_on_reply</function> usage</title>
	    <programlisting>
...
loadmodule "/usr/local/lib/ser/modules/nathelper.so"
...
route { 
	/* if natted */
	t_on_reply("1"); 
	t_relay(); 
} 

onreply_route[1] {
	if (status=~ "(183)|2[0-9][0-9]"){
		force_rtp_proxy();
		search_append('^(Contact|m)[ \t]*:.*sip:[^>[:cntrl:]]*', ';nat=yes');
	}
	if (nat_uac_test("1")){
		fix_nated_contact();
	}
}
	    </programlisting>
	</example>
	</section>

	<section id="tm.f.t_on_branch">
	<title>
	    <function>t_on_branch(branch_route)</function>
	</title>
	<para>
	    Sets the branch routing block, to which control is passed after
	    forking (when a new branch is created). For now branch routes
	    are intended only for last minute changes of the SIP messages
	    (like adding new headers).
	    Note that the set of commands which are usable within branch_routes is
	    very limited. It is not possible to generate a reply.
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>branch_route</emphasis> - branch route block to be
			called.
		</para>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function>t_on_branch</function> usage</title>
	    <programlisting>
...
route { 
	t_on_branch("1"); 
	t_relay(); 
} 

branch_route[1] {
	if (uri=~"sip:[0-9]+"){
		append_hf("P-Warn: numeric uri\r\n");
	}
}
	    </programlisting>
	</example>
	</section>

    <section id="tm.f.t_newtran">
	<title>
	    <function>t_newtran()</function>
	</title>
	<para>
	    Creates a new transaction, returns a negative value on error. This
	    is the only way a script can add a new transaction in an atomic
	    way. Typically, it is used to deploy a UAS.
	</para>
	<example>
	    <title><function>t_newtran</function> usage</title>
	    <programlisting>
...
if (t_newtran()) { 
    log("UAS logic"); 
    t_reply("999","hello"); 
} else sl_reply_error();
...
	    </programlisting>
	</example>
	<para>
	    See test/uas.cfg for more examples.
	</para>
    </section>

    <section id="tm.f.t_reply">
	<title>
	    <function>t_reply(code, reason_phrase)</function>
	</title>
	<para>
	    Sends a stateful reply after a transaction has been
	    established. See <function>t_newtran</function> for usage.
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>code</emphasis> - Reply code number.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>reason_phrase</emphasis> - Reason string.
		</para>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function>t_reply</function> usage</title>
	    <programlisting>
...
t_reply("404", "Not found");
...
	    </programlisting>
	</example>
    </section>

    <section id="tm.f.t_lookup_request">
	<title>
	    <function>t_lookup_request()</function>
	</title>
	<para>
	    Checks if a transaction exists. Returns a positive value if so,
	    negative otherwise.  Most likely you will not want to use it, as a
	    typical application of a look-up is to introduce a new transaction
	    if none was found. However this is safely (atomically) done using
	    <function>t_newtran</function>.
	</para>
	<example>
	    <title><function>t_lookup_request</function> usage</title>
	    <programlisting>
...
if (t_lookup_request()) {
    ...
};
...
	    </programlisting>
	</example>
    </section>

    <section id="tm.f.t_retransmit_reply">
	<title>
	    <function>t_retransmit_reply()</function>
	</title>
	<para>
	    Retransmits a reply sent previously by UAS transaction.
	</para>
	<example>
	    <title><function>t_retransmit_reply</function> usage</title>
	    <programlisting>
...
t_retransmit_reply();
...
	    </programlisting>
	</example>
    </section>

    <section id="tm.f.t_release">
	<title>
	    <function>t_release()</function>
	</title>
	<para>
	    Remove transaction from memory (it will be first put on a wait
	    timer to absorb delayed messages).
	</para>
	<example>
	    <title><function>t_release</function> usage</title>
	    <programlisting>
...
t_release();
...
	    </programlisting>
	</example>
    </section>

    <section id="tm.f.t_forward_nonack">
	<title>
	    <function>t_forward_nonack([ip, port])</function>
	</title>
	<para>
		Mainly for internal usage -- forward a non-ACK request statefully.
		Variants of this functions can enforce a specific transport protocol.
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>ip</emphasis> - IP address where the message should be sent.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>port</emphasis> - Port number.
		</para>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function>t_forward_nonack</function> usage</title>
	    <programlisting>
...
t_forward_nonack("1.2.3.4", "5060");
...
	    </programlisting>
	</example>
    </section>

   <section id="tm.f.t_forward_nonack_udp">
	<title>
	    <function>t_forward_nonack_udp(ip, port)</function>
	</title>
	<para>
	    See function <function>t_forward_nonack([ip, port])</function>.
	</para>
    </section>

   <section id="tm.f.t_forward_nonack_tcp">
	<title>
	    <function>t_forward_nonack_tcp(ip, port)</function>
	</title>
	<para>
	    See function <function>t_forward_nonack([ip, port])</function>.
	</para>
    </section>

   <section id="tm.f.t_forward_nonack_tls">
	<title>
	    <function>t_forward_nonack_tls(ip, port)</function>
	</title>
	<para>
	    See function <function>t_forward_nonack([ip, port])</function>.
	</para>
    </section>

   <section id="tm.f.t_forward_nonack_sctp">
	<title>
	    <function>t_forward_nonack_sctp(ip, port)</function>
	</title>
	<para>
	    See function <function>t_forward_nonack([ip, port])</function>.
	</para>
    </section>

	<section id="tm.f.t_set_fr">
	<title>
	    <function>t_set_fr(fr_inv_timeout [, fr_timeout])</function>
	</title>
	<para>
		Sets the fr_inv_timeout and optionally fr_timeout for the current
		transaction or for transactions created during the same script 
		invocation, after calling this function.
		If the transaction is already created (e.g called after
		 <function>t_relay()</function> or in an onreply_route) all the
		 branches will have their final response timeout updated on-the-fly.
		If one of the parameters is 0, its value won't be changed.
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>fr_inv_timeout</emphasis> - new final response timeout
			(in milliseconds) for INVITEs. See also 
			<varname>fr_inv_timer</varname>.
		</para>
		<para><emphasis>fr_timeout</emphasis> - new final response timeout
		 	(in milliseconds) for non-INVITE transaction, or INVITEs which 
			haven't received yet a provisional response. See also
			<varname>fr_timer</varname>.
		</para>
	    </listitem>
	</itemizedlist>
	<para>
		See also: 
			<varname>fr_timer</varname>,
			<varname>fr_inv_timer</varname>,
			<function>t_reset_fr()</function>.
	</para>
	<example>
	    <title><function>t_set_fr</function> usage</title>
	    <programlisting>
...
route { 
	t_set_fr(10000); # set only fr invite timeout to 10s
	t_on_branch("1");
	t_relay(); 
} 

branch_route[1] {
	# if we are calling the pstn, extend the invite timeout to 50s
	# for all the branches, and set the no-reply-received timeout to 2s
	if (uri=~"sip:[0-9]+"){
		t_set_fr(50000, 2000); 
	}
}
	    </programlisting>
	</example>
	</section>

	<section id="tm.f.t_reset_fr">
	<title>
	    <function>t_reset_fr()</function>
	</title>
	<para>
		Resets the <varname>fr_inv_timer</varname> and 
		<varname>fr_timer</varname> for the current transaction to the default
		values (set using the tm module parameters
		<varname>fr_inv_timer</varname> and <varname>fr_timer</varname>).
	</para>
	<para>
		It will effectively cancel any previous calls to 
		<function>t_set_fr</function> for the same transaction.
	</para>
	<para>
		See also: <varname>fr_timer</varname>,
				<varname>fr_inv_timer</varname>,
				<function>t_set_fr</function>.
	</para>
	<example>
		<title><function>t_reset_fr</function> usage</title>
		<programlisting>
...
route { 
...
		t_reset_fr();
...
} 
		</programlisting>
	</example>
	</section>


	<section id="tm.f.t_set_max_lifetime">
	<title>
	    <function>t_set_max_lifetime(inv_lifetime, noninv_lifetime)</function>
	</title>
	<para>
		Sets the maximum lifetime for the current INVITE or non-INVITE 
		transaction, or for transactions created during the same script
		invocation, after calling this function (that's why it takes values
		for both INVITE and non-INVITE).
		If one of the parameters is 0, its value won't be changed.
	</para>
	<para>
		It works as a per transaction <varname>max_inv_lifetime</varname> or
		<varname>max_noninv_lifetime</varname>.
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>inv_lifetime</emphasis> - maximum INVITE transaction
			lifetime (in milliseconds). See also 
			<varname>max_inv_lifetime</varname>.
		</para>
		<para><emphasis>noninv_lifetime</emphasis> - maximum non-INVITE 
			transaction lifetime (in milliseconds).
			See also <varname>max_noninv_lifetime</varname>.
		</para>
	    </listitem>
	</itemizedlist>
	<para>
		See also: <varname>max_inv_lifetime</varname>,
				<varname>max_noninv_lifetime</varname>,
				<function>t_reset_max_lifetime</function>.
	</para>
	<example>
		<title><function>t_set_max_lifetime</function> usage</title>
		<programlisting>
...
route { 
    if (src_ip=1.2.3.4)
        t_set_max_lifetime(120000, 0); # set only max_inv_lifetime to 120s
    else
        t_set_max_lifetime(90000, 15000); # set the maximum lifetime to 90s if
                                          # the current transaction is an 
                                          # INVITE and to 15s if not
} 

		</programlisting>
	</example>
	</section>

	<section id="tm.f.t_reset_max_lifetime">
	<title>
	    <function>t_reset_max_lifetime()</function>
	</title>
	<para>
		Resets the the maximum lifetime for the current INVITE or non-INVITE 
		transaction to the default value (set using the tm module parameter
		<varname>max_inv_lifetime</varname> or 
		<varname>max_noninv_lifetime</varname>).
	</para>
	<para>
		It will effectively cancel any previous calls to 
		<function>t_set_max_lifetime</function> for the same transaction.
	</para>
	<para>
		See also: <varname>max_inv_lifetime</varname>,
				<varname>max_noninv_lifetime</varname>,
				<function>t_set_max_lifetime</function>.
	</para>
	<example>
		<title><function>t_reset_max_lifetime</function> usage</title>
		<programlisting>
...
route { 
...
		t_reset_max_lifetime();
...
} 
		</programlisting>
	</example>
	</section>

	<section id="tm.f.t_set_retr">
	<title>
	    <function>t_set_retr(retr_t1_interval, retr_t2_interval)</function>
	</title>
	<para>
		Sets the retr_t1_interval and retr_t2_interval for the current
		transaction or for transactions created during the same script 
		invocation, after calling this function.
		If one of the parameters is 0, it's value won't be changed.
		If the transaction is already created (e.g called after
		 <function>t_relay()</function> or in an onreply_route) all the
		 existing branches will have their retransmissions intervals updated 
		 on-the-fly:
		 if the retransmission interval for the branch has not yet reached T2
		  the interval will be reset to retr_t1_interval, else to 
		  retr_t2_interval. Note that the change will happen after the current
		  interval expires (after the next retransmission, the next-next 
		  retransmission will take place at retr_t1_interval or 
		  retr_t2_interval).
		 All new branches of the same transaction will start with the new 
		 values.
		 This function will work even if it's called in the script before
		a transaction creating function (e.g.: t_set_retr(500, 4000);
		t_relay()). All new transaction created after this function call, 
		during the same script invocation will use the new values.
		Note that this function will work only if tm is compile with
		 -DTM_DIFF_RT_TIMEOUT (which increases every transaction size with
		 4 bytes).
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>retr_t1_interval</emphasis> - new T1 retransmission
			interval (in milliseconds). See also
			<varname>retr_t1_timeout</varname>.
		</para>
		<para><emphasis>retr_t2_interval</emphasis> - new T2 (or maximum) 
			retransmission interval (in milliseconds). See also
			<varname>retr_t2_timeout</varname>.
		</para>
	    </listitem>
	</itemizedlist>
	<para>
		See also: 
			<varname>retr_timer1</varname>,
			<varname>retr_timer2</varname>,
			<function>t_reset_retr()</function>.
	</para>
	<example>
	    <title><function>t_set_retr</function> usage</title>
	    <programlisting>
...
route { 
	t_set_retr(250, 0); # set only T1 to 250 ms
	t_on_branch("1");
	t_relay(); 
} 

branch_route[1] {
	# if we are calling the a remote pstn, extend T1 and decrease T2
	# for all the branches
	if (uri=~"sip:[0-9]+"){
		t_set_retr(500, 2000); 
	}
}
	    </programlisting>
	</example>
	</section>


	<section id="tm.f.t_reset_retr">
	<title>
	    <function>t_reset_retr()</function>
	</title>
	<para>
		Resets the <varname>retr_timer1</varname> and 
		<varname>retr_timer2</varname> for the current transaction to the 
		default values (set using the tm module parameters
		<varname>retr_timer1</varname> and <varname>retr_timer2</varname>).
	</para>
	<para>
		It will effectively cancel any previous calls to 
		<function>t_set_retr</function> for the same transaction.
	</para>
	<para>
		See also: <varname>retr_timer1</varname>,
				<varname>retr_timer2</varname>,
				<function>t_set_retr</function>.
	</para>
	<example>
		<title><function>t_reset_retr</function> usage</title>
		<programlisting>
...
route { 
...
		t_reset_retr();
...
} 
		</programlisting>
	</example>
	</section>

	<section id="tm.f.t_set_auto_inv_100">
	<title>
	    <function>t_set_auto_inv_100(0|1)</function>
	</title>
	<para>
		Switch automatically sending 100 replies to INVITEs on/off on a 
		per transaction basis. It overrides the 
		<varname>auto_inv_100</varname> value for the current transaction.
	</para>
	<para>
		See also: <varname>auto_inv_100</varname>.
	</para>
	<example>
		<title><function>t_set_auto_inv_100</function> usage</title>
		<programlisting>
...
route { 
...
	if (src_ip==1.2.3.0/24)
		t_set_auto_inv_100(0); # turn off automatic 100 replies
...
} 
		</programlisting>
	</example>
	</section>

	<section id="tm.f.t_branch_timeout">
	<title>
	    <function>t_branch_timeout()</function>
	</title>
	<para>
		Returns true if the failure route is executed for a branch that did
		timeout. It can be used from 
		<emphasis>failure_route</emphasis> and
		<emphasis>branch-failure</emphasis> event route.
	</para>
	<example>
	    <title><function>t_branch_timeout</function> usage</title>
	    <programlisting>
...
failure_route[0]{ 
	if (t_branch_timeout()){
		log("timeout\n");
		# ... 
	}
} 
	    </programlisting>
	</example>
	</section>

<section id="tm.f.t_branch_replied">
	<title>
	    <function>t_branch_replied()</function>
	</title>
	<para>
		Returns true if the failure route is executed for a branch that did
		receive at least one reply in the past (the "current" reply is not 
		taken into account). It can be used from
		<emphasis>failure_route</emphasis>  and
		<emphasis>branch-failure</emphasis> event route.
	</para>
	<example>
	    <title><function>t_branch_replied</function> usage</title>
	    <programlisting>
...
failure_route[0]{ 
	if (t_branch_timeout()){
		if (t_branch_replied())
			log("timeout after receiving a reply (no answer?)\n");
		else
			log("timeout, remote side seems to be down\n");
		# ... 
	}
} 
	    </programlisting>
	</example>
	</section>

<section id="tm.f.t_any_timeout">
	<title>
	    <function>t_any_timeout()</function>
	</title>
	<para>
		Returns true if at least one of the current transactions branches
		did timeout.
	</para>
	<example>
	    <title><function>t_any_timeout</function> usage</title>
	    <programlisting>
...
failure_route[0]{ 
	if (!t_branch_timeout()){
		if (t_any_timeout()){
			log("one branch did timeout\n");
			sl_send_reply("408", "Timeout");
		}
	}
} 
	    </programlisting>
	</example>
	</section>

<section id="tm.f.t_any_replied">
	<title>
	    <function>t_any_replied()</function>
	</title>
	<para>
		Returns true if at least one of the current transactions branches
		did receive some reply in the past. If called from a failure or
		onreply route, the "current" reply is not taken into account.
	</para>
	<example>
	    <title><function>t_any_replied</function> usage</title>
	    <programlisting>
...
onreply_route[0]{ 
	if (!t_any_replied()){
		log("first reply received\n");
		# ...
	}
} 
	    </programlisting>
	</example>
</section>

<section id="tm.f.t_grep_status">
	<title>
	    <function>t_grep_status("code")</function>
	</title>
	<para>
		Returns true if "code" is the final reply received (or locally
		 generated) in at least one of the current transactions branches.
	</para>
	<example>
	    <title><function>t_grep_status</function> usage</title>
	    <programlisting>
...
onreply_route[0]{ 
	if (t_grep_status("486")){
		/* force a 486 reply, even if this is not the winning branch */
		t_reply("486", "Busy");
	}
} 
	    </programlisting>
	</example>
</section>

<section id="tm.f.t_is_canceled">
	<title>
	    <function>t_is_canceled()</function>
	</title>
	<para>
		Returns true if the current transaction was canceled.
	</para>
	<example>
	    <title><function>t_is_canceled</function> usage</title>
	    <programlisting>
...
failure_route[0]{ 
	if (t_is_canceled()){
		log("transaction canceled\n");
		# ...
	}
} 
	    </programlisting>
	</example>
	</section>

	<section id="tm.f.t_is_expired">
	<title>
	    <function>t_is_expired()</function>
	</title>
	<para>
		Returns true if the current transaction has already been expired,
		i.e. the max_inv_lifetime/max_noninv_lifetime interval has already
		elapsed.
	</para>
	<example>
	    <title><function>t_is_expired</function> usage</title>
	    <programlisting>
...
failure_route[0]{ 
	if (t_is_expired()){
		log("transaction expired\n");
		# There is no point in adding a new branch.
	}
} 
	    </programlisting>
	</example>
	</section>

    <section id="tm.f.t_relay_cancel">
	<title>
	    <function>t_relay_cancel()</function>
	</title>
	<para>
		Forwards the CANCEL if the corresponding INVITE transaction
		exists. The function is supposed to be used at the very
		beginning of the script, because the CANCELs can be caught
		and the rest of the script can be bypassed this way. Do not disable
		<varname>reparse_invite</varname> module parameter, and call
		<varname>t_relay_cancel()</varname> right after the sanity tests.
	</para>
	<para>
		Return value is 0 (drop) if the corresponding INVITE was found
		and the CANCELs were successfully sent to the pending branches,
		true if the INVITE was not found, and false in case of any error.
	</para>
	<example>
	    <title><function>t_relay_cancel</function> usage</title>
	    <programlisting>

if (method == CANCEL) {
	if (!t_relay_cancel()) {  # implicit drop if relaying was successful,
                                  # nothing to do

		# corresponding INVITE transaction found but error occurred
		sl_reply("500", "Internal Server Error");
		drop;
	}
	# bad luck, corresponding INVITE transaction is missing,
	# do the same as for INVITEs
}
	    </programlisting>
	</example>
    </section>

    <section id="tm.f.t_lookup_cancel">
	<title>
	    <function>t_lookup_cancel([1])</function>
	</title>
	<para>
		Returns true if the corresponding INVITE transaction exists
		for a CANCEL request. The function can be called at the beginning
		of the script to check whether or not the CANCEL can be immediately
		forwarded bypassing the rest of the script. Note however that
		<function>t_relay_cancel</function> includes
		<function>t_lookup_cancel</function> as well, therefore it is not
		needed to explicitly call this function unless something has to be
		logged for example.
	</para>
	<para>
		If the function parameter (optional) is set to 1, the message flags
		are overwritten with the flags of the INVITE. isflagset() can be used
		to check the flags of the previously forwarded INVITE in this case.
	</para>
	<example>
	    <title><function>t_lookup_cancel</function> usage</title>
	    <programlisting>

if (method == CANCEL) {
	if (t_lookup_cancel()) {
		log("INVITE transaction exists");
		if (!t_relay_cancel()) {  # implicit drop if
                                          # relaying was successful,
                                          # nothing to do

			# corresponding INVITE transaction found
			# but error occurred
			sl_reply("500", "Internal Server Error");
			drop;
		}
	}
	# bad luck, corresponding INVITE transaction is missing,
	# do the same as for INVITEs
}
	    </programlisting>
	</example>
    </section>

    <section id="tm.f.t_drop_replies">
	<title>
	    <function>t_drop_replies([mode])</function>
	</title>
	<para>
		Drops all the previously received replies in failure_route
		block to make sure that none of them is picked up again.
	</para>
	<para>
		The parameter 'mode' controls which replies are dropped: 'a'
		or missing - all replies are dropped; 'l' - replies received for
		last set of branches are dropped; 'n' - no reply is dropped.
	</para>
	<para>
		Dropping replies works only if a new branch is added to the
		transaction, or it is explicitly replied in the script!
	</para>
	<example>
	    <title><function>t_drop_replies()</function> usage</title>
	    <programlisting>
...
failure_route[0]{ 
	if (t_check_status("5[0-9][0-9]")){
		# I do not like the 5xx responses,
		# so I give another chance to "foobar.com",
		# and I drop all the replies to make sure that
		# they are not forwarded to the caller.
		t_drop_replies();
		
		rewritehostport("foobar.com");
		append_branch();
		t_relay();
	}
} 
	    </programlisting>
	</example>
    </section>

    <section id="tm.f.t_save_lumps">
	<title>
	    <function>t_save_lumps()</function>
	</title>
	<para>
		Forces the modifications of the processed SIP message
		to be saved in shared memory before t_relay() is called.
		The new branches which are created in failure_route will
		contain the same modifications, and any other modification
		after t_save_lumps() will be lost.
	</para>
	<para>
		Note that t_relay() automatically saves the modifications
		when it is called the first time, there is no need for
		t_save_lumps() unless message changes between t_save_lumps()
		and t_relay() must not be propagated to failure_route.
	</para>
	<para>
		The transaction must be created by t_newtran() before
		calling t_save_lumps().
	</para>
	<example>
	    <title><function>t_save_lumps()</function> usage</title>
	    <programlisting>
route {
	...
	t_newtran();
	append_hf("hf1: my first header\r\n");
	...
	t_save_lumps();
	append_hf("hf2: my second header\r\n");
	...
	t_on_failure("1");
	t_relay();
}

failure_route[1] {
	append_branch();
	append_hf("hf3: my third header\r\n");
	#
	# This branch contains hf1 and hf3, but does
	# not contain hf2 header.
	# hf2 would be also present here without
	# t_save_lumps().
	...
	t_relay();
}
	    </programlisting>
	</example>
    </section>

	<section id="tm.f.t_load_contacts">
		<title>
		<function moreinfo="none">t_load_contacts()</function>
		</title>
		<para>
		  This is the first of the three functions that can be used
		  to implement 
		  serial/parallel forking based on q and +sip.instance
		  values of individual branches in the destination set.
		</para>
		<para>
		  Function <function>t_load_contacts()</function> removes
		  all branches from the current destination set and stores
		  them into the XAVP whose name is configured with the
		  parameter <varname>contacts_avp</varname>.
		  Note that you have to
		  configure this parameter before you can use the function, the
		  parameter is set to NULL by default, which disables
		  the function.
		</para>
		<para>
		  If the destination set contains only one branch,
		  the function does nothing.
		</para>
		<para>
		  If the current destination set contains more than one branch,
		  the function sorts them
		  according to increasing value of the q parameter and
		  then stores the branches in reverse order into the XAVP.
		</para>
		<para>
		  The q parameter of a branch contains a value from range 0-1.0
		  and it  expresses relative preferrence of the branch
		  among all branches in the destination set.
		  The higher the q value the more preference the
		  user agent gave to the branch. Branches with higher q
		  values will be tried before branches with lower ones
		  when serial forking takes place.
		</para>
		<para>
		  After calling <function>t_load_contacts()</function>, function
		  <function>t_next_contacts()</function> and possibly
		  also <function>t_next_contact_flow()</function> need
		  to be called
		  one or more times in order to retrieve the branches based
		  on their q value.
		</para>
		<para>
		  Function returns 1 if loading of contacts succeeded or
		  there was nothing to do. In case of an error,
		  function returns -1 (see syslog).
		</para>
		<para>
		This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>t_load_contacts</function> usage</title>
		<programlisting format="linespecific">
...
if (!t_load_contacts()) {
        sl_send_reply("500", "Server Internal Error - Cannot load contacts");
        exit;
};
...
</programlisting>
		</example>
	</section>

	<section id="tm.f.t_next_contacts">
		<title>
		<function moreinfo="none">t_next_contacts()</function>
		</title>
		<para>
		  Function <function>t_next_contacts()</function> is the
		  second of the three functions that can be used to
		  implement serial/parallel
		  forking based on the q value of the individual branches
		  in a destination set.
		</para>
		<para>
		  The function adds to request a new destination set that
		  includes the highest priority contacts in contacts_avp,
		  but only one contact with the same +sip.instance value is
		  included.  Duplicate contacts are added to contact_flows_avp
		  for later consumption by function 
		  <function>next_contact_flow()</function>.
		  Upon each call, Request URI is rewritten with
		  the first contact and the remaining contacts (if any) are
		  added as branches. Then all highest priority contacts
		  are removed from contacts_avp.
		</para>
		<para>
		  Function does nothing if <varname>contact_avp</varname> has
		  no values.
		</para>
		<para>
		Function returns 1 if contacts_avp was not empty and a
		destination set was successfully added,
		returns -2 if contacts_avp was empty and thus there was
		nothing to do, and returns -1 in case of an error (see
		syslog).
          	Function can be called from REQUEST_ROUTE and FAILURE_ROUTE.
		</para>
		<para>
		  Note that if you use <function>t_load_contacts</function>
		  and <function>t_next_contacts</function> functions then
		  you should also set the value of
		  <varname>restart_fr_on_each_reply</varname>
		  parameter to 0. If you do not do that, it can
		  happen that a
		  broken user agent that retransmits 180 periodically will keep
		  resetting the fr_inv_timer value and serial
		  forking never happens.
		</para>
		<para>
		Before calling t_relay(), you can check if the
		previous call of <function>next_contacts()</function>
		consumed all branches
		by checking if <varname>contact_avp</varname> and
		<varname>contact_flows_avp</varname> are not anymore set.
		Based on
		that test, you can then use t_set_fr() function to set
		timers according to your needs.
		</para>
		<example>
		<title><function>t_next_contacts</function> usage</title>
		<programlisting format="linespecific">
...
# First call after t_load_contacts() when transaction does not exist yet
# and contacts should be available
if (!t_next_contacts()) {
        sl_send_reply("500", "Server Internal Error - Cannot get contacts");
} else {
        t_relay();
};
...
# Following call, when transaction exists and there may or may not be
# contacts left
if (!t_next_contacts()) {
        t_reply("408", "Request Timeout");
} else {
        t_relay();
};
...
</programlisting>
		</example>
	</section>

	<section id="tm.f.t_next_contact_flow">
		<title>
		<function moreinfo="none">t_next_contact_flow()</function>
		</title>
		<para>
		  Function <function>t_next_contact_flow()</function>
		  is the last of the three functions that can be used to
		  implement serial/parallel forking based on the q value
		  and instance value of individual branches in a destination set.
		</para>
		<para>
		  Function adds a new branch to the request that includes
		  the first contact from <varname>contact_flows_avp</varname>
		  that matches the +sip.instance value of the flow that has failed.
		  Upon each call, Request URI is rewritten with the contact. The
		  used contact is removed from <varname>contact_flows_avp</varname>.
		</para>
		<para>
		  Function does nothing if there are
		  no <varname>contact_flows_avp</varname> values.
		</para>
		<para>
		Function returns 1 if <varname>contact_flows_avp</varname>
		was not empty and a destination set was successfully added,
		returns -2 if <varname>contacts_avp</varname>
		was empty and thus there was
		nothing to do, and returns -1 in case of an error (see
		syslog).
		This function can be used from a BRANCH_FAILURE event route.
		</para>
		<example>
		<title><function>t_next_contact_flow</function> usage</title>
		<programlisting format="linespecific">
...
event_route[tm:branch-failure:outbound]
{
	if (t_next_contact_flow())
	{
		t_relay();
	} else {
		xlog("L_INFO", "No more flows\n");
	}
...
</programlisting>
		</example>
	</section>

	<section id="tm.f.t_check_status">
		<title>
		<function moreinfo="none">t_check_status(re)</function>
		</title>
		<para>
		Returns true if the regular expresion <quote>re</quote> match the
		reply code of the response message as follows:
		<itemizedlist>
		<listitem>
			<para><emphasis>in routing block</emphasis> - the code of the
			last sent reply.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>in on_reply block</emphasis> - the code of the
			current received reply.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>in on_failure block</emphasis> - the code of the
			selected negative final reply.
			</para>
		</listitem>
		</itemizedlist>
		</para>
		<para>
		This function can be used from ANY_ROUTE .
		</para>
		<example>
		<title><function>t_check_status</function> usage</title>
		<programlisting format="linespecific">
...
if (t_check_status("(487)|(408)")) {
    log("487 or 408 negative reply\n");
}
...
</programlisting>
		</example>
	</section>

	<section id="tm.f.t_check_trans">
	<title>
		<function>t_check_trans()</function>
	</title>
	<para>
		<function>t_check_trans()</function> can be used to quickly check if
		a message belongs or is related to a transaction. It behaves
		differently for different types of messages:
		<itemizedlist>
			<listitem>
				<para>For a SIP Reply it returns true if the reply belongs to
				an existing transaction and false otherwise.</para>
			</listitem>
			<listitem>
				<para>For a CANCEL it behaves exactly as
				<function>t_lookup_cancel()</function>: returns true if a
				corresponding INVITE transaction exists for the CANCEL and
				false otherwise.</para>
			</listitem>
			<listitem>
				<para>For ACKs to negative replies or for ACKs to local
				transactions it will terminate the script if the ACK belongs
				to a transaction (it would make very little sense to process
				an ACK to a negative reply  for an existing transaction in
				some other way then to simply pass it to tm) or return false
				if not.</para>
			</listitem>
			<listitem>
				<para>For end-to-end ACKs (ACKs to 2xx responses for forwarded
				INVITE transactions) it will return true if the corresponding
				INVITE transaction is found and still active and false if not.
				</para>
				<note>
				<para>
				Note that the e2e ACK matching is more of a hint
				then a certainty. A delayed e2e ACK might arrive after the
				transaction wait time elapses, when the INVITE transaction no
				longer exists and thus would not match anything. There are
				also cases when tm would not keep all the information needed
				for e2e ACK matching (since this is not needed for a statefull
				proxy and it requires additional memory, tm will not keep this
				information unless needed by some other module or callbacks).
				</para>
				</note>
			</listitem>
			<listitem>
				<para>For other requests (non ACKs and non CANCELs), in case of
				a retransmission matching a transaction, it resends the last
				reply for that transaction and terminates the config execution.
				Otherwise, it returns false (in case of new requests for which
				no transaction exists yet).</para>
			</listitem>
		</itemizedlist>
	</para>
	<note><para>
		An important difference from kamailio version is that for an ACK to
		negative reply or for a local transaction, the script execution will be
		immediately stopped and the message handled by tm, instead of returning
		true.
	</para></note>
	<para><function>t_check_trans()</function> functionality for requests,
		except for the e2e ACK matching, can be replicated in the script
		using <function>t_lookup_cancel()</function> and
		<function>t_lookup_request()</function>.
	</para>
	<para>See also: <function>t_lookup_request()</function>,
					<function>t_lookup_cancel()</function>.
	</para>
	<example>
		<title><function>t_check_trans</function> usage</title>
		<programlisting>

if ( method == "CANCEL" &amp;&amp; !t_check_trans())
	sl_reply("403", "cancel out of the blue forbidden");
# note: in this example t_check_trans() can be replaced by t_lookup_cancel()

		</programlisting>
	</example>
	</section>

	<section id="tm.f.t_set_disable_6xx">
	<title>
		<function>t_set_disable_6xx(0|1)</function>
	</title>
	<para>
		Turn off/on 6xx replies special rfc conformant handling on a per
		transaction basis. If turned off
		(<function>t_set_disable_6xx("1")</function>) 6XXs will be treated
		like normal replies.
	</para>
	<para>
		It overrides the <varname>disable_6xx_block</varname> value for
		the current transaction.
	</para>
	<para>
		See also: <varname>disable_6xx_block</varname>.
	</para>
	<example>
		<title><function>t_set_disable_6xx</function> usage</title>
		<programlisting>
...
route {
...
	if (src_ip==1.2.3.4) # bad user agent that sends 603
		t_set_disable_6xx(1); # turn off 6xx special handling
...
}
		</programlisting>
	</example>
	</section>

	<section id="tm.f.t_set_disable_failover">
	<title>
		<function>t_set_disable_failover(0|1)</function>
	</title>
	<para>
		Turn off/on dns failover on a per transaction basis.
	</para>
	<para>
		See also: <varname>use_dns_failover</varname>.
	</para>
	<example>
		<title><function>t_set_disable_failover</function> usage</title>
		<programlisting>
...
route {
...
	if (uri=~"@foo.bar$")
		t_set_disable_failover(1); # turn off dns failover
...
}
		</programlisting>
	</example>
	</section>

	<section id="tm.f.t_set_disable_internal_reply">
	<title>
		<function>t_set_disable_internal_reply(0|1)</function>
	</title>
	<para>
		Turn off/on sending internally a SIP reply in case of relay errors.
	</para>
	<example>
		<title><function>t_set_disable_internal_reply</function> usage</title>
		<programlisting>
...
t_set_disable_internal_reply(1); # turn off sending internal reply on error
if(!t_relay()) {
   send_reply("500", "Server error");
}
...
		</programlisting>
	</example>
	</section>

	<section id="tm.f.t_replicate">
	<title>
	    <function>t_replicate([params])</function>
	</title>
	<para>
		Replicate the SIP request to a specific address.
	</para>
	<para>
		There are several function prototypes:
		<itemizedlist>
		<listitem><para>
	    <function>t_replicate([uri])</function>,
		</para></listitem>
		<listitem><para>
	    <function>t_replicate(host, port)</function>,
		</para></listitem>
		<listitem><para>
	    <function>t_replicate_udp(host, port)</function>
		</para></listitem>
		<listitem><para>
	    <function>t_replicate_tcp(host, port)</function>
		</para></listitem>
		<listitem><para>
	    <function>t_replicate_tls(host, port)</function>
		</para></listitem>
		<listitem><para>
	    <function>t_replicate_sctp(host, port)</function>
		</para></listitem>
		<listitem><para>
	    <function>t_replicate_to(proto, hostport)</function>
		</para></listitem>
		</itemizedlist>
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>uri</emphasis> - SIP URI where the message should be sent.
			It can be given via a script variable. It is optional - when missing, the
			dst-uri or r-uri are used as next hop address.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>host</emphasis> - host address where the message should be sent.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>port</emphasis> - port number.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>proto</emphasis> - transport protocol to be used.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>hostport</emphasis> - address in "host:port" format. It can be
		given via an AVP.
		</para>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function>t_replicate</function> usage</title>
	    <programlisting>
...
# sent to 1.2.3.4:5060 over tcp
t_replicate("sip:1.2.3.4:5060;transport=tcp");

# sent to 1.2.3.4:5061 over tls
$var(h) = "1.2.3.4:5061";
t_replicate("sip:$var(h);transport=tls");

# sent to 1.2.3.4:5060 over udp
t_replicate_to_udp("1.2.3.4", "5060");
...
	    </programlisting>
	</example>
    </section>
	<section id="tm.f.t_relay_to">
	<title>
	    <function>t_relay_to(proxy, flags)</function>
	</title>
	<para>
		Forward the SIP request to a specific address, controlling internal
		behavior via flags.
	</para>
	<para>
		There are several function prototypes:
		<itemizedlist>
		<listitem><para>
	    <function>t_relay_to()</function>,
		</para></listitem>
		<listitem><para>
	    <function>t_relay_to(proxy)</function>,
		</para></listitem>
		<listitem><para>
	    <function>t_relay_to(flags)</function>
		</para></listitem>
		<listitem><para>
	    <function>t_relay_to(proxy, flags)</function>
		</para></listitem>
		</itemizedlist>
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>proxy</emphasis> - address where the request should
		be sent. Format is: "proto:host:port" - any of proto or port can be
		ommitted, along with the semicolon after or before.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>flags</emphasis> - bitmask integer value to control
		the internal behavior. Bits can be:
		</para>
		<itemizedlist>
	    <listitem>
		<para><emphasis>0x01</emphasis> - do not generate 100 reply.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>0x02</emphasis> - do not generate reply on internal
		error.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>0x04</emphasis> - disable dns failover.
		</para>
	    </listitem>
		</itemizedlist>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function>t_relay_to</function> usage</title>
	    <programlisting>
...
# sent to 1.2.3.4:5060 over tcp
t_relay_to("tcp:1.2.3.4:5060");

# sent to 1.2.3.4 over tls
t_relay_to("tls:1.2.3.4");

# sent to dst URI or R-URI without a 100 reply
t_relay_to("0x01");
...
	    </programlisting>
	</example>
    </section>


	<section id="tm.f.t_set_no_e2e_cancel_reason">
	<title>
		<function>t_set_no_e2e_cancel_reason(0|1)</function>
	</title>
	<para>
		Enables/disables reason header (RFC 3326) copying from the triggering
		received CANCEL to the generated hop-by-hop CANCEL. 0 enables and
		1 disables.
	</para>
	<para>
		It overrides the <varname>e2e_cancel_reason</varname> setting (module
		 parameter) for the current transaction.
	</para>
	<para>
		See also: <varname>e2e_cancel_reason</varname>.
	</para>
	<example>
		<title><function>t_set_no_e2e_cancel_reason</function> usage</title>
		<programlisting>
...
route {
...
	if (src_ip!=10.0.0.0/8) #  don't trust CANCELs from the outside
		t_set_no_e2e_cancel_reason(1); # turn off CANCEL reason header copying
...
}
		</programlisting>
	</example>
	</section>

	<section id="tm.f.t_is_set">
	<title>
	    <function>t_is_set(target)</function>
	</title>
	<para>
		Return true if the attribute specified by 'target' is set for transaction.
	</para>
	<para>The target parameter can be:</para>
	<itemizedlist>
	    <listitem>
		<para><emphasis>branch_route</emphasis> - the function returns true if a
			branch route is set to be executed.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>failure_route</emphasis> - the function returns true if a
			failure route is set to be executed.
		</para>
	    </listitem>
	    <listitem>
		<para><emphasis>onreply_route</emphasis> - the function returns true if an
			onreply route is set to be executed.
		</para>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function>t_replicate</function> usage</title>
	    <programlisting>
...
if(!t_is_set("failure_route"))
    LM_DBG("no failure route will be executed for current transaction\n");
...
	    </programlisting>
	</example>
    </section>

	<section id="tm.f.t_use_uac_headers">
	<title>
	    <function>t_use_uac_headers()</function>
	</title>
	<para>
	Set internal flags to tell tm to use UAC side for building headers for
	local generated requests (ACK, CANCEL) - useful when changing From/To
	headers using other functions than uac_replace_[from|to]().
	</para>
	<para>It returns true.</para>
	<example>
	    <title><function>t_use_uac_headers</function> usage</title>
	    <programlisting>
...
t_use_uac_headers();
...
	    </programlisting>
	</example>
    </section>

</section>