README 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621
  1. perl Module
  2. Bastian Friedrich
  3. Collax GmbH
  4. Edited by
  5. Bastian Friedrich
  6. Copyright © 2007 Collax GmbH
  7. __________________________________________________________________
  8. Table of Contents
  9. 1. Admin Guide
  10. 1. Overview
  11. 2. Installing the module
  12. 3. Using the module
  13. 4. Dependencies
  14. 4.1. Kamailio Modules
  15. 4.2. External Libraries or Applications
  16. 5. Parameters
  17. 5.1. filename (string)
  18. 5.2. modpath (string)
  19. 6. Functions
  20. 6.1. perl_exec_simple(func, [param])
  21. 6.2. perl_exec(func, [param])
  22. 2. Kamailio Perl API
  23. 1. Kamailio
  24. 1.1. log(level,message)
  25. 2. Kamailio::Message
  26. 2.1. getType()
  27. 2.2. getStatus()
  28. 2.3. getReason()
  29. 2.4. getVersion()
  30. 2.5. getRURI()
  31. 2.6. getMethod()
  32. 2.7. getFullHeader()
  33. 2.8. getBody()
  34. 2.9. getMessage()
  35. 2.10. getHeader(name)
  36. 2.11. getHeaderNames()
  37. 2.12. moduleFunction(func,string1,string2)
  38. 2.13. log(level,message) (deprecated type)
  39. 2.14. rewrite_ruri(newruri)
  40. 2.15. setFlag(flag)
  41. 2.16. resetFlag(flag)
  42. 2.17. isFlagSet(flag)
  43. 2.18. pseudoVar(string)
  44. 2.19. append_branch(branch,qval)
  45. 2.20. getParsedRURI()
  46. 3. Kamailio::URI
  47. 3.1. user()
  48. 3.2. host()
  49. 3.3. passwd()
  50. 3.4. port()
  51. 3.5. params()
  52. 3.6. headers()
  53. 3.7. transport()
  54. 3.8. ttl()
  55. 3.9. user_param()
  56. 3.10. maddr()
  57. 3.11. method()
  58. 3.12. lr()
  59. 3.13. r2()
  60. 3.14. transport_val()
  61. 3.15. ttl_val()
  62. 3.16. user_param_val()
  63. 3.17. maddr_val()
  64. 3.18. method_val()
  65. 3.19. lr_val()
  66. 3.20. r2_val()
  67. 4. Kamailio::AVP
  68. 4.1. add(name,val)
  69. 4.2. get(name)
  70. 4.3. destroy(name)
  71. 5. Kamailio::Utils::PhoneNumbers
  72. 5.1.
  73. new(publicAccessPrefix,internationalPrefix,longDistanceP
  74. refix,countryCode,areaCode,pbxCode)
  75. 5.2. canonicalForm( number [, context] )
  76. 5.3. dialNumber( number [, context] )
  77. 6. Kamailio::LDAPUtils::LDAPConf
  78. 6.1. Constructor new()
  79. 6.2. Method base()
  80. 6.3. Method host()
  81. 6.4. Method port()
  82. 6.5. Method uri()
  83. 6.6. Method rootbindpw()
  84. 6.7. Method rootbinddn()
  85. 6.8. Method binddn()
  86. 6.9. Method bindpw()
  87. 7. Kamailio::LDAPUtils::LDAPConnection
  88. 7.1. Constructor new( [config, [authenticated]] )
  89. 7.2. Function/Method search( conf, filter, base,
  90. [requested_attributes ...])
  91. 7.2.1. Arguments:
  92. 7.2.2. Result:
  93. 8. Kamailio::VDB
  94. 9. Kamailio::Constants
  95. 10. Kamailio::VDB::Adapter::Speeddial
  96. 11. Kamailio::VDB::Adapter::Alias
  97. 11.1. query(conds,retkeys,order)
  98. 12. Kamailio::VDB::Adapter::AccountingSIPtrace
  99. 13. Kamailio::VDB::Adapter::Describe
  100. 14. Kamailio::VDB::Adapter::Auth
  101. 15. Kamailio::VDB::ReqCond
  102. 15.1. new(key,op,type,name)
  103. 15.2. op()
  104. 16. Kamailio::VDB::Pair
  105. 16.1. new(key,type,name)
  106. 16.2. key()
  107. 17. Kamailio::VDB::VTab
  108. 17.1. new()
  109. 17.2. call(op,[args])
  110. 18. Kamailio::VDB::Value
  111. 18.1. stringification
  112. 18.2. new(type,data)
  113. 18.3. type()
  114. 18.4. data()
  115. 19. Kamailio::VDB::Column
  116. 19.1. Stringification
  117. 19.2. new(type,name)
  118. 19.3. type( )
  119. 19.4. name()
  120. 19.5. Kamailio::VDB::Result
  121. 19.6. new(coldefs,[row, row, ...])
  122. 19.7. coldefs()
  123. 19.8. rows()
  124. 3. Perl samples
  125. 1. Sample directory
  126. 1.1. Script descriptions
  127. 1.1.1. branches.pl
  128. 1.1.2. firstline.pl
  129. 1.1.3. flags.pl
  130. 1.1.4. functions.pl
  131. 1.1.5. headers.pl
  132. 1.1.6. logging.pl
  133. 1.1.7. messagedump.pl
  134. 1.1.8. persistence.pl
  135. 1.1.9. phonenumbers.pl
  136. 1.1.10. pseudovars.pl
  137. 4. Frequently Asked Questions
  138. List of Examples
  139. 1.1. Set filename parameter
  140. 1.2. Set modpath parameter
  141. 1.3. perl_exec_simple() usage
  142. 1.4. perl_exec() usage
  143. Chapter 1. Admin Guide
  144. Table of Contents
  145. 1. Overview
  146. 2. Installing the module
  147. 3. Using the module
  148. 4. Dependencies
  149. 4.1. Kamailio Modules
  150. 4.2. External Libraries or Applications
  151. 5. Parameters
  152. 5.1. filename (string)
  153. 5.2. modpath (string)
  154. 6. Functions
  155. 6.1. perl_exec_simple(func, [param])
  156. 6.2. perl_exec(func, [param])
  157. 1. Overview
  158. The time needed when writing a new Kamailio module unfortunately is
  159. quite high, while the options provided by the configuration file are
  160. limited to the features implemented in the modules.
  161. With this Perl module, you can easily implement your own Kamailio
  162. extensions in Perl. This allows for simple access to the full world of
  163. CPAN modules. SIP URI rewriting could be implemented based on regular
  164. expressions; accessing arbitrary data backends, e.g. LDAP or Berkeley
  165. DB files, is now extremely simple.
  166. 2. Installing the module
  167. This Perl module is loaded in kamailio.cfg (just like all the other
  168. modules) with loadmodule("/path/to/perl.so");.
  169. For the Perl module to compile, you need a reasonably recent version of
  170. perl (tested with 5.8.8) linked dynamically. It is strongly advised to
  171. use a threaded version. The default binary packages from your favorite
  172. Linux distribution should work fine.
  173. Cross compilation is supported by the Makefile. You need to set the
  174. environment variables PERLLDOPTS, PERLCCOPTS and TYPEMAP to values
  175. similar to the output of
  176. PERLLDOPTS: perl -MExtUtils::Embed -e ldopts
  177. PERLCCOPTS: perl -MExtUtils::Embed -e ccopts
  178. TYPEMAP: echo "`perl -MConfig -e 'print $Config{installprivlib}'`/ExtUtils/ty
  179. pemap"
  180. The exact position of your (precompiled!) perl libraries depends on the
  181. setup of your environment.
  182. 3. Using the module
  183. The Perl module has two interfaces: The perl side, and the Kamailio
  184. side. Once a Perl function is defined and loaded via the module
  185. parameters (see below), it may be called in Kamailio's configuration at
  186. an arbitary point. E.g., you could write a function "ldap_alias" in
  187. Perl, and then execute
  188. ...
  189. if (perl_exec("ldap_alias")) {
  190. ...
  191. }
  192. ...
  193. just as you would have done with the current alias_db module.
  194. The functions you can use are listed in the "Exported Functions"
  195. section below.
  196. On the Perl side, there are a number of functions that let you read and
  197. modify the current SIP message, such as the RURI or the message flags.
  198. An introduction to the Perl interface and the full reference
  199. documentation can be found below.
  200. 4. Dependencies
  201. 4.1. Kamailio Modules
  202. 4.2. External Libraries or Applications
  203. 4.1. Kamailio Modules
  204. The following modules must be loaded before this module:
  205. * The "sl" module is needed for sending replies uppon fatal errors.
  206. All other modules can be accessed from the Perl module, though.
  207. 4.2. External Libraries or Applications
  208. The following libraries or applications must be installed before
  209. running Kamailio with this module loaded:
  210. * Perl 5.8.x or later
  211. Additionally, a number of perl modules should be installed. The
  212. Kamailio::LDAPUtils package relies on Net::LDAP to be installed. One of
  213. the sample scripts needs IPC::Shareable
  214. This module has been developed and tested with Perl 5.8.8, but should
  215. work with any 5.8.x release. Compilation is possible with 5.6.x, but
  216. its behavior is unsupported. Earlier versions do not work.
  217. On current Debian systems, at least the following packages should be
  218. installed:
  219. * perl
  220. * perl-base
  221. * perl-modules
  222. * libperl5.8
  223. * libperl-dev
  224. * libnet-ldap-perl
  225. * libipc-shareable-perl
  226. It was reported that other Debian-style distributions (such as Ubuntu)
  227. need the same packages.
  228. On SuSE systems, at least the following packages should be installed:
  229. * perl
  230. * perl-ldap
  231. * IPC::Shareable perl module from CPAN
  232. Although SuSE delivers a lot of perl modules, others may have to be
  233. fetched from CPAN. Consider using the program “cpan2rpm” - which, in
  234. turn, is available on CPAN. It creates RPM files from CPAN.
  235. 5. Parameters
  236. 5.1. filename (string)
  237. 5.2. modpath (string)
  238. 5.1. filename (string)
  239. This is the file name of your script. This may be set once only, but it
  240. may include an arbitary number of functions and “use” as many Perl
  241. module as necessary.
  242. May not be empty!
  243. Example 1.1. Set filename parameter
  244. ...
  245. modparam("perl", "filename", "/home/test/kamailio/myperl.pl")
  246. ...
  247. 5.2. modpath (string)
  248. The path to the Perl modules included (Kamailio.pm et.al). It is not
  249. absolutely crucial to set this path, as you may install the Modules in
  250. Perl's standard path, or update the “%INC” variable from within your
  251. script. Using this module parameter is the standard behavior, though.
  252. Multiple paths may be specified by separating them with a “:”
  253. character. The maximum is 10 paths.
  254. Example 1.2. Set modpath parameter
  255. ...
  256. modparam("perl", "modpath", "/usr/local/lib/kamailio/perl/")
  257. ...
  258. 6. Functions
  259. 6.1. perl_exec_simple(func, [param])
  260. 6.2. perl_exec(func, [param])
  261. 6.1. perl_exec_simple(func, [param])
  262. Calls a perl function without passing it the current SIP message. May
  263. be used for very simple simple requests that do not have to fiddle with
  264. the message themselves, but rather return information values about the
  265. environment.
  266. The first parameter is the function to be called. An arbitrary string
  267. may optionally be passed as a parameter.
  268. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
  269. ONREPLY_ROUTE and BRANCH_ROUTE.
  270. Example 1.3. perl_exec_simple() usage
  271. ...
  272. if (method=="INVITE") {
  273. perl_exec_simple("dosomething", "on invite messages");
  274. };
  275. ...
  276. 6.2. perl_exec(func, [param])
  277. Calls a perl function with passing it the current SIP message. The SIP
  278. message is reflected by a Perl module that gives you access to the
  279. information in the current SIP message (Kamailio::Message).
  280. The first parameter is the function to be called. An arbitrary string
  281. may be passed as a parameter.
  282. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
  283. ONREPLY_ROUTE and BRANCH_ROUTE.
  284. Example 1.4. perl_exec() usage
  285. ...
  286. if (perl_exec("ldapalias")) {
  287. ...
  288. };
  289. ...
  290. Chapter 2. Kamailio Perl API
  291. Table of Contents
  292. 1. Kamailio
  293. 1.1. log(level,message)
  294. 2. Kamailio::Message
  295. 2.1. getType()
  296. 2.2. getStatus()
  297. 2.3. getReason()
  298. 2.4. getVersion()
  299. 2.5. getRURI()
  300. 2.6. getMethod()
  301. 2.7. getFullHeader()
  302. 2.8. getBody()
  303. 2.9. getMessage()
  304. 2.10. getHeader(name)
  305. 2.11. getHeaderNames()
  306. 2.12. moduleFunction(func,string1,string2)
  307. 2.13. log(level,message) (deprecated type)
  308. 2.14. rewrite_ruri(newruri)
  309. 2.15. setFlag(flag)
  310. 2.16. resetFlag(flag)
  311. 2.17. isFlagSet(flag)
  312. 2.18. pseudoVar(string)
  313. 2.19. append_branch(branch,qval)
  314. 2.20. getParsedRURI()
  315. 3. Kamailio::URI
  316. 3.1. user()
  317. 3.2. host()
  318. 3.3. passwd()
  319. 3.4. port()
  320. 3.5. params()
  321. 3.6. headers()
  322. 3.7. transport()
  323. 3.8. ttl()
  324. 3.9. user_param()
  325. 3.10. maddr()
  326. 3.11. method()
  327. 3.12. lr()
  328. 3.13. r2()
  329. 3.14. transport_val()
  330. 3.15. ttl_val()
  331. 3.16. user_param_val()
  332. 3.17. maddr_val()
  333. 3.18. method_val()
  334. 3.19. lr_val()
  335. 3.20. r2_val()
  336. 4. Kamailio::AVP
  337. 4.1. add(name,val)
  338. 4.2. get(name)
  339. 4.3. destroy(name)
  340. 5. Kamailio::Utils::PhoneNumbers
  341. 5.1.
  342. new(publicAccessPrefix,internationalPrefix,longDistancePrefix,
  343. countryCode,areaCode,pbxCode)
  344. 5.2. canonicalForm( number [, context] )
  345. 5.3. dialNumber( number [, context] )
  346. 6. Kamailio::LDAPUtils::LDAPConf
  347. 6.1. Constructor new()
  348. 6.2. Method base()
  349. 6.3. Method host()
  350. 6.4. Method port()
  351. 6.5. Method uri()
  352. 6.6. Method rootbindpw()
  353. 6.7. Method rootbinddn()
  354. 6.8. Method binddn()
  355. 6.9. Method bindpw()
  356. 7. Kamailio::LDAPUtils::LDAPConnection
  357. 7.1. Constructor new( [config, [authenticated]] )
  358. 7.2. Function/Method search( conf, filter, base,
  359. [requested_attributes ...])
  360. 7.2.1. Arguments:
  361. 7.2.2. Result:
  362. 8. Kamailio::VDB
  363. 9. Kamailio::Constants
  364. 10. Kamailio::VDB::Adapter::Speeddial
  365. 11. Kamailio::VDB::Adapter::Alias
  366. 11.1. query(conds,retkeys,order)
  367. 12. Kamailio::VDB::Adapter::AccountingSIPtrace
  368. 13. Kamailio::VDB::Adapter::Describe
  369. 14. Kamailio::VDB::Adapter::Auth
  370. 15. Kamailio::VDB::ReqCond
  371. 15.1. new(key,op,type,name)
  372. 15.2. op()
  373. 16. Kamailio::VDB::Pair
  374. 16.1. new(key,type,name)
  375. 16.2. key()
  376. 17. Kamailio::VDB::VTab
  377. 17.1. new()
  378. 17.2. call(op,[args])
  379. 18. Kamailio::VDB::Value
  380. 18.1. stringification
  381. 18.2. new(type,data)
  382. 18.3. type()
  383. 18.4. data()
  384. 19. Kamailio::VDB::Column
  385. 19.1. Stringification
  386. 19.2. new(type,name)
  387. 19.3. type( )
  388. 19.4. name()
  389. 19.5. Kamailio::VDB::Result
  390. 19.6. new(coldefs,[row, row, ...])
  391. 19.7. coldefs()
  392. 19.8. rows()
  393. 1. Kamailio
  394. 1.1. log(level,message)
  395. This module provides access to a limited number of Kamailio core
  396. functions. As the most interesting functions deal with SIP messages,
  397. they are located in the Kamailio::Message class below.
  398. 1.1. log(level,message)
  399. Logs the message with Kamailio's logging facility. The logging level is
  400. one of the following:
  401. * L_ALERT
  402. * L_CRIT
  403. * L_ERR
  404. * L_WARN
  405. * L_NOTICE
  406. * L_INFO
  407. * L_DBG
  408. Please note that this method is NOT automatically exported, as it
  409. collides with the perl function log (which calculates the logarithm).
  410. Either explicitly import the function (via use Kamailio qw ( log );),
  411. or call it with its full name:
  412. Kamailio::log(L_INFO, "foobar");
  413. 2. Kamailio::Message
  414. 2.1. getType()
  415. 2.2. getStatus()
  416. 2.3. getReason()
  417. 2.4. getVersion()
  418. 2.5. getRURI()
  419. 2.6. getMethod()
  420. 2.7. getFullHeader()
  421. 2.8. getBody()
  422. 2.9. getMessage()
  423. 2.10. getHeader(name)
  424. 2.11. getHeaderNames()
  425. 2.12. moduleFunction(func,string1,string2)
  426. 2.13. log(level,message) (deprecated type)
  427. 2.14. rewrite_ruri(newruri)
  428. 2.15. setFlag(flag)
  429. 2.16. resetFlag(flag)
  430. 2.17. isFlagSet(flag)
  431. 2.18. pseudoVar(string)
  432. 2.19. append_branch(branch,qval)
  433. 2.20. getParsedRURI()
  434. This package provides access functions for an Kamailio sip_msg
  435. structure and its sub-components. Through its means it is possible to
  436. fully configure alternative routing decisions.
  437. 2.1. getType()
  438. Returns one of the constants SIP_REQUEST, SIP_REPLY, SIP_INVALID
  439. stating the type of the current message.
  440. 2.2. getStatus()
  441. Returns the status code of the current Reply message. This function is
  442. invalid in Request context!
  443. 2.3. getReason()
  444. Returns the reason of the current Reply message. This function is
  445. invalid in Request context!
  446. 2.4. getVersion()
  447. Returns the version string of the current SIP message.
  448. 2.5. getRURI()
  449. This function returns the recipient URI of the present SIP message:
  450. my $ruri = $m->getRURI();
  451. getRURI returns a string. See “getParsedRURI()” below how to receive a
  452. parsed structure.
  453. This function is valid in request messages only.
  454. 2.6. getMethod()
  455. Returns the current method, such as INVITE, REGISTER, ACK and so on.
  456. my $method = $m->getMethod();
  457. This function is valid in request messages only.
  458. 2.7. getFullHeader()
  459. Returns the full message header as present in the current message. You
  460. might use this header to further work with it with your favorite MIME
  461. package.
  462. my $hdr = $m->getFullHeader();
  463. 2.8. getBody()
  464. Returns the message body.
  465. 2.9. getMessage()
  466. Returns the whole message including headers and body.
  467. 2.10. getHeader(name)
  468. Returns the body of the first message header with this name.
  469. print $m->getHeader("To");
  470. "John" <sip:[email protected]>
  471. 2.11. getHeaderNames()
  472. Returns an array of all header names. Duplicates possible!
  473. 2.12. moduleFunction(func,string1,string2)
  474. Search for an arbitrary function in module exports and call it with the
  475. parameters self, string1, string2.
  476. string1 and/or string2 may be omitted.
  477. As this function provides access to the functions that are exported to
  478. the Kamailio configuration file, it is autoloaded for unknown
  479. functions. Instead of writing
  480. $m->moduleFunction("sl_send_reply", "500", "Internal Error");
  481. $m->moduleFunction("xlog", "L_INFO", "foo");
  482. you may as well write
  483. $m->sl_send_reply("500", "Internal Error");
  484. $m->xlog("L_INFO", "foo");
  485. WARNING
  486. In Kamailio 1.2, only a limited subset of module functions is
  487. available. This restriction will be removed in a later version.
  488. Here is a list of functions that are expected to be working (not
  489. claiming completeness):
  490. * alias_db_lookup
  491. * consume_credentials
  492. * is_rpid_user_e164
  493. * append_rpid_hf
  494. * bind_auth
  495. * avp_print
  496. * cpl_process_register
  497. * cpl_process_register_norpl
  498. * load_dlg
  499. * ds_next_dst
  500. * ds_next_domain
  501. * ds_mark_dst
  502. * ds_mark_dst
  503. * is_from_local
  504. * is_uri_host_local
  505. * dp_can_connect
  506. * dp_apply_policy
  507. * enum_query (without parameters)
  508. * enum_fquery (without parameters)
  509. * is_from_user_enum (without parameters)
  510. * i_enum_query (without parameters)
  511. * imc_manager
  512. * jab_* (all functions from the jabber module)
  513. * load_gws (without parameters)
  514. * next_gw
  515. * from_gw (without parameters)
  516. * to_gw (without parameters)
  517. * load_contacts
  518. * next_contacts
  519. * sdp_mangle_ip
  520. * sdp_mangle_port
  521. * encode_contact
  522. * decode_contact
  523. * decode_contact_header
  524. * fix_contact
  525. * use_media_proxy
  526. * end_media_session
  527. * m_store
  528. * m_dump
  529. * fix_nated_contact
  530. * unforce_rtp_proxy
  531. * force_rtp_proxy
  532. * fix_nated_register
  533. * add_rcv_param
  534. * options_reply
  535. * checkospheader
  536. * validateospheader
  537. * requestosprouting
  538. * checkosproute
  539. * prepareosproute
  540. * prepareallosproutes
  541. * checkcallingtranslation
  542. * reportospusage
  543. * mangle_pidf
  544. * mangle_message_cpim
  545. * add_path (without parameters)
  546. * add_path_received (without parameters)
  547. * prefix2domain
  548. * allow_routing (without parameters)
  549. * allow_trusted
  550. * pike_check_req
  551. * handle_publish
  552. * handle_subscribe
  553. * stored_pres_info
  554. * bind_pua
  555. * send_publish
  556. * send_subscribe
  557. * pua_set_publish
  558. * loose_route
  559. * record_route
  560. * load_rr
  561. * sip_trace
  562. * sl_reply_error
  563. * sms_send_msg
  564. * sd_lookup
  565. * sstCheckMin
  566. * append_time
  567. * has_body (without parameters)
  568. * is_peer_verified
  569. * t_newtran
  570. * t_release
  571. * t_relay (without parameters)
  572. * t_flush_flags
  573. * t_check_trans
  574. * t_was_cancelled
  575. * t_load_contacts
  576. * t_next_contacts
  577. * uac_restore_from
  578. * uac_auth
  579. * has_totag
  580. * tel2sip
  581. * check_to
  582. * check_from
  583. * radius_does_uri_exist
  584. * ul_* (All functions exported by the usrloc module for user access)
  585. * xmpp_send_message
  586. 2.13. log(level,message) (deprecated type)
  587. Logs the message with Kamailio's logging facility. The logging level is
  588. one of the following:
  589. * L_ALERT
  590. * L_CRIT
  591. * L_ERR
  592. * L_WARN
  593. * L_NOTICE
  594. * L_INFO
  595. * L_DBG
  596. The logging function should be accessed via the Kamailio module
  597. variant. This one, located in Kamailio::Message, is deprecated.
  598. 2.14. rewrite_ruri(newruri)
  599. Sets a new destination (recipient) URI. Useful for rerouting the
  600. current message/call.
  601. if ($m->getRURI() =~ m/\@somedomain.net/) {
  602. $m->rewrite_ruri("sip:dispatcher\@organization.net");
  603. }
  604. 2.15. setFlag(flag)
  605. Sets a message flag. The constants as known from the C API may be used,
  606. when Constants.pm is included.
  607. 2.16. resetFlag(flag)
  608. Resets a message flag.
  609. 2.17. isFlagSet(flag)
  610. Returns whether a message flag is set or not.
  611. 2.18. pseudoVar(string)
  612. Returns a new string where all pseudo variables are substituted by
  613. their values. Can be used to receive the values of single variables,
  614. too.
  615. Please remember that you need to escape the '$' sign in perl strings!
  616. 2.19. append_branch(branch,qval)
  617. Append a branch to current message.
  618. 2.20. getParsedRURI()
  619. Returns the current destination URI as an Kamailio::URI object.
  620. 3. Kamailio::URI
  621. 3.1. user()
  622. 3.2. host()
  623. 3.3. passwd()
  624. 3.4. port()
  625. 3.5. params()
  626. 3.6. headers()
  627. 3.7. transport()
  628. 3.8. ttl()
  629. 3.9. user_param()
  630. 3.10. maddr()
  631. 3.11. method()
  632. 3.12. lr()
  633. 3.13. r2()
  634. 3.14. transport_val()
  635. 3.15. ttl_val()
  636. 3.16. user_param_val()
  637. 3.17. maddr_val()
  638. 3.18. method_val()
  639. 3.19. lr_val()
  640. 3.20. r2_val()
  641. This package provides functions for access to sip_uri structures.
  642. 3.1. user()
  643. Returns the user part of this URI.
  644. 3.2. host()
  645. Returns the host part of this URI.
  646. 3.3. passwd()
  647. Returns the passwd part of this URI.
  648. 3.4. port()
  649. Returns the port part of this URI.
  650. 3.5. params()
  651. Returns the params part of this URI.
  652. 3.6. headers()
  653. Returns the headers part of this URI.
  654. 3.7. transport()
  655. Returns the transport part of this URI.
  656. 3.8. ttl()
  657. Returns the ttl part of this URI.
  658. 3.9. user_param()
  659. Returns the user_param part of this URI.
  660. 3.10. maddr()
  661. Returns the maddr part of this URI.
  662. 3.11. method()
  663. Returns the method part of this URI.
  664. 3.12. lr()
  665. Returns the lr part of this URI.
  666. 3.13. r2()
  667. Returns the r2 part of this URI.
  668. 3.14. transport_val()
  669. Returns the transport_val part of this URI.
  670. 3.15. ttl_val()
  671. Returns the ttl_val part of this URI.
  672. 3.16. user_param_val()
  673. Returns the user_param_val part of this URI.
  674. 3.17. maddr_val()
  675. Returns the maddr_val part of this URI.
  676. 3.18. method_val()
  677. Returns the method_val part of this URI.
  678. 3.19. lr_val()
  679. Returns the lr_val part of this URI.
  680. 3.20. r2_val()
  681. Returns the r2_val part of this URI.
  682. 4. Kamailio::AVP
  683. 4.1. add(name,val)
  684. 4.2. get(name)
  685. 4.3. destroy(name)
  686. This package provides access functions for Kamailio's AVPs. These
  687. variables can be created, evaluated, modified and removed through this
  688. package.
  689. Please note that these functions do NOT support the notation used in
  690. the configuration file, but directly work on strings or numbers. See
  691. documentation of add method below.
  692. 4.1. add(name,val)
  693. Add an AVP.
  694. Add an Kamailio AVP to its environment. name and val may both be
  695. integers or strings; this function will try to guess what is correct.
  696. Please note that
  697. Kamailio::AVP::add("10", "10")
  698. is something different than
  699. Kamailio::AVP::add(10, 10)
  700. due to this evaluation: The first will create _string_ AVPs with the
  701. name 10, while the latter will create a numerical AVP.
  702. You can modify/overwrite AVPs with this function.
  703. 4.2. get(name)
  704. get an Kamailio AVP:
  705. my $numavp = Kamailio::AVP::get(5);
  706. my $stravp = Kamailio::AVP::get("foo");
  707. 4.3. destroy(name)
  708. Destroy an AVP.
  709. Kamailio::AVP::destroy(5);
  710. Kamailio::AVP::destroy("foo");
  711. 5. Kamailio::Utils::PhoneNumbers
  712. 5.1.
  713. new(publicAccessPrefix,internationalPrefix,longDistancePrefix,count
  714. ryCode,areaCode,pbxCode)
  715. 5.2. canonicalForm( number [, context] )
  716. 5.3. dialNumber( number [, context] )
  717. Kamailio::Utils::PhoneNumbers - Functions for canonical forms of phone
  718. numbers.
  719. use Kamailio::Utils::PhoneNumbers;
  720. my $phonenumbers = new Kamailio::Utils::PhoneNumbers(
  721. publicAccessPrefix => "0",
  722. internationalPrefix => "+",
  723. longDistancePrefix => "0",
  724. areaCode => "761",
  725. pbxCode => "456842",
  726. countryCode => "49"
  727. );
  728. $canonical = $phonenumbers->canonicalForm("07612034567");
  729. $number = $phonenumbers->dialNumber("+497612034567");
  730. A telphone number starting with a plus sign and containing all dial
  731. prefixes is in canonical form. This is usally not the number to dial at
  732. any location, so the dialing number depends on the context of the
  733. user/system.
  734. The idea to canonicalize numbers were taken from hylafax.
  735. Example: +497614514829 is the canonical form of my phone number, 829 is
  736. the number to dial at Pyramid, 4514829 is the dialing number from
  737. Freiburg are and so on.
  738. To canonicalize any number, we strip off any dial prefix we find and
  739. then add the prefixes for the location. So, when the user enters the
  740. number 04514829 in context pyramid, we remove the publicAccessPrefix
  741. (at Pyramid this is 0) and the pbxPrefix (4514 here). The result is
  742. 829. Then we add all the general dial prefixes - 49 (country) 761
  743. (area) 4514 (pbx) and 829, the number itself => +497614514829
  744. To get the dialing number from a canonical phone number, we substract
  745. all general prefixes until we have something
  746. As said before, the interpretation of a phone number depends on the
  747. context of the location. For the functions in this package, the context
  748. is created through the new operator.
  749. The following fields should be set:
  750. 'longDistancePrefix'
  751. 'areaCode'
  752. 'pbxCode'
  753. 'internationalPrefix'
  754. 'publicAccessPrefix'
  755. 'countryCode'
  756. This module exports the following functions when useed:
  757. 5.1. new(publicAccessPrefix,internationalPrefix,longDistancePrefix,countryCod
  758. e,areaCode,pbxCode)
  759. The new operator returns an object of this type and sets its locational
  760. context according to the passed parameters. See
  761. Kamailio::Utils::PhoneNumbers above.
  762. 5.2. canonicalForm( number [, context] )
  763. Convert a phone number (given as first argument) into its canonical
  764. form. When no context is passed in as the second argument, the default
  765. context from the systems configuration file is used.
  766. 5.3. dialNumber( number [, context] )
  767. Convert a canonical phone number (given in the first argument) into a
  768. number to to dial. WHen no context is given in the second argument, a
  769. default context from the systems configuration is used.
  770. 6. Kamailio::LDAPUtils::LDAPConf
  771. 6.1. Constructor new()
  772. 6.2. Method base()
  773. 6.3. Method host()
  774. 6.4. Method port()
  775. 6.5. Method uri()
  776. 6.6. Method rootbindpw()
  777. 6.7. Method rootbinddn()
  778. 6.8. Method binddn()
  779. 6.9. Method bindpw()
  780. Kamailio::LDAPUtils::LDAPConf - Read openldap config from standard
  781. config files.
  782. use Kamailio::LDAPUtils::LDAPConf;
  783. my $conf = new Kamailio::LDAPUtils::LDAPConf();
  784. This module may be used to retrieve the global LDAP configuration as
  785. used by other LDAP software, such as nsswitch.ldap and pam-ldap. The
  786. configuration is usualy stored in /etc/openldap/ldap.conf
  787. When used from an account with sufficient privilegs (e.g. root), the
  788. ldap manager passwort is also retrieved.
  789. 6.1. Constructor new()
  790. Returns a new, initialized Kamailio::LDAPUtils::LDAPConf object.
  791. 6.2. Method base()
  792. Returns the servers base-dn to use when doing queries.
  793. 6.3. Method host()
  794. Returns the ldap host to contact.
  795. 6.4. Method port()
  796. Returns the ldap servers port.
  797. 6.5. Method uri()
  798. Returns an uri to contact the ldap server. When there is no ldap_uri in
  799. the configuration file, an ldap: uri is constucted from host and port.
  800. 6.6. Method rootbindpw()
  801. Returns the ldap "root" password.
  802. Note that the rootbindpw is only available when the current account has
  803. sufficient privilegs to access /etc/openldap/ldap.secret.
  804. 6.7. Method rootbinddn()
  805. Returns the DN to use for "root"-access to the ldap server.
  806. 6.8. Method binddn()
  807. Returns the DN to use for authentication to the ldap server. When no
  808. bind dn has been specified in the configuration file, returns the
  809. rootbinddn.
  810. 6.9. Method bindpw()
  811. Returns the password to use for authentication to the ldap server. When
  812. no bind password has been specified, returns the rootbindpw if any.
  813. 7. Kamailio::LDAPUtils::LDAPConnection
  814. 7.1. Constructor new( [config, [authenticated]] )
  815. 7.2. Function/Method search( conf, filter, base, [requested_attributes
  816. ...])
  817. 7.2.1. Arguments:
  818. 7.2.2. Result:
  819. Kamailio::LDAPUtils::LDAPConnection - Perl module to perform simple
  820. LDAP queries.
  821. OO-Style interface:
  822. use Kamailio::LDAPUtils::LDAPConnection;
  823. my $ldap = new Kamailio::LDAPUtils::LDAPConnection;
  824. my @rows = $ldap-search("uid=andi","ou=people,ou=coreworks,ou=de");
  825. Procedural interface:
  826. use Kamailio::LDAPUtils::LDAPConnection;
  827. my @rows = $ldap->search(
  828. new Kamailio::LDAPUtils::LDAPConfig(), "uid=andi","ou=people,ou=coreworks,
  829. ou=de");
  830. This perl module offers a somewhat simplified interface to the
  831. Net::LDAP functionality. It is intended for cases where just a few
  832. attributes should be retrieved without the overhead of the full
  833. featured Net::LDAP.
  834. 7.1. Constructor new( [config, [authenticated]] )
  835. Set up a new LDAP connection.
  836. The first argument, when given, should be a hash reference pointing to
  837. to the connection parameters, possibly an
  838. Kamailio::LDAPUtils::LDAPConfig object. This argument may be undef in
  839. which case a new (default) Kamailio::LDAPUtils::LDAPConfig object is
  840. used.
  841. When the optional second argument is a true value, the connection will
  842. be authenticated. Otherwise an anonymous bind is done.
  843. On success, a new LDAPConnection object is returned, otherwise the
  844. result is undef.
  845. 7.2. Function/Method search( conf, filter, base, [requested_attributes ...])
  846. perform an ldap search, return the dn of the first matching directory
  847. entry, unless a specific attribute has been requested, in wich case the
  848. values(s) fot this attribute are returned.
  849. When the first argument (conf) is a
  850. Kamailio::LDAPUtils::LDAPConnection, it will be used to perform the
  851. queries. You can pass the first argument implicitly by using the
  852. "method" syntax.
  853. Otherwise the conf argument should be a reference to a hash containing
  854. the connection setup parameters as contained in a
  855. Kamailio::LDAPUtils::LDAPConf object. In this mode, the
  856. Kamailio::LDAPUtils::LDAPConnection from previous queries will be
  857. reused.
  858. 7.2.1. Arguments:
  859. conf
  860. configuration object, used to find host,port,suffix and
  861. use_ldap_checks
  862. filter
  863. ldap search filter, eg '(mail=some@domain)'
  864. base
  865. search base for this query. If undef use default suffix, concat
  866. base with default suffix if the last char is a ','
  867. requested_attributes
  868. retrieve the given attributes instead of the dn from the ldap
  869. directory.
  870. 7.2.2. Result:
  871. Without any specific requested_attributes, return the dn of all
  872. matching entries in the LDAP directory.
  873. When some requested_attributes are given, return an array with those
  874. attibutes. When multiple entries match the query, the attribute lists
  875. are concatenated.
  876. 8. Kamailio::VDB
  877. This package is an (abstract) base class for all virtual databases.
  878. Derived packages can be configured to be used by Kamailio as a
  879. database.
  880. The base class itself should NOT be used in this context, as it does
  881. not provide any functionality.
  882. 9. Kamailio::Constants
  883. This package provides a number of constants taken from enums and
  884. defines of Kamailio header files. Unfortunately, there is no mechanism
  885. for updating the constants automatically, so check the values if you
  886. are in doubt.
  887. 10. Kamailio::VDB::Adapter::Speeddial
  888. This adapter can be used with the speeddial module.
  889. 11. Kamailio::VDB::Adapter::Alias
  890. 11.1. query(conds,retkeys,order)
  891. This package is intended for usage with the alias_db module. The query
  892. VTab has to take two arguments and return an array of two arguments
  893. (user name/domain).
  894. 11.1. query(conds,retkeys,order)
  895. Queries the vtab with the given arguments for request conditions, keys
  896. to return and sort order column name.
  897. 12. Kamailio::VDB::Adapter::AccountingSIPtrace
  898. This package is an Adapter for the acc and siptrace modules, featuring
  899. only an insert operation.
  900. 13. Kamailio::VDB::Adapter::Describe
  901. This package is intended for debug usage. It will print information
  902. about requested functions and operations of a client module.
  903. Use this module to request schema information when creating new
  904. adapters.
  905. 14. Kamailio::VDB::Adapter::Auth
  906. This adapter is intended for usage with the auth_db module. The VTab
  907. should take a username as an argument and return a (plain text!)
  908. password.
  909. 15. Kamailio::VDB::ReqCond
  910. 15.1. new(key,op,type,name)
  911. 15.2. op()
  912. This package represents a request condition for database access,
  913. consisting of a column name, an operator (=, <, >, ...), a data type
  914. and a value.
  915. This package inherits from Kamailio::VDB::Pair and thus includes its
  916. methods.
  917. 15.1. new(key,op,type,name)
  918. Constructs a new Column object.
  919. 15.2. op()
  920. Returns or sets the current operator.
  921. 16. Kamailio::VDB::Pair
  922. 16.1. new(key,type,name)
  923. 16.2. key()
  924. This package represents database key/value pairs, consisting of a key,
  925. a value type, and the value.
  926. This package inherits from Kamailio::VDB::Value and thus has the same
  927. methods.
  928. 16.1. new(key,type,name)
  929. Constructs a new Column object.
  930. 16.2. key()
  931. Returns or sets the current key.
  932. 17. Kamailio::VDB::VTab
  933. 17.1. new()
  934. 17.2. call(op,[args])
  935. This package handles virtual tables and is used by the Kamailio::VDB
  936. class to store information about valid tables. The package is not
  937. inteded for end user access.
  938. 17.1. new()
  939. Constructs a new VTab object
  940. 17.2. call(op,[args])
  941. Invokes an operation on the table (insert, update, ...) with the given
  942. arguments.
  943. 18. Kamailio::VDB::Value
  944. 18.1. stringification
  945. 18.2. new(type,data)
  946. 18.3. type()
  947. 18.4. data()
  948. This package represents a database value. Additional to the data
  949. itself, information about its type is stored.
  950. 18.1. stringification
  951. When accessing a Kamailio::VDB::Value object as a string, it simply
  952. returns its data regardless of its type. =cut
  953. use strict;
  954. package Kamailio::VDB::Value;
  955. use overload '""' => \&stringify;
  956. sub stringify { shift->{data} }
  957. use Kamailio; use Kamailio::Constants;
  958. our @ISA = qw ( Kamailio::Utils::Debug );
  959. 18.2. new(type,data)
  960. Constructs a new Value object. Its data type and the data are passed as
  961. parameters.
  962. 18.3. type()
  963. Returns or sets the current data type. Please consider using the
  964. constants from Kamailio::Constants
  965. 18.4. data()
  966. Returns or sets the current data.
  967. 19. Kamailio::VDB::Column
  968. 19.1. Stringification
  969. 19.2. new(type,name)
  970. 19.3. type( )
  971. 19.4. name()
  972. 19.5. Kamailio::VDB::Result
  973. 19.6. new(coldefs,[row, row, ...])
  974. 19.7. coldefs()
  975. 19.8. rows()
  976. This package represents database column definition, consisting of a
  977. column name and its data type.
  978. 19.1. Stringification
  979. When accessing a Kamailio::VDB::Column object as a string, it simply
  980. returns its column name regardless of its type. =cut
  981. package Kamailio::VDB::Column;
  982. use overload '""' => \&stringify;
  983. sub stringify { shift->{name} }
  984. use Kamailio; use Kamailio::Constants;
  985. our @ISA = qw ( Kamailio::Utils::Debug );
  986. 19.2. new(type,name)
  987. Constructs a new Column object. Its type and the name are passed as
  988. parameters.
  989. 19.3. type( )
  990. Returns or sets the current type. Please consider using the constants
  991. from Kamailio::Constants
  992. 19.4. name()
  993. Returns or sets the current column name.
  994. 19.5. Kamailio::VDB::Result
  995. This class represents a VDB result set. It contains a column
  996. definition, plus an array of rows. Rows themselves are simply
  997. references to arrays of scalars.
  998. 19.6. new(coldefs,[row, row, ...])
  999. The constructor creates a new Result object. Its first parameter is a
  1000. reference to an array of Kamailio::VDB::Column objects. Additional
  1001. parameters may be passed to provide initial rows, which are references
  1002. to arrays of scalars.
  1003. 19.7. coldefs()
  1004. Returns or sets the column definition of the object.
  1005. 19.8. rows()
  1006. Returns or sets the rows of the object.
  1007. Chapter 3. Perl samples
  1008. Table of Contents
  1009. 1. Sample directory
  1010. 1.1. Script descriptions
  1011. 1.1.1. branches.pl
  1012. 1.1.2. firstline.pl
  1013. 1.1.3. flags.pl
  1014. 1.1.4. functions.pl
  1015. 1.1.5. headers.pl
  1016. 1.1.6. logging.pl
  1017. 1.1.7. messagedump.pl
  1018. 1.1.8. persistence.pl
  1019. 1.1.9. phonenumbers.pl
  1020. 1.1.10. pseudovars.pl
  1021. 1. Sample directory
  1022. 1.1. Script descriptions
  1023. 1.1.1. branches.pl
  1024. 1.1.2. firstline.pl
  1025. 1.1.3. flags.pl
  1026. 1.1.4. functions.pl
  1027. 1.1.5. headers.pl
  1028. 1.1.6. logging.pl
  1029. 1.1.7. messagedump.pl
  1030. 1.1.8. persistence.pl
  1031. 1.1.9. phonenumbers.pl
  1032. 1.1.10. pseudovars.pl
  1033. There are a number of example scripts in the “samples/”. They are
  1034. documented well. Read them, it will explain a lot to you :)
  1035. If you want to use any of these scripts directly in your
  1036. implementation, you can use Perl's “require” mechanism to import them
  1037. (just remember that you need to use quotes when require'ing .pl files).
  1038. 1.1. Script descriptions
  1039. The included sample scripts are described below:
  1040. 1.1.1. branches.pl
  1041. The minimal function in branches.pl demonstrates that you can access
  1042. the "append_branch" function from within perl, just as you would have
  1043. done from your normal configuration file. You'll find documentation on
  1044. the concepts of branching in the Kamailio documentation.
  1045. 1.1.2. firstline.pl
  1046. Message's first_line structure may be evaluated. Message can be either
  1047. of SIP_REQUEST or SIP_REPLY. Depending on that, different information
  1048. can be received. This script demonstrates these functions.
  1049. 1.1.3. flags.pl
  1050. The perl module provides access to Kamailio's flagging mechanism. The
  1051. flag names available for Kamailio modules are made available through
  1052. the Kamailio::Constants package, so you can flag messages as "green",
  1053. "magenta" etc.
  1054. The first function, setflag, demonstrates how the "green" flag is set.
  1055. In the second function, readflag, the "green" and "magenta" flags are
  1056. evaluated.
  1057. 1.1.4. functions.pl
  1058. This sample script demonstrates different things related to calling
  1059. functions from within perl, and the different types of functions you
  1060. can offer for Kamailio access.
  1061. “exportedfuncs” simply demonstrates that you can use the moduleFunction
  1062. method to call functions offered by other modules. The results are
  1063. equivalent to calling these functions from your config file. In the
  1064. demonstrated case, telephone calls with a destination number beginning
  1065. with 555... are rejected with an internal server error. Other
  1066. destination addresses are passed to the alias_db module.
  1067. Please note that the moduleFunction method is not fully available in
  1068. Kamailio 1.2. See the method's documentation for details.
  1069. “paramfunc” shows that you can pass arbitrary strings to perl
  1070. functions. Do with them whatever you want :)
  1071. “autotest” demonstrates that unknown functions in Kamailio::Message
  1072. objects are automatically transformed into calls to module functions.
  1073. The “diefunc”s show that dying perl scripts - by "manual" dying, or
  1074. because of script errors - are handled by the Kamailio package. The
  1075. error message is logged through Kamailio's logging mechanism. Please
  1076. note that this only works correctly if you do NOT overwrite the default
  1077. die handler. Oh, yes, that works for warnings, too.
  1078. 1.1.5. headers.pl
  1079. Header extraction is among the most crucial functionalities while
  1080. processing SIP messages. This sample script demonstrates access to
  1081. header names and values within two sample functions.
  1082. “headernames” extracts all header names and logs their names.
  1083. “someheaders” logs the contents of the two headers, “To” and
  1084. “WWW-Contact”. As you can see, headers that occur more than once are
  1085. retrieved as an array, which may be accessed by Perl's array accessing
  1086. methods.
  1087. 1.1.6. logging.pl
  1088. For debugging purposes, you probably want to write messages to the
  1089. syslog. The “logdemo” shows three ways to access the Kamailio log
  1090. function: it is available through the Kamailio class as well as through
  1091. the Kamailio::Message class.
  1092. Remember that you can use exported functions from other modules. You
  1093. may thus as well use the “xlog” module and it's xlog function.
  1094. The L_INFO, L_DBG, L_ERR, L_CRIT... constants are available through the
  1095. Kamailio::Constants package.
  1096. 1.1.7. messagedump.pl
  1097. This script demonstrates how to access the whole message header of the
  1098. current message. Please note that modifications on the message made by
  1099. earlier function calls in your configuration script may NOT be
  1100. reflected in this dump.
  1101. 1.1.8. persistence.pl
  1102. When processing SIP messages, you may want to use persistent data
  1103. across multiple calls to your Perl functions. Your first option is to
  1104. use global variables in your script. Unfortunately, these globals are
  1105. not visible from the mulitple instances of Kamailio. You may want to
  1106. use a mechanism such as the IPC::Shareable shared memory access package
  1107. to correct this.
  1108. 1.1.9. phonenumbers.pl
  1109. The Kamailio::Utils::PhoneNumbers package provides two methods for the
  1110. transformation of local to canonical telephone numbers, and vice versa.
  1111. This script demonstrates it's use.
  1112. 1.1.10. pseudovars.pl
  1113. This script demonstrates the Perl module's “pseudoVar” method. It may
  1114. be used to retrieve the values of current pseudo variables.
  1115. You might notice that there is no particular function for setting
  1116. pseudo variables; you may use the exported functions from the avpops
  1117. module, though.
  1118. Chapter 4. Frequently Asked Questions
  1119. 4.1. Are there known bugs in the Perl module?
  1120. 4.2. Where can I find more about Kamailio?
  1121. 4.3. Where can I post a question about this module?
  1122. 4.4. How can I report a bug?
  1123. 4.1.
  1124. Are there known bugs in the Perl module?
  1125. The Perl module does have a few shortcomings that may be regarded as
  1126. bugs.
  1127. * Missing module functions. Not all functions of other modules are
  1128. available for Perl access. The reason for this is a design property
  1129. of Kamailio. Making available more functions is work in progress.
  1130. * Perl and threads. Perl itself is, when compiled with the correct
  1131. parameters, thread safe; unfortunately, not all Perl modules are.
  1132. The DBI modules, especially (but not restricted to) DBI::ODBC are
  1133. known NOT to be thread safe.
  1134. Using DBI::ODBC -- and possibly other non-thread-safe Perl
  1135. extensions -- may result in erroneous behavior of Kamailio,
  1136. including (but not restricted to) server crashes and wrong routing.
  1137. 4.2.
  1138. Where can I find more about Kamailio?
  1139. Take a look at http://www.kamailio.org/.
  1140. 4.3.
  1141. Where can I post a question about this module?
  1142. First at all check if your question was already answered on one of our
  1143. mailing lists:
  1144. * User Mailing List -
  1145. http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
  1146. * Developer Mailing List -
  1147. http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
  1148. E-mails regarding any stable Kamailio release should be sent to
  1149. <[email protected]> and e-mails regarding development
  1150. versions should be sent to <[email protected]>.
  1151. If you want to keep the mail private, send it to
  1152. <[email protected]>.
  1153. 4.4.
  1154. How can I report a bug?
  1155. Please follow the guidelines provided at:
  1156. http://sip-router.org/tracker.