-
Notifications
You must be signed in to change notification settings - Fork 908
/
rtjson_admin.xml
334 lines (320 loc) · 8.23 KB
/
rtjson_admin.xml
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
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
%docentities;
]>
<!-- Module User's Guide -->
<chapter>
<title>&adminguide;</title>
<section>
<title>Overview</title>
<para>
This module facilitates SIP routing based on JSON specifications.
</para>
<para>
The values for R-URI ($ru), outbound proxy ($du) and other attributes
used for SIP routing can be retrieved in a JSON document. It is able
to process attributes for more than one destination and prepare for
routing in serial or parallel fashion.
</para>
</section>
<section>
<title>Dependencies</title>
<section>
<title>&kamailio; Modules</title>
<para>
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>tm</emphasis> - (optional) transaction management.
</para>
<para>
<emphasis>uac</emphasis> - (optional) user agent operations.
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External Libraries or Applications</title>
<para>
The following libraries or applications must be installed before running
&kamailio; with this module loaded:
<itemizedlist>
<listitem>
<para>
<emphasis>None</emphasis>
</para>
</listitem>
</itemizedlist>
</para>
</section>
</section>
<section>
<title>Parameters</title>
<section id="rtjson.p.xavp_cfg">
<title><varname>xavp_cfg</varname> (str)</title>
<para>
The name of the xavp to be used internally by the module.
</para>
<para>
<emphasis>
Default value is "rtjson".
</emphasis>
</para>
<example>
<title>Set <varname>xavp_cfg</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("rtjson", "xavp_cfg", "myxavp")
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Functions</title>
<section id="rtjson.f.rtjson_init_routes">
<title>
<function moreinfo="none">rtjson_init_routes(rtdoc)</function>
</title>
<para>
Initialize routing based on JSON document stored in rtdoc parameter.
</para>
<para>
The rtdoc parameter can be a static string or a dynamic string
value with config variables. It has to result in a valid JSON document
with the structure specified in chapter 'JSON Routing Structure'.
</para>
<para>
This function can be used from REQUEST_ROUTE.
</para>
<example>
<title><function>rtjson_init_routes</function> usage</title>
<programlisting format="linespecific">
...
rtjson_init_routes("$var(json)");
...
</programlisting>
</example>
</section>
<section id="rtjson.f.rtjson_push_routes">
<title>
<function moreinfo="none">rtjson_push_routes()</function>
</title>
<para>
Push the routes given in JSON document to rtjson_init_routes(rtdoc) to
the internal fields used by &kamailio; for routing.
</para>
<para>
This function can be used from REQUEST_ROUTE.
</para>
<example>
<title><function>rtjson_push_routes</function> usage</title>
<programlisting format="linespecific">
...
rtjson_init_routes("$var(json)");
rtjson_push_routes();
...
</programlisting>
</example>
</section>
<section id="rtjson.f.rtjson_next_route">
<title>
<function moreinfo="none">rtjson_next_route()</function>
</title>
<para>
To be used in failure_route for serial forking, to push the next route
to the internal fields used by &kamailio; for routing.
</para>
<para>
This function can be used from FAILURE_ROUTE.
</para>
<example>
<title><function>rtjson_next_route</function> usage</title>
<programlisting format="linespecific">
...
rtjson_init_routes("$var(json)");
rtjson_push_routes();
t_on_failure("REROUTE");
t_relay();
...
failure_route[REROUTE] {
rtjson_next_route();
}
...
</programlisting>
</example>
</section>
<section id="rtjson.f.rtjson_update_branch">
<title>
<function moreinfo="none">rtjson_update_branch()</function>
</title>
<para>
To be used in branch_route if the JSON document had attributes
that needs to be set for each branch.
</para>
<para>
This function can be used from BRANCH_ROUTE.
</para>
<example>
<title><function>rtjson_update_branch</function> usage</title>
<programlisting format="linespecific">
...
rtjson_init_routes("$var(json)");
rtjson_push_routes();
t_on_branch("OUTGOING");
t_relay();
...
branch_route[OUTGOING] {
rtjson_update_branch();
}
...
</programlisting>
</example>
</section>
</section>
<section id="rtjson.json-routing-structure">
<title>JSON Routing Structure</title>
<para>
The format of the JSON document containing routing information.
</para>
<para>
Description of the fields in the JSON routing document:
<itemizedlist>
<listitem>
<para>
<emphasis>version</emphasis> - intended to enforce versioning
checks (not enforced yet), recommended to be set to "1.0".
</para>
</listitem>
<listitem>
<para>
<emphasis>routing</emphasis> - can be "serial" or "parallel",
corresponding to desired routing type: serial or parallel forking.
</para>
</listitem>
<listitem>
<para>
<emphasis>routes</emphasis> - an array with structures holding
the attributes for destinations. The attributes can be:
<itemizedlist>
<listitem>
<para>
<emphasis>uri</emphasis> - request URI
</para>
</listitem>
<listitem>
<para>
<emphasis>dst_uri</emphasis> - outbound proxy URI
</para>
</listitem>
<listitem>
<para>
<emphasis>path</emphasis> - Path URI vector
</para>
</listitem>
<listitem>
<para>
<emphasis>socket</emphasis> - local socket
</para>
</listitem>
<listitem>
<para>
<emphasis>headers</emphasis> - a structure with values for headers
From and To specified as display name and URI, plus extra
headers to be appended to SIP request. It requires uac module in
order to update From and To headers.
Set by rtjson_update_branch() only for serial routing.
</para>
</listitem>
<listitem>
<para>
<emphasis>branch_flags</emphasis> - branch flags.
Set by rtjson_update_branch() only for serial routing.
</para>
</listitem>
<listitem>
<para>
<emphasis>fr_timer</emphasis> - value for fr_timer parameter of
tm module.
Set by rtjson_update_branch() only for serial routing.
</para>
</listitem>
<listitem>
<para>
<emphasis>fr_inv_timer</emphasis> - value for fr_inv_timer parameter
of tm module.
Set by rtjson_update_branch() only for serial routing.
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</itemizedlist>
</para>
<para>
Other fields can appear in the JSON routing document, being ignored
by rtjson functions. They can be processed directly in the configuration
files using json or jansson modules. For example, the document can include
the transaction identification tuple (index,label) that can be used
to resume the execution of a suspended transaction.
</para>
<example>
<title>JSON Routing Structure</title>
<programlisting format="linespecific">
...
{
"version": "1.0",
"routing": "serial",
"routes": [
{
"uri": "sip:127.0.0.1:5080",
"dst_uri": "sip:127.0.0.1:5082",
"path": "<sip:127.0.0.1:5084>, <sip:127.0.0.1:5086>",
"socket": "udp:127.0.0.1:5060",
"headers": {
"from": {
"display": "Alice",
"uri": "sip:alice@127.0.0.1"
},
"to": {
"display": "Alice",
"uri": "sip:alice@127.0.0.1"
},
"extra": "X-Hdr-A: abc\r\nX-Hdr-B: bcd\r\n"
},
"branch_flags": 8,
"fr_timer": 5000,
"fr_inv_timer": 30000
},
{
"uri": "sip:127.0.0.1:5080",
"dst_uri": "sip:127.0.0.1:5082",
"path": "<sip:127.0.0.1:5084>, <sip:127.0.0.1:5086>",
"socket": "udp:127.0.0.1:5060",
"headers": {
"from": {
"display": "Alice",
"uri": "sip:alice@127.0.0.1"
},
"to": {
"display": "Alice",
"uri": "sip:alice@127.0.0.1"
},
"extra": "X-Hdr-A: abc\r\nX-Hdr-B: bcd\r\n"
},
"branch_flags": 8,
"fr_timer": 5000,
"fr_inv_timer": 30000
}
]
}
...
</programlisting>
</example>
</section>
</chapter>