-
Notifications
You must be signed in to change notification settings - Fork 909
/
topos_admin.xml
739 lines (724 loc) · 20.6 KB
/
topos_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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
<?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 "../../../../doc/docbook/entities.xml">
%docentities;
]>
<!-- Module User's Guide -->
<chapter>
<title>&adminguide;</title>
<section>
<title>Overview</title>
<para>
This module offers topology hiding for INVITE-based dialogs, by stripping
the SIP routing headers that show topology details .
The script interpreter gets the SIP messages with full content,
so all existing functionality is preserved.
</para>
<para>
The module is transparent for the configuration writer. It only needs to be
loaded (tune the module parameters if needed).
</para>
<para>
It also works for SIP MESSAGE or other requests that do not create
a dialog (e.g., OPTIONS) -- record_route() must be used for them as well,
the headers are not going to be in the messages sent to the network, they
are needed to know local addresses used to communicate with each side.
This module is designed to work for presence (SUBSCRIBE-based) dialogs too.
</para>
<para>
The REGISTER and PUBLISH requests are skipped from processing
by this module, expected to be terminated on a local SIP server.
</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>rr module</emphasis> - server must perform record
routing to ensure in-dialog requests are encoded/decoded (it
must be done for all initial requests).
</para>
</listitem>
<listitem>
<para>
<emphasis>database module</emphasis> - to store the data
for topology stripping and restoring.
</para>
</listitem>
<listitem>
<para>
<emphasis>topoh module</emphasis> - in case of Call-ID mask
for Call-ID masking.
</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="topos.p.storage">
<title><varname>storage</varname> (str)</title>
<para>
Type of storage, valid types are:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>db</emphasis> - Database Backend
</para>
</listitem>
<listitem>
<para>
<emphasis>redis</emphasis> - Redis Backend
</para>
</listitem>
</itemizedlist>
<para>
<emphasis>
Default value is <quote>db</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>storage</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "storage", "redis")
...
</programlisting>
</example>
</section>
<section id="topos.p.db_url">
<title><varname>db_url</varname> (str)</title>
<para>
Database URL.
</para>
<para>
<emphasis>
Default value is <quote>&defaultdb;</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>db_url</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "db_url", "&exampledb;")
...
</programlisting>
</example>
</section>
<section id="topos.p.mask_callid">
<title><varname>mask_callid</varname> (int)</title>
<para>
Whether to encode the Call-id: header. Some SIP extensions include
the Call-id in the SIP message payload or header, so it is safe to
not encode Call-id in such cases. Well-known extensions such as
call transfer or conference join will be added to work with encoded
Call-id.
Topoh module should be loaded with use_mode paramerter set to 1
</para>
<para>
<emphasis>
Default value is 0 (do not mask).
</emphasis>
</para>
<example>
<title>Set <varname>mask_callid</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "mask_callid", 1)
...
</programlisting>
</example>
</section>
<section id="topos.p.sanity_checks">
<title><varname>sanity_checks</varname> (int)</title>
<para>
If set to 1, topos module will bind to sanity module in order
to perform sanity checks over received SIP request. Default
sanity checks are done. It is useful to check if received request
is well formatted before proceeding to encoding/decoding.
</para>
<para>
<emphasis>
Default value is 0 (do not bind to sanity module).
</emphasis>
</para>
<example>
<title>Set <varname>sanity_checks</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "sanity_checks", 1)
...
</programlisting>
</example>
</section>
<section id="topos.p.branch_expire">
<title><varname>branch_expire</varname> (int)</title>
<para>
Interval in seconds after which the branch records are deleted.
</para>
<para>
<emphasis>
Default value is 180 (3 min).
</emphasis>
</para>
<example>
<title>Set <varname>branch_expire</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "branch_expire", 300)
...
</programlisting>
</example>
</section>
<section id="topos.p.dialog_expire">
<title><varname>dialog_expire</varname> (int)</title>
<para>
Interval in seconds after which the dialog records are deleted.
Keep in mind that the module does not update the dialog timestamp
after the initial call setup on re-INVITEs or other in-dialog
messages. So set a large enough value (according your longest call
duration) to prevent problems in re-writing messages.
This key is only relevant for INVITE dialog.
SUBSCRIBE dialog records lifetime are based on value set in expires
header. Moreover each re-SUBSCRIBEs update the dialog timestamp.
</para>
<para>
<emphasis>
Default value is 10800 (3 hours).
</emphasis>
</para>
<example>
<title>Set <varname>dialog_expire</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "dialog_expire", 3600)
...
</programlisting>
</example>
</section>
<section id="topos.p.clean_interval">
<title><varname>clean_interval</varname> (int)</title>
<para>
Interval in seconds to run the clean up of stored
records.
</para>
<para>
<emphasis>
Default value is 60 (1 min).
</emphasis>
</para>
<example>
<title>Set <varname>clean_interval</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "clean_interval", 30)
...
</programlisting>
</example>
</section>
<section id="topos.p.event_callback">
<title><varname>event_callback</varname> (str)</title>
<para>
The name of the function in the KEMI configuration file (embedded
scripting language such as Lua, Python, ...) to be executed instead
of event_route[...] blocks.
</para>
<para>
The function receives a string parameter with the name of the event.
</para>
<para>
<emphasis>
Default value is 'empty' (no function is executed for events).
</emphasis>
</para>
<example>
<title>Set <varname>event_callback</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "event_callback", "ksr_topos_event")
...
-- event callback function implemented in Lua
function ksr_topos_event(evname)
KSR.info("===== topos module triggered event: " .. evname .. "\n");
return 1;
end
...
</programlisting>
</example>
</section>
<section id="topos.p.event_mode">
<title><varname>event_mode</varname> (int)</title>
<para>
Control what event_route blocks to be executed. It is a bitmask of:
1 - execute event_route[topos:msg-outgoing]; 2 - execute
event_route[topos:msg-sending]; 4 execute
event_route[topos:msg-incoming]; 8 execute
event_route[topos:msg-receiving];.
</para>
<para>
<emphasis>
Default value is 3 (execute both event_route blocks).
</emphasis>
</para>
<example>
<title>Set <varname>event_mode</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "event_mode", 2)
...
</programlisting>
</example>
</section>
<section id="topos.p.contact_host">
<title><varname>contact_host</varname> (str)</title>
<para>
You may need to control the host part of the Contact header added
by topos. If the xavu_field_contact_host parameter is set, this value is
ignored.
For example when using TLS with TOPOS the remote UAS must be able to open
a new TLS socket to the contact header.
In this case, the contact header must contain a domain name with a trusted CA
signed certitificate.
</para>
<para>
<emphasis>
Default value is taken from the Record-Route URI.
</emphasis>
</para>
<example>
<title>Set <varname>contact_host</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "contact_host", "proxy.domain.com")
...
</programlisting>
</example>
</section>
<section id="topos.p.contact_mode">
<title><varname>contact_mode</varname> (int)</title>
<para>
Control the mode where the key to lookup the message data from
the database or redis server is stored. The default is to use
the Contact user (0), alternatively a Contact URI parameter
can be used (1) with values from the SIP message, or from AVP
variables (2). This can be useful for interoperating which
gateways that need a certain user part in the Contact URI.
</para>
<para>In mode (1) the a-side contact user is taken from the
request URI and the b-side contact user from the Contact header
of the processed initial SIP request.
</para>
<para>If you use the mode (2), you need to configure the
<emphasis>xavu_field_a_contact</emphasis> and <emphasis>xavu_field_b_contact</emphasis>
parameter. Furthermore you need to assign values to them during
the processing of the initial SIP request.
</para>
<para>
The name of the Contact URI parameter can be customized with
the <emphasis>cparam_name</emphasis> parameter.
</para>
<para>
<emphasis>
Default value is 0 - use the Contact user
</emphasis>
</para>
<example>
<title>Set <varname>contact_mode</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "contact_mode", 1)
...
</programlisting>
</example>
</section>
<section id="topos.p.cparam_name">
<title><varname>cparam_name</varname> (int)</title>
<para>
Name of the Contact URI parameter to store the database or
redis server key for message lookup.
</para>
<para>
This parameter is only used when the <emphasis>contact_mode</emphasis>
parameter is set to <emphasis>1</emphasis> or <emphasis>2</emphasis>.
</para>
<para>
<emphasis>
Default value is <quote>tps</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>cparam_name</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "cparam_name", "xyz")
...
</programlisting>
</example>
</section>
<section id="topos.p.xavu_cfg">
<title><varname>xavu_cfg</varname> (str)</title>
<para>
Name of root XAVU to hold config-specific values to be used by
module at runtime.
</para>
<para>
Note: this parameter must be set if any other parameter prefixed
with `xavu_field_` is used.
</para>
<para>
<emphasis>
Default value is <quote>NULL</quote> (disabled).
</emphasis>
</para>
<example>
<title>Set <varname>xavu_cfg</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "xavu_cfg", "_tps_")
modparam("topos", "xavu_field_a_contact", "a_contact")
...
$xavu(_tps_=>a_contact) = "...";
...
</programlisting>
</example>
</section>
<section id="topos.p.xavu_field_a_contact">
<title><varname>xavu_field_a_contact</varname> (str)</title>
<para>
Name of the field inside root XAVU specifed by `xavu_cfg`
to evaluate for the A-side Contact Header user part. This parameter
is only necessary in contact_mode (2).
</para>
<para>
<emphasis>
Default value is <quote>NULL</quote> (disabled).
</emphasis>
</para>
<example>
<title>Set <varname>xavu_field_a_contact</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "xavu_cfg", "_tps_")
modparam("topos", "xavu_field_a_contact", "a_contact")
...
$xavu(_tps_=>a_contact) = "...";
...
</programlisting>
</example>
</section>
<section id="topos.p.xavu_field_b_contact">
<title><varname>xavu_field_b_contact</varname> (str)</title>
<para>
Name of the field inside root XAVU specifed by `xavu_cfg`
to evaluate for the B-side Contact Header user part. This parameter
is only necessary in contact_mode (2).
</para>
<para>
<emphasis>
Default value is <quote>NULL</quote> (disabled).
</emphasis>
</para>
<example>
<title>Set <varname>xavu_field_b_contact</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "xavu_cfg", "_tps_")
modparam("topos", "xavu_field_b_contact", "b_contact")
...
$xavu(_tps_=>b_contact) = "...";
...
</programlisting>
</example>
</section>
<section id="topos.p.xavu_field_contact_host">
<title><varname>xavu_field_contact_host</varname> (str)</title>
<para>
Control from where to take the host part of the Contact header added
by topos. This parameter allows to take the value from an XAVU
during run-time, it specifies the field inside XAVU "xavu_cfg".
If this parameter is set, the contact_host parameter is ignored.
For example when using TLS with TOPOS the remote UAS must be able to open
a new TLS socket to the contact header.
In this case, the contact header must contain a domain name with a trusted CA
signed certitificate.
</para>
<para>
<emphasis>
Default value is empty, not set.
</emphasis>
</para>
<example>
<title>Set <varname>xavu_field_contact_host</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "xavu_cfg", "_tps_")
modparam("topos", "xavu_field_contact_host", "contact_host")
...
$xavu(_tps_=>contact_host) = "kamailio.org";
...
</programlisting>
</example>
</section>
<section id="topos.p.rr_update">
<title><varname>rr_update</varname> (int)</title>
<para>
If set to 1, topos module will track and update record
route changes on re-invite.
</para>
<para>
<emphasis>
Default value is 0 (do not update record route changes within dialog).
</emphasis>
</para>
<example>
<title>Set <varname>rr_update</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "rr_update", 1)
...
</programlisting>
</example>
</section>
<section id="topos.p.context">
<title><varname>context</varname> (str)</title>
<para>
Set the global context for topos instance.
</para>
<para>
The value has to be maximum 12 characters.
</para>
<para>
<emphasis>
Default value is <quote>NULL</quote> (disabled).
</emphasis>
</para>
<example>
<title>Set <varname>context</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "context", "srvone")
...
</programlisting>
</example>
</section>
<section id="topos.p.methods_nocontact">
<title><varname>methods_nocontact</varname> (str)</title>
<para>
List of SIP methods to skip adding Contact header for.
</para>
<para>
<emphasis>
Default value is <quote>BYE,CANCEL,PRACK</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>methods_nocontact</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "methods_nocontact", "CANCEL,PRACK")
...
</programlisting>
</example>
</section>
<section id="topos.p.header_mode">
<title><varname>header_mode</varname> (int)</title>
<para>
List of headers to disable multiple comma separated values inserted in compact form.
Altough compact form is RFC compliant this paramter gives possibilty to disable
compact form header values for UA that don't support or can't handle it.
The following options are available:
(1) - disable multiple comma separated values for Via header
(2) - disable multiple comma separated values for Record-Route header
(4) - disable multiple comma separated values for Route header
</para>
<para>
<emphasis>
Default value is <quote>0</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>header_mode</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "header_mode", 1)
...
</programlisting>
</example>
</section>
<section id="topos.p.methods_noinitial">
<title><varname>methods_noinitial</varname> (str)</title>
<para>
List of SIP methods to skip doing topos if it is an intial request
(no To-tag).
</para>
<para>
<emphasis>
Default value is <quote></quote> (no method).
</emphasis>
</para>
<example>
<title>Set <varname>methods_noinitial</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("topos", "methods_noinitial", "OPTIONS,NOTIFY")
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Functions</title>
<section id="topos.f.tps_set_context">
<title>
<function moreinfo="none">tps_set_context(ctx)</function>
</title>
<para>
Update the context at runtime. If the value is emtpy string, then
the runtime context is reset.
</para>
<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>tps_set_context</function> usage</title>
<programlisting format="linespecific">
...
request_route {
...
tps_set_context("srvone");
...
}
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Event Routes</title>
<section id="topos.e.msg_outgoing">
<title>event_route[topos:msg-outgoing]</title>
<para>
It is executed before doing topology stripping processing for an outgoing
SIP message. If 'drop' is executed inside the event route, then the
module skips doing the topology hiding.
</para>
<para>
Inside the event route the variables $sndto(ip), $sndto(port) and
$sndto(proto) point to the destination. The SIP message is not the one
to be sent out, but an internally generated one at startup, to avoid
reparsing the outgoing SIP message for the cases when topology hiding
is not wanted.
</para>
<example>
<title>Usage of event_route[topos:msg-outgoing]</title>
<programlisting format="linespecific">
...
event_route[topos:msg-outgoing] {
if($sndto(ip)=="10.1.1.10") {
drop;
}
}
...
</programlisting>
</example>
</section>
<section id="topos.e.msg_sending">
<title>event_route[topos:msg-sending]</title>
<para>
It is executed before doing topology stripping processing for a SIP
message to be sent out, being executed after event_route[topos:msg-outgoing].
</para>
<para>
Inside the event route the variables $sndto(ip), $sndto(port) and
$sndto(proto) point to the destination. The SIP message is the one
to be sent out.
</para>
<example>
<title>Usage of event_route[topos:msg-sending]</title>
<programlisting format="linespecific">
...
event_route[topos:msg-sending] {
if(is_request() and $fU=="alice") {
drop;
}
}
...
</programlisting>
</example>
</section>
<section id="topos.e.msg_incoming">
<title>event_route[topos:msg-incoming]</title>
<para>
It is executed before doing topology stripping processing for an incoming
SIP message. If 'drop' is executed inside the event route, then the
module skips doing the topology hiding.
</para>
<para>
Inside the event route the variables $si, $sp and
$proto point to the source address. The SIP message is not the one
to be sent out, but an internally generated one at startup, to avoid
reparsing the outgoing SIP message for the cases when topology hiding
is not wanted.
</para>
<example>
<title>Usage of event_route[topos:msg-incoming]</title>
<programlisting format="linespecific">
...
event_route[topos:msg-incoming] {
if($si=="10.1.1.10") {
drop;
}
}
...
</programlisting>
</example>
</section>
<section id="topos.e.msg_receiving">
<title>event_route[topos:msg-receiving]</title>
<para>
It is executed before doing topology stripping processing for a SIP
message that was received, being executed after event_route[topos:msg-incoing].
</para>
<para>
Inside the event route the variables $si, $sp and
$proto point to the source address. The SIP message is the one
to be sent out.
</para>
<example>
<title>Usage of event_route[topos:msg-receoving]</title>
<programlisting format="linespecific">
...
event_route[topos:msg-receiving] {
if(is_request() and $fU=="alice") {
drop;
}
}
...
</programlisting>
</example>
</section>
</section>
</chapter>