Debian Codegraph @

src/modules/app_perl/README

raw
1 perl Module
2
3 Bastian Friedrich
4
5 Collax GmbH
6
7 Edited by
8
9 Bastian Friedrich
10
11 Copyright © 2007 Collax GmbH
12 __________________________________________________________________
13
14 Table of Contents
15
16 1. Admin Guide
17
18 1. Overview
19 2. Installing the module
20 3. Using the module
21 4. Dependencies
22
23 4.1. Kamailio Modules
24 4.2. External Libraries or Applications
25
26 5. Parameters
27
28 5.1. filename (string)
29 5.2. modpath (string)
30 5.3. reset_cycles (int)
31 5.4. perl_destroy_func (string)
32 5.5. parse_mode (int)
33 5.6. warn_mode (int)
34
35 6. Functions
36
37 6.1. perl_exec_simple(func, [param])
38 6.2. perl_exec(func, [param])
39
40 7. RPC Commands
41
42 7.1. app_perl.set_reset_cycles
43 7.2. app_perl.get_reset_cycles
44
45 2. Kamailio Perl API
46
47 1. Kamailio
48
49 1.1. log(level,message)
50
51 2. Kamailio::Message
52
53 2.1. getType()
54 2.2. getStatus()
55 2.3. getReason()
56 2.4. getVersion()
57 2.5. getRURI()
58 2.6. getMethod()
59 2.7. getFullHeader()
60 2.8. getBody()
61 2.9. getMessage()
62 2.10. getHeader(name)
63 2.11. getHeaderNames()
64 2.12. moduleFunction(func,string1,string2)
65 2.13. log(level,message) (deprecated type)
66 2.14. rewrite_ruri(newruri)
67 2.15. setFlag(flag)
68 2.16. resetFlag(flag)
69 2.17. isFlagSet(flag)
70 2.18. pseudoVar(string)
71 2.19. append_branch(branch,qval)
72 2.20. getParsedRURI()
73
74 3. Kamailio::URI
75
76 3.1. user()
77 3.2. host()
78 3.3. passwd()
79 3.4. port()
80 3.5. params()
81 3.6. headers()
82 3.7. transport()
83 3.8. ttl()
84 3.9. user_param()
85 3.10. maddr()
86 3.11. method()
87 3.12. lr()
88 3.13. r2()
89 3.14. transport_val()
90 3.15. ttl_val()
91 3.16. user_param_val()
92 3.17. maddr_val()
93 3.18. method_val()
94 3.19. lr_val()
95 3.20. r2_val()
96
97 4. Kamailio::AVP
98
99 4.1. add(name,val)
100 4.2. get(name)
101 4.3. destroy(name)
102
103 5. Kamailio::Utils::PhoneNumbers
104
105 5.1.
106 new(publicAccessPrefix,internationalPrefix,longDistanceP
107 refix,countryCode,areaCode,pbxCode)
108
109 5.2. canonicalForm( number [, context] )
110 5.3. dialNumber( number [, context] )
111
112 6. Kamailio::LDAPUtils::LDAPConf
113
114 6.1. Constructor new()
115 6.2. Method base()
116 6.3. Method host()
117 6.4. Method port()
118 6.5. Method uri()
119 6.6. Method rootbindpw()
120 6.7. Method rootbinddn()
121 6.8. Method binddn()
122 6.9. Method bindpw()
123
124 7. Kamailio::LDAPUtils::LDAPConnection
125
126 7.1. Constructor new( [config, [authenticated]] )
127 7.2. Function/Method search( conf, filter, base,
128 [requested_attributes ...])
129
130 7.2.1. Arguments:
131 7.2.2. Result:
132
133 8. Kamailio::VDB
134 9. Kamailio::Constants
135 10. Kamailio::VDB::Adapter::Speeddial
136 11. Kamailio::VDB::Adapter::Alias
137
138 11.1. query(conds,retkeys,order)
139
140 12. Kamailio::VDB::Adapter::AccountingSIPtrace
141 13. Kamailio::VDB::Adapter::Describe
142 14. Kamailio::VDB::Adapter::Auth
143 15. Kamailio::VDB::ReqCond
144
145 15.1. new(key,op,type,name)
146 15.2. op()
147
148 16. Kamailio::VDB::Pair
149
150 16.1. new(key,type,name)
151 16.2. key()
152
153 17. Kamailio::VDB::VTab
154
155 17.1. new()
156 17.2. call(op,[args])
157
158 18. Kamailio::VDB::Value
159
160 18.1. stringification
161 18.2. new(type,data)
162 18.3. type()
163 18.4. data()
164
165 19. Kamailio::VDB::Column
166
167 19.1. Stringification
168 19.2. new(type,name)
169 19.3. type( )
170 19.4. name()
171 19.5. Kamailio::VDB::Result
172 19.6. new(coldefs,[row, row, ...])
173 19.7. coldefs()
174 19.8. rows()
175
176 3. Perl samples
177
178 1. Sample directory
179
180 1.1. Script descriptions
181
182 1.1.1. branches.pl
183 1.1.2. firstline.pl
184 1.1.3. flags.pl
185 1.1.4. functions.pl
186 1.1.5. headers.pl
187 1.1.6. logging.pl
188 1.1.7. messagedump.pl
189 1.1.8. persistence.pl
190 1.1.9. phonenumbers.pl
191 1.1.10. pseudovars.pl
192
193 4. Frequently Asked Questions
194
195 List of Examples
196
197 1.1. Set filename parameter
198 1.2. Set modpath parameter
199 1.3. Set reset_cycles parameter
200 1.4. Set perl_destroy_func parameter
201 1.5. Set parse_mode parameter
202 1.6. Set warn_mode parameter
203 1.7. perl_exec_simple() usage
204 1.8. perl_exec() usage
205 1.9. app_perl.set_reset_cycles usage
206 1.10. app_perl.get_reset_cycles usage
207
208 Chapter 1. Admin Guide
209
210 Table of Contents
211
212 1. Overview
213 2. Installing the module
214 3. Using the module
215 4. Dependencies
216
217 4.1. Kamailio Modules
218 4.2. External Libraries or Applications
219
220 5. Parameters
221
222 5.1. filename (string)
223 5.2. modpath (string)
224 5.3. reset_cycles (int)
225 5.4. perl_destroy_func (string)
226 5.5. parse_mode (int)
227 5.6. warn_mode (int)
228
229 6. Functions
230
231 6.1. perl_exec_simple(func, [param])
232 6.2. perl_exec(func, [param])
233
234 7. RPC Commands
235
236 7.1. app_perl.set_reset_cycles
237 7.2. app_perl.get_reset_cycles
238
239 1. Overview
240
241 The time needed when writing a new Kamailio module unfortunately is
242 quite high, while the options provided by the configuration file are
243 limited to the features implemented in the modules.
244
245 With this Perl module, you can easily implement your own Kamailio
246 extensions in Perl. This allows for simple access to the full world of
247 CPAN modules. SIP URI rewriting could be implemented based on regular
248 expressions; accessing arbitrary data backends, e.g. LDAP files, is now
249 extremely simple.
250
251 2. Installing the module
252
253 This Perl module is loaded in kamailio.cfg (just like all the other
254 modules) with loadmodule("/path/to/perl.so");.
255
256 For the Perl module to compile, you need a reasonably recent version of
257 perl (tested with 5.8.8) linked dynamically. It is strongly advised to
258 use a threaded version. The default binary packages from your favorite
259 Linux distribution should work fine.
260
261 Cross compilation is supported by the Makefile. You need to set the
262 environment variables PERLLDOPTS, PERLCCOPTS and TYPEMAP to values
263 similar to the output of
264 PERLLDOPTS: perl -MExtUtils::Embed -e ldopts
265 PERLCCOPTS: perl -MExtUtils::Embed -e ccopts
266 TYPEMAP: echo "`perl -MConfig -e 'print $Config{installprivlib}'`/ExtUtils/ty
267 pemap"
268
269 The exact position of your (precompiled!) perl libraries depends on the
270 setup of your environment.
271
272 3. Using the module
273
274 The Perl module has two interfaces: The perl side, and the Kamailio
275 side. Once a Perl function is defined and loaded via the module
276 parameters (see below), it may be called in Kamailio's configuration at
277 an arbitrary point. E.g., you could write a function "ldap_alias" in
278 Perl, and then execute
279 ...
280 if (perl_exec("ldap_alias")) {
281 ...
282 }
283 ...
284
285 just as you would have done with the current alias_db module.
286
287 The functions you can use are listed in the "Exported Functions"
288 section below.
289
290 On the Perl side, there are a number of functions that let you read and
291 modify the current SIP message, such as the RURI or the message flags.
292 An introduction to the Perl interface and the full reference
293 documentation can be found below.
294
295 4. Dependencies
296
297 4.1. Kamailio Modules
298 4.2. External Libraries or Applications
299
300 4.1. Kamailio Modules
301
302 The following modules must be loaded before this module:
303 * The "sl" module is needed for sending replies upon fatal errors.
304 All other modules can be accessed from the Perl module, though.
305
306 4.2. External Libraries or Applications
307
308 The following libraries or applications must be installed before
309 running Kamailio with this module loaded:
310 * Perl 5.8.x or later
311
312 Additionally, a number of perl modules should be installed. The
313 Kamailio::LDAPUtils package relies on Net::LDAP to be installed. One of
314 the sample scripts needs IPC::Shareable
315
316 This module has been developed and tested with Perl 5.8.8, but should
317 work with any 5.8.x release. Compilation is possible with 5.6.x, but
318 its behavior is unsupported. Earlier versions do not work.
319
320 On current Debian systems, at least the following packages should be
321 installed:
322 * perl
323 * perl-base
324 * perl-modules
325 * libperl5.8
326 * libperl-dev
327 * libnet-ldap-perl
328 * libipc-shareable-perl
329
330 It was reported that other Debian-style distributions (such as Ubuntu)
331 need the same packages.
332
333 On SuSE systems, at least the following packages should be installed:
334 * perl
335 * perl-ldap
336 * IPC::Shareable perl module from CPAN
337
338 Although SuSE delivers a lot of perl modules, others may have to be
339 fetched from CPAN. Consider using the program “cpan2rpm” - which, in
340 turn, is available on CPAN. It creates RPM files from CPAN.
341
342 5. Parameters
343
344 5.1. filename (string)
345 5.2. modpath (string)
346 5.3. reset_cycles (int)
347 5.4. perl_destroy_func (string)
348 5.5. parse_mode (int)
349 5.6. warn_mode (int)
350
351 5.1. filename (string)
352
353 This is the file name of your script. This may be set once only, but it
354 may include an arbitrary number of functions and “use” as many Perl
355 module as necessary.
356
357 Must not be empty!
358
359 Example 1.1. Set filename parameter
360 ...
361 modparam("app_perl", "filename", "/home/test/kamailio/myperl.pl")
362 ...
363
364 5.2. modpath (string)
365
366 The path to the Perl modules included (Kamailio.pm et.al). It is not
367 absolutely crucial to set this path, as you may install the Modules in
368 Perl's standard path, or update the “%INC” variable from within your
369 script. Using this module parameter is the standard behavior, though.
370 Multiple paths may be specified by separating them with a “:”
371 character. The maximum is 10 paths.
372
373 Example 1.2. Set modpath parameter
374 ...
375 modparam("app_perl", "modpath", "/usr/local/lib/kamailio/perl/")
376 ...
377
378 5.3. reset_cycles (int)
379
380 The number of execution cycles after which the embedded perl
381 interpreter is reset. Sometimes is hard to track the scope of variables
382 in all used perl modules and that can result in leaks of system memory.
383 Resetting the interpreter cleans the memory space.
384
385 When the interpreter is reset, the perl script is loaded again. Note
386 that not all Kamailio processes will reset the interpreter at the same
387 time. Each will do it when it has executed the script for the number of
388 reset_cycles. Also, be aware that the reset of the interpreter is
389 taking a bit of time (in the order of tens of milliseconds).
390
391 Default value is 0 - never reset the interpreter.
392
393 Example 1.3. Set reset_cycles parameter
394 ...
395 modparam("app_perl", "reset_cycles", 100000)
396 ...
397
398 5.4. perl_destroy_func (string)
399
400 The name of Perl function to be executed before the interpreter is
401 re-initialized (reset -- see reset_cycles parameter) at runtime. This
402 could be useful to clean global variables or file descriptors from the
403 Perl script.
404
405 Example 1.4. Set perl_destroy_func parameter
406 ...
407 modparam("app_perl", "perl_destroy_func", "my_perl_destroy")
408 ...
409
410 5.5. parse_mode (int)
411
412 Control how to behave on perl_parse() return code - on some versions it
413 is the value for application exit and can break reloading.
414
415 If set to 0, continue even of perl_parse() returns non-zero, logging a
416 warning. If set to 1, reload fails on non-zero return code and triggers
417 an exit.
418
419 Default value is 0.
420
421 Example 1.5. Set parse_mode parameter
422 ...
423 modparam("app_perl", "parse_mode", 1)
424 ...
425
426 5.6. warn_mode (int)
427
428 Allows to enable warning for perl_parse(). If set to 1, "-w" is passed
429 to perl_parse() and detected warnings in the Perl script should be
430 printed to the log. If set to 1, then "-W" is passed to perl_parse().
431
432 Default value is 0.
433
434 Example 1.6. Set warn_mode parameter
435 ...
436 modparam("app_perl", "warn_mode", 1)
437 ...
438
439 6. Functions
440
441 6.1. perl_exec_simple(func, [param])
442 6.2. perl_exec(func, [param])
443
444 6.1. perl_exec_simple(func, [param])
445
446 Calls a perl function without passing it the current SIP message. May
447 be used for very simple simple requests that do not have to fiddle with
448 the message themselves, but rather return information values about the
449 environment.
450
451 The first parameter is the function to be called. An arbitrary string
452 may optionally be passed as a parameter.
453
454 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
455 ONREPLY_ROUTE and BRANCH_ROUTE.
456
457 Example 1.7. perl_exec_simple() usage
458 ...
459 if (method=="INVITE") {
460 perl_exec_simple("dosomething", "on invite messages");
461 };
462 ...
463
464 6.2. perl_exec(func, [param])
465
466 Calls a perl function with passing it the current SIP message. The SIP
467 message is reflected by a Perl module that gives you access to the
468 information in the current SIP message (Kamailio::Message).
469
470 The first parameter is the function to be called. An arbitrary string
471 may be passed as a parameter.
472
473 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
474 ONREPLY_ROUTE and BRANCH_ROUTE.
475
476 Example 1.8. perl_exec() usage
477 ...
478 if (perl_exec("ldapalias")) {
479 ...
480 };
481 ...
482
483 7. RPC Commands
484
485 7.1. app_perl.set_reset_cycles
486 7.2. app_perl.get_reset_cycles
487
488 7.1. app_perl.set_reset_cycles
489
490 Set the value of the reset_cycle. The command has one integer
491 parameter.
492
493 Example 1.9. app_perl.set_reset_cycles usage
494 ...
495 kamctl rpc app_perl.set_reset_cycles 20000
496 ...
497
498 7.2. app_perl.get_reset_cycles
499
500 Return the value of the reset_cycle.
501
502 Example 1.10. app_perl.get_reset_cycles usage
503 ...
504 kamctl rpc app_perl.get_reset_cycles
505 ...
506
507 Chapter 2. Kamailio Perl API
508
509 Table of Contents
510
511 1. Kamailio
512
513 1.1. log(level,message)
514
515 2. Kamailio::Message
516
517 2.1. getType()
518 2.2. getStatus()
519 2.3. getReason()
520 2.4. getVersion()
521 2.5. getRURI()
522 2.6. getMethod()
523 2.7. getFullHeader()
524 2.8. getBody()
525 2.9. getMessage()
526 2.10. getHeader(name)
527 2.11. getHeaderNames()
528 2.12. moduleFunction(func,string1,string2)
529 2.13. log(level,message) (deprecated type)
530 2.14. rewrite_ruri(newruri)
531 2.15. setFlag(flag)
532 2.16. resetFlag(flag)
533 2.17. isFlagSet(flag)
534 2.18. pseudoVar(string)
535 2.19. append_branch(branch,qval)
536 2.20. getParsedRURI()
537
538 3. Kamailio::URI
539
540 3.1. user()
541 3.2. host()
542 3.3. passwd()
543 3.4. port()
544 3.5. params()
545 3.6. headers()
546 3.7. transport()
547 3.8. ttl()
548 3.9. user_param()
549 3.10. maddr()
550 3.11. method()
551 3.12. lr()
552 3.13. r2()
553 3.14. transport_val()
554 3.15. ttl_val()
555 3.16. user_param_val()
556 3.17. maddr_val()
557 3.18. method_val()
558 3.19. lr_val()
559 3.20. r2_val()
560
561 4. Kamailio::AVP
562
563 4.1. add(name,val)
564 4.2. get(name)
565 4.3. destroy(name)
566
567 5. Kamailio::Utils::PhoneNumbers
568
569 5.1.
570 new(publicAccessPrefix,internationalPrefix,longDistancePrefix,
571 countryCode,areaCode,pbxCode)
572
573 5.2. canonicalForm( number [, context] )
574 5.3. dialNumber( number [, context] )
575
576 6. Kamailio::LDAPUtils::LDAPConf
577
578 6.1. Constructor new()
579 6.2. Method base()
580 6.3. Method host()
581 6.4. Method port()
582 6.5. Method uri()
583 6.6. Method rootbindpw()
584 6.7. Method rootbinddn()
585 6.8. Method binddn()
586 6.9. Method bindpw()
587
588 7. Kamailio::LDAPUtils::LDAPConnection
589
590 7.1. Constructor new( [config, [authenticated]] )
591 7.2. Function/Method search( conf, filter, base,
592 [requested_attributes ...])
593
594 7.2.1. Arguments:
595 7.2.2. Result:
596
597 8. Kamailio::VDB
598 9. Kamailio::Constants
599 10. Kamailio::VDB::Adapter::Speeddial
600 11. Kamailio::VDB::Adapter::Alias
601
602 11.1. query(conds,retkeys,order)
603
604 12. Kamailio::VDB::Adapter::AccountingSIPtrace
605 13. Kamailio::VDB::Adapter::Describe
606 14. Kamailio::VDB::Adapter::Auth
607 15. Kamailio::VDB::ReqCond
608
609 15.1. new(key,op,type,name)
610 15.2. op()
611
612 16. Kamailio::VDB::Pair
613
614 16.1. new(key,type,name)
615 16.2. key()
616
617 17. Kamailio::VDB::VTab
618
619 17.1. new()
620 17.2. call(op,[args])
621
622 18. Kamailio::VDB::Value
623
624 18.1. stringification
625 18.2. new(type,data)
626 18.3. type()
627 18.4. data()
628
629 19. Kamailio::VDB::Column
630
631 19.1. Stringification
632 19.2. new(type,name)
633 19.3. type( )
634 19.4. name()
635 19.5. Kamailio::VDB::Result
636 19.6. new(coldefs,[row, row, ...])
637 19.7. coldefs()
638 19.8. rows()
639
640 1. Kamailio
641
642 1.1. log(level,message)
643
644 This module provides access to a limited number of Kamailio core
645 functions. As the most interesting functions deal with SIP messages,
646 they are located in the Kamailio::Message class below.
647
648 1.1. log(level,message)
649
650 Logs the message with Kamailio's logging facility. The logging level is
651 one of the following:
652 * L_ALERT
653 * L_CRIT
654 * L_ERR
655 * L_WARN
656 * L_NOTICE
657 * L_INFO
658 * L_DBG
659
660 Please note that this method is NOT automatically exported, as it
661 collides with the perl function log (which calculates the logarithm).
662 Either explicitly import the function (via use Kamailio qw ( log );),
663 or call it with its full name:
664 Kamailio::log(L_INFO, "foobar");
665
666 2. Kamailio::Message
667
668 2.1. getType()
669 2.2. getStatus()
670 2.3. getReason()
671 2.4. getVersion()
672 2.5. getRURI()
673 2.6. getMethod()
674 2.7. getFullHeader()
675 2.8. getBody()
676 2.9. getMessage()
677 2.10. getHeader(name)
678 2.11. getHeaderNames()
679 2.12. moduleFunction(func,string1,string2)
680 2.13. log(level,message) (deprecated type)
681 2.14. rewrite_ruri(newruri)
682 2.15. setFlag(flag)
683 2.16. resetFlag(flag)
684 2.17. isFlagSet(flag)
685 2.18. pseudoVar(string)
686 2.19. append_branch(branch,qval)
687 2.20. getParsedRURI()
688
689 This package provides access functions for a Kamailio sip_msg structure
690 and its sub-components. Through its means it is possible to fully
691 configure alternative routing decisions.
692
693 2.1. getType()
694
695 Returns one of the constants SIP_REQUEST, SIP_REPLY, SIP_INVALID
696 stating the type of the current message.
697
698 2.2. getStatus()
699
700 Returns the status code of the current Reply message. This function is
701 invalid in Request context!
702
703 2.3. getReason()
704
705 Returns the reason of the current Reply message. This function is
706 invalid in Request context!
707
708 2.4. getVersion()
709
710 Returns the version string of the current SIP message.
711
712 2.5. getRURI()
713
714 This function returns the recipient URI of the present SIP message:
715
716 my $ruri = $m->getRURI();
717
718 getRURI returns a string. See “getParsedRURI()” below how to receive a
719 parsed structure.
720
721 This function is valid in request messages only.
722
723 2.6. getMethod()
724
725 Returns the current method, such as INVITE, REGISTER, ACK and so on.
726
727 my $method = $m->getMethod();
728
729 This function is valid in request messages only.
730
731 2.7. getFullHeader()
732
733 Returns the full message header as present in the current message. You
734 might use this header to further work with it with your favorite MIME
735 package.
736
737 my $hdr = $m->getFullHeader();
738
739 2.8. getBody()
740
741 Returns the message body.
742
743 2.9. getMessage()
744
745 Returns the whole message including headers and body.
746
747 2.10. getHeader(name)
748
749 Returns the body of the first message header with this name.
750
751 print $m->getHeader("To");
752
753 "John" <sip:[email protected]>
754
755 2.11. getHeaderNames()
756
757 Returns an array of all header names. Duplicates possible!
758
759 2.12. moduleFunction(func,string1,string2)
760
761 Search for an arbitrary function in module exports and call it with the
762 parameters self, string1, string2.
763
764 string1 and/or string2 may be omitted.
765
766 As this function provides access to the functions that are exported to
767 the Kamailio configuration file, it is autoloaded for unknown
768 functions. Instead of writing
769 $m->moduleFunction("sl_send_reply", "500", "Internal Error");
770 $m->moduleFunction("xlog", "L_INFO", "foo");
771
772 you may as well write
773 $m->sl_send_reply("500", "Internal Error");
774 $m->xlog("L_INFO", "foo");
775
776 WARNING
777
778 In Kamailio 1.2, only a limited subset of module functions is
779 available. This restriction will be removed in a later version.
780
781 Here is a list of functions that are expected to be working (not
782 claiming completeness):
783 * alias_db_lookup
784 * consume_credentials
785 * is_rpid_user_e164
786 * append_rpid_hf
787 * bind_auth
788 * avp_print
789 * cpl_process_register
790 * cpl_process_register_norpl
791 * load_dlg
792 * ds_next_dst
793 * ds_next_domain
794 * ds_mark_dst
795 * ds_mark_dst
796 * is_from_local
797 * is_uri_host_local
798 * dp_can_connect
799 * dp_apply_policy
800 * enum_query (without parameters)
801 * enum_fquery (without parameters)
802 * is_from_user_enum (without parameters)
803 * i_enum_query (without parameters)
804 * imc_manager
805 * jab_* (all functions from the jabber module)
806 * load_gws (without parameters)
807 * next_gw
808 * from_gw (without parameters)
809 * to_gw (without parameters)
810 * load_contacts
811 * next_contacts
812 * sdp_mangle_ip
813 * sdp_mangle_port
814 * encode_contact
815 * decode_contact
816 * decode_contact_header
817 * fix_contact
818 * use_media_proxy
819 * end_media_session
820 * m_store
821 * m_dump
822 * fix_nated_contact
823 * unforce_rtp_proxy
824 * force_rtp_proxy
825 * fix_nated_register
826 * add_rcv_param
827 * options_reply
828 * checkospheader
829 * validateospheader
830 * requestosprouting
831 * checkosproute
832 * prepareosproute
833 * prepareallosproutes
834 * checkcallingtranslation
835 * reportospusage
836 * mangle_pidf
837 * mangle_message_cpim
838 * add_path (without parameters)
839 * add_path_received (without parameters)
840 * prefix2domain
841 * allow_routing (without parameters)
842 * allow_trusted
843 * pike_check_req
844 * handle_publish
845 * handle_subscribe
846 * stored_pres_info
847 * bind_pua
848 * send_publish
849 * send_subscribe
850 * pua_set_publish
851 * loose_route
852 * record_route
853 * load_rr
854 * sip_trace
855 * sl_reply_error
856 * sms_send_msg
857 * sd_lookup
858 * sstCheckMin
859 * append_time
860 * has_body (without parameters)
861 * is_peer_verified
862 * t_newtran
863 * t_release
864 * t_relay (without parameters)
865 * t_flush_flags
866 * t_check_trans
867 * t_was_cancelled
868 * t_load_contacts
869 * t_next_contacts
870 * uac_restore_from
871 * uac_auth
872 * has_totag
873 * tel2sip
874 * check_to
875 * check_from
876 * radius_does_uri_exist
877 * ul_* (All functions exported by the usrloc module for user access)
878 * xmpp_send_message
879
880 2.13. log(level,message) (deprecated type)
881
882 Logs the message with Kamailio's logging facility. The logging level is
883 one of the following:
884 * L_ALERT
885 * L_CRIT
886 * L_ERR
887 * L_WARN
888 * L_NOTICE
889 * L_INFO
890 * L_DBG
891
892 The logging function should be accessed via the Kamailio module
893 variant. This one, located in Kamailio::Message, is deprecated.
894
895 2.14. rewrite_ruri(newruri)
896
897 Sets a new destination (recipient) URI. Useful for rerouting the
898 current message/call.
899 if ($m->getRURI() =~ m/\@somedomain.net/) {
900 $m->rewrite_ruri("sip:dispatcher\@organization.net");
901 }
902
903 2.15. setFlag(flag)
904
905 Sets a message flag. The constants as known from the C API may be used,
906 when Constants.pm is included.
907
908 2.16. resetFlag(flag)
909
910 Resets a message flag.
911
912 2.17. isFlagSet(flag)
913
914 Returns whether a message flag is set or not.
915
916 2.18. pseudoVar(string)
917
918 Returns a new string where all pseudo variables are substituted by
919 their values. Can be used to receive the values of single variables,
920 too.
921
922 Please remember that you need to escape the '$' sign in perl strings!
923
924 2.19. append_branch(branch,qval)
925
926 Append a branch to current message.
927
928 2.20. getParsedRURI()
929
930 Returns the current destination URI as a Kamailio::URI object.
931
932 3. Kamailio::URI
933
934 3.1. user()
935 3.2. host()
936 3.3. passwd()
937 3.4. port()
938 3.5. params()
939 3.6. headers()
940 3.7. transport()
941 3.8. ttl()
942 3.9. user_param()
943 3.10. maddr()
944 3.11. method()
945 3.12. lr()
946 3.13. r2()
947 3.14. transport_val()
948 3.15. ttl_val()
949 3.16. user_param_val()
950 3.17. maddr_val()
951 3.18. method_val()
952 3.19. lr_val()
953 3.20. r2_val()
954
955 This package provides functions for access to sip_uri structures.
956
957 3.1. user()
958
959 Returns the user part of this URI.
960
961 3.2. host()
962
963 Returns the host part of this URI.
964
965 3.3. passwd()
966
967 Returns the passwd part of this URI.
968
969 3.4. port()
970
971 Returns the port part of this URI.
972
973 3.5. params()
974
975 Returns the params part of this URI.
976
977 3.6. headers()
978
979 Returns the headers part of this URI.
980
981 3.7. transport()
982
983 Returns the transport part of this URI.
984
985 3.8. ttl()
986
987 Returns the ttl part of this URI.
988
989 3.9. user_param()
990
991 Returns the user_param part of this URI.
992
993 3.10. maddr()
994
995 Returns the maddr part of this URI.
996
997 3.11. method()
998
999 Returns the method part of this URI.
1000
1001 3.12. lr()
1002
1003 Returns the lr part of this URI.
1004
1005 3.13. r2()
1006
1007 Returns the r2 part of this URI.
1008
1009 3.14. transport_val()
1010
1011 Returns the transport_val part of this URI.
1012
1013 3.15. ttl_val()
1014
1015 Returns the ttl_val part of this URI.
1016
1017 3.16. user_param_val()
1018
1019 Returns the user_param_val part of this URI.
1020
1021 3.17. maddr_val()
1022
1023 Returns the maddr_val part of this URI.
1024
1025 3.18. method_val()
1026
1027 Returns the method_val part of this URI.
1028
1029 3.19. lr_val()
1030
1031 Returns the lr_val part of this URI.
1032
1033 3.20. r2_val()
1034
1035 Returns the r2_val part of this URI.
1036
1037 4. Kamailio::AVP
1038
1039 4.1. add(name,val)
1040 4.2. get(name)
1041 4.3. destroy(name)
1042
1043 This package provides access functions for Kamailio's AVPs. These
1044 variables can be created, evaluated, modified and removed through this
1045 package.
1046
1047 Please note that these functions do NOT support the notation used in
1048 the configuration file, but directly work on strings or numbers. See
1049 documentation of add method below.
1050
1051 4.1. add(name,val)
1052
1053 Add an AVP.
1054
1055 Add a Kamailio AVP to its environment. name and val may both be
1056 integers or strings; this function will try to guess what is correct.
1057 Please note that
1058 Kamailio::AVP::add("10", "10")
1059
1060 is something different than
1061 Kamailio::AVP::add(10, 10)
1062
1063 due to this evaluation: The first will create _string_ AVPs with the
1064 name 10, while the latter will create a numerical AVP.
1065
1066 You can modify/overwrite AVPs with this function.
1067
1068 4.2. get(name)
1069
1070 get a Kamailio AVP:
1071 my $numavp = Kamailio::AVP::get(5);
1072 my $stravp = Kamailio::AVP::get("foo");
1073
1074 4.3. destroy(name)
1075
1076 Destroy an AVP.
1077 Kamailio::AVP::destroy(5);
1078 Kamailio::AVP::destroy("foo");
1079
1080 5. Kamailio::Utils::PhoneNumbers
1081
1082 5.1.
1083 new(publicAccessPrefix,internationalPrefix,longDistancePrefix,count
1084 ryCode,areaCode,pbxCode)
1085
1086 5.2. canonicalForm( number [, context] )
1087 5.3. dialNumber( number [, context] )
1088
1089 Kamailio::Utils::PhoneNumbers - Functions for canonical forms of phone
1090 numbers.
1091 use Kamailio::Utils::PhoneNumbers;
1092
1093 my $phonenumbers = new Kamailio::Utils::PhoneNumbers(
1094 publicAccessPrefix => "0",
1095 internationalPrefix => "+",
1096 longDistancePrefix => "0",
1097 areaCode => "761",
1098 pbxCode => "456842",
1099 countryCode => "49"
1100 );
1101
1102 $canonical = $phonenumbers->canonicalForm("07612034567");
1103 $number = $phonenumbers->dialNumber("+497612034567");
1104
1105 A telephone number starting with a plus sign and containing all dial
1106 prefixes is in canonical form. This is usually not the number to dial
1107 at any location, so the dialing number depends on the context of the
1108 user/system.
1109
1110 The idea to canonicalize numbers were taken from hylafax.
1111
1112 Example: +497614514829 is the canonical form of my phone number, 829 is
1113 the number to dial at Pyramid, 4514829 is the dialing number from
1114 Freiburg are and so on.
1115
1116 To canonicalize any number, we strip off any dial prefix we find and
1117 then add the prefixes for the location. So, when the user enters the
1118 number 04514829 in context pyramid, we remove the publicAccessPrefix
1119 (at Pyramid this is 0) and the pbxPrefix (4514 here). The result is
1120 829. Then we add all the general dial prefixes - 49 (country) 761
1121 (area) 4514 (pbx) and 829, the number itself => +497614514829
1122
1123 To get the dialing number from a canonical phone number, we subtract
1124 all general prefixes until we have something
1125
1126 As said before, the interpretation of a phone number depends on the
1127 context of the location. For the functions in this package, the context
1128 is created through the new operator.
1129
1130 The following fields should be set:
1131 'longDistancePrefix'
1132 'areaCode'
1133 'pbxCode'
1134 'internationalPrefix'
1135 'publicAccessPrefix'
1136 'countryCode'
1137
1138 This module exports the following functions when useed:
1139
1140 5.1. new(publicAccessPrefix,internationalPrefix,longDistancePrefix,countryCod
1141 e,areaCode,pbxCode)
1142
1143 The new operator returns an object of this type and sets its locational
1144 context according to the passed parameters. See
1145 Kamailio::Utils::PhoneNumbers above.
1146
1147 5.2. canonicalForm( number [, context] )
1148
1149 Convert a phone number (given as first argument) into its canonical
1150 form. When no context is passed in as the second argument, the default
1151 context from the systems configuration file is used.
1152
1153 5.3. dialNumber( number [, context] )
1154
1155 Convert a canonical phone number (given in the first argument) into a
1156 number to to dial. WHen no context is given in the second argument, a
1157 default context from the systems configuration is used.
1158
1159 6. Kamailio::LDAPUtils::LDAPConf
1160
1161 6.1. Constructor new()
1162 6.2. Method base()
1163 6.3. Method host()
1164 6.4. Method port()
1165 6.5. Method uri()
1166 6.6. Method rootbindpw()
1167 6.7. Method rootbinddn()
1168 6.8. Method binddn()
1169 6.9. Method bindpw()
1170
1171 Kamailio::LDAPUtils::LDAPConf - Read openldap config from standard
1172 config files.
1173 use Kamailio::LDAPUtils::LDAPConf;
1174 my $conf = new Kamailio::LDAPUtils::LDAPConf();
1175
1176 This module may be used to retrieve the global LDAP configuration as
1177 used by other LDAP software, such as nsswitch.ldap and pam-ldap. The
1178 configuration is usually stored in /etc/openldap/ldap.conf
1179
1180 When used from an account with sufficient privileges (e.g. root), the
1181 ldap manager password is also retrieved.
1182
1183 6.1. Constructor new()
1184
1185 Returns a new, initialized Kamailio::LDAPUtils::LDAPConf object.
1186
1187 6.2. Method base()
1188
1189 Returns the servers base-dn to use when doing queries.
1190
1191 6.3. Method host()
1192
1193 Returns the ldap host to contact.
1194
1195 6.4. Method port()
1196
1197 Returns the ldap servers port.
1198
1199 6.5. Method uri()
1200
1201 Returns an uri to contact the ldap server. When there is no ldap_uri in
1202 the configuration file, an ldap: uri is constructed from host and port.
1203
1204 6.6. Method rootbindpw()
1205
1206 Returns the ldap "root" password.
1207
1208 Note that the rootbindpw is only available when the current account has
1209 sufficient privileges to access /etc/openldap/ldap.secret.
1210
1211 6.7. Method rootbinddn()
1212
1213 Returns the DN to use for "root"-access to the ldap server.
1214
1215 6.8. Method binddn()
1216
1217 Returns the DN to use for authentication to the ldap server. When no
1218 bind dn has been specified in the configuration file, returns the
1219 rootbinddn.
1220
1221 6.9. Method bindpw()
1222
1223 Returns the password to use for authentication to the ldap server. When
1224 no bind password has been specified, returns the rootbindpw if any.
1225
1226 7. Kamailio::LDAPUtils::LDAPConnection
1227
1228 7.1. Constructor new( [config, [authenticated]] )
1229 7.2. Function/Method search( conf, filter, base, [requested_attributes
1230 ...])
1231
1232 7.2.1. Arguments:
1233 7.2.2. Result:
1234
1235 Kamailio::LDAPUtils::LDAPConnection - Perl module to perform simple
1236 LDAP queries.
1237
1238 OO-Style interface:
1239 use Kamailio::LDAPUtils::LDAPConnection;
1240 my $ldap = new Kamailio::LDAPUtils::LDAPConnection;
1241 my @rows = $ldap-search("uid=andi","ou=people,ou=coreworks,ou=de");
1242
1243 Procedural interface:
1244 use Kamailio::LDAPUtils::LDAPConnection;
1245 my @rows = $ldap->search(
1246 new Kamailio::LDAPUtils::LDAPConfig(), "uid=andi","ou=people,ou=coreworks,
1247 ou=de");
1248
1249 This perl module offers a somewhat simplified interface to the
1250 Net::LDAP functionality. It is intended for cases where just a few
1251 attributes should be retrieved without the overhead of the full
1252 featured Net::LDAP.
1253
1254 7.1. Constructor new( [config, [authenticated]] )
1255
1256 Set up a new LDAP connection.
1257
1258 The first argument, when given, should be a hash reference pointing to
1259 to the connection parameters, possibly a
1260 Kamailio::LDAPUtils::LDAPConfig object. This argument may be undef in
1261 which case a new (default) Kamailio::LDAPUtils::LDAPConfig object is
1262 used.
1263
1264 When the optional second argument is a true value, the connection will
1265 be authenticated. Otherwise an anonymous bind is done.
1266
1267 On success, a new LDAPConnection object is returned, otherwise the
1268 result is undef.
1269
1270 7.2. Function/Method search( conf, filter, base, [requested_attributes ...])
1271
1272 perform an ldap search, return the dn of the first matching directory
1273 entry, unless a specific attribute has been requested, in which case
1274 the values(s) for this attribute are returned.
1275
1276 When the first argument (conf) is a
1277 Kamailio::LDAPUtils::LDAPConnection, it will be used to perform the
1278 queries. You can pass the first argument implicitly by using the
1279 "method" syntax.
1280
1281 Otherwise the conf argument should be a reference to a hash containing
1282 the connection setup parameters as contained in a
1283 Kamailio::LDAPUtils::LDAPConf object. In this mode, the
1284 Kamailio::LDAPUtils::LDAPConnection from previous queries will be
1285 reused.
1286
1287 7.2.1. Arguments:
1288
1289 conf
1290 configuration object, used to find host,port,suffix and
1291 use_ldap_checks
1292
1293 filter
1294 ldap search filter, eg '(mail=some@domain)'
1295
1296 base
1297 search base for this query. If undef use default suffix, concat
1298 base with default suffix if the last char is a ','
1299
1300 requested_attributes
1301 retrieve the given attributes instead of the dn from the ldap
1302 directory.
1303
1304 7.2.2. Result:
1305
1306 Without any specific requested_attributes, return the dn of all
1307 matching entries in the LDAP directory.
1308
1309 When some requested_attributes are given, return an array with those
1310 attributes. When multiple entries match the query, the attribute lists
1311 are concatenated.
1312
1313 8. Kamailio::VDB
1314
1315 This package is an (abstract) base class for all virtual databases.
1316 Derived packages can be configured to be used by Kamailio as a
1317 database.
1318
1319 The base class itself should NOT be used in this context, as it does
1320 not provide any functionality.
1321
1322 9. Kamailio::Constants
1323
1324 This package provides a number of constants taken from enums and
1325 defines of Kamailio header files. Unfortunately, there is no mechanism
1326 for updating the constants automatically, so check the values if you
1327 are in doubt.
1328
1329 10. Kamailio::VDB::Adapter::Speeddial
1330
1331 This adapter can be used with the speeddial module.
1332
1333 11. Kamailio::VDB::Adapter::Alias
1334
1335 11.1. query(conds,retkeys,order)
1336
1337 This package is intended for usage with the alias_db module. The query
1338 VTab has to take two arguments and return an array of two arguments
1339 (user name/domain).
1340
1341 11.1. query(conds,retkeys,order)
1342
1343 Queries the vtab with the given arguments for request conditions, keys
1344 to return and sort order column name.
1345
1346 12. Kamailio::VDB::Adapter::AccountingSIPtrace
1347
1348 This package is an Adapter for the acc and siptrace modules, featuring
1349 only an insert operation.
1350
1351 13. Kamailio::VDB::Adapter::Describe
1352
1353 This package is intended for debug usage. It will print information
1354 about requested functions and operations of a client module.
1355
1356 Use this module to request schema information when creating new
1357 adapters.
1358
1359 14. Kamailio::VDB::Adapter::Auth
1360
1361 This adapter is intended for usage with the auth_db module. The VTab
1362 should take a username as an argument and return a (plain text!)
1363 password.
1364
1365 15. Kamailio::VDB::ReqCond
1366
1367 15.1. new(key,op,type,name)
1368 15.2. op()
1369
1370 This package represents a request condition for database access,
1371 consisting of a column name, an operator (=, <, >, ...), a data type
1372 and a value.
1373
1374 This package inherits from Kamailio::VDB::Pair and thus includes its
1375 methods.
1376
1377 15.1. new(key,op,type,name)
1378
1379 Constructs a new Column object.
1380
1381 15.2. op()
1382
1383 Returns or sets the current operator.
1384
1385 16. Kamailio::VDB::Pair
1386
1387 16.1. new(key,type,name)
1388 16.2. key()
1389
1390 This package represents database key/value pairs, consisting of a key,
1391 a value type, and the value.
1392
1393 This package inherits from Kamailio::VDB::Value and thus has the same
1394 methods.
1395
1396 16.1. new(key,type,name)
1397
1398 Constructs a new Column object.
1399
1400 16.2. key()
1401
1402 Returns or sets the current key.
1403
1404 17. Kamailio::VDB::VTab
1405
1406 17.1. new()
1407 17.2. call(op,[args])
1408
1409 This package handles virtual tables and is used by the Kamailio::VDB
1410 class to store information about valid tables. The package is not
1411 intended for end user access.
1412
1413 17.1. new()
1414
1415 Constructs a new VTab object
1416
1417 17.2. call(op,[args])
1418
1419 Invokes an operation on the table (insert, update, ...) with the given
1420 arguments.
1421
1422 18. Kamailio::VDB::Value
1423
1424 18.1. stringification
1425 18.2. new(type,data)
1426 18.3. type()
1427 18.4. data()
1428
1429 This package represents a database value. Additional to the data
1430 itself, information about its type is stored.
1431
1432 18.1. stringification
1433
1434 When accessing a Kamailio::VDB::Value object as a string, it simply
1435 returns its data regardless of its type. =cut
1436
1437 use strict;
1438
1439 package Kamailio::VDB::Value;
1440
1441 use overload '""' => \&stringify;
1442
1443 sub stringify { shift->{data} }
1444
1445 use Kamailio; use Kamailio::Constants;
1446
1447 our @ISA = qw ( Kamailio::Utils::Debug );
1448
1449 18.2. new(type,data)
1450
1451 Constructs a new Value object. Its data type and the data are passed as
1452 parameters.
1453
1454 18.3. type()
1455
1456 Returns or sets the current data type. Please consider using the
1457 constants from Kamailio::Constants
1458
1459 18.4. data()
1460
1461 Returns or sets the current data.
1462
1463 19. Kamailio::VDB::Column
1464
1465 19.1. Stringification
1466 19.2. new(type,name)
1467 19.3. type( )
1468 19.4. name()
1469 19.5. Kamailio::VDB::Result
1470 19.6. new(coldefs,[row, row, ...])
1471 19.7. coldefs()
1472 19.8. rows()
1473
1474 This package represents database column definition, consisting of a
1475 column name and its data type.
1476
1477 19.1. Stringification
1478
1479 When accessing a Kamailio::VDB::Column object as a string, it simply
1480 returns its column name regardless of its type. =cut
1481
1482 package Kamailio::VDB::Column;
1483
1484 use overload '""' => \&stringify;
1485
1486 sub stringify { shift->{name} }
1487
1488 use Kamailio; use Kamailio::Constants;
1489
1490 our @ISA = qw ( Kamailio::Utils::Debug );
1491
1492 19.2. new(type,name)
1493
1494 Constructs a new Column object. Its type and the name are passed as
1495 parameters.
1496
1497 19.3. type( )
1498
1499 Returns or sets the current type. Please consider using the constants
1500 from Kamailio::Constants
1501
1502 19.4. name()
1503
1504 Returns or sets the current column name.
1505
1506 19.5. Kamailio::VDB::Result
1507
1508 This class represents a VDB result set. It contains a column
1509 definition, plus an array of rows. Rows themselves are simply
1510 references to arrays of scalars.
1511
1512 19.6. new(coldefs,[row, row, ...])
1513
1514 The constructor creates a new Result object. Its first parameter is a
1515 reference to an array of Kamailio::VDB::Column objects. Additional
1516 parameters may be passed to provide initial rows, which are references
1517 to arrays of scalars.
1518
1519 19.7. coldefs()
1520
1521 Returns or sets the column definition of the object.
1522
1523 19.8. rows()
1524
1525 Returns or sets the rows of the object.
1526
1527 Chapter 3. Perl samples
1528
1529 Table of Contents
1530
1531 1. Sample directory
1532
1533 1.1. Script descriptions
1534
1535 1.1.1. branches.pl
1536 1.1.2. firstline.pl
1537 1.1.3. flags.pl
1538 1.1.4. functions.pl
1539 1.1.5. headers.pl
1540 1.1.6. logging.pl
1541 1.1.7. messagedump.pl
1542 1.1.8. persistence.pl
1543 1.1.9. phonenumbers.pl
1544 1.1.10. pseudovars.pl
1545
1546 1. Sample directory
1547
1548 1.1. Script descriptions
1549
1550 1.1.1. branches.pl
1551 1.1.2. firstline.pl
1552 1.1.3. flags.pl
1553 1.1.4. functions.pl
1554 1.1.5. headers.pl
1555 1.1.6. logging.pl
1556 1.1.7. messagedump.pl
1557 1.1.8. persistence.pl
1558 1.1.9. phonenumbers.pl
1559 1.1.10. pseudovars.pl
1560
1561 There are a number of example scripts in the “samples/”. They are
1562 documented well. Read them, it will explain a lot to you :)
1563
1564 If you want to use any of these scripts directly in your
1565 implementation, you can use Perl's “require” mechanism to import them
1566 (just remember that you need to use quotes when require'ing .pl files).
1567
1568 1.1. Script descriptions
1569
1570 The included sample scripts are described below:
1571
1572 1.1.1. branches.pl
1573
1574 The minimal function in branches.pl demonstrates that you can access
1575 the "append_branch" function from within perl, just as you would have
1576 done from your normal configuration file. You'll find documentation on
1577 the concepts of branching in the Kamailio documentation.
1578
1579 1.1.2. firstline.pl
1580
1581 Message's first_line structure may be evaluated. Message can be either
1582 of SIP_REQUEST or SIP_REPLY. Depending on that, different information
1583 can be received. This script demonstrates these functions.
1584
1585 1.1.3. flags.pl
1586
1587 The perl module provides access to Kamailio's flagging mechanism. The
1588 flag names available for Kamailio modules are made available through
1589 the Kamailio::Constants package, so you can flag messages as "green",
1590 "magenta" etc.
1591
1592 The first function, setflag, demonstrates how the "green" flag is set.
1593 In the second function, readflag, the "green" and "magenta" flags are
1594 evaluated.
1595
1596 1.1.4. functions.pl
1597
1598 This sample script demonstrates different things related to calling
1599 functions from within perl, and the different types of functions you
1600 can offer for Kamailio access.
1601
1602 “exportedfuncs” simply demonstrates that you can use the moduleFunction
1603 method to call functions offered by other modules. The results are
1604 equivalent to calling these functions from your config file. In the
1605 demonstrated case, telephone calls with a destination number beginning
1606 with 555... are rejected with an internal server error. Other
1607 destination addresses are passed to the alias_db module.
1608
1609 Please note that the moduleFunction method is not fully available in
1610 Kamailio 1.2. See the method's documentation for details.
1611
1612 “paramfunc” shows that you can pass arbitrary strings to perl
1613 functions. Do with them whatever you want :)
1614
1615 “autotest” demonstrates that unknown functions in Kamailio::Message
1616 objects are automatically transformed into calls to module functions.
1617
1618 The “diefunc”s show that dying perl scripts - by "manual" dying, or
1619 because of script errors - are handled by the Kamailio package. The
1620 error message is logged through Kamailio's logging mechanism. Please
1621 note that this only works correctly if you do NOT overwrite the default
1622 die handler. Oh, yes, that works for warnings, too.
1623
1624 1.1.5. headers.pl
1625
1626 Header extraction is among the most crucial functionalities while
1627 processing SIP messages. This sample script demonstrates access to
1628 header names and values within two sample functions.
1629
1630 “headernames” extracts all header names and logs their names.
1631
1632 “someheaders” logs the contents of the two headers, “To” and
1633 “WWW-Contact”. As you can see, headers that occur more than once are
1634 retrieved as an array, which may be accessed by Perl's array accessing
1635 methods.
1636
1637 1.1.6. logging.pl
1638
1639 For debugging purposes, you probably want to write messages to the
1640 syslog. The “logdemo” shows three ways to access the Kamailio log
1641 function: it is available through the Kamailio class as well as through
1642 the Kamailio::Message class.
1643
1644 Remember that you can use exported functions from other modules. You
1645 may thus as well use the “xlog” module and it's xlog function.
1646
1647 The L_INFO, L_DBG, L_ERR, L_CRIT... constants are available through the
1648 Kamailio::Constants package.
1649
1650 1.1.7. messagedump.pl
1651
1652 This script demonstrates how to access the whole message header of the
1653 current message. Please note that modifications on the message made by
1654 earlier function calls in your configuration script may NOT be
1655 reflected in this dump.
1656
1657 1.1.8. persistence.pl
1658
1659 When processing SIP messages, you may want to use persistent data
1660 across multiple calls to your Perl functions. Your first option is to
1661 use global variables in your script. Unfortunately, these globals are
1662 not visible from the multiple instances of Kamailio. You may want to
1663 use a mechanism such as the IPC::Shareable shared memory access package
1664 to correct this.
1665
1666 1.1.9. phonenumbers.pl
1667
1668 The Kamailio::Utils::PhoneNumbers package provides two methods for the
1669 transformation of local to canonical telephone numbers, and vice versa.
1670 This script demonstrates its use.
1671
1672 1.1.10. pseudovars.pl
1673
1674 This script demonstrates the Perl module's “pseudoVar” method. It may
1675 be used to retrieve the values of current pseudo variables.
1676
1677 You might notice that there is no particular function for setting
1678 pseudo variables; you may use the exported functions from the avpops
1679 module, though.
1680
1681 Chapter 4. Frequently Asked Questions
1682
1683 4.1. Are there known bugs in the Perl module?
1684 4.2. Where can I find more about Kamailio?
1685 4.3. Where can I post a question about this module?
1686 4.4. How can I report a bug?
1687
1688 4.1.
1689
1690 Are there known bugs in the Perl module?
1691
1692 The Perl module does have a few shortcomings that may be regarded as
1693 bugs.
1694 * Missing module functions. Not all functions of other modules are
1695 available for Perl access. The reason for this is a design property
1696 of Kamailio. Making available more functions is work in progress.
1697 * Perl and threads. Perl itself is, when compiled with the correct
1698 parameters, thread safe; unfortunately, not all Perl modules are.
1699 The DBI modules, especially (but not restricted to) DBI::ODBC are
1700 known NOT to be thread safe.
1701 Using DBI::ODBC -- and possibly other non-thread-safe Perl
1702 extensions -- may result in erroneous behavior of Kamailio,
1703 including (but not restricted to) server crashes and wrong routing.
1704
1705 4.2.
1706
1707 Where can I find more about Kamailio?
1708
1709 Take a look at https://www.kamailio.org/.
1710
1711 4.3.
1712
1713 Where can I post a question about this module?
1714
1715 First at all check if your question was already answered on one of our
1716 mailing lists:
1717 * User Mailing List -
1718 https://lists.kamailio.org/mailman3/postorius/lists/sr-users.lists.
1719 kamailio.org/
1720 * Developer Mailing List -
1721 https://lists.kamailio.org/mailman3/postorius/lists/sr-dev.lists.ka
1722 mailio.org/
1723
1724 E-mails regarding any stable Kamailio release should be sent to
1725 <[email protected]> and e-mails regarding development
1726 versions should be sent to <[email protected]>.
1727
1728 4.4.
1729
1730 How can I report a bug?
1731
1732 Please follow the guidelines provided at:
1733 https://github.com/kamailio/kamailio/issues.