uid_domain.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  4. <book id="uid_domain" xmlns:xi="http://www.w3.org/2001/XInclude">
  5. <bookinfo>
  6. <title>UID Domain Module</title>
  7. <authorgroup>
  8. <author>
  9. <firstname>Juha</firstname>
  10. <surname>Heinanen</surname>
  11. <email>[email protected]</email>
  12. </author>
  13. </authorgroup>
  14. <copyright>
  15. <year>2002-2010</year>
  16. <holder>Juha Heinanen</holder>
  17. </copyright>
  18. </bookinfo>
  19. <toc></toc>
  20. <chapter>
  21. <title>Admin Guide</title>
  22. <section id="uid_domain.overview">
  23. <title>Overview</title>
  24. <para>Domain modules, as the name suggests, implements support for
  25. multiple independent virtual domains hosted on one SIP server. This is
  26. often useful if you have multiple domain names and you want to make
  27. them all work and appear as one. Alternatively you might find the
  28. module useful if you want to run a shared SIP service for multiple
  29. independent customers. The module stores all supported domains and
  30. associated configuration in a database table. Most of the information
  31. can be cached in memory for performance reasons.</para>
  32. <section>
  33. <title>Virtual Domains</title>
  34. <para>The domain module adds support for so-called virtual
  35. domains. A virtual domain is just a collection of domain names and
  36. associated configuration information identified by a unique
  37. identifier. We refer to the domain identifier as DID elsewhere in
  38. the documentation. DID stands for "Domain IDentifier". In
  39. traditional POST world the term DID has a different meaning
  40. though. Please be aware that this is just pure coincidence.</para>
  41. <para>All domain names that belong to one virtual domain are
  42. interchangeable. From SIP server's perspective there is no
  43. difference between them. They can be used in SIP URIs
  44. interchangeably and the behavior of the SIP server will not be
  45. affected. This is called "domain name normalization" and it is one
  46. of the steps performed early during SIP message processing.</para>
  47. <para>The DID identifier can be anything. To the SIP server DIDs
  48. are just opaque strings and what format you choose depends on your
  49. requirements and the type of the setup. You can use numbers in
  50. smaller setups if the size of the data is a concern. You can set
  51. the DID to the canonical domain name of the domain. You can use
  52. RFC 4122 style UUIDs if your setup is large and distributed. You
  53. can use anything as long as it can be represented as string. The
  54. only requirement is that the identifier of each virtual domain
  55. must be unique.</para>
  56. <para>The following example illustrates how one virtual domain can
  57. be represented. The iptel.org domain runs a public SIP
  58. service. The users of the service can use SIP URIs of form
  59. sip:[email protected]. The SIP service is distributed, there is a
  60. number of SIP servers. The SIP servers are also available through
  61. a number of other domain names, such as sip.iptel.org,
  62. proxy.iptel.org and so on. We created one virtual domain in the
  63. domain module and added all such domain names to the virtual
  64. domain:</para>
  65. <example>
  66. <title>Virtual Domain iptel.org</title>
  67. <programlisting>
  68. iptel
  69. |
  70. +---iptel.org
  71. +---sip.iptel.org
  72. +---proxy.iptel.org
  73. +---213.192.59.75
  74. </programlisting>
  75. </example>
  76. <para>In the example above, we chose "iptel" as the unique
  77. identifier for the virtual domain. This identifier is
  78. permanent. It never changes. Over time we may change domain names
  79. assigned to this virtual domain, but this identifier never
  80. changes. The main reason why virtual domain identifiers must never
  81. change is that because they are referenced from other tables, for
  82. example the accounting table. The data in the accounting table is
  83. long-lived, usually archived, and this ensures that the data will
  84. still reference correct virtual domain, no matter what domain
  85. names are assigned to it.</para>
  86. <para>The virtual domain described above will be stored in the
  87. domain table in the database:</para>
  88. <example>
  89. <title>Database Representation of Virtual Domain</title>
  90. <programlisting>
  91. +-------+-----------------+-------+
  92. | did | domain | flags |
  93. +-------+-----------------+-------+
  94. | iptel | iptel.org | 33 |
  95. | iptel | sip.iptel.org | 33 |
  96. | iptel | proxy.iptel.org | 33 |
  97. | iptel | 213.192.59.75 | 33 |
  98. +-------+-----------------+-------+
  99. </programlisting>
  100. </example>
  101. <para>Because all domain names that belong to one particular
  102. virtual domain are equal, it does not matter which domain name is
  103. used in the host part of the SIP URI. Thus an imaginary user joe
  104. with SIP URI sip:[email protected] will also be reachable as
  105. sip:[email protected], sip:[email protected], and
  106. sip:[email protected]. If we add a new domain name to this virtual
  107. domain then joe will also be able to use the new domain name in
  108. his SIP URI, without the need to change anything.</para>
  109. </section>
  110. <section>
  111. <title>Domain-level Configuration Attributes</title>
  112. <para>In addition to a number of domain names, each virtual domain
  113. can also have extra configuration information associated with
  114. it. The possibility to configure the SIP server sightly
  115. differently in each virtual domain is, in fact, the main reason
  116. why we introduced the concept of virtual domains. We wanted to
  117. have one SIP server which will provide SIP service to multiple
  118. different customers and each of the customers may have slightly
  119. different configuration requirements. That's how domain-level
  120. configuration attributes were born.</para>
  121. <para>Because the administrator of the SIP server seldom knows
  122. configuration requirements in advance, we decided to implement a
  123. generic solution and store all configuration options in named
  124. attributes. Named attributes are just like variables, they have a
  125. name and they have a value. Attributes are accessible from the
  126. configuration script of the SIP server. Domain-level attributes
  127. are attributes that are associated with a particular virtual
  128. domain. They can be used to store additional configuration for the
  129. entire virtual domain, that is all users that belong (or have SIP
  130. URI) in that particular virtual domain. Domain-level attributes
  131. can be overridden be user-level attributes with the same name
  132. configured for a particular user. In other words a domain level
  133. attribute will only be effective if no user-level attribute with
  134. the same name exists.</para>
  135. <para>Domain-level attributes are stored in a separate table. The
  136. name of the table is domain_attrs and it is defined as follows:
  137. </para>
  138. <example>
  139. <title>Table domain_attrs</title>
  140. <programlisting>
  141. +-------+------------------+------+-----+---------+-------+
  142. | Field | Type | Null | Key | Default | Extra |
  143. +-------+------------------+------+-----+---------+-------+
  144. | did | varchar(64) | YES | MUL | NULL | |
  145. | name | varchar(32) | NO | | NULL | |
  146. | type | int(11) | NO | | 0 | |
  147. | value | varchar(255) | YES | | NULL | |
  148. | flags | int(10) unsigned | NO | | 0 | |
  149. +-------+------------------+------+-----+---------+-------+
  150. </programlisting>
  151. </example>
  152. <para>Each attribute has name, type and value. A single attribute
  153. can have multiple values and in that case it will occupy more rows
  154. in the table. Each attribute is associated with a particular
  155. virtual domain using the DID identifier. Domain-level attributes
  156. can contain just about anything. It is a generic configuration
  157. mechanism and it is up to you to define a list of attribute that
  158. are meaningful in your setup and use those attributes in the
  159. routing part of the configuration file.
  160. </para>
  161. <para>Attributes for a particular virtual-domain are made
  162. available to script function by the lookup_domain function. This
  163. is the function that is used to map domain names to DIDs. One of
  164. the side-effects of the function is that it makes domain-level
  165. attributes available to script function if a matching virtual
  166. domain is found.
  167. </para>
  168. <para>When caching is enabled, all attributes from domain_attrs
  169. table are cached in memory, just like virtual domain
  170. themselves. If you disable caching then the domain module will
  171. attempt to load attributes from the database each time you call
  172. lookup_domain. Attributes cached in memory can be realoaded with
  173. the domain.reload management function.</para>
  174. </section>
  175. <section>
  176. <title>Caching</title>
  177. <para>Domain module operates in caching or non-caching mode
  178. depending on value of module parameter
  179. <parameter>db_mode</parameter>. In caching mode domain module
  180. reads the contents of domain table into cache memory when the
  181. module is loaded. After that domain table is re-read only when
  182. module is given domain_reload fifo command. Any changes in domain
  183. table must thus be followed by domain_reload command in order to
  184. reflect them in module behavior. In non-caching mode domain module
  185. always queries domain table in the database.</para>
  186. <para>Caching is implemented using a hash table. The size of the
  187. hash table is given by HASH_SIZE constant defined in
  188. domain_mod.h. Its "factory default" value is 128. Caching mode is
  189. highly recommended if you want to use domain-level
  190. attributes.</para>
  191. </section>
  192. </section>
  193. <section id="uid_domain.dep">
  194. <title>Dependencies</title>
  195. <para>
  196. The module depends on the following modules (in the other words
  197. the listed modules must be loaded before this module):
  198. <itemizedlist>
  199. <listitem>
  200. <para><emphasis>database</emphasis> - Any database module</para>
  201. </listitem>
  202. </itemizedlist>
  203. </para>
  204. </section>
  205. <section id="uid_domain.known_limitations">
  206. <title>Known Limitations</title>
  207. <para>
  208. There is an unlikely race condition on domain list update. If a process uses a table,
  209. which is reloaded at the same time twice through <acronym>FIFO</acronym>, the second
  210. reload will delete the original table still in use by the process.
  211. </para>
  212. </section>
  213. <xi:include href="params.xml"/>
  214. <xi:include href="functions.xml"/>
  215. <xi:include href="fifo.xml"/>
  216. <xi:include href="domain_api.xml"/>
  217. </chapter>
  218. </book>