Debian Codegraph @

src/modules/tmx/README

raw
1 TMX Module
2
3 Daniel-Constantin Mierla
4
5 asipto.com
6 <[email protected]>
7
8 Juha Heinanen
9
10 TutPro Inc.
11 <[email protected]>
12
13 Edited by
14
15 Daniel-Constantin Mierla
16
17 <[email protected]>
18
19 Juha Heinanen
20
21 <[email protected]>
22
23 Copyright © 2009 Daniel-Constantin Mierla
24 __________________________________________________________________
25
26 Table of Contents
27
28 1. Admin Guide
29
30 1. Overview
31 2. Dependencies
32
33 2.1. Kamailio Modules
34 2.2. External Libraries or Applications
35
36 3. Parameters
37
38 3.1. precheck_trans (int)
39
40 4. Functions
41
42 4.1. t_cancel_branches(which)
43 4.2. t_cancel_callid(callid, cseq, flag [, rcode])
44 4.3. t_uac_ack_local(callid, cseq [, headers [, body]])
45 4.4. t_reply_callid(callid, cseq, code, reason)
46 4.5. t_flush_flags()
47 4.6. t_flush_xflags()
48 4.7. t_is_failure_route()
49 4.8. t_is_branch_route()
50 4.9. t_is_reply_route()
51 4.10. t_is_request_route()
52 4.11. t_suspend()
53 4.12. t_continue(tindex, tlabel, rtname)
54 4.13. t_drop([rcode])
55 4.14. t_reuse_branch()
56 4.15. t_precheck_trans()
57
58 5. Exported Variables
59 6. Statistics
60
61 6.1. UAS_transactions
62 6.2. UAC_transactions
63 6.3. 2xx_transactions
64 6.4. 3xx_transactions
65 6.5. 4xx_transactions
66 6.6. 5xx_transactions
67 6.7. 6xx_transactions
68 6.8. inuse_transactions
69 6.9. active_transactions
70 6.10. rpl_received
71 6.11. rpl_absorbed
72 6.12. rpl_relayed
73 6.13. rpl_generated
74 6.14. rpl_sent
75
76 List of Examples
77
78 1.1. precheck_trans (int)
79 1.2. t_cancel_branches usage
80 1.3. t_cancel_callid usage
81 1.4. t_uac_ack_local usage
82 1.5. t_reply_callid usage
83 1.6. t_flush_flags usage
84 1.7. t_flush_xflags usage
85 1.8. t_is_failure_route usage
86 1.9. t_is_branch_route usage
87 1.10. t_is_reply_route usage
88 1.11. t_is_request_route usage
89 1.12. t_suspend usage
90 1.13. t_continue usage
91 1.14. t_drop usage
92 1.15. t_reuse_branch usage
93 1.16. t_precheck_trans usage
94
95 Chapter 1. Admin Guide
96
97 Table of Contents
98
99 1. Overview
100 2. Dependencies
101
102 2.1. Kamailio Modules
103 2.2. External Libraries or Applications
104
105 3. Parameters
106
107 3.1. precheck_trans (int)
108
109 4. Functions
110
111 4.1. t_cancel_branches(which)
112 4.2. t_cancel_callid(callid, cseq, flag [, rcode])
113 4.3. t_uac_ack_local(callid, cseq [, headers [, body]])
114 4.4. t_reply_callid(callid, cseq, code, reason)
115 4.5. t_flush_flags()
116 4.6. t_flush_xflags()
117 4.7. t_is_failure_route()
118 4.8. t_is_branch_route()
119 4.9. t_is_reply_route()
120 4.10. t_is_request_route()
121 4.11. t_suspend()
122 4.12. t_continue(tindex, tlabel, rtname)
123 4.13. t_drop([rcode])
124 4.14. t_reuse_branch()
125 4.15. t_precheck_trans()
126
127 5. Exported Variables
128 6. Statistics
129
130 6.1. UAS_transactions
131 6.2. UAC_transactions
132 6.3. 2xx_transactions
133 6.4. 3xx_transactions
134 6.5. 4xx_transactions
135 6.6. 5xx_transactions
136 6.7. 6xx_transactions
137 6.8. inuse_transactions
138 6.9. active_transactions
139 6.10. rpl_received
140 6.11. rpl_absorbed
141 6.12. rpl_relayed
142 6.13. rpl_generated
143 6.14. rpl_sent
144
145 1. Overview
146
147 This module collects extensions from Kamailio TM module.
148
149 Kamailio TM (Transaction Management) module documentation is available
150 at: https://www.kamailio.org/docs/modules/stable/modules/tm.html
151
152 2. Dependencies
153
154 2.1. Kamailio Modules
155 2.2. External Libraries or Applications
156
157 2.1. Kamailio Modules
158
159 The following modules must be loaded before this module:
160 * tm - transaction management.
161
162 2.2. External Libraries or Applications
163
164 The following libraries or applications must be installed before
165 running Kamailio with this module loaded:
166 * None.
167
168 3. Parameters
169
170 3.1. precheck_trans (int)
171
172 3.1. precheck_trans (int)
173
174 Enable/disable transaction pre-check via t_precheck_trans() function.
175 If set to 0, the internal structures are not created at startup and the
176 function will return false always.
177
178 Default value is 1 (enabled).
179
180 Example 1.1. precheck_trans (int)
181 ...
182 modparam("tmx", "precheck_trans", 0)
183 ...
184
185 4. Functions
186
187 4.1. t_cancel_branches(which)
188 4.2. t_cancel_callid(callid, cseq, flag [, rcode])
189 4.3. t_uac_ack_local(callid, cseq [, headers [, body]])
190 4.4. t_reply_callid(callid, cseq, code, reason)
191 4.5. t_flush_flags()
192 4.6. t_flush_xflags()
193 4.7. t_is_failure_route()
194 4.8. t_is_branch_route()
195 4.9. t_is_reply_route()
196 4.10. t_is_request_route()
197 4.11. t_suspend()
198 4.12. t_continue(tindex, tlabel, rtname)
199 4.13. t_drop([rcode])
200 4.14. t_reuse_branch()
201 4.15. t_precheck_trans()
202
203 4.1. t_cancel_branches(which)
204
205 Cancel branches of an active SIP transaction. The function can be
206 called for a SIP reply that will identify the current branch.
207
208 Parameter can be:.
209 * all - cancel all branches.
210 * others - cancel all branches but the current one.
211 * this - cancel current branch.
212
213 This function can be used in ONREPLY_ROUTE.
214
215 Example 1.2. t_cancel_branches usage
216 ...
217 if (t_cancel_branches("all")) {
218 xlog("cancelled all branches\n");
219 }
220 ...
221
222 4.2. t_cancel_callid(callid, cseq, flag [, rcode])
223
224 Cancel first INVITE transaction identified by callid and cseq. It sets
225 the flag if the value is greater than zero
226
227 Parameters:.
228 * callid - call-id value.
229 * cseq - cseq number.
230 * flag - index of the flag to set.
231 * rcode - code to be added as cause attribute in Reason header for
232 generated CANCEL request. This parameter is optional.
233
234 This function can be used in ANY_ROUTE.
235
236 Example 1.3. t_cancel_callid usage
237 ...
238 if (t_cancel_callid("123qaz", "5", "22")) {
239 xlog("transaction cancelled\n");
240 }
241 ...
242 if (t_cancel_callid("123qaz", "5", "22", "200")) {
243 xlog("transaction cancelled with [Reason: cause=200]\n");
244 }
245 ...
246
247 4.3. t_uac_ack_local(callid, cseq [, headers [, body]])
248
249 ACK the first transaction found with specified Call-ID and C-Seq.
250 Optionally include extra headers and request body.
251
252 Parameters:.
253 * callid - call-id value.
254 * cseq - cseq number.
255 * headers - extra headers to append
256 * body - body to include
257
258 This function can be used in ANY_ROUTE.
259
260 Example 1.4. t_uac_ack_local usage
261 ...
262 if (t_uac_ack_local("123qaz", "5")) {
263 xlog("transaction ACKed\n");
264 }
265 ...
266
267 4.4. t_reply_callid(callid, cseq, code, reason)
268
269 Send reply to first transaction identified by callid and cseq.
270
271 Parameters:.
272 * callid - call-id value.
273 * cseq - cseq number.
274 * code - reply code.
275 * reason - reply reason.
276
277 This function can be used in ANY_ROUTE.
278
279 Example 1.5. t_reply_callid usage
280 ...
281 if (t_reply_callid("123qaz", "5", "458", "Replied remotely")) {
282 xlog("transaction replied\n");
283 }
284 ...
285
286 4.5. t_flush_flags()
287
288 Flush the flags from current SIP message into the already created
289 transaction. It makes sense only in routing block if the transaction
290 was created via t_newtran() and the flags have been altered since.
291
292 It is not needed to execute this function when using t_relay() (or
293 similar tm relay functions, flags are synchronized automatically in
294 that case).
295
296 This function can be used from ANY_ROUTE .
297
298 Example 1.6. t_flush_flags usage
299 ...
300 t_flush_flags();
301 ...
302
303 4.6. t_flush_xflags()
304
305 Flush the extended flags from current SIP message into the already
306 created transaction. It makes sense only in routing block if the
307 transaction was created via t_newtran() and the extended flags have
308 been altered since.
309
310 It is not needed to execute this function when using t_relay() (or
311 similar tm relay functions, xflags are synchronized automatically in
312 that case).
313
314 This function can be used from ANY_ROUTE .
315
316 Example 1.7. t_flush_xflags usage
317 ...
318 t_flush_xflags();
319 ...
320
321 4.7. t_is_failure_route()
322
323 Returns true if the top-executed route block is failure_route.
324
325 This function can be used from ANY_ROUTE .
326
327 Example 1.8. t_is_failure_route usage
328 ...
329 failure_route[xyz] {
330 route(abc);
331 }
332
333 route[abc] {
334 if(t_is_failure_route()) { ... }
335 }
336 ...
337
338 4.8. t_is_branch_route()
339
340 Returns true if the top-executed route block is branch_route.
341
342 This function can be used from ANY_ROUTE .
343
344 Example 1.9. t_is_branch_route usage
345 ...
346 branch_route[xyz] {
347 route(abc);
348 }
349
350 route[abc] {
351 if(t_is_branch_route()) { ... }
352 }
353 ...
354
355 4.9. t_is_reply_route()
356
357 Returns true if the top-executed route block is reply_route.
358
359 This function can be used from ANY_ROUTE .
360
361 Example 1.10. t_is_reply_route usage
362 ...
363 reply_route[xyz] {
364 route(abc);
365 }
366
367 route[abc] {
368 if(t_is_reply_route()) { ... }
369 }
370 ...
371
372 4.10. t_is_request_route()
373
374 Returns true if the top-executed route block is request_route.
375
376 This function can be used from ANY_ROUTE .
377
378 Example 1.11. t_is_request_route usage
379 ...
380 request_route[xyz] {
381 route(abc);
382 }
383
384 route[abc] {
385 if(t_is_request_route()) { ... }
386 }
387 ...
388
389 4.11. t_suspend()
390
391 Suspend the execution of SIP request in a transaction. If transaction
392 was not created yet, it is created by this function. Returns true in
393 case of success and internal transaction index and label are available
394 via $T(id_index) and $T(id_label).
395
396 This function can be used from ANY_ROUTE .
397
398 Example 1.12. t_suspend usage
399 ...
400 if(t_suspend())
401 {
402 xlog("processing suspended in transaction [$T(id_index):$T(id_label)]\n");
403 exit;
404 }
405 ...
406
407 4.12. t_continue(tindex, tlabel, rtname)
408
409 Continue the execution of the transaction identified by tindex and
410 tlabel with the actions defined in route[rtname].
411
412 Parameters:.
413 * tindex - internal index of transaction. Can be an integer or a
414 pseudo-variable.
415 * tlabel - internal label of transaction. Can be an integer or a
416 pseudo-variable.
417 * rtname - the name of the route block to execute. Can be a static
418 string value or a dynamic string with pseudo-variables.
419
420 Important note: the route[rtname] is executed in the context of a
421 failure (same behaviour for functions as they were used in a
422 failure_route block).
423
424 This function can be used in ANY_ROUTE.
425
426 Example 1.13. t_continue usage
427 ...
428 t_continue('123', '456', 'MYROUTE');
429 ...
430 route[MYROUTE] {
431 xlog("executed by t continue\n");
432 ...
433 }
434 ...
435
436 4.13. t_drop([rcode])
437
438 Drops the transaction with response code (500 default).
439
440 Parameters:.
441 * rcode - response code to set in uas status.
442
443 This function can be used in ANY_ROUTE.
444
445 Example 1.14. t_drop usage
446 ...
447 route[MYREQ]
448 {
449 ...
450 if (!t_newtran()) {
451 xlog("L_ERROR", "$ci|log|failed to create transaction\n");
452 drop;
453 }
454
455 t_on_failure("TR_ERROR");
456 t_on_reply("TR_OK");
457 t_relay();
458 }
459
460 failure_route[TR_ERROR]
461 {
462 xlog("L_INFO", "$ci|log|failed $T_reply_code $T_reply_reason\n");
463 t_drop();
464 }
465
466 onreply_route[TR_OK]
467 {
468 xlog("L_INFO", "$ci|log|checking transaction result\n");
469 if(status=~"60[0-9]") {
470 t_drop();
471 }
472 ...
473 }
474 ...
475
476 4.14. t_reuse_branch()
477
478 Creates new "main" branch by making copy of branch-failure branch.
479 Currently the following branch attributes are copied from
480 branch-failure branch: request-uri, ruid, path, instance, and branch
481 flags.
482
483 This function can be used from tm:branch-failure event_route.
484
485 Example 1.15. t_reuse_branch usage
486 ...
487 event_route [tm:branch-failure:contact] {
488 t_reuse_branch();
489 setbflag(10);
490 t_relay();
491 exit;
492 }
493 ...
494
495 4.15. t_precheck_trans()
496
497 Check if current processed message is handled by other process. This
498 function is useful to catch retransmissions before transaction is
499 created. The function returns true if the request is handled by another
500 process.
501
502 Note that ACK and CANCEL requests are not tracked by this function, the
503 return code being false for them.
504
505 This function can be used from REQUEST_ROUTE .
506
507 Example 1.16. t_precheck_trans usage
508 ...
509 # handle retransmissions
510 if(t_precheck_trans()) {
511 t_check_trans();
512 exit;
513 }
514 t_check_trans();
515 ...
516
517 5. Exported Variables
518
519 * $T_branch_idx
520 * $T_reply_code
521 * $T_reply_reason
522 * $T_reply_last
523 * $T_req(pv)
524 * $T_rpl(pv)
525 * $T_reply_ruid
526 * $T_branch(name)
527 * $T_inv(pv)
528 * $T(name)
529
530 Exported pseudo-variables are documented at
531 https://www.kamailio.org/wikidocs/.
532
533 6. Statistics
534
535 6.1. UAS_transactions
536 6.2. UAC_transactions
537 6.3. 2xx_transactions
538 6.4. 3xx_transactions
539 6.5. 4xx_transactions
540 6.6. 5xx_transactions
541 6.7. 6xx_transactions
542 6.8. inuse_transactions
543 6.9. active_transactions
544 6.10. rpl_received
545 6.11. rpl_absorbed
546 6.12. rpl_relayed
547 6.13. rpl_generated
548 6.14. rpl_sent
549
550 Exported statistics are listed in the next sections. These statistics
551 cannot be reset (see counters module for alternative).
552
553 6.1. UAS_transactions
554
555 Total number of transactions created by received requests.
556
557 6.2. UAC_transactions
558
559 Total number of transactions created by local generated requests.
560
561 6.3. 2xx_transactions
562
563 Total number of transactions completed with 2xx replies.
564
565 6.4. 3xx_transactions
566
567 Total number of transactions completed with 3xx replies.
568
569 6.5. 4xx_transactions
570
571 Total number of transactions completed with 4xx replies.
572
573 6.6. 5xx_transactions
574
575 Total number of transactions completed with 5xx replies.
576
577 6.7. 6xx_transactions
578
579 Total number of transactions completed with 6xx replies.
580
581 6.8. inuse_transactions
582
583 Number of transactions existing in memory at current time.
584
585 6.9. active_transactions
586
587 Number of ongoing transactions at current time.
588
589 6.10. rpl_received
590
591 Total number of replies received by TM module.
592
593 6.11. rpl_absorbed
594
595 Total number of replies received and not relayed by TM module.
596
597 6.12. rpl_relayed
598
599 Total number of replies received and relayed by TM module.
600
601 6.13. rpl_generated
602
603 Total number of replies locally generated and relayed by TM module.
604
605 6.14. rpl_sent
606
607 Total number of replies relayed by TM module.