app_perl_pod.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. <?xml version="1.0" encoding='ISO-8859-1'?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!--
  9. Generated by Pod::DocBook v1.2, using:
  10. Digest::MD5 v2.36
  11. Pod::Parser v1.32
  12. Pod::ParseLink v1.06
  13. Text::ParseWords v3.24
  14. Text::Wrap v2005.082401
  15. -->
  16. <chapter><title>Kamailio Perl API</title>
  17. <section id="ID-d83a4c83b0cd455aef9602128b87c323"><title>Kamailio</title>
  18. <para>
  19. This module provides access to a limited number of Kamailio core
  20. functions. As the most interesting functions deal with SIP messages,
  21. they are located in the Kamailio::Message class below.
  22. </para>
  23. <section id="ID-3ae476990b7b1fe73d972e68eb52f93c"><title>log(level,message)</title>
  24. <para>
  25. Logs the message with Kamailio's logging facility. The logging level
  26. is one of the following:
  27. </para>
  28. <screen><![CDATA[* L_ALERT
  29. * L_CRIT
  30. * L_ERR
  31. * L_WARN
  32. * L_NOTICE
  33. * L_INFO
  34. * L_DBG]]></screen>
  35. <para>
  36. Please note that this method is <emphasis
  37. role="italic">NOT</emphasis> automatically exported, as it collides
  38. with the perl function log (which calculates the logarithm). Either
  39. explicitly import the function (via <literal
  40. role="code"><![CDATA[use Kamailio qw ( log );]]></literal>), or call
  41. it with its full name:
  42. </para>
  43. <screen><![CDATA[Kamailio::log(L_INFO, "foobar");]]></screen>
  44. </section>
  45. </section>
  46. <section id="ID-949656abaac653354242d1d0e9b418be"><title>Kamailio::Message</title>
  47. <para>
  48. This package provides access functions for an Kamailio <literal
  49. role="code"><![CDATA[sip_msg]]></literal> structure and its
  50. sub-components. Through its means it is possible to fully configure
  51. alternative routing decisions.
  52. </para>
  53. <section id="ID-4462b43922a45955436db6a77eff1274"><title>getType()</title>
  54. <para>
  55. Returns one of the constants SIP_REQUEST, SIP_REPLY, SIP_INVALID
  56. stating the type of the current message.
  57. </para>
  58. </section>
  59. <section id="ID-48eb6f3897940320d3dca81eee99e60f"><title>getStatus()</title>
  60. <para>
  61. Returns the status code of the current Reply message. This function
  62. is invalid in Request context!
  63. </para>
  64. </section>
  65. <section id="ID-06ad673da0ada52b0d53a16dc5edf3c7"><title>getReason()</title>
  66. <para>
  67. Returns the reason of the current Reply message. This function is
  68. invalid in Request context!
  69. </para>
  70. </section>
  71. <section id="ID-defa3c4593f2232a246f800880c3db8d"><title>getVersion()</title>
  72. <para>
  73. Returns the version string of the current SIP message.
  74. </para>
  75. </section>
  76. <section id="ID-40655f47473dfd0b09ab79f021379661"><title>getRURI()</title>
  77. <para>
  78. This function returns the recipient URI of the present SIP message:
  79. </para>
  80. <para>
  81. <literal role="code"><![CDATA[my $ruri =
  82. $m->getRURI();]]></literal>
  83. </para>
  84. <para>
  85. getRURI returns a string. See <link
  86. linkend="ID-f20c57aaa92a757d7152aa0479ee1fc0"><quote>getParsedRURI()</quote></link>
  87. below how to receive a parsed structure.
  88. </para>
  89. <para>
  90. This function is valid in request messages only.
  91. </para>
  92. </section>
  93. <section id="ID-09d760cb43aa35ee3338a63959e1ad52"><title>getMethod()</title>
  94. <para>
  95. Returns the current method, such as <literal
  96. role="code"><![CDATA[INVITE]]></literal>, <literal
  97. role="code"><![CDATA[REGISTER]]></literal>, <literal
  98. role="code"><![CDATA[ACK]]></literal> and so on.
  99. </para>
  100. <para>
  101. <literal role="code"><![CDATA[my $method =
  102. $m->getMethod();]]></literal>
  103. </para>
  104. <para>
  105. This function is valid in request messages only.
  106. </para>
  107. </section>
  108. <section id="ID-29a7bfa2b533d46b900690c15e89dac0"><title>getFullHeader()</title>
  109. <para>
  110. Returns the full message header as present in the current message.
  111. You might use this header to further work with it with your
  112. favorite MIME package.
  113. </para>
  114. <para>
  115. <literal role="code"><![CDATA[my $hdr =
  116. $m->getFullHeader();]]></literal>
  117. </para>
  118. </section>
  119. <section id="ID-d4227612556f15885224f8d7c9baa63d"><title>getBody()</title>
  120. <para>
  121. Returns the message body.
  122. </para>
  123. </section>
  124. <section id="ID-5c55b75dca8e197bf8d4e9195f3fc78b"><title>getMessage()</title>
  125. <para>
  126. Returns the whole message including headers and body.
  127. </para>
  128. </section>
  129. <section id="ID-2cd2368ec9da09ded819e54da7ed7e56"><title>getHeader(name)</title>
  130. <para>
  131. Returns the body of the first message header with this name.
  132. </para>
  133. <para>
  134. <literal role="code"><![CDATA[print
  135. $m->getHeader("To");]]></literal>
  136. </para>
  137. <para>
  138. <emphasis role="bold"><literal role="code"><![CDATA["John"
  139. <sip:[email protected]>]]></literal></emphasis>
  140. </para>
  141. </section>
  142. <section id="ID-e6f4b718fa39a84855f41d5048abfd17"><title>getHeaderNames()</title>
  143. <para>
  144. Returns an array of all header names. Duplicates possible!
  145. </para>
  146. </section>
  147. <section id="ID-7b0efd72c8ec89bc43dad940590b40c6"><title>moduleFunction(func,string1,string2)</title>
  148. <para>
  149. Search for an arbitrary function in module exports and call it with
  150. the parameters self, string1, string2.
  151. </para>
  152. <para>
  153. <literal role="code"><![CDATA[string1]]></literal> and/or <literal
  154. role="code"><![CDATA[string2]]></literal> may be omitted.
  155. </para>
  156. <para>
  157. As this function provides access to the functions that are exported
  158. to the Kamailio configuration file, it is autoloaded for unknown
  159. functions. Instead of writing
  160. </para>
  161. <screen><![CDATA[$m->moduleFunction("sl_send_reply", "500", "Internal Error");
  162. $m->moduleFunction("xlog", "L_INFO", "foo");]]></screen>
  163. <para>
  164. you may as well write
  165. </para>
  166. <screen><![CDATA[$m->sl_send_reply("500", "Internal Error");
  167. $m->xlog("L_INFO", "foo");]]></screen>
  168. <para>
  169. WARNING
  170. </para>
  171. <para>
  172. In Kamailio 1.2, only a limited subset of module functions is
  173. available. This restriction will be removed in a later version.
  174. </para>
  175. <para>
  176. Here is a list of functions that are expected to be working (not
  177. claiming completeness):
  178. </para>
  179. <screen><![CDATA[* alias_db_lookup
  180. * consume_credentials
  181. * is_rpid_user_e164
  182. * append_rpid_hf
  183. * bind_auth
  184. * avp_print
  185. * cpl_process_register
  186. * cpl_process_register_norpl
  187. * load_dlg
  188. * ds_next_dst
  189. * ds_next_domain
  190. * ds_mark_dst
  191. * ds_mark_dst
  192. * is_from_local
  193. * is_uri_host_local
  194. * dp_can_connect
  195. * dp_apply_policy
  196. * enum_query (without parameters)
  197. * enum_fquery (without parameters)
  198. * is_from_user_enum (without parameters)
  199. * i_enum_query (without parameters)
  200. * imc_manager
  201. * jab_* (all functions from the jabber module)
  202. * load_gws (without parameters)
  203. * next_gw
  204. * from_gw (without parameters)
  205. * to_gw (without parameters)
  206. * load_contacts
  207. * next_contacts
  208. * sdp_mangle_ip
  209. * sdp_mangle_port
  210. * encode_contact
  211. * decode_contact
  212. * decode_contact_header
  213. * fix_contact
  214. * use_media_proxy
  215. * end_media_session
  216. * m_store
  217. * m_dump
  218. * fix_nated_contact
  219. * unforce_rtp_proxy
  220. * force_rtp_proxy
  221. * fix_nated_register
  222. * add_rcv_param
  223. * options_reply
  224. * checkospheader
  225. * validateospheader
  226. * requestosprouting
  227. * checkosproute
  228. * prepareosproute
  229. * prepareallosproutes
  230. * checkcallingtranslation
  231. * reportospusage
  232. * mangle_pidf
  233. * mangle_message_cpim
  234. * add_path (without parameters)
  235. * add_path_received (without parameters)
  236. * prefix2domain
  237. * allow_routing (without parameters)
  238. * allow_trusted
  239. * pike_check_req
  240. * handle_publish
  241. * handle_subscribe
  242. * stored_pres_info
  243. * bind_pua
  244. * send_publish
  245. * send_subscribe
  246. * pua_set_publish
  247. * loose_route
  248. * record_route
  249. * load_rr
  250. * sip_trace
  251. * sl_reply_error
  252. * sms_send_msg
  253. * sd_lookup
  254. * sstCheckMin
  255. * append_time
  256. * has_body (without parameters)
  257. * is_peer_verified
  258. * t_newtran
  259. * t_release
  260. * t_relay (without parameters)
  261. * t_flush_flags
  262. * t_check_trans
  263. * t_was_cancelled
  264. * t_load_contacts
  265. * t_next_contacts
  266. * uac_restore_from
  267. * uac_auth
  268. * has_totag
  269. * tel2sip
  270. * check_to
  271. * check_from
  272. * radius_does_uri_exist
  273. * ul_* (All functions exported by the usrloc module for user access)
  274. * xmpp_send_message]]></screen>
  275. </section>
  276. <section id="ID-9fb36151aa2a86585e66dc19227b7d92"><title>log(level,message) (deprecated type)</title>
  277. <para>
  278. Logs the message with Kamailio's logging facility. The logging level
  279. is one of the following:
  280. </para>
  281. <screen><![CDATA[* L_ALERT
  282. * L_CRIT
  283. * L_ERR
  284. * L_WARN
  285. * L_NOTICE
  286. * L_INFO
  287. * L_DBG]]></screen>
  288. <para>
  289. The logging function should be accessed via the Kamailio module
  290. variant. This one, located in Kamailio::Message, is deprecated.
  291. </para>
  292. </section>
  293. <section id="ID-b6b5403d6a2b667316e7ce7ddd0937d0"><title>rewrite_ruri(newruri)</title>
  294. <para>
  295. Sets a new destination (recipient) URI. Useful for rerouting the
  296. current message/call.
  297. </para>
  298. <screen><![CDATA[if ($m->getRURI() =~ m/\@somedomain.net/) {
  299. $m->rewrite_ruri("sip:dispatcher\@organization.net");
  300. }]]></screen>
  301. </section>
  302. <section id="ID-43bdd45f2267be3165993d728ae6ac58"><title>setFlag(flag)</title>
  303. <para>
  304. Sets a message flag. The constants as known from the C API may be
  305. used, when Constants.pm is included.
  306. </para>
  307. </section>
  308. <section id="ID-d3f836fca6d5be320332751cb544a50b"><title>resetFlag(flag)</title>
  309. <para>
  310. Resets a message flag.
  311. </para>
  312. </section>
  313. <section id="ID-9df30424b7e93814c7928cf5899a12cc"><title>isFlagSet(flag)</title>
  314. <para>
  315. Returns whether a message flag is set or not.
  316. </para>
  317. </section>
  318. <section id="ID-cfb8c8675a6620394b21ab786379acfa"><title>pseudoVar(string)</title>
  319. <para>
  320. Returns a new string where all pseudo variables are substituted by
  321. their values. Can be used to receive the values of single
  322. variables, too.
  323. </para>
  324. <para>
  325. <emphasis role="bold">Please remember that you need to escape the
  326. '$' sign in perl strings!</emphasis>
  327. </para>
  328. </section>
  329. <section id="ID-098e67bc760ef445343eb9e8f93ece8b"><title>append_branch(branch,qval)</title>
  330. <para>
  331. Append a branch to current message.
  332. </para>
  333. </section>
  334. <section id="ID-f20c57aaa92a757d7152aa0479ee1fc0"><title>getParsedRURI()</title>
  335. <para>
  336. Returns the current destination URI as an Kamailio::URI object.
  337. </para>
  338. </section>
  339. </section>
  340. <section id="ID-ea7b3e8a4dc6ddf7af0e02f7cec8eef1"><title>Kamailio::URI</title>
  341. <para>
  342. This package provides functions for access to sip_uri structures.
  343. </para>
  344. <section id="ID-f0b0fe573c97823c7db7e6d2f763eecd"><title>user()</title>
  345. <para>
  346. Returns the user part of this URI.
  347. </para>
  348. </section>
  349. <section id="ID-13f823f4d5d264262256ce6c13ebda7f"><title>host()</title>
  350. <para>
  351. Returns the host part of this URI.
  352. </para>
  353. </section>
  354. <section id="ID-f16f4d3590aeadbb89be6381c63d31ba"><title>passwd()</title>
  355. <para>
  356. Returns the passwd part of this URI.
  357. </para>
  358. </section>
  359. <section id="ID-0e78ab3771467ade60bb813acff96e1f"><title>port()</title>
  360. <para>
  361. Returns the port part of this URI.
  362. </para>
  363. </section>
  364. <section id="ID-f09a07f5c225a4cdc0c8cf1b562feca5"><title>params()</title>
  365. <para>
  366. Returns the params part of this URI.
  367. </para>
  368. </section>
  369. <section id="ID-6ac4960ecbb77b9b208182e39c3fced6"><title>headers()</title>
  370. <para>
  371. Returns the headers part of this URI.
  372. </para>
  373. </section>
  374. <section id="ID-edbeee75601887c5522ec606864fcf06"><title>transport()</title>
  375. <para>
  376. Returns the transport part of this URI.
  377. </para>
  378. </section>
  379. <section id="ID-9b062529593a90fa98b8fdaf147d9625"><title>ttl()</title>
  380. <para>
  381. Returns the ttl part of this URI.
  382. </para>
  383. </section>
  384. <section id="ID-af281c7d5fa29dfa3d059c93e2ece82f"><title>user_param()</title>
  385. <para>
  386. Returns the user_param part of this URI.
  387. </para>
  388. </section>
  389. <section id="ID-cc3ad600892aefceee9bb7f7d083b9eb"><title>maddr()</title>
  390. <para>
  391. Returns the maddr part of this URI.
  392. </para>
  393. </section>
  394. <section id="ID-bcde93cc9055b03c23ac61f4f7aba922"><title>method()</title>
  395. <para>
  396. Returns the method part of this URI.
  397. </para>
  398. </section>
  399. <section id="ID-ffda2446aa820304039c53eaca5c1383"><title>lr()</title>
  400. <para>
  401. Returns the lr part of this URI.
  402. </para>
  403. </section>
  404. <section id="ID-e07722a580a9e670d428835b7efacfaf"><title>r2()</title>
  405. <para>
  406. Returns the r2 part of this URI.
  407. </para>
  408. </section>
  409. <section id="ID-20d6cdc41465025baceba8056215ac58"><title>transport_val()</title>
  410. <para>
  411. Returns the transport_val part of this URI.
  412. </para>
  413. </section>
  414. <section id="ID-6643223dbdb425407fe9801fd4d2fa5b"><title>ttl_val()</title>
  415. <para>
  416. Returns the ttl_val part of this URI.
  417. </para>
  418. </section>
  419. <section id="ID-aa87e27dd0cce4de62a0f32a7ecb7a33"><title>user_param_val()</title>
  420. <para>
  421. Returns the user_param_val part of this URI.
  422. </para>
  423. </section>
  424. <section id="ID-85b278e13c1c6169d612921b32a42c3a"><title>maddr_val()</title>
  425. <para>
  426. Returns the maddr_val part of this URI.
  427. </para>
  428. </section>
  429. <section id="ID-64d75002d2db35d7a66847e0c92f37a9"><title>method_val()</title>
  430. <para>
  431. Returns the method_val part of this URI.
  432. </para>
  433. </section>
  434. <section id="ID-cdb1f6d4201cd9b6ee19e6f58236a900"><title>lr_val()</title>
  435. <para>
  436. Returns the lr_val part of this URI.
  437. </para>
  438. </section>
  439. <section id="ID-af30e585b8decaf3e377375210e977b6"><title>r2_val()</title>
  440. <para>
  441. Returns the r2_val part of this URI.
  442. </para>
  443. </section>
  444. </section>
  445. <section id="ID-f092a1ce520e2e575c41702289adf85e"><title>Kamailio::AVP</title>
  446. <para>
  447. This package provides access functions for Kamailio's AVPs. These
  448. variables can be created, evaluated, modified and removed through
  449. this package.
  450. </para>
  451. <para>
  452. Please note that these functions do NOT support the notation used in
  453. the configuration file, but directly work on strings or numbers. See
  454. documentation of add method below.
  455. </para>
  456. <section id="ID-d4453222c49e08dc556c25a6586a00bc"><title>add(name,val)</title>
  457. <para>
  458. Add an AVP.
  459. </para>
  460. <para>
  461. Add an Kamailio AVP to its environment. name and val may both be
  462. integers or strings; this function will try to guess what is
  463. correct. Please note that
  464. </para>
  465. <screen><![CDATA[Kamailio::AVP::add("10", "10")]]></screen>
  466. <para>
  467. is something different than
  468. </para>
  469. <screen><![CDATA[Kamailio::AVP::add(10, 10)]]></screen>
  470. <para>
  471. due to this evaluation: The first will create _string_ AVPs with
  472. the name 10, while the latter will create a numerical AVP.
  473. </para>
  474. <para>
  475. You can modify/overwrite AVPs with this function.
  476. </para>
  477. </section>
  478. <section id="ID-ad3f402b1c78426a3a1de4d0c1d9ad6c"><title>get(name)</title>
  479. <para>
  480. get an Kamailio AVP:
  481. </para>
  482. <screen><![CDATA[my $numavp = Kamailio::AVP::get(5);
  483. my $stravp = Kamailio::AVP::get("foo");]]></screen>
  484. </section>
  485. <section id="ID-15db533161502fc4591ec9acdd990ef4"><title>destroy(name)</title>
  486. <para>
  487. Destroy an AVP.
  488. </para>
  489. <screen><![CDATA[Kamailio::AVP::destroy(5);
  490. Kamailio::AVP::destroy("foo");]]></screen>
  491. </section>
  492. </section>
  493. <section id="ID-b2dcbd51ac3a3e6208edd5e4f6a5ef63"><title>Kamailio::Utils::PhoneNumbers</title>
  494. <para>
  495. Kamailio::Utils::PhoneNumbers - Functions for canonical forms of phone
  496. numbers.
  497. </para>
  498. <screen><![CDATA[use Kamailio::Utils::PhoneNumbers;
  499. my $phonenumbers = new Kamailio::Utils::PhoneNumbers(
  500. publicAccessPrefix => "0",
  501. internationalPrefix => "+",
  502. longDistancePrefix => "0",
  503. areaCode => "761",
  504. pbxCode => "456842",
  505. countryCode => "49"
  506. );
  507. $canonical = $phonenumbers->canonicalForm("07612034567");
  508. $number = $phonenumbers->dialNumber("+497612034567");]]></screen>
  509. <para>
  510. A telphone number starting with a plus sign and containing all dial
  511. prefixes is in canonical form. This is usally not the number to dial
  512. at any location, so the dialing number depends on the context of the
  513. user/system.
  514. </para>
  515. <para>
  516. The idea to canonicalize numbers were taken from hylafax.
  517. </para>
  518. <para>
  519. Example: +497614514829 is the canonical form of my phone number, 829
  520. is the number to dial at Pyramid, 4514829 is the dialing number from
  521. Freiburg are and so on.
  522. </para>
  523. <para>
  524. To canonicalize any number, we strip off any dial prefix we find and
  525. then add the prefixes for the location. So, when the user enters the
  526. number 04514829 in context pyramid, we remove the publicAccessPrefix
  527. (at Pyramid this is 0) and the pbxPrefix (4514 here). The result is
  528. 829. Then we add all the general dial prefixes - 49 (country) 761
  529. (area) 4514 (pbx) and 829, the number itself =&gt; +497614514829
  530. </para>
  531. <para>
  532. To get the dialing number from a canonical phone number, we substract
  533. all general prefixes until we have something
  534. </para>
  535. <para>
  536. As said before, the interpretation of a phone number depends on the
  537. context of the location. For the functions in this package, the
  538. context is created through the <literal
  539. role="code"><![CDATA[new]]></literal> operator.
  540. </para>
  541. <para>
  542. The following fields should be set:
  543. </para>
  544. <screen><![CDATA['longDistancePrefix'
  545. 'areaCode'
  546. 'pbxCode'
  547. 'internationalPrefix'
  548. 'publicAccessPrefix'
  549. 'countryCode']]></screen>
  550. <para>
  551. This module exports the following functions when <literal
  552. role="code"><![CDATA[use]]></literal>ed:
  553. </para>
  554. <section id="ID-bd49dfdfc2284e87abd95fbce2d63cbd"><title>new(publicAccessPrefix,internationalPrefix,longDistancePrefix,countryCode,areaCode,pbxCode)</title>
  555. <para>
  556. The new operator returns an object of this type and sets its
  557. locational context according to the passed parameters. See
  558. <citerefentry>
  559. <refentrytitle>Kamailio::Utils::PhoneNumbers</refentrytitle>
  560. </citerefentry> above.
  561. </para>
  562. </section>
  563. <section id="ID-aa52786fee82fe6e26ac766b30a1a4fa"><title>canonicalForm( number [, context] )</title>
  564. <para>
  565. Convert a phone number (given as first argument) into its canonical
  566. form. When no context is passed in as the second argument, the
  567. default context from the systems configuration file is used.
  568. </para>
  569. </section>
  570. <section id="ID-31479dee3ae037c27cd7a84aa7358bd2"><title>dialNumber( number [, context] )</title>
  571. <para>
  572. Convert a canonical phone number (given in the first argument) into
  573. a number to to dial. WHen no context is given in the second
  574. argument, a default context from the systems configuration is used.
  575. </para>
  576. </section>
  577. </section>
  578. <section id="ID-05a2ba8f92ec3fe3d26bcb69d169a1b1"><title>Kamailio::LDAPUtils::LDAPConf</title>
  579. <para>
  580. Kamailio::LDAPUtils::LDAPConf - Read openldap config from standard
  581. config files.
  582. </para>
  583. <screen><![CDATA[use Kamailio::LDAPUtils::LDAPConf;
  584. my $conf = new Kamailio::LDAPUtils::LDAPConf();]]></screen>
  585. <para>
  586. This module may be used to retrieve the global LDAP configuration as
  587. used by other LDAP software, such as <literal
  588. role="code"><![CDATA[nsswitch.ldap]]></literal> and <literal
  589. role="code"><![CDATA[pam-ldap]]></literal>. The configuration is
  590. usualy stored in <literal
  591. role="code"><![CDATA[/etc/openldap/ldap.conf]]></literal>
  592. </para>
  593. <para>
  594. When used from an account with sufficient privilegs (e.g. root), the
  595. ldap manager passwort is also retrieved.
  596. </para>
  597. <section id="ID-77bbb24cd07a34db564171c3072c9f8c"><title>Constructor new()</title>
  598. <para>
  599. Returns a new, initialized <literal
  600. role="code"><![CDATA[Kamailio::LDAPUtils::LDAPConf]]></literal>
  601. object.
  602. </para>
  603. </section>
  604. <section id="ID-09b3942c6aa316dd4659cc1d84cfab21"><title>Method base()</title>
  605. <para>
  606. Returns the servers base-dn to use when doing queries.
  607. </para>
  608. </section>
  609. <section id="ID-cabd9882c784cf96cf68ca988c1dae0f"><title>Method host()</title>
  610. <para>
  611. Returns the ldap host to contact.
  612. </para>
  613. </section>
  614. <section id="ID-467ec702bbcdb63e337bbff9e3a5bf01"><title>Method port()</title>
  615. <para>
  616. Returns the ldap servers port.
  617. </para>
  618. </section>
  619. <section id="ID-1a047746515766cf720b5cc0f154c783"><title>Method uri()</title>
  620. <para>
  621. Returns an uri to contact the ldap server. When there is no
  622. ldap_uri in the configuration file, an <literal
  623. role="code"><![CDATA[ldap:]]></literal> uri is constucted from host
  624. and port.
  625. </para>
  626. </section>
  627. <section id="ID-35ebbd3612d026b4176d2eb8eae428b0"><title>Method rootbindpw()</title>
  628. <para>
  629. Returns the ldap "root" password.
  630. </para>
  631. <para>
  632. Note that the <literal role="code"><![CDATA[rootbindpw]]></literal>
  633. is only available when the current account has sufficient privilegs
  634. to access <literal
  635. role="code"><![CDATA[/etc/openldap/ldap.secret]]></literal>.
  636. </para>
  637. </section>
  638. <section id="ID-5e0c4c1de34f9247439d8d10d6734b9e"><title>Method rootbinddn()</title>
  639. <para>
  640. Returns the DN to use for "root"-access to the ldap server.
  641. </para>
  642. </section>
  643. <section id="ID-cdb5e3ce4599d0613db43f1f387f7ea6"><title>Method binddn()</title>
  644. <para>
  645. Returns the DN to use for authentication to the ldap server. When
  646. no bind dn has been specified in the configuration file, returns
  647. the <literal role="code"><![CDATA[rootbinddn]]></literal>.
  648. </para>
  649. </section>
  650. <section id="ID-3c51d4eeaae6feb7498a2f562b176df3"><title>Method bindpw()</title>
  651. <para>
  652. Returns the password to use for authentication to the ldap server.
  653. When no bind password has been specified, returns the <literal
  654. role="code"><![CDATA[rootbindpw]]></literal> if any.
  655. </para>
  656. </section>
  657. </section>
  658. <section id="ID-10d643239760bcd4a2286051808d077e"><title>Kamailio::LDAPUtils::LDAPConnection</title>
  659. <para>
  660. Kamailio::LDAPUtils::LDAPConnection - Perl module to perform simple
  661. LDAP queries.
  662. </para>
  663. <para>
  664. OO-Style interface:
  665. </para>
  666. <screen><![CDATA[use Kamailio::LDAPUtils::LDAPConnection;
  667. my $ldap = new Kamailio::LDAPUtils::LDAPConnection;
  668. my @rows = $ldap-search("uid=andi","ou=people,ou=coreworks,ou=de");]]></screen>
  669. <para>
  670. Procedural interface:
  671. </para>
  672. <screen><![CDATA[use Kamailio::LDAPUtils::LDAPConnection;
  673. my @rows = $ldap->search(
  674. new Kamailio::LDAPUtils::LDAPConfig(), "uid=andi","ou=people,ou=coreworks,ou=de");]]></screen>
  675. <para>
  676. This perl module offers a somewhat simplified interface to the
  677. <literal role="code"><![CDATA[Net::LDAP]]></literal> functionality.
  678. It is intended for cases where just a few attributes should be
  679. retrieved without the overhead of the full featured <literal
  680. role="code"><![CDATA[Net::LDAP]]></literal>.
  681. </para>
  682. <section id="ID-58e29437b48125a88033370afe8fa32b"><title>Constructor new( [config, [authenticated]] )</title>
  683. <para>
  684. Set up a new LDAP connection.
  685. </para>
  686. <para>
  687. The first argument, when given, should be a hash reference pointing
  688. to to the connection parameters, possibly an <literal
  689. role="code"><![CDATA[Kamailio::LDAPUtils::LDAPConfig]]></literal>
  690. object. This argument may be <literal
  691. role="code"><![CDATA[undef]]></literal> in which case a new
  692. (default) <literal
  693. role="code"><![CDATA[Kamailio::LDAPUtils::LDAPConfig]]></literal>
  694. object is used.
  695. </para>
  696. <para>
  697. When the optional second argument is a true value, the connection
  698. will be authenticated. Otherwise an anonymous bind is done.
  699. </para>
  700. <para>
  701. On success, a new <literal
  702. role="code"><![CDATA[LDAPConnection]]></literal> object is
  703. returned, otherwise the result is <literal
  704. role="code"><![CDATA[undef]]></literal>.
  705. </para>
  706. </section>
  707. <section id="ID-129bd2634f1c36a401321f2fa34be026"><title>Function/Method search( conf, filter, base, [requested_attributes ...])</title>
  708. <para>
  709. perform an ldap search, return the dn of the first matching
  710. directory entry, unless a specific attribute has been requested, in
  711. wich case the values(s) fot this attribute are returned.
  712. </para>
  713. <para>
  714. When the first argument (conf) is a <literal
  715. role="code"><![CDATA[Kamailio::LDAPUtils::LDAPConnection]]></literal>,
  716. it will be used to perform the queries. You can pass the first
  717. argument implicitly by using the "method" syntax.
  718. </para>
  719. <para>
  720. Otherwise the <literal role="code"><![CDATA[conf]]></literal>
  721. argument should be a reference to a hash containing the connection
  722. setup parameters as contained in a <literal
  723. role="code"><![CDATA[Kamailio::LDAPUtils::LDAPConf]]></literal>
  724. object. In this mode, the <literal
  725. role="code"><![CDATA[Kamailio::LDAPUtils::LDAPConnection]]></literal>
  726. from previous queries will be reused.
  727. </para>
  728. <section id="ID-fb371aca693935a2ea3467c59473c78f"><title>Arguments:</title>
  729. <para>
  730. <variablelist>
  731. <varlistentry>
  732. <term><anchor id="ID-08e27c41a71d449b64a8b443ae34bdb2"/>conf</term>
  733. <listitem>
  734. <para>
  735. configuration object, used to find host,port,suffix and
  736. use_ldap_checks
  737. </para>
  738. </listitem>
  739. </varlistentry>
  740. <varlistentry>
  741. <term><anchor id="ID-e6b91204102eda9679a64633dadda9cb"/>filter</term>
  742. <listitem>
  743. <para>
  744. ldap search filter, eg '(mail=some@domain)'
  745. </para>
  746. </listitem>
  747. </varlistentry>
  748. <varlistentry>
  749. <term><anchor id="ID-1067b3f87b6da6a8f5e87238609c1802"/>base</term>
  750. <listitem>
  751. <para>
  752. search base for this query. If undef use default suffix,
  753. concat base with default suffix if the last char is a ','
  754. </para>
  755. </listitem>
  756. </varlistentry>
  757. <varlistentry>
  758. <term><anchor id="ID-1c7c9132da5e8bb2a9c24aec3df86e47"/>requested_attributes</term>
  759. <listitem>
  760. <para>
  761. retrieve the given attributes instead of the dn from the
  762. ldap directory.
  763. </para>
  764. </listitem>
  765. </varlistentry>
  766. </variablelist>
  767. </para>
  768. </section>
  769. <section id="ID-5c0875c73d1d44335ab71b50d8930584"><title>Result:</title>
  770. <para>
  771. Without any specific <literal
  772. role="code"><![CDATA[requested_attributes]]></literal>, return
  773. the dn of all matching entries in the LDAP directory.
  774. </para>
  775. <para>
  776. When some <literal
  777. role="code"><![CDATA[requested_attributes]]></literal> are given,
  778. return an array with those attibutes. When multiple entries match
  779. the query, the attribute lists are concatenated.
  780. </para>
  781. </section>
  782. </section>
  783. </section>
  784. <section id="ID-94fdb1e4103544a567ac38ee23c8a4d1"><title>Kamailio::VDB</title>
  785. <para>
  786. This package is an (abstract) base class for all virtual databases.
  787. Derived packages can be configured to be used by Kamailio as a
  788. database.
  789. </para>
  790. <para>
  791. The base class itself should NOT be used in this context, as it does
  792. not provide any functionality.
  793. </para>
  794. </section>
  795. <section id="ID-d97df315e2044f430319fc4cd9937aa5"><title>Kamailio::Constants</title>
  796. <para>
  797. This package provides a number of constants taken from enums and
  798. defines of Kamailio header files. Unfortunately, there is no mechanism
  799. for updating the constants automatically, so check the values if you
  800. are in doubt.
  801. </para>
  802. </section>
  803. <section id="ID-9658bbad14831f685cca13a5c9bb4335"><title>Kamailio::VDB::Adapter::Speeddial</title>
  804. <para>
  805. This adapter can be used with the speeddial module.
  806. </para>
  807. </section>
  808. <section id="ID-5cdb14839de18c32782e3d768e170da7"><title>Kamailio::VDB::Adapter::Alias</title>
  809. <para>
  810. This package is intended for usage with the alias_db module. The
  811. query VTab has to take two arguments and return an array of two
  812. arguments (user name/domain).
  813. </para>
  814. <section id="ID-748da8d11c20576948ef68d62753a06a"><title>query(conds,retkeys,order)</title>
  815. <para>
  816. Queries the vtab with the given arguments for request conditions,
  817. keys to return and sort order column name.
  818. </para>
  819. </section>
  820. </section>
  821. <section id="ID-8165ac0b808b36ff72ee4032e0f62881"><title>Kamailio::VDB::Adapter::AccountingSIPtrace</title>
  822. <para>
  823. This package is an Adapter for the acc and siptrace modules,
  824. featuring only an insert operation.
  825. </para>
  826. </section>
  827. <section id="ID-048913e15394a9675cfe02af5c340528"><title>Kamailio::VDB::Adapter::Describe</title>
  828. <para>
  829. This package is intended for debug usage. It will print information
  830. about requested functions and operations of a client module.
  831. </para>
  832. <para>
  833. Use this module to request schema information when creating new
  834. adapters.
  835. </para>
  836. </section>
  837. <section id="ID-682dd320dd536e7fb0de4a24e9d1e46e"><title>Kamailio::VDB::Adapter::Auth</title>
  838. <para>
  839. This adapter is intended for usage with the auth_db module. The VTab
  840. should take a username as an argument and return a (plain text!)
  841. password.
  842. </para>
  843. </section>
  844. <section id="ID-f245c032bf4b4837415c871537a63e3b"><title>Kamailio::VDB::ReqCond</title>
  845. <para>
  846. This package represents a request condition for database access,
  847. consisting of a column name, an operator (=, &lt;, &gt;, ...), a data
  848. type and a value.
  849. </para>
  850. <para>
  851. This package inherits from Kamailio::VDB::Pair and thus includes its
  852. methods.
  853. </para>
  854. <section id="ID-c50f7cee51ceffdb7253101a36d6b7b3"><title>new(key,op,type,name)</title>
  855. <para>
  856. Constructs a new Column object.
  857. </para>
  858. </section>
  859. <section id="ID-cb5f02a3144f3af620484048b11472af"><title>op()</title>
  860. <para>
  861. Returns or sets the current operator.
  862. </para>
  863. </section>
  864. </section>
  865. <section id="ID-4be9a5fa03b11c2c2dad3594fc3b585d"><title>Kamailio::VDB::Pair</title>
  866. <para>
  867. This package represents database key/value pairs, consisting of a
  868. key, a value type, and the value.
  869. </para>
  870. <para>
  871. This package inherits from Kamailio::VDB::Value and thus has the same
  872. methods.
  873. </para>
  874. <section id="ID-e6cc5b1a997ea8e29d2a00b986784dc0"><title>new(key,type,name)</title>
  875. <para>
  876. Constructs a new Column object.
  877. </para>
  878. </section>
  879. <section id="ID-9c70856322a870405521ad299a6785d6"><title>key()</title>
  880. <para>
  881. Returns or sets the current key.
  882. </para>
  883. </section>
  884. </section>
  885. <section id="ID-41cd8a9b5b94c05139d2a7f62d5a967b"><title>Kamailio::VDB::VTab</title>
  886. <para>
  887. This package handles virtual tables and is used by the Kamailio::VDB
  888. class to store information about valid tables. The package is not
  889. inteded for end user access.
  890. </para>
  891. <section id="ID-a42ddb87d67983028cf8d1b7d6f46baa"><title>new()</title>
  892. <screen><![CDATA[Constructs a new VTab object]]></screen>
  893. </section>
  894. <section id="ID-c00e2c0b9abc7cd56be59f2b051a538c"><title>call(op,[args])</title>
  895. <para>
  896. Invokes an operation on the table (insert, update, ...) with the
  897. given arguments.
  898. </para>
  899. </section>
  900. </section>
  901. <section id="ID-dd87abbf6c21bba656e60f50bf1db81b"><title>Kamailio::VDB::Value</title>
  902. <para>
  903. This package represents a database value. Additional to the data
  904. itself, information about its type is stored.
  905. </para>
  906. <section id="ID-f8210a055e2dc48b7cd31acfbe483ef9"><title>stringification</title>
  907. <para>
  908. When accessing a Kamailio::VDB::Value object as a string, it simply
  909. returns its data regardless of its type. =cut
  910. </para>
  911. <para>
  912. use strict;
  913. </para>
  914. <para>
  915. package Kamailio::VDB::Value;
  916. </para>
  917. <para>
  918. use overload '""' =&gt; \&amp;stringify;
  919. </para>
  920. <para>
  921. sub stringify { shift-&gt;{data} }
  922. </para>
  923. <para>
  924. use Kamailio; use Kamailio::Constants;
  925. </para>
  926. <para>
  927. our @ISA = qw ( Kamailio::Utils::Debug );
  928. </para>
  929. </section>
  930. <section id="ID-246aa300bb8cb062e3126e6eddd094c4"><title>new(type,data)</title>
  931. <para>
  932. Constructs a new Value object. Its data type and the data are
  933. passed as parameters.
  934. </para>
  935. </section>
  936. <section id="ID-1b24f490feaba7e8ffde5919a34a3ea5"><title>type()</title>
  937. <para>
  938. Returns or sets the current data type. Please consider using the
  939. constants from Kamailio::Constants
  940. </para>
  941. </section>
  942. <section id="ID-8ed1b290ce747e1e6fc97d5c253d67eb"><title>data()</title>
  943. <para>
  944. Returns or sets the current data.
  945. </para>
  946. </section>
  947. </section>
  948. <section id="ID-01b04d0ae14c862d7543534782702100"><title>Kamailio::VDB::Column</title>
  949. <para>
  950. This package represents database column definition, consisting of a
  951. column name and its data type.
  952. </para>
  953. <section id="ID-c1f63ab2d499e0ffb0eff65d3d1bcaa3"><title>Stringification</title>
  954. <para>
  955. When accessing a Kamailio::VDB::Column object as a string, it simply
  956. returns its column name regardless of its type. =cut
  957. </para>
  958. <para>
  959. package Kamailio::VDB::Column;
  960. </para>
  961. <para>
  962. use overload '""' =&gt; \&amp;stringify;
  963. </para>
  964. <para>
  965. sub stringify { shift-&gt;{name} }
  966. </para>
  967. <para>
  968. use Kamailio; use Kamailio::Constants;
  969. </para>
  970. <para>
  971. our @ISA = qw ( Kamailio::Utils::Debug );
  972. </para>
  973. </section>
  974. <section id="ID-9be0a542b4be1d36c09e57a0a7785b8b"><title>new(type,name)</title>
  975. <para>
  976. Constructs a new Column object. Its type and the name are passed as
  977. parameters.
  978. </para>
  979. </section>
  980. <section id="ID-9e27faa58b7b4659e2d511fd4ed58ccd"><title>type( )</title>
  981. <para>
  982. Returns or sets the current type. Please consider using the
  983. constants from Kamailio::Constants
  984. </para>
  985. </section>
  986. <section id="ID-e3219d620b6d1b4f5656ee466ef3cf22"><title>name()</title>
  987. <para>
  988. Returns or sets the current column name.
  989. </para>
  990. </section>
  991. <section id="ID-07e232dc068e186782a8d0c0bbae91d3"><title>Kamailio::VDB::Result</title>
  992. <para>
  993. This class represents a VDB result set. It contains a column
  994. definition, plus an array of rows. Rows themselves are simply
  995. references to arrays of scalars.
  996. </para>
  997. </section>
  998. <section id="ID-54e80aeec6aaaa66afb9548d25388dea"><title>new(coldefs,[row, row, ...])</title>
  999. <para>
  1000. The constructor creates a new Result object. Its first parameter is
  1001. a reference to an array of Kamailio::VDB::Column objects. Additional
  1002. parameters may be passed to provide initial rows, which are
  1003. references to arrays of scalars.
  1004. </para>
  1005. </section>
  1006. <section id="ID-c77fe41ba24f3f04c12254c9f001bb27"><title>coldefs()</title>
  1007. <screen><![CDATA[Returns or sets the column definition of the object.]]></screen>
  1008. </section>
  1009. <section id="ID-a20f0baefcdf46a3e923bb02203b3792"><title>rows()</title>
  1010. <screen><![CDATA[Returns or sets the rows of the object.]]></screen>
  1011. </section>
  1012. </section>
  1013. </chapter>