Debian Codegraph @

src/modules/kex/README

raw
1 KEx Module
2
3 Daniel-Constantin Mierla
4
5 asipto.com
6 <[email protected]>
7
8 Ovidiu Sas
9
10 VoIP Embedded, Inc.
11
12 Edited by
13
14 Daniel-Constantin Mierla
15
16 <[email protected]>
17
18 Ovidiu Sas
19
20 <[email protected]>
21
22 Copyright © 2009 Daniel-Constantin Mierla
23
24 Copyright © 2014 VoIP Embedded, Inc.
25 __________________________________________________________________
26
27 Table of Contents
28
29 1. Admin Guide
30
31 1. Overview
32 2. Dependencies
33
34 2.1. Kamailio Modules
35 2.2. External Libraries or Applications
36
37 3. Functions
38
39 3.1. setsflag(flag)
40 3.2. issflagset(flag)
41 3.3. resetsflag(flag)
42 3.4. setbflag(flag [, branch])
43 3.5. isbflagset(flag [, branch])
44 3.6. resetbflag(flag [, branch])
45 3.7. setdsturi(uri)
46 3.8. resetdsturi()
47 3.9. isdsturiset()
48 3.10. pv_printf(var, str)
49 3.11. is_myself(uri)
50 3.12. is_myhost(uri)
51 3.13. setdebug(level)
52 3.14. resetdebug()
53 3.15. km_append_branch([uri])
54
55 4. RPC Commands
56
57 4.1. core.aliases_list
58 4.2. core.arg
59 4.3. core.echo
60 4.4. core.flags
61 4.5. core.info
62 4.6. core.runinfo
63 4.7. core.kill
64 4.8. core.printi
65 4.9. core.prints
66 4.10. core.ps
67 4.11. core.psx
68 4.12. core.pwd
69 4.13. core.shmmem
70 4.14. core.sockets_list
71 4.15. core.tcp_info
72 4.16. core.tcp_list
73 4.17. core.tcp_options
74 4.18. core.udp4_raw_info
75 4.19. core.uptime
76 4.20. core.version
77 4.21. core.ppdefines
78 4.22. core.modules
79 4.23. modparam.getn
80 4.24. modparam.gets
81 4.25. modparam.setn
82 4.26. modparam.list
83 4.27. pkg.stats
84 4.28. pkg.info
85 4.29. stats.get_statistics
86 4.30. stats.fetch
87 4.31. stats.fetchn
88 4.32. stats.reset_statistics
89 4.33. stats.clear_statistics
90 4.34. system.listMethods
91 4.35. system.methodHelp
92 4.36. system.methodSignature
93 4.37. mod.mem_stats
94 4.38. mod.stats
95 4.39. mod.mem_statsx
96
97 List of Examples
98
99 1.1. setsflag usage
100 1.2. issflagset usage
101 1.3. resetsflag usage
102 1.4. setbflag usage
103 1.5. isbflagset usage
104 1.6. resetbflag usage
105 1.7. setdsturi usage
106 1.8. resetdsturi usage
107 1.9. isdsturiset usage
108 1.10. pv_printf usage
109 1.11. is_myself usage
110 1.12. is_myhost usage
111 1.13. setdebug usage
112 1.14. resetdebug usage
113
114 Chapter 1. Admin Guide
115
116 Table of Contents
117
118 1. Overview
119 2. Dependencies
120
121 2.1. Kamailio Modules
122 2.2. External Libraries or Applications
123
124 3. Functions
125
126 3.1. setsflag(flag)
127 3.2. issflagset(flag)
128 3.3. resetsflag(flag)
129 3.4. setbflag(flag [, branch])
130 3.5. isbflagset(flag [, branch])
131 3.6. resetbflag(flag [, branch])
132 3.7. setdsturi(uri)
133 3.8. resetdsturi()
134 3.9. isdsturiset()
135 3.10. pv_printf(var, str)
136 3.11. is_myself(uri)
137 3.12. is_myhost(uri)
138 3.13. setdebug(level)
139 3.14. resetdebug()
140 3.15. km_append_branch([uri])
141
142 4. RPC Commands
143
144 4.1. core.aliases_list
145 4.2. core.arg
146 4.3. core.echo
147 4.4. core.flags
148 4.5. core.info
149 4.6. core.runinfo
150 4.7. core.kill
151 4.8. core.printi
152 4.9. core.prints
153 4.10. core.ps
154 4.11. core.psx
155 4.12. core.pwd
156 4.13. core.shmmem
157 4.14. core.sockets_list
158 4.15. core.tcp_info
159 4.16. core.tcp_list
160 4.17. core.tcp_options
161 4.18. core.udp4_raw_info
162 4.19. core.uptime
163 4.20. core.version
164 4.21. core.ppdefines
165 4.22. core.modules
166 4.23. modparam.getn
167 4.24. modparam.gets
168 4.25. modparam.setn
169 4.26. modparam.list
170 4.27. pkg.stats
171 4.28. pkg.info
172 4.29. stats.get_statistics
173 4.30. stats.fetch
174 4.31. stats.fetchn
175 4.32. stats.reset_statistics
176 4.33. stats.clear_statistics
177 4.34. system.listMethods
178 4.35. system.methodHelp
179 4.36. system.methodSignature
180 4.37. mod.mem_stats
181 4.38. mod.stats
182 4.39. mod.mem_statsx
183
184 1. Overview
185
186 This module collects extensions from Kamailio core.
187
188 Kamailio Core Cookbook is available at:
189 https://www.kamailio.org/wikidocs/
190
191 2. Dependencies
192
193 2.1. Kamailio Modules
194 2.2. External Libraries or Applications
195
196 2.1. Kamailio Modules
197
198 The following modules must be loaded before this module:
199 * No dependencies on other Kamailio modules.
200
201 2.2. External Libraries or Applications
202
203 The following libraries or applications must be installed before
204 running Kamailio with this module loaded:
205 * None.
206
207 3. Functions
208
209 3.1. setsflag(flag)
210 3.2. issflagset(flag)
211 3.3. resetsflag(flag)
212 3.4. setbflag(flag [, branch])
213 3.5. isbflagset(flag [, branch])
214 3.6. resetbflag(flag [, branch])
215 3.7. setdsturi(uri)
216 3.8. resetdsturi()
217 3.9. isdsturiset()
218 3.10. pv_printf(var, str)
219 3.11. is_myself(uri)
220 3.12. is_myhost(uri)
221 3.13. setdebug(level)
222 3.14. resetdebug()
223 3.15. km_append_branch([uri])
224
225 3.1. setsflag(flag)
226
227 Set the script flag.
228
229 Meaning of the parameters is as follows:
230 * flag - the index of the script flag to be set. Can be integer or
231 pseudo-variable with integer value.
232
233 This function can be used from ANY_ROUTE.
234
235 Example 1.1. setsflag usage
236 ...
237 setsflag("1");
238 ...
239 $var(flag) = 11;
240 setsflag("$var(flag)");
241 ...
242
243 3.2. issflagset(flag)
244
245 Return true if the script flag is set.
246
247 Meaning of the parameters is as follows:
248 * flag - the index of the script flag to be tested. Can be integer or
249 pseudo-variable with integer value.
250
251 This function can be used from ANY_ROUTE.
252
253 Example 1.2. issflagset usage
254 ...
255 if(issflagset("1"))
256 {
257 ...
258 }
259 ...
260
261 3.3. resetsflag(flag)
262
263 Reset the script flag.
264
265 Meaning of the parameters is as follows:
266 * flag - the index of the script flag to be reset. Can be integer or
267 pseudo-variable with integer value.
268
269 This function can be used from ANY_ROUTE.
270
271 Example 1.3. resetsflag usage
272 ...
273 resetsflag("1");
274 ...
275
276 3.4. setbflag(flag [, branch])
277
278 Set the branch flag.
279
280 Meaning of the parameters is as follows:
281 * flag - the index of the branch flag to be set. Can be integer or
282 pseudo-variable with integer value.
283 * branch - the index of the branch whose flag to be set. Can be
284 integer or pseudo-variable with integer value. If omitted, then
285 branch 0 is used (R-URI).
286
287 This function can be used from ANY_ROUTE.
288
289 Example 1.4. setbflag usage
290 ...
291 setbflag("1");
292 ...
293 $var(flag) = 11;
294 setbflag("$var(flag)", "1");
295 ...
296
297 3.5. isbflagset(flag [, branch])
298
299 Return true if the branch flag is set.
300
301 Meaning of the parameters is as follows:
302 * flag - the index of the branch flag to be tested. Can be integer or
303 pseudo-variable with integer value.
304 * branch - the index of the branch whose flag to be set. Can be
305 integer or pseudo-variable with integer value. If omitted, then
306 branch 0 is used (R-URI).
307
308 This function can be used from ANY_ROUTE.
309
310 Example 1.5. isbflagset usage
311 ...
312 if(isbflagset("1"))
313 {
314 ...
315 }
316 ...
317
318 3.6. resetbflag(flag [, branch])
319
320 Reset the branch flag.
321
322 Meaning of the parameters is as follows:
323 * flag - the index of the branch flag to be reset. Can be integer or
324 pseudo-variable with integer value.
325 * branch - the index of the branch whose flag to be set. Can be
326 integer or pseudo-variable with integer value. If omitted, then
327 branch 0 is used (R-URI).
328
329 This function can be used from ANY_ROUTE.
330
331 Example 1.6. resetbflag usage
332 ...
333 resetbflag("1");
334 ...
335
336 3.7. setdsturi(uri)
337
338 Set the destination address URI (outbound proxy address).
339
340 Meaning of the parameters is as follows:
341 * uri - Valid SIP URI representing the address where to send the
342 request. It must be a static string, no variables are evaluated at
343 runtime. If you need to set outbound proxy address via a variable,
344 use assignment to $du.
345
346 This function can be used from ANY_ROUTE.
347
348 Example 1.7. setdsturi usage
349 ...
350 setdsturi("sip:10.0.0.10");
351 ...
352
353 3.8. resetdsturi()
354
355 Reset the destination address URI (outbound proxy address).
356
357 This function can be used from ANY_ROUTE.
358
359 Example 1.8. resetdsturi usage
360 ...
361 resetdsturi();
362 ...
363
364 3.9. isdsturiset()
365
366 Check if the destination address URI (outbound proxy address) is set.
367
368 This function can be used from ANY_ROUTE.
369
370 Example 1.9. isdsturiset usage
371 ...
372 if(isdsturiset())
373 {
374 ...
375 }
376 ...
377
378 3.10. pv_printf(var, str)
379
380 Evaluates the str and sets the resulting value to variable var. For
381 backward compatibility reasons, the same function can be executed via
382 'avp_printf(var, str)'.
383
384 Meaning of the parameters is as follows:
385 * var - name of a writable variable
386 * str - string that may contain variables which will be evaluated at
387 runtime.
388
389 This function can be used from ANY_ROUTE.
390
391 Example 1.10. pv_printf usage
392 ...
393 pv_printf("$ru", "sip:$rU@$fd");
394 pv_printf("$avp(x)", "From: $fU - To: $tU");
395 ...
396
397 3.11. is_myself(uri)
398
399 Check if the parameter matches the 'myself' condition (i.e., is a local
400 IP or domain). Note that if the port is missing in the URI, then no
401 port matching is done (in other words, port matching is skipped -- it
402 does not use default SIP ports 5060 or 5061 for matching).
403
404 Meaning of the parameters is as follows:
405 * uri - Valid SIP URI or IP address to check against the list of
406 local IP addresses or domains, matching as well the port and
407 protocol if they are provided. The parameter value can contain
408 pseudo-variables.
409
410 This function can be used from ANY_ROUTE.
411
412 Example 1.11. is_myself usage
413 ...
414 if(is_myself("$fu")) {
415 ...
416 }
417 ...
418
419 3.12. is_myhost(uri)
420
421 Check if the host part of the parameter matches a local domain or IP
422 address.
423
424 Meaning of the parameters is as follows:
425 * uri - Valid SIP URI, hostname of IP address to check against the
426 list of local IP addresses or domains. If it is a SIP URI, the port
427 and protocol are ignored. The parameter value can contain
428 pseudo-variables.
429
430 This function can be used from ANY_ROUTE.
431
432 Example 1.12. is_myhost usage
433 ...
434 if(is_myhost("$tu")) {
435 ...
436 }
437 ...
438
439 3.13. setdebug(level)
440
441 Set the debug log level per process.
442
443 Meaning of the parameters is as follows:
444 * level - the debug log level to be set. Can be integer or
445 pseudo-variable with integer value.
446
447 This function can be used from ANY_ROUTE.
448
449 Example 1.13. setdebug usage
450 ...
451 setdebug("1");
452 ...
453 $var(level) = 2;
454 setdebug("$var(level)");
455 ...
456
457 3.14. resetdebug()
458
459 Reset the local debug log level back to the value of core parameter
460 'debug'.
461
462 This function can be used from ANY_ROUTE.
463
464 Example 1.14. resetdebug usage
465 ...
466 resetdebug();
467 ...
468
469 3.15. km_append_branch([uri])
470
471 This function was replaced by append_branch() from corex module,
472 starting with version 4.0.0.
473
474 4. RPC Commands
475
476 4.1. core.aliases_list
477 4.2. core.arg
478 4.3. core.echo
479 4.4. core.flags
480 4.5. core.info
481 4.6. core.runinfo
482 4.7. core.kill
483 4.8. core.printi
484 4.9. core.prints
485 4.10. core.ps
486 4.11. core.psx
487 4.12. core.pwd
488 4.13. core.shmmem
489 4.14. core.sockets_list
490 4.15. core.tcp_info
491 4.16. core.tcp_list
492 4.17. core.tcp_options
493 4.18. core.udp4_raw_info
494 4.19. core.uptime
495 4.20. core.version
496 4.21. core.ppdefines
497 4.22. core.modules
498 4.23. modparam.getn
499 4.24. modparam.gets
500 4.25. modparam.setn
501 4.26. modparam.list
502 4.27. pkg.stats
503 4.28. pkg.info
504 4.29. stats.get_statistics
505 4.30. stats.fetch
506 4.31. stats.fetchn
507 4.32. stats.reset_statistics
508 4.33. stats.clear_statistics
509 4.34. system.listMethods
510 4.35. system.methodHelp
511 4.36. system.methodSignature
512 4.37. mod.mem_stats
513 4.38. mod.stats
514 4.39. mod.mem_statsx
515
516 4.1. core.aliases_list
517
518 Returns the list of local SIP server host aliases.
519
520 4.2. core.arg
521
522 Print command line arguments.
523
524 Name: core.arg
525
526 Parameters: none.
527
528 RPC Command Format:
529 ...
530 kamctl rpc core.arg
531 ...
532
533 4.3. core.echo
534
535 Returns back its parameters.
536
537 4.4. core.flags
538
539 Returns the compile flags.
540
541 4.5. core.info
542
543 Verbose info, including version number, compile flags, compiler,
544 repository, hash
545
546 4.6. core.runinfo
547
548 Runtime details like running version, uptime, ...
549
550 4.7. core.kill
551
552 Kill the application.
553
554 Name: core.kill
555
556 Parameters: none.
557
558 RPC Command Format:
559 ...
560 kamctl rpc core.kill
561 ...
562
563 4.8. core.printi
564
565 Returns the integers given as parameters.
566
567 4.9. core.prints
568
569 Returns the strings given as parameters.
570
571 4.10. core.ps
572
573 Returns the description of running processes.
574
575 4.11. core.psx
576
577 Returns the detailed description of running processes.
578
579 4.12. core.pwd
580
581 Print working directory.
582
583 Name: core.pwd
584
585 Parameters: none.
586
587 RPC Command Format:
588 ...
589 kamctl rpc core.pwd
590 ...
591
592 4.13. core.shmmem
593
594 Returns shared memory info. It has an optional parameter that specifies
595 the measuring unit: b - bytes (default), k or kb, m or mb, g or gb.
596 Note: when using something different from bytes, the value is
597 truncated.
598
599 4.14. core.sockets_list
600
601 Returns the list of local SIP server listen sockets.
602
603 4.15. core.tcp_info
604
605 Returns TCP related info.
606
607 4.16. core.tcp_list
608
609 Returns TCP connections details.
610
611 4.17. core.tcp_options
612
613 Returns active TCP options.
614
615 4.18. core.udp4_raw_info
616
617 Returns udp4_raw mode related info.
618
619 4.19. core.uptime
620
621 Print uptime.
622
623 Name: core.uptime
624
625 Parameters: none.
626
627 RPC Command Format:
628 ...
629 kamctl rpc core.uptime
630 ...
631
632 4.20. core.version
633
634 Print version information.
635
636 Name: core.version
637
638 Parameters: none.
639
640 RPC Command Format:
641 ...
642 kamctl rpc core.version
643 ...
644
645 4.21. core.ppdefines
646
647 List preprocessor defines enabled in config.
648
649 Name: core.ppdefines
650
651 Parameters: none.
652
653 RPC Command Format:
654 ...
655 kamctl rpc core.ppdefines
656 ...
657
658 4.22. core.modules
659
660 List loaded modules in config.
661
662 Name: core.modules
663
664 Parameters: none.
665
666 RPC Command Format:
667 ...
668 kamctl rpc core.modules
669 ...
670
671 4.23. modparam.getn
672
673 Get the value of a module parameter with integer value.
674
675 Name: modparam.getn
676
677 Parameters: module_name and parameter_name.
678
679 RPC Command Format:
680 ...
681 kamcli rpc modparam.getn tls keylog_mode
682 ...
683
684 4.24. modparam.gets
685
686 Get the value of a module parameter with string value.
687
688 Name: modparam.gets
689
690 Parameters: module_name and parameter_name.
691
692 RPC Command Format:
693 ...
694 kamcli rpc modparam.gets tls config
695 ...
696
697 4.25. modparam.setn
698
699 Set the value of a module parameter with integer value stored in shared
700 memory.
701
702 Name: modparam.setn
703
704 Parameters: module_name, parameter_name and value.
705
706 RPC Command Format:
707 ...
708 kamcli rpc modparam.setn tls keylog_mode 15
709 ...
710
711 4.26. modparam.list
712
713 List the parameters of the loaded modules.
714
715 Name: modparam.list
716
717 Parameters: module_name (optional).
718
719 RPC Command Format:
720 ...
721 kamcli rpc modparam.list
722 kamcli rpc modparam.list tls
723 ...
724
725 4.27. pkg.stats
726
727 Print private memory (pkg) usage statistics per process. It can take
728 optionally a filter to print statistics only for a specific process or
729 set of processes. If no filter is given, it prints statistics for all
730 processes.
731
732 The filter can be:
733 * pid value - print statistics for specific process pid.
734 * rank value - print statistics for specific process rank.
735 * index value - print statistics for specific index in process table.
736
737 Examples:
738 kamctl rpc pkg.stats
739 kamctl rpc pkg.stats pid 1234
740 kamctl rpc pkg.stats rank 1
741 kamctl rpc pkg.stats index 10
742
743 4.28. pkg.info
744
745 Get pkg manager details.
746
747 Example:
748 kamcli rpc pkg.info
749
750 4.29. stats.get_statistics
751
752 Print the list of available internal statistics.
753
754 NOTE: the result is an array of strings that have the list of
755 statistics formatted like "name = value", being propagated over the
756 time from the MI variant. Use "stats.fetch" or "stats.fetchn"commands
757 to have a more JSON-friendly output.
758
759 Parameters: statsid - which statistics to be printed. If set to 'all'
760 then all statistics are printed; if set to 'statsgroup:' then all
761 statistics in the group are printed; if set to 'statsname' then the
762 statistics identified by the name is printed.
763
764 Examples:
765 kamctl rpc stats.get_statistics all
766 kamctl rpc stats.get_statistics core:
767 kamctl rpc stats.get_statistics unsupported_methods
768 kamctl rpc stats.get_statistics shmem: fwd_requests fwd_replies
769
770 4.30. stats.fetch
771
772 Print the list of available internal statistics with a more json
773 friendly output. Each printed statistic is a field in the output
774 structure: {"statsgroup.statsname" : "statsvalue"}. The value is
775 represented as string to accommodate large numbers.
776
777 Parameters: statsid - which statistics to be printed. If set to 'all'
778 then all statistics are printed; if set to 'statsgroup:' then all
779 statistics in the group are printed; if set to 'statsname' then the
780 statistics identified by the name is printed (can be also
781 'statsgroup.stastname' or 'statsgroup:statsname').
782
783 Examples:
784 kamctl rpc stats.fetch all
785 kamctl rpc stats.fetch core:
786 kamctl rpc stats.fetch unsupported_methods
787 kamctl rpc stats.fetch shmem.free_size
788 kamctl rpc stats.fetch shmem: fwd_requests fwd_replies
789
790 4.31. stats.fetchn
791
792 Print the list of available internal statistics with a more json
793 friendly output. Each printed statistic is a field in the output
794 structure: {"statsgroup.statsname" : statsvalue}. The value is
795 represented as number.
796
797 Parameters: statsid - which statistics to be printed. If set to 'all'
798 then all statistics are printed; if set to 'statsgroup:' then all
799 statistics in the group are printed; if set to 'statsname' then the
800 statistics identified by the name is printed (can be also
801 'statsgroup.stastname' or 'statsgroup:statsname').
802
803 Examples:
804 kamctl rpc stats.fetchn all
805 kamctl rpc stats.fetchn core:
806 kamctl rpc stats.fetchn unsupported_methods
807 kamctl rpc stats.fetchn shmem.free_size
808 kamctl rpc stats.fetchn shmem: fwd_requests fwd_replies
809
810 4.32. stats.reset_statistics
811
812 Reset internal statistics.
813
814 Parameters: statsid - same as for get_statistics.
815
816 Examples:
817 kamctl rpc stats.reset_statistics all
818 kamctl rpc stats.reset_statistics core:
819 kamctl rpc stats.reset_statistics unsupported_methods
820 kamctl rpc stats.reset_statistics shmem: fwd_requests fwd_replie
821 s
822
823 4.33. stats.clear_statistics
824
825 Return statistics and reset their value in one command.
826
827 Parameters: statsid - same as for get_statistics.
828
829 Examples:
830 kamctl rpc stats.reset_statistics all
831 kamctl rpc stats.reset_statistics core:
832 kamctl rpc stats.reset_statistics unsupported_methods
833 kamctl rpc stats.reset_statistics shmem: fwd_requests fwd_replie
834 s
835
836 4.34. system.listMethods
837
838 Print list of available RPC commands.
839
840 Name: system.listMethods
841
842 Parameters: none.
843
844 RPC Command Format:
845 ...
846 kamctl rpc system.listMethods
847 ...
848
849 4.35. system.methodHelp
850
851 Print the help string for given method.
852
853 4.36. system.methodSignature
854
855 Returns signature of given method.
856
857 4.37. mod.mem_stats
858
859 Print private(pkg) or shared(shm) memory currently allocated a given
860 module or by all modules.
861
862 NOTE: Processing is done only when the command is issued and involves
863 iterating through the list of memory fragments and printing details
864 about them.
865
866 NOTE: Only the module functions that directly calls shm_alloc or
867 pkg_alloc are taken into consideration.
868
869 The first parameter can be one of the following:
870 * module_name - print statistics for specific module. Either a module
871 name (like "usrloc") or "core" for the Kamailio core.
872 * all - print statistics for all modules that uses memory.
873
874 The second parameter can be:
875 * pkg - print private (process) memory statistics.
876 * shm - print shared memory statistics.
877 * all - print both private and shared memory statistics.
878
879 Examples:
880 kamctl rpc mod.stats core all
881 kamctl rpc mod.stats tm shm
882 kamctl rpc mod.stats kex pkg
883 kamctl rpc mod.stats all all
884
885 Output:
886 Module: kex
887 {
888 // this is the pkg zone of the module
889 // function_name(line_where_pkg_malloc_was_called): size_alloc'ed_by_pkg_mal
890 loc
891 init_rpc_uptime(74): 56
892 Total: 56
893 }
894 {
895 // this is the shm zone of the module
896 // function_name(line_where_shm_malloc_was_called): size_alloc'ed_by_shm_mal
897 loc
898 pkg_proc_stats_init(79): 864
899 Total: 864
900 }
901
902 4.38. mod.stats
903
904 Same as RPC command "mod.mem_stats", this is an alias command to
905 preserve backward compatibility.
906
907 4.39. mod.mem_statsx
908
909 Similar to RPC command "mod.mem_stats", but the output has an extended
910 format, printing info that includes the allocated size and the count of
911 allocated chunks in a combined string value. The parameters are the
912 same like for "mod.mem_stats".