path_admin.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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. This module is designed to be used at intermediate sip proxies like loadbalancers in front of
  15. registrars and proxies. It provides functions for inserting a Path header including a parameter for
  16. passing forward the received-&uri; of a registration to the next hop. It also provides a mechanism
  17. for evaluating this parameter in subsequent requests and to set the destination &uri; according to it.
  18. </para>
  19. <section>
  20. <title>Path insertion for registrations</title>
  21. <para>
  22. For registrations in a scenario like <quote>[UAC] -> [P1] -> [REG]</quote>,
  23. the "path" module can be used at the intermediate proxy P1 to insert a Path
  24. header into the message before forwarding it to the registrar REG. Two functions
  25. can be used to achieve this:
  26. <itemizedlist>
  27. <listitem>
  28. <para>
  29. <emphasis>add_path(...)</emphasis> adds a Path header in the form of
  30. <quote>Path: &lt;sip:1.2.3.4;lr&gt;</quote> to the message using the address
  31. of the outgoing interface. A port is only added if it's not the default
  32. port 5060.
  33. </para>
  34. <para>
  35. If a username is passed to the function, it is also included in the Path
  36. &uri;, like <quote>Path: &lt;sip:[email protected];lr&gt;</quote>.
  37. </para>
  38. </listitem>
  39. <listitem>
  40. <para>
  41. <emphasis>add_path_received(...)</emphasis> also add a Path header in the
  42. same form as above, but also adds a parameter indicating the received-&uri;
  43. of the message, like
  44. <quote>Path: &lt;sip:1.2.3.4;received=sip:2.3.4.5:1234;lr&gt;</quote>. This
  45. is especially useful if the proxy does NAT detection and wants to pass
  46. the NAT'ed address to the registrar.
  47. </para>
  48. <para>
  49. If the function is called with a username, it's included in the Path &uri; too.
  50. </para>
  51. </listitem>
  52. </itemizedlist>
  53. </para>
  54. <para>
  55. </para>
  56. </section>
  57. <section>
  58. <title>Outbound routing to NAT'ed UACs</title>
  59. <para>
  60. If the NAT'ed address of an UAC is passed to the registrar, the registrar routes back
  61. subsequent requests using the Path header of the registration as Route header of the
  62. current request. If the intermediate proxy had inserted a Path header including the
  63. <quote>received</quote> parameter during the registration, this parameter will show up
  64. in the Route header of the new request as well, allowing the intermediate proxy to route
  65. to this address instead of the one propagated in the Route &uri; for tunneling through NAT.
  66. This behaviour can be activated by setting the module parameter <quote>use_received</quote>.
  67. </para>
  68. </section>
  69. </section>
  70. <section>
  71. <title>Dependencies</title>
  72. <section>
  73. <title>&kamailio; Modules</title>
  74. <para>
  75. The following modules must be loaded before this module:
  76. <itemizedlist>
  77. <listitem>
  78. <para>
  79. The "rr" module is needed for outbound routing according to the <quote>received</quote>
  80. parameter.
  81. </para>
  82. </listitem>
  83. <listitem>
  84. <para>
  85. The "outbound" module is needed for outbound routing as per RFC 5626.
  86. </para>
  87. </listitem>
  88. </itemizedlist>
  89. </para>
  90. </section>
  91. <section>
  92. <title>External Libraries or Applications</title>
  93. <para>
  94. The following libraries or applications must be installed before
  95. running &kamailio; with this module loaded:
  96. <itemizedlist>
  97. <listitem>
  98. <para>
  99. <emphasis>None</emphasis>.
  100. </para>
  101. </listitem>
  102. </itemizedlist>
  103. </para>
  104. </section>
  105. </section>
  106. <section>
  107. <title>Parameters</title>
  108. <section>
  109. <title><varname>use_received</varname> (int)</title>
  110. <para>
  111. If set to 1, the <quote>received</quote> parameter of the first Route &uri; is evaluated and
  112. used as destination-&uri; if present.
  113. </para>
  114. <para>
  115. <emphasis>
  116. Default value is 0.
  117. </emphasis>
  118. </para>
  119. <example>
  120. <title>Set <varname>use_received</varname> parameter</title>
  121. <programlisting format="linespecific">
  122. ...
  123. modparam("path", "use_received", 1)
  124. ...
  125. </programlisting>
  126. </example>
  127. </section>
  128. </section>
  129. <section>
  130. <title>Functions</title>
  131. <section>
  132. <title>
  133. <function moreinfo="none">add_path()</function>
  134. </title>
  135. <para>
  136. This function is used to insert a Path header in the form
  137. <quote>Path: &lt;sip:1.2.3.4;lr&gt;</quote>, where <quote>1.2.3.4</quote> is the address
  138. of the outgoing interface.
  139. </para>
  140. <para>
  141. If the <quote>outbound</quote> module was loaded before this module, and outbound is
  142. required for this request, the header will be in the form
  143. <quote>Path: &lt;sip:[email protected];lr;ob&gt;</quote>, where <quote>flowtoken</quote>
  144. is the RFC 5636 flow-token that can be used to identify the source and local address and
  145. transport the request was received on, and where <quote>1.2.3.4</quote> is the address of
  146. the outgoing interface.
  147. </para>
  148. <para>
  149. This function can be used from REQUEST_ROUTE.
  150. </para>
  151. <example>
  152. <title><function>add_path</function> usage</title>
  153. <programlisting format="linespecific">
  154. ...
  155. if (!add_path()) {
  156. sl_send_reply("503", "Internal Path Error");
  157. ...
  158. };
  159. ...
  160. </programlisting>
  161. </example>
  162. </section>
  163. <section>
  164. <title>
  165. <function moreinfo="none">add_path(user)</function>
  166. </title>
  167. <para>
  168. This function adds a Path header in the form
  169. <quote>Path: &lt;sip:[email protected];lr&gt;</quote>.
  170. </para>
  171. <para>Meaning of the parameters is as follows:</para>
  172. <itemizedlist>
  173. <listitem>
  174. <para>
  175. <emphasis>user</emphasis> - The username to be inserted as user part.
  176. SPVE is supported.
  177. </para>
  178. </listitem>
  179. </itemizedlist>
  180. <para>
  181. This function can be used from REQUEST_ROUTE.
  182. </para>
  183. <example>
  184. <title><function>add_path(user)</function> usage</title>
  185. <programlisting format="linespecific">
  186. ...
  187. if (!add_path("loadbalancer")) {
  188. sl_send_reply("503", "Internal Path Error");
  189. ...
  190. };
  191. ...
  192. </programlisting>
  193. </example>
  194. </section>
  195. <section>
  196. <title>
  197. <function moreinfo="none">add_path(user, parameters)</function>
  198. </title>
  199. <para>
  200. This function adds a Path header in the form
  201. <quote>Path: &lt;sip:[email protected];lr&gt;</quote> and appends the
  202. given <emphasis>parameters</emphasis> as additional URI parameters.
  203. </para>
  204. <para>Meaning of the parameters is as follows:</para>
  205. <itemizedlist>
  206. <listitem>
  207. <para>
  208. <emphasis>user</emphasis> - The username to be inserted as user part.
  209. SPVE is supported.
  210. </para>
  211. </listitem>
  212. <listitem>
  213. <para>
  214. <emphasis>parameters</emphasis> - Additional URI parameters to be
  215. appended to the URI. The semicolon separator is added automatically.
  216. The script writer is responsible for proper URI escaping.
  217. SPVE is supported.
  218. </para>
  219. </listitem>
  220. </itemizedlist>
  221. <para>
  222. This function can be used from REQUEST_ROUTE.
  223. </para>
  224. <example>
  225. <title><function>add_path(user, parameters)</function> usage</title>
  226. <programlisting format="linespecific">
  227. ...
  228. if (!add_path("loadbalancer", "ob")) {
  229. sl_send_reply("503", "Internal Path Error");
  230. ...
  231. };
  232. ...
  233. </programlisting>
  234. </example>
  235. </section>
  236. <section>
  237. <title>
  238. <function moreinfo="none">add_path_received()</function>
  239. </title>
  240. <para>
  241. This function adds a Path header in the form
  242. <quote>Path: &lt;sip:1.2.3.4;received=sip:2.3.4.5:1234;lr&gt;</quote>, setting its own
  243. outgoing address as domain-part, and the address the request has been received from as
  244. received-parameter.
  245. </para>
  246. <para>
  247. This function can be used from REQUEST_ROUTE.
  248. </para>
  249. <example>
  250. <title><function>add_path_received()</function> usage</title>
  251. <programlisting format="linespecific">
  252. ...
  253. if (!add_path_received()) {
  254. sl_send_reply("503", "Internal Path Error");
  255. ...
  256. };
  257. ...
  258. </programlisting>
  259. </example>
  260. </section>
  261. <section>
  262. <title>
  263. <function moreinfo="none">add_path_received(user)</function>
  264. </title>
  265. <para>
  266. This function adds a Path header in the form
  267. <quote>Path: &lt;sip:[email protected];received=sip:2.3.4.5:1234;lr&gt;</quote>, setting
  268. 'user' as username part of address, its own
  269. outgoing address as domain-part, and the address the request has been received from as
  270. received-parameter.
  271. </para>
  272. <para>
  273. This function can be used from REQUEST_ROUTE.
  274. </para>
  275. <example>
  276. <title><function>add_path_received(user)</function> usage</title>
  277. <programlisting format="linespecific">
  278. ...
  279. if (!add_path_received("inbound")) {
  280. sl_send_reply("503", "Internal Path Error");
  281. ...
  282. };
  283. ...
  284. </programlisting>
  285. </example>
  286. </section>
  287. <section>
  288. <title>
  289. <function moreinfo="none">add_path_received(user, parameters)</function>
  290. </title>
  291. <para>
  292. This function adds a Path header in the form
  293. <quote>Path: &lt;sip:[email protected];received=sip:2.3.4.5:1234;lr&gt;</quote>, setting
  294. 'user' as username part of address, its own
  295. outgoing address as domain-part, and the address the request has been received from as
  296. received-parameter.
  297. </para>
  298. <para>
  299. This function can be used from REQUEST_ROUTE.
  300. </para>
  301. <example>
  302. <title><function>add_path_received(user, parameters)</function> usage</title>
  303. <programlisting format="linespecific">
  304. ...
  305. if (!add_path_received("inbound", "ob")) {
  306. sl_send_reply("503", "Internal Path Error");
  307. ...
  308. };
  309. ...
  310. </programlisting>
  311. </example>
  312. </section>
  313. </section>
  314. </chapter>