File: README

package info (click to toggle)
kamailio 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 56,100 kB
  • sloc: ansic: 552,832; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (333 lines) | stat: -rw-r--r-- 8,842 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
utils

Juha Heinanen

   TutPro Inc.

Carsten Bock

   ng-voice GmbH

   Copyright (c) 2008-2009 Juha Heinanen

   Copyright (c) 2013 Carsten Bock, ng-voice GmbH
     __________________________________________________________________

   Table of Contents

   1. Admin Guide

        1. Overview
        2. Dependencies

              2.1. Kamailio Modules
              2.2. External Libraries or Applications

        3. Parameters

              3.1. http_query_timeout (int)
              3.2. forward_active (int)
              3.3. pres_db_url (string)
              3.4. xcap_table (string)

        4. Functions

              4.1. http_query(url, [post-data], result)
              4.2. xcap_auth_status(watcher_uri, presentity_uri)

        5. MI Commands

              5.1. forward_list
              5.2. forward_switch
              5.3. forward_filter
              5.4. forward_proxy

        6. Configuration syntax

   List of Examples

   1.1. Set http_query_timeout parameter
   1.2. Set forward_active parameter
   1.3. Set pres_db_url parameter
   1.4. Set xcap_table parameter
   1.5. http_query() usage
   1.6. xcap_auth_status() usage
   1.7. forward_list usage
   1.8. forward_switch usage
   1.9. forward_filter usage
   1.10. forward_proxy usage

Chapter 1. Admin Guide

   Table of Contents

   1. Overview
   2. Dependencies

        2.1. Kamailio Modules
        2.2. External Libraries or Applications

   3. Parameters

        3.1. http_query_timeout (int)
        3.2. forward_active (int)
        3.3. pres_db_url (string)
        3.4. xcap_table (string)

   4. Functions

        4.1. http_query(url, [post-data], result)
        4.2. xcap_auth_status(watcher_uri, presentity_uri)

   5. MI Commands

        5.1. forward_list
        5.2. forward_switch
        5.3. forward_filter
        5.4. forward_proxy

   6. Configuration syntax

1. Overview

   This module implements various utility functions that are not SIP
   related.

   Function http_query allows Kamailio to issue an HTTP GET request and
   get access to parts of the reply.

   The forward functionality allows Kamailio to configure forwarding at
   runtime with FIFO commands. The forwarding is executed in the pre
   script call back and therefore handled before the routing script is
   executed on the current message. The callback is not installed on
   default, thus this functionality has no runtime overhead when its
   deactivated.

   Function xcap_auth_status can be used to check from presence server
   database, if watcher is authorized to subscribe event "presence" of
   presentity.

2. Dependencies

   2.1. Kamailio Modules
   2.2. External Libraries or Applications

2.1. Kamailio Modules

   The following modules must be loaded before this module:
     * a database module if xcap_auth_status function is enabled.

2.2. External Libraries or Applications

   The following libraries or applications must be installed before
   running Kamailio with this module loaded:
     * libcurl.

3. Parameters

   3.1. http_query_timeout (int)
   3.2. forward_active (int)
   3.3. pres_db_url (string)
   3.4. xcap_table (string)

3.1. http_query_timeout (int)

   Defines in seconds how long Kamailio waits for response from HTTP
   server.

   Default value is zero, i.e., that the http_query_timeout function is
   disabled.

   Example 1.1. Set http_query_timeout parameter
...
modparam("utils", "http_query_timeout", 2)
...

3.2. forward_active (int)

   Defines if the forwarding callback should be installed.

   Default value is "0" - disabled.

   Example 1.2. Set forward_active parameter
                                        ...
                                        modparam("utils", "forward_active", 1)
                                        ...

3.3. pres_db_url (string)

   Defines presence server database URL. If not given, the
   xcap_auth_status function is disabled.

   There is no default value.

   Example 1.3. Set pres_db_url parameter
...
modparam("utils", "pres_db_url", "mysql://foo:secret@localhost/pres")
...

3.4. xcap_table (string)

   Defines the name of the xcap table in the presence server database. See
   the xcap_server module documentation for more information.

   Default value is "xcap".

   Example 1.4. Set xcap_table parameter
...
modparam("utils", "xcap_table", "pres_xcap")
...

4. Functions

   4.1. http_query(url, [post-data], result)
   4.2. xcap_auth_status(watcher_uri, presentity_uri)

4.1.  http_query(url, [post-data], result)

   Sends HTTP GET or POST request according to URL given in "url"
   parameter, which is a string that may contain pseudo variables.

   If you want to make a POST-Request, you have to define the "post"-data,
   that should be submitted in that request as the second parameter.

   If HTTP server returns a class 2xx, 3xx or 4xx reply, the first line of
   the reply's body (if any) is stored in "result" parameter, which must
   be a writable pseudo variable.

   Function returns reply code of HTTP reply or -1 if something went
   wrong.

   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
   FAILURE_ROUTE, and BRANCH_ROUTE.

   Example 1.5. http_query() usage
...
# GET-Request
http_query("http://tutpro.com/index.php?r_uri=$(ru{s.escape.param})&f_uri=$(fu{s
.escape.param})",
           "$var(result)")
switch ($retcode) {
       ...
}
...
...
# POST-Request
http_query("http://tutpro.com/index.php", "r_uri=$(ru{s.escape.param})&f_uri=$(f
u{s.escape.param})",
           "$var(result)")
switch ($retcode) {
       ...
}
...

4.2.  xcap_auth_status(watcher_uri, presentity_uri)

   Function checks in the presence server database if a watcher is
   authorized to subscribe to event "presence" of presentity. Sphere
   checking is not included.

   Both watcher_uri and presentity_uri are pseudo variables. The function
   returns ACTIVE_STATUS, if a subscription is allowed and PENDING_STATUS,
   TERMINATED_STATUS, or WAITING_STATUS otherwise. See
   presence/subscribe.h for the corresponding integer codes. In case of
   error, function returns -1.

   Function can be used from REQUEST_ROUTE.

   Example 1.6. xcap_auth_status() usage
...
if (method=="MESSAGE") {
    xcap_auth_status("$fu", $ru");
    if ($retcode == 1) {
        t_relay();
    } else {
        send_reply("403", "Forbidden");
    }
}
...

5. MI Commands

   5.1. forward_list
   5.2. forward_switch
   5.3. forward_filter
   5.4. forward_proxy

5.1. forward_list

   List active forward rules.

   No parameters.

   Example 1.7. forward_list usage
...
kamctl fifo forward_list
id switch                         filter proxy
 0    off      REGISTER:INVITE:SUBSCRIBE host-a.domain-a:5060
...

5.2. forward_switch

   This command can be used to activate or deactivate forwarding rules.
   The syntax of this configuration string is described in 1.6.
   (switch_setting_list).

   Example 1.8. forward_switch usage
...
kamctl fifo forward_switch 0=on
...

5.3. forward_filter

   Can be used to specify the filter for a certain id. Messages will only
   be forwarded if one of the filters matches the message.

   There are special filters and regular filters. Special filters are:
     * REQUEST (matches on every request)
     * REPLY (matches on every reply)

   Regular filters are arbitrary strings not containing the delimiter ':'.
   They are matched against the request method names of the sip messages.
   The syntax of this configuration string is described in 1.6.
   (filter_setting_list).

   Example 1.9. forward_filter usage
...
kamctl fifo forward_filter 0=REGISTER:INVITE
...

5.4. forward_proxy

   This command can be used to configure forwarding rules. Specifies the
   destination for a certain id. Messages will be forwarded to this
   destination if the preconditions hold (matching id, filter, and
   switch). The syntax of this configuration string is described in 1.6.
   (proxy_setting_list).

   Example 1.10. forward_proxy usage
...
kamctl fifo forward_proxy 0=host-c.domain-c:5060
...

6. Configuration syntax

   This grammar specify the usable configuration syntax
     * switch_setting_list ::= switch_setting { "," switch_setting }
     * filter_setting_list ::= switch_setting { "," switch_setting }
     * proxy_setting_list ::= proxy_setting { "," proxy_setting }
     * switch_setting ::= id "=" switch
     * filter_setting ::= id "=" filter_list
     * proxy_setting ::= id "=" proxy
     * switch ::= ( "off" | "on" )
     * filter_list ::= filter { ":" filter }
     * proxy ::= host ":" port
     * filter ::= ( special_filter | regular_filter )
     * special_filter ::= ( "REQUEST" | "REPLY" )
     * regular_filter ::= ? [^:]* ?
     * host ::= char { char }
     * char ::= ? A-Za-z0-9.-_ ?
     * id ::= number
     * port ::= number
     * number ::= digit {digit}
     * digit ::= ? 0-9 ?