Debian Codegraph @

src/modules/lost/doc/lost_admin.xml

raw symbols SCIP
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
5 <!-- Include general documentation entities -->
6 <!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
7 %docentities;
8
9 ]>
10 <!-- Module User's Guide -->
11
12 <chapter>
13 <title>&adminguide;</title>
14 <section>
15 <title>Overview</title>
16 <para>
17 SIP requests may be forwarded based on a location provided by the
18 request or retrieved from a specific location server using an identity
19 (HELD). This module implements the basic functionality to get or parse
20 location information (civic and geodetic) and to query a mapping service
21 (LOST) to get the next hop based on location and service urn either
22 specified or provided with the request.
23 </para>
24 <para>
25 This module implements protocol functions that use the http_client API
26 to fetch data from external LOST and HELD servers. The module is using
27 the http_client concept of "connections" to define properties of HTTP
28 sessions. A connection has one or multiple servers and a set of settings
29 that apply to the specific connection.
30 </para>
31 <para>
32 The function lost_held_query allows &kamailio; to assemble a HELD
33 locationRequest as defined in RFC6155
34 (<ulink url="https://tools.ietf.org/html/rfc6155"/>) to query location
35 information represented as PIDF-LO for a given identity (in most cases
36 a SIP URI). The identity may be a specific parameter or taken from the
37 P-Asserted-Identity or From header. The locationRequest response is
38 parsed and represented as PIDF-LO and location URI to dereference
39 location via HTTP(S).
40 </para>
41 <para>
42 The function lost_held_dereference allows &kamailio; to assemble a HELD
43 dereference request as defined in RFC6155
44 (<ulink url="https://tools.ietf.org/html/rfc6753"/>) to dereference location
45 information represented as PIDF-LO for a given URL. Required parameters are
46 an URL, responseTime, and responseType. The response is represented as PIDF-LO.
47 </para>
48 <para>
49 The function lost_query allows &kamailio; to assemble a LOST
50 findService request as defined in RFC5222
51 (<ulink url="https://tools.ietf.org/html/rfc5255"/>) to query
52 routing information for a given (geodetic or civic) location and a service
53 URN. Both, PIDF-LO and service URN may be provided as function parameters,
54 or are taken from the request message if applicable. The findServiceResponse
55 is parsed and represented as display name and SIP URI typically used as the next
56 hop in a Route header.
57 </para>
58 <para>
59 The http_client module uses the CURL library to set up connections.
60 The CURL library by default uses the system-configured DNS resolver,
61 not the Kamailio resolver.
62 </para>
63 <para>
64 The module is limited to using HTTP and HTTPS protocols.
65 </para>
66 </section>
67 <section>
68 <title>Dependencies</title>
69 <section>
70 <title>&kamailio; Modules</title>
71 <para>
72 The following modules must be loaded before this module:
73 <itemizedlist>
74 <listitem><para>
75 HTTP_CLIENT - the http_client module should be
76 loaded first to initialize connections properly.
77 </para></listitem>
78 <listitem><para>
79 TLS - if you use TLS connections (https) the TLS module
80 should be loaded first in order to initialize &openssl; properly.
81 </para></listitem>
82 </itemizedlist>
83 </para>
84 </section>
85 <section>
86 <title>External Libraries or Applications</title>
87 <para>
88 The following libraries or applications must be
89 installed before running &kamailio; with this module loaded:
90 <itemizedlist>
91 <listitem>
92 <para>
93 <emphasis>&libcurl;</emphasis>
94 </para>
95 </listitem>
96 <listitem>
97 <para>
98 <emphasis>libxml2</emphasis>
99 </para>
100 </listitem>
101 </itemizedlist>
102 </para>
103 </section>
104 </section>
105 <section id="lost.p.general">
106 <title>Parameters</title>
107 <para>
108 Besides parameters listed, this module uses <emphasis>http_client</emphasis>
109 therefore appropriate module parameters may apply.
110 </para>
111 <section id="lost.p.exact_type">
112 <title><varname>exact_type</varname> (int)</title>
113 <para>
114 Indicates to the location server that the contents of the "location_type"
115 parameter must be strictly followed. Values are 0 (false) or 1 (true).
116 </para>
117 <para>
118 Default: 0 (false)
119 </para>
120 <example>
121 <title>Set <varname>exact_type</varname> parameter</title>
122 <programlisting format="linespecific">
123 ...
124 modparam("lost", "exact_type", 1)
125 ...
126 </programlisting>
127 </example>
128 </section>
129 <section id="lost.p.response_time">
130 <title><varname>response_time</varname> (int)</title>
131 <para>
132 A time value informs the location server how long the client is
133 prepared to wait for a response.
134 </para>
135 <para>
136 The value is expressed as an integer, either -1 'emergencyDispatch', 0 'emergencyRouting',
137 a non-negative integer (>0) in units of milliseconds.
138 Note: The time value is indicative only.
139 </para>
140 <para>
141 Default: 0 ('emergencyRouting')
142 </para>
143 <example>
144 <title>Set <varname>response_time</varname> parameter</title>
145 <programlisting format="linespecific">
146 ...
147 modparam("lost", "response_time", 0)
148 ...
149 </programlisting>
150 </example>
151 </section>
152 <section id="lost.p.location_type">
153 <title><varname>location_type</varname> (string)</title>
154 <para>
155 The "locationType" element contains a list of types that are requested.
156 Values are "any", "geodetic", "civic" or "locationURI" and combinations.
157 </para>
158 <itemizedlist>
159 <listitem><para>
160 <emphasis>any</emphasis> - returns location information in all forms available
161 </para></listitem>
162 <listitem><para>
163 <emphasis>geodetic</emphasis> - returns a location by value in the form of a geodetic location
164 </para></listitem>
165 <listitem><para>
166 <emphasis>civic</emphasis> - returns a location by value in the form of a civic address
167 </para></listitem>
168 <listitem><para>
169 <emphasis>locationURI</emphasis> - returns a set of location URIs (location by reference)
170 </para></listitem>
171 </itemizedlist>
172 <para>
173 Default: "geodetic locationURI".
174 </para>
175 <example>
176 <title>Set <varname>location_type</varname> parameter</title>
177 <programlisting format="linespecific">
178 ...
179 modparam("lost", "location_type", "civic geodetic locationURI")
180 ...
181 </programlisting>
182 </example>
183 </section>
184 <section id="lost.p.post_request">
185 <title><varname>post_request</varname> (int)</title>
186 <para>
187 Dereferencing the location can be done using either the HTTP GET or POST method. This parameter
188 globally defines whether only HTTP POST method should be used. Values are 0 (GET) or 1 (POST).
189 </para>
190 <para>
191 Default: 0 (GET)
192 </para>
193 <example>
194 <title>Set <varname>post_request</varname> parameter</title>
195 <programlisting format="linespecific">
196 ...
197 modparam("lost", "post_request", 1)
198 ...
199 </programlisting>
200 </example>
201 </section>
202 <section id="lost.p.location_profile">
203 <title><varname>location_profile</varname> (int)</title>
204 <para>
205 A Presence Information Data Format Location Object (PIDF-LO) may contain geodetic or civic location
206 profile or combinations. A LoST <emphasis>findService</emphasis> contains only one location, which
207 is selected via this parameter as follows:
208 </para>
209 <itemizedlist>
210 <listitem><para>
211 <emphasis>0</emphasis> - takes the first location of any type
212 </para></listitem>
213 <listitem><para>
214 <emphasis>1</emphasis> - takes the last location of any type
215 </para></listitem>
216 <listitem><para>
217 <emphasis>2</emphasis> - takes the first geodetic location
218 </para></listitem>
219 <listitem><para>
220 <emphasis>3</emphasis> - takes the first civic location
221 </para></listitem>
222 </itemizedlist>
223 <para>
224 Default: 0 (first).
225 </para>
226 <example>
227 <title>Set <varname>location_profile</varname> parameter</title>
228 <programlisting format="linespecific">
229 ...
230 modparam("lost", "location_profile, 2)
231 ...
232 </programlisting>
233 </example>
234 </section>
235 <section id="lost.p.location_3d">
236 <title><varname>location_3d</varname> (int)</title>
237 <para>
238 A Presence Information Data Format Location Object (PIDF-LO) may
239 contain one of the shape types as listed in RFC5491
240 (<ulink url="https://tools.ietf.org/html/rfc5491"/>).
241 A LoST <emphasis>findService</emphasis> request currently contains only
242 a profile for two-dimensional geodetic location information, which
243 is the default setting for this parameter. The parameter can be set
244 to 1 if a LoST server supports 3d, otherwise a 3d location is reduced
245 to 2d by the module.
246 </para>
247 <itemizedlist>
248 <listitem><para>
249 <emphasis>0</emphasis> - two-dimensional (2d) shape representations only
250 </para></listitem>
251 <listitem><para>
252 <emphasis>1</emphasis> - three-dimensional (3d) volume representations allowed
253 </para></listitem>
254 </itemizedlist>
255 <para>
256 Default: 0 (2d representations).
257 </para>
258 <example>
259 <title>Set <varname>location_3d</varname> parameter</title>
260 <programlisting format="linespecific">
261 ...
262 modparam("lost", "location_3d, 1)
263 ...
264 </programlisting>
265 </example>
266 </section>
267 <section id="lost.p.geoheader_type">
268 <title><varname>geoheader_type</varname> (int)</title>
269 <para>
270 A Geolocation header may include a list of locationValues pointing
271 to either a Presence Information Data Format Location Object
272 (PIDF-LO) in the SIP body using a content-indirection (cid:) URI
273 per RFC4483 (<ulink url="https://tools.ietf.org/html/rfc4483"/>),
274 or an http(s) URI pointing to an external source. This parameter
275 supports filtering of the following types:
276 </para>
277 <itemizedlist>
278 <listitem><para>
279 <emphasis>0 (any)</emphasis> - any URI (first or last)
280 </para></listitem>
281 <listitem><para>
282 <emphasis>1 (cid)</emphasis> - cid URI (aka Location-by-Value)
283 </para></listitem>
284 <listitem><para>
285 <emphasis>2 (http)</emphasis> - http URI (aka Location-by-Reference)
286 </para></listitem>
287 <listitem><para>
288 <emphasis>3 (https)</emphasis> - https URI (aka Location-by-Reference)
289 </para></listitem>
290 </itemizedlist>
291 <para>
292 Default: 0 (any)
293 </para>
294 <example>
295 <title>Set <varname>geoheader_type</varname> parameter</title>
296 <programlisting format="linespecific">
297 ...
298 modparam("lost", "geoheader_type", 1)
299 ...
300 </programlisting>
301 </example>
302 </section>
303 <section id="lost.p.geoheader_order">
304 <title><varname>geoheader_order</varname> (int)</title>
305 <para>
306 A Geolocation header may include a list of locationValues. This
307 parameter sets the order of the URI used to retrieve the location
308 information, either the first element of a certain type or the
309 last. Values are 0 (first) or 1 (last).
310 </para>
311 <para>
312 Default: 0 (first)
313 </para>
314 <example>
315 <title>Set <varname>geoheader_order</varname> parameter</title>
316 <programlisting format="linespecific">
317 ...
318 modparam("lost", "geoheader_order", 0)
319 ...
320 </programlisting>
321 </example>
322 </section>
323 <section id="lost.p.recursion">
324 <title><varname>recursion</varname> (int)</title>
325 <para>
326 A Geolocation header may include a list of locationValues. This
327 parameter sets the order of the URI used to retrieve the location
328 information, either the first element of a certain type or the
329 last. Values are 0 (first) or 1 (last).
330 </para>
331 <para>
332 Default: 1 (allowed)
333 </para>
334 <example>
335 <title>Set <varname>recursion</varname> parameter</title>
336 <programlisting format="linespecific">
337 ...
338 modparam("lost", "recursion", 0)
339 ...
340 </programlisting>
341 </example>
342 </section>
343 <section id="lost.p.verbose">
344 <title><varname>verbose</varname> (int)</title>
345 <para>
346 Detailed output of LoST findService, redirect or error response as shown below.
347 Values are 0 (disabled) or 1 (enabled).
348 <programlisting format="linespecific">
349 ### LOST expires: [2031-01-27T14:54:21+00:00]
350 ### LOST lastUpdated: [2021-01-29T14:54:21+00:00]
351 ### LOST source: [ecrf.demo.gridgears.xx]
352 ### LOST sourceId: [06ac5b1c-d6c8-42bd-a667-5d1b90bb3d95]
353 ### LOST displayName: [Polizeinotruf (de)]
354 ### LOST serviceNumber: [112]
355 ### LOST service: [urn:service:sos]
356 ### LOST uri: [sip:[email protected]]
357 ### LOST via: [ecrf.demo.gridgears.xx]
358 </programlisting>
359 </para>
360 <para>
361 Default: 0
362 </para>
363 <example>
364 <title>Set <varname>verbose</varname> parameter</title>
365 <programlisting format="linespecific">
366 ...
367 modparam("lost", "verbose", 1)
368 ...
369 </programlisting>
370 </example>
371 </section>
372 </section>
373 <section>
374 <title>Functions</title>
375 <section id="lost.f.lost_held_query">
376 <title>
377 <function moreinfo="none">lost_held_query(con, [id,] pidf-lo, url, error)</function>
378 </title>
379 <para>
380 Sends a HELD locationRequest to a given connection. The device identity is either
381 specified, or the P-A-I header value, or the From header value.
382 </para>
383 <itemizedlist>
384 <listitem><para>
385 <emphasis>con</emphasis> - the name of an existing
386 HTTP connection, defined by a httpcon modparam
387 </para></listitem>
388 <listitem><para>
389 <emphasis>id</emphasis> - the device id used in the HELD
390 locationRequest
391 </para></listitem>
392 <listitem><para>
393 <emphasis>pidf-lo</emphasis> - the PIDF-LO returned in the
394 HELD locationRequest response
395 </para></listitem>
396 <listitem><para>
397 <emphasis>url</emphasis> - the location reference returned
398 in the HELD locationRequest response - this reference may be
399 added as Geolocation header value and forwarded downstream.
400 Note: to work properly, it is required to include "locationURI"
401 in the location_type parameter.
402 </para></listitem>
403 <listitem><para>
404 <emphasis>error</emphasis> - any error code returned in the
405 HELD response
406 </para></listitem>
407 </itemizedlist>
408 <para>
409 The return value is 200 on success, 400 if an internal error occurred, or 500 if an
410 error code is returned in the HELD locationRequest response.
411 </para>
412 <para>
413 This function can be used from REQUEST_ROUTE,
414 ONREPLY_ROUTE, FAILURE_ROUTE, and BRANCH_ROUTE.
415 </para>
416 <example>
417 <title><function>lost_held_query()</function> usage</title>
418 <programlisting format="linespecific">
419 ...
420 modparam("http_client", "httpcon", "heldsrv=>http://service.org/api/held");
421 ...
422 # HELD location request
423 $var(id) = "sip:alice@atlanta";
424 $var(res) = lost_held_query("heldsrv", "$var(id)" , "$var(pidf)", "$var(url)", "$var(err)");
425 xlog("L_INFO", "HELD locationRequest: Result code $var(res)\nUrl: $var(url)\n$var(pidf)");
426 ...
427 $var(res) = lost_held_query("heldsrv", "$var(pidf)", "$var(url)", "$var(err)");
428 xlog("L_INFO", "HELD locationRequest: Result code $var(res)\nUrl: $var(url)\n$var(pidf)\n");
429 ...
430 </programlisting>
431 </example>
432 </section>
433 <section id="lost.f.lost_held_dereference">
434 <title>
435 <function moreinfo="none">lost_held_dereference(url, rtime, rtype, pidf-lo, error)</function>
436 </title>
437 <para>
438 Sends a HELD POST locationRequest to a given URL. Attributes are responseTime and responseType.
439 The <emphasis>locationType</emphasis> property "exact" is set to "false".
440 </para>
441 <itemizedlist>
442 <listitem><para>
443 <emphasis>url</emphasis> - a URL received via Geolocation header to dereference
444 location
445 </para></listitem>
446 <listitem><para>
447 <emphasis>rtime</emphasis> - the response time as defined
448 in <xref linkend="lost.p.response_time"/>
449 </para></listitem>
450 <listitem><para>
451 <emphasis>rtype</emphasis> - the response type (location) as defined
452 in <xref linkend="lost.p.location_type"/>
453 </para></listitem>
454 <listitem><para>
455 <emphasis>pidf-lo</emphasis> - the PIDF-LO returned in the
456 HELD locationRequest response
457 </para></listitem>
458 <listitem><para>
459 <emphasis>error</emphasis> - any error code returned in the
460 HELD response
461 </para></listitem>
462 </itemizedlist>
463 <para>
464 The return value is 200..203 on success, 400 if an internal error occurred, or 500 if an
465 error code is returned in the HELD response. Success codes in detail are as follows:
466 </para>
467 <itemizedlist>
468 <listitem><para>
469 <emphasis>200</emphasis> - received 200 OK, but neither location-info nor locationURI element found
470 </para></listitem>
471 <listitem><para>
472 <emphasis>201</emphasis> - received 200 OK with locationURI (aka Location-by-Reference)
473 </para></listitem>
474 <listitem><para>
475 <emphasis>202</emphasis> - received 200 OK with location-info element (aka Location-by-Value)
476 </para></listitem>
477 <listitem><para>
478 <emphasis>203</emphasis> - received 200 OK with location-info and locationURI element
479 </para></listitem>
480 </itemizedlist>
481 <para>
482 This function can be used from REQUEST_ROUTE,
483 ONREPLY_ROUTE, FAILURE_ROUTE, and BRANCH_ROUTE.
484 </para>
485 <example>
486 <title><function>lost_held_dereference()</function> usage</title>
487 <programlisting format="linespecific">
488 ...
489 # HELD location dereference
490 if ($hdr(Geolocation)=~"^&lt;http.*$") {
491 $var(url) = $(hdr(Geolocation){s.select,0,;});
492 $var(res) = lost_held_dereference("$(var(url){s.unbracket})", "emergencyDispatch", "civic geodetic", "$var(pidf)", "$var(err)");
493 xlog("L_INFO", "HELD location dereference: Result code $var(res)\n$var(pidf)");
494 ...
495 }
496 </programlisting>
497 </example>
498 </section>
499 <section id="lost.f.lost_query">
500 <title>
501 <function moreinfo="none">lost_query(con, [pidf-lo, urn,] uri, name, error)</function>
502 </title>
503 <para>
504 Sends a LOST findService request to a given connection. PIDF-LO and URN are either specified,
505 or, if omitted, parsed from the message body (PIDF-LO) and request line (URN). Either "pidf-lo"
506 or "urn" can be set to an empty string to be ignored.
507 </para>
508 <itemizedlist>
509 <listitem><para>
510 <emphasis>con</emphasis> - the name of an existing
511 HTTP connection defined by a httpcon modparam
512 </para></listitem>
513 <listitem><para>
514 <emphasis>pidf-lo</emphasis> - the PIDF-LO used to create the
515 LOST findService request
516 </para></listitem>
517 <listitem><para>
518 <emphasis>urn</emphasis> - the URN used to create the
519 LOST findService request
520 </para></listitem>
521 <listitem><para>
522 <emphasis>uri</emphasis> - the SIP uri returned in the
523 LOST findServiceResponse
524 </para></listitem>
525 <listitem><para>
526 <emphasis>name</emphasis> - the display name returned in the
527 LOST findServiceResponse
528 </para></listitem>
529 <listitem><para>
530 <emphasis>error</emphasis> - any error code returned in the
531 LOST findServiceResponse
532 </para></listitem>
533 </itemizedlist>
534 <para>
535 The return value is 200 on success, 400 if an internal error occurred, or 500 if an
536 error code is returned in the LOST findServiceResponse.
537 </para>
538 <para>
539 This function can be used from REQUEST_ROUTE,
540 ONREPLY_ROUTE, FAILURE_ROUTE, and BRANCH_ROUTE.
541 </para>
542 <example>
543 <title><function>lost()</function> usage</title>
544 <programlisting format="linespecific">
545 ...
546 modparam("http_client", "httpcon", "heldsrv=>http://service.org/api/held");
547 modparam("http_client", "httpcon", "lostsrv=>http://service.org/api/lost");
548 ...
549 # HELD location request
550 $var(id) = "sip:alice@atlanta";
551 $var(res) = lost_held_query("heldsrv", "$var(id)" , "$var(pidf)", "$var(url)", "$var(err)");
552 ...
553 # LOST findService request - pidf-lo and urn as parameter
554 $var(id) = "urn:service:sos";
555 $var(res) = lost_query("lostsrv", "$var(pidf)", "$var(urn)", "$var(uri)", "$var(name)", "$var(err)");
556 xlog("L_INFO", "LOST findService: Result code $var(res)\nUri: $var(uri)\nName: $var(name)\n");
557 ...
558 # LOST findService request - pidf-lo as parameter, urn taken from request line
559 $var(res) = lost_query("lostsrv", "$var(pidf)", "", "$var(uri)", "$var(name)", "$var(err)");
560 xlog("L_INFO", "LOST findService: Result code $var(res)\nUri: $var(uri)\nName: $var(name)\n");
561 ...
562 # LOST findService request - urn as parameter, pidf-lo taken from message body
563 $var(res) = lost_query("lostsrv", "", "$var(urn)", "$var(uri)", "$var(name)", "$var(err)");
564 xlog("L_INFO", "LOST findService: Result code $var(res)\nUri: $var(uri)\nName: $var(name\n");
565 ...
566 # LOST findService request - pidf-lo and urn taken from message
567 $var(res) = lost_query("lostsrv", "$var(uri)", "$var(name)", "$var(err)");
568 xlog("L_INFO", "LOST findService: Result code $var(res)\nUri: $var(uri)\nName: $var(name)\n");
569 ...
570 </programlisting>
571 </example>
572 </section>
573
574 </section>
575 <section id="lost.s.counters">
576 <title>Counters</title>
577 <para>
578 This module has no specific counters but uses http_client therefore
579 according counters may apply.
580 </para>
581 </section>
582
583 <section id="lost.s.remarks">
584 <title>Remarks</title>
585 <para>
586 Note: libcurl leak in CentOS 6 - this module uses libcurl library
587 (via http_client) and in case you are using CentOS 6, be aware that
588 standard libcurl-7.19.7-52 has a memory leak. To fix this memory, install
589 libcurl from city-fan repository. More details at:
590 <ulink url="https://www.digitalocean.com/community/questions/how-to-upgrade-curl-in-centos6"></ulink>.
591 </para>
592 <para>
593 Note: http_client_query exported by the http_client API returns by
594 default the first line of the HTTP response, but the lost module requires
595 the complete response message, otherwise dereferencing location via the
596 HTTP URL provided with the Geolocation header causes an error. Therefore,
597 to work properly, it is required to set the http_client module parameter
598 query_result to 0. More details at:
599 <ulink url="https://www.kamailio.org/docs/modules/devel/modules/http_client.html#http_client.p.query_result"></ulink>.
600 </para>
601 <para>
602 Note: to test the module with a mapping service (LOST), an API key may be requested under the
603 following link (search for "GET ACCESS"):
604 <ulink url="https://gridgears.at/"></ulink>.
605 </para>
606 <para>
607 Note: in case modparam "geoheader_type" is set to 2 (http), the module may
608 use 3 (https) as a fallback and vice versa.
609 </para>
610 </section>
611 </chapter>