alias_db_admin.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. <!-- Module User's Guide -->
  9. <chapter>
  10. <title>&adminguide;</title>
  11. <section>
  12. <title>Overview</title>
  13. <para>
  14. The ALIAS_DB module can be used as an alternative for user aliases
  15. via usrloc. The main feature is that it does not store all addiacent
  16. data as for user location and always uses the database for search (no
  17. memory caching). A common use case is to provide additional user
  18. aliases, i.e. to supplement the registration in the location database.
  19. Users are this way on a proxy reachable with several request URIs.
  20. </para>
  21. <para>
  22. As the module use no memory caching the lookup is a bit slower but the
  23. data provisioning is easier. With very fast databases like MySQL the speed
  24. penalty can be lowered. Also, the search can be performed on different
  25. tables in the same script.
  26. </para>
  27. </section>
  28. <section>
  29. <title>Dependencies</title>
  30. <section>
  31. <title>&kamailio; Modules</title>
  32. <para>
  33. The following modules must be loaded before this module:
  34. <itemizedlist>
  35. <listitem>
  36. <para>
  37. <emphasis>database module</emphasis> (mysql, dbtext, ...).
  38. </para>
  39. </listitem>
  40. </itemizedlist>
  41. </para>
  42. </section>
  43. <section>
  44. <title>External Libraries or Applications</title>
  45. <para>
  46. The following libraries or applications must be installed before
  47. running &kamailio; with this module loaded:
  48. <itemizedlist>
  49. <listitem>
  50. <para>
  51. <emphasis>None</emphasis>.
  52. </para>
  53. </listitem>
  54. </itemizedlist>
  55. </para>
  56. </section>
  57. </section>
  58. <section>
  59. <title>Parameters</title>
  60. <section>
  61. <title><varname>db_url</varname> (str)</title>
  62. <para>
  63. Database URL.
  64. </para>
  65. <para>
  66. <emphasis>
  67. Default value is <quote>&defaultrodb;</quote>.
  68. </emphasis>
  69. </para>
  70. <example>
  71. <title>Set <varname>db_url</varname> parameter</title>
  72. <programlisting format="linespecific">
  73. ...
  74. modparam("alias_db", "db_url", "&exampledb;")
  75. ...
  76. </programlisting>
  77. </example>
  78. </section>
  79. <section>
  80. <title><varname>user_column</varname> (str)</title>
  81. <para>
  82. Name of the column storing username.
  83. </para>
  84. <para>
  85. <emphasis>
  86. Default value is <quote>username</quote>.
  87. </emphasis>
  88. </para>
  89. <example>
  90. <title>Set <varname>user_column</varname> parameter</title>
  91. <programlisting format="linespecific">
  92. ...
  93. modparam("alias_db", "user_column", "susername")
  94. ...
  95. </programlisting>
  96. </example>
  97. </section>
  98. <section>
  99. <title><varname>domain_column</varname> (str)</title>
  100. <para>
  101. Name of the column storing user's domain.
  102. </para>
  103. <para>
  104. <emphasis>
  105. Default value is <quote>domain</quote>.
  106. </emphasis>
  107. </para>
  108. <example>
  109. <title>Set <varname>domain_column</varname> parameter</title>
  110. <programlisting format="linespecific">
  111. ...
  112. modparam("alias_db", "domain_column", "sdomain")
  113. ...
  114. </programlisting>
  115. </example>
  116. </section>
  117. <section>
  118. <title><varname>alias_user_column</varname> (str)</title>
  119. <para>
  120. Name of the column storing alias username.
  121. </para>
  122. <para>
  123. <emphasis>
  124. Default value is <quote>alias_username</quote>.
  125. </emphasis>
  126. </para>
  127. <example>
  128. <title>Set <varname>alias_user_column</varname> parameter</title>
  129. <programlisting format="linespecific">
  130. ...
  131. modparam("alias_db", "alias_user_column", "auser")
  132. ...
  133. </programlisting>
  134. </example>
  135. </section>
  136. <section>
  137. <title><varname>alias_domain_column</varname> (str)</title>
  138. <para>
  139. Name of the column storing alias domain.
  140. </para>
  141. <para>
  142. <emphasis>
  143. Default value is <quote>alias_domain</quote>.
  144. </emphasis>
  145. </para>
  146. <example>
  147. <title>Set <varname>alias_domain_column</varname> parameter</title>
  148. <programlisting format="linespecific">
  149. ...
  150. modparam("alias_db", "alias_domain_column", "adomain")
  151. ...
  152. </programlisting>
  153. </example>
  154. </section>
  155. <section>
  156. <title><varname>use_domain</varname> (int)</title>
  157. <para>
  158. Specifies whether to use or not the domain from R-URI when searching
  159. for alias. If set to 0, the domain from R-URI is not used, if set to
  160. 1 the domain from R-URI is used.
  161. </para>
  162. <para>
  163. <emphasis>
  164. Default value is <quote>0</quote>.
  165. </emphasis>
  166. </para>
  167. <example>
  168. <title>Set <varname>use_domain</varname> parameter</title>
  169. <programlisting format="linespecific">
  170. ...
  171. modparam("alias_db", "use_domain", 1)
  172. ...
  173. </programlisting>
  174. </example>
  175. </section>
  176. <section>
  177. <title><varname>domain_prefix</varname> (str)</title>
  178. <para>
  179. Specifies the prefix to be stripped from the domain in R-URI before
  180. doing the search.
  181. </para>
  182. <para>
  183. <emphasis>
  184. Default value is <quote>NULL</quote>.
  185. </emphasis>
  186. </para>
  187. <example>
  188. <title>Set <varname>domain_prefix</varname> parameter</title>
  189. <programlisting format="linespecific">
  190. ...
  191. modparam("alias_db", "domain_prefix", "sip.")
  192. ...
  193. </programlisting>
  194. </example>
  195. </section>
  196. <section>
  197. <title><varname>append_branches</varname> (int)</title>
  198. <para>
  199. If the alias resolves to many SIP IDs, the first is replacing
  200. the R-URI, the rest are added as branches.
  201. </para>
  202. <para>
  203. <emphasis>
  204. Default value is <quote>0</quote> (0 - don't add branches;
  205. 1 - add branches).
  206. </emphasis>
  207. </para>
  208. <example>
  209. <title>Set <varname>append_branches</varname> parameter</title>
  210. <programlisting format="linespecific">
  211. ...
  212. modparam("alias_db", "append_branches", 1)
  213. ...
  214. </programlisting>
  215. </example>
  216. </section>
  217. </section>
  218. <section>
  219. <title>Functions</title>
  220. <section>
  221. <title>
  222. <function moreinfo="none">alias_db_lookup(table_name)</function>
  223. </title>
  224. <para>
  225. The function takes the R-URI and search to see whether it is an alias
  226. or not. If it is an alias for a local user, the R-URI is replaced with
  227. user's SIP uri.
  228. </para>
  229. <para>
  230. The function returns TRUE if R-URI is alias and it was replaced by
  231. user's SIP uri.
  232. </para>
  233. <para>Meaning of the parameters is as follows:</para>
  234. <itemizedlist>
  235. <listitem>
  236. <para><emphasis>table_name</emphasis> - the name of the table
  237. where to search for alias. It can include pseudo-variables.
  238. </para>
  239. </listitem>
  240. </itemizedlist>
  241. <para>
  242. This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
  243. </para>
  244. <example>
  245. <title><function>alias_db_lookup()</function> usage</title>
  246. <programlisting format="linespecific">
  247. ...
  248. alias_db_lookup("dbaliases");
  249. alias_db_lookup("dba_$(rU{s.substr,0,1})");
  250. ...
  251. </programlisting>
  252. </example>
  253. </section>
  254. </section>
  255. </chapter>