/
uac_admin.xml
1664 lines (1610 loc) · 48.8 KB
/
uac_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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?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>
The <acronym>UAC</acronym> (User Agent Client) module provides some basic UAC
functionalities like sending SIP requests, registering with a remote service,
From: header manipulation (anonymization) and client authentication.
</para>
<para>
The UAC module also supports sending a SIP request from the
configuration file. See variable $uac_req(name) and the function
uac_req_send().
</para>
<para>
In addition, the module supports database-driven SIP registration functionality. See
the uac_reg_lookup() function and dedicated section for remote
registration configuration.
</para>
<para>
Known limitations in this version:
</para>
<itemizedlist>
<listitem>
<para>
Authentication does not support qop auth-int, just qop auth;
</para>
</listitem>
<listitem>
<para>
CSeq is not increased automatically by uac_auth() during authentication
- the follow up request may be rejected. CSeq can be increased when
authenticating INVITE requests - dialog module has to be used, with
CSeq tracking feature enabled (see the readme of dialog module).
</para>
</listitem>
<listitem>
<para>
The <quote>uac_replace_*</quote> functions can only be run once on the same
SIP request. Try to save needed changes in a pseudovariable and
apply them once.
</para>
<para>
There is also a limitation regarding the use of the
<quote>msg_apply_changes()</quote> function together with the
<quote>uac_replace_*</quote> functions for messages that are
loose-routed (e.g. Re-INVITE requests). In this case you need
to call the <quote>loose_route()</quote> function after the
replace and msg_apply_changes. Otherwise Kamailio can create
replies with wrong From/To headers (e.g. for the 100 - Trying
reply in the Re-INVITE example).
</para>
</listitem>
</itemizedlist>
</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 - Transaction Module</emphasis>
</para>
</listitem>
<listitem>
<para>
<emphasis>RR - Record-Route Module</emphasis>, but only if
restore mode for From: URI is set to <quote>auto</quote>.
</para>
</listitem>
<listitem>
<para>
<emphasis>Dialog Module</emphasis>, but only if
restore mode for From: URI is set to <quote>auto</quote> and
you want uac_replace_from or uac_replace_to to store the values
of the URIs as dialog variables.
</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="uac.p.rr_from_store_param">
<title><varname>rr_from_store_param</varname> (string)</title>
<para>
Name of Record-Route header parameter that will be used to store
an encoded version of the original FROM URI.
</para>
<para>
<emphasis>
This parameter is optional, it's default value being
<quote>vsf</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>rr_from_store_param</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac","rr_from_store_param","my_param")
...
</programlisting>
</example>
</section>
<section id="uac.p.rr_to_store_param">
<title><varname>rr_to_store_param</varname> (string)</title>
<para>
Name of Record-Route header parameter that will be used to store
(encoded) the original TO URI.
</para>
<para>
<emphasis>
This parameter is optional, it's default value being
<quote>vst</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>rr_to_store_param</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac","rr_to_store_param","my_param")
...
</programlisting>
</example>
</section>
<section id="uac.p.restore_mode">
<title><varname>restore_mode</varname> (string)</title>
<para>
There are 3 modes of restoring the original FROM URI and the original TO URI:
<itemizedlist>
<listitem>
<para>
<quote>none</quote> - no information about original URI is
stored; restoration is not possible.
</para>
</listitem>
<listitem>
<para>
<quote>manual</quote> - all following replies will be restored,
but not also the sequential requests - this must be manually
updated based on original URI.
</para>
</listitem>
<listitem>
<para>
<quote>auto</quote> - all sequential requests and replies will
be automatically updated based on stored original URI. For this
option you have to set <quote>modparam("rr", "append_fromtag", 1)</quote>.
</para>
</listitem>
</itemizedlist>
</para>
<para>
<emphasis>
This parameter is optional, it's default value being
<quote>auto</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>restore_mode</varname> parameter
</title>
<programlisting format="linespecific">
...
modparam("uac","restore_mode","auto")
...
</programlisting>
</example>
</section>
<section id="uac.p.restore_dlg">
<title><varname>restore_dlg</varname> (int)</title>
<para>
If set to 1, the module uses dialog variables to store initial and
new values for From/To headers. The Dialog module has to be loaded and
all calls that involve changes to From/To headers must be tracked.
</para>
<para>
<emphasis>
Default value of this parameter is 0.
</emphasis>
</para>
<example>
<title>Set <varname>restore_dlg</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "restore_dlg", 1)
...
</programlisting>
</example>
</section>
<section id="uac.p.restore_passwd">
<title><varname>restore_passwd</varname> (string)</title>
<para>
String password to be used to encrypt the RR storing parameters. If
empty, no encryption will be used.
</para>
<para>
<emphasis>
Default value of this parameter is empty.
</emphasis>
</para>
<example>
<title>Set <varname>restore_passwd</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac","restore_passwd","my_secret_passwd")
...
</programlisting>
</example>
</section>
<section id="uac.p.restore_from_avp">
<title><varname>restore_from_avp</varname> (string)</title>
<para>
If defined and restore_mode is manual or auto, the avp is used to save
the original from uri in order to be able to restore it in replies.
That makes sense, if the original-uri can not be extracted from the original
request, e.g. if msg_apply_changes() was used after calling uac_replace_from()
or uac_replace_to().
</para>
<para>
If you create a dialog ( with dlg_manage() ) before calling uac_replace_from(),
this avp will not be needed. The values of the uris will be stored as dialog variables.
</para>
<para><emphasis>
Default value of this parameter is empty.
</emphasis>
</para>
<example>
<title>Set <varname>restore_from_avp</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac","restore_from_avp","$avp(original_uri_from)")
...
</programlisting>
</example>
</section>
<section id="uac.p.restore_to_avp">
<title><varname>restore_to_avp</varname> (string)</title>
<para>
If defined and restore_mode is manual or auto, the avp is used to save
the original To URI in order to be able to restore it in replies.
That makes sense if the original-uri can not be extracted from the original
request, e.g. if msg_apply_changes() was used after calling uac_replace_to()
</para>
<para>
If you create a dialog ( with dlg_manage() ) before calling or uac_replace_to(),
this avp will not be needed. The values of the uris will be stored as dialog variables.
</para>
<para><emphasis>
Default value of this parameter is empty.
</emphasis>
</para>
<example>
<title>Set <varname>restore_to_avp</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac","restore_to_avp","$avp(original_uri_to)")
...
</programlisting>
</example>
</section>
<section id="uac.p.credential">
<title><varname>credential</varname> (string)</title>
<para>
Contains a multiple definition of credentials used to perform
authentication.
</para>
<para>
<emphasis>
This parameter is required if UAC authentication is used.
</emphasis>
</para>
<example>
<title>Set <varname>credential</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac","credential","username:domain:password")
...
</programlisting>
</example>
</section>
<section id="uac.p.auth_realm_avp">
<title><varname>auth_realm_avp</varname> (string)</title>
<para>
The definition of an PV that might contain the realm to be used
to perform authentication.
</para>
<para>
When the PV value is an empty string or NULL when uac_auth() is called,
the realm is taken from the reply and only username matching is done.
This can be used if the realm upstream will be using is not known in advance.
</para>
<para><emphasis>
If you define it, you also need to define
<quote>auth_username_avp</quote>
(<xref linkend="uac.p.auth_username_avp"/>) and
<quote>auth_password_avp</quote>
(<xref linkend="uac.p.auth_password_avp"/>).
</emphasis></para>
<example>
<title>Set <varname>auth_realm_avp</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac","auth_realm_avp","$avp(arealm)")
...
</programlisting>
</example>
</section>
<section id="uac.p.auth_username_avp">
<title><varname>auth_username_avp</varname> (string)</title>
<para>
The definition of an AVP that might contain the username to be used
to perform authentication.
</para>
<para><emphasis>
If you define it, you also need to define
<quote>auth_realm_avp</quote>
(<xref linkend="uac.p.auth_realm_avp"/>) and
<quote>auth_password_avp</quote>
(<xref linkend="uac.p.auth_password_avp"/>).
</emphasis></para>
<example>
<title>Set <varname>auth_username_avp</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac","auth_username_avp","$avp(auser)")
...
</programlisting>
</example>
</section>
<section id="uac.p.auth_password_avp">
<title><varname>auth_password_avp</varname> (string)</title>
<para>
The definition of an AVP that might contain the password to be used
to perform authentication.
</para>
<para><emphasis>
If you define it, you also need to define
<quote>auth_realm_avp</quote>
(<xref linkend="uac.p.auth_realm_avp"/>) and
<quote>auth_username_avp</quote>
(<xref linkend="uac.p.auth_username_avp"/>).
</emphasis></para>
<example>
<title>Set <varname>auth_password_avp</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac","auth_password_avp","$avp(apasswd)")
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_db_url">
<title><varname>reg_db_url</varname> (string)</title>
<para>
DB URL to fetch account profiles for registration. This parameter
must be set in order to enable remote registrations feature.
</para>
<para>The default value is "" (no value).</para>
<example>
<title>Set <varname>reg_db_url</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_db_url",
"&defaultdb;")
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_timer_interval">
<title><varname>reg_timer_interval</varname> (int)</title>
<para>
Timer interval (in seconds) at which registrations are managed, e.g. renewed as needed.
</para>
<para>
<emphasis>
The default value is 90 seconds.
</emphasis>
</para>
<example>
<title>Set <varname>reg_timer_interval</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_timer_interval", 60)
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_retry_interval">
<title><varname>reg_retry_interval</varname> (int)</title>
<para>
Failed registration attempts will be retried after this interval
(in seconds). The interval is not exact, retries may be
attempted as much as reg_timer_interval secs earlier.
If set to 0, failed registrations will be disabled permanently.
</para>
<para>The default value is 0 sec (disabled)</para>
<example>
<title>Set <varname>reg_retry_interval</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_retry_interval", 300)
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_random_delay">
<title><varname>reg_random_delay</varname> (int)</title>
<para>
Set a random reg_delay for each registration that has
reg_delay set to 0 in the database.
If set to 0, randomization will be disabled.
</para>
<para>The default value is 0 sec (disabled)</para>
<example>
<title>Set <varname>reg_random_delay</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_random_delay", 300)
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_hash_size">
<title><varname>reg_hash_size</varname> (int)</title>
<para>
The number of entries of the hash table used by uac_reg to store the
registration records is 2^hash_size. For hash_size=4, the number of
slots of the hash table is 16.
</para>
<para>
<emphasis>Default value is <quote>4</quote> (16 slots).</emphasis>
</para>
<example>
<title>Set <varname>reg_hash_size</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_hash_size", 10)
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_db_table">
<title><varname>reg_db_table</varname> (string)</title>
<para>
DB table name to fetch user profiles for registration.
</para>
<para>
<emphasis>
This parameter is optional, it's default value being
<quote>uacreg</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>reg_db_table</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_db_table", "uacreg")
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_contact_addr">
<title><varname>reg_contact_addr</varname> (string)</title>
<para>
Address to be used to build contact address. Must be at least
host part, can have port and parameters. Must not include 'sip:'.
The username part of the Contact: URI will be the L_UUID field in the database.
</para>
<para>
A contact_addr value in the uacreg table will
override the parameter for this particular entry.
</para>
<example>
<title>Set <varname>reg_contact_addr</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_contact_addr", "192.168.1.2:5080")
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_keep_callid">
<title><varname>reg_keep_callid</varname> (int)</title>
<para>
If set to 0 (default), a new Call-Id will be generated for each
registration attempt.
If set to non-zero, the same Call-Id will be used for
re-registrations, as recommended by RFC3261 section 10.2.4.
A new Call-Id will be generated when a previous registration
had failed.
</para>
<example>
<title>Set <varname>reg_keep_callid</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_keep_callid", 1)
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_active">
<title><varname>reg_active</varname> (int)</title>
<para>
If set to 0, no remote regisrations are done. In other words,
it can control at once if the module should do remote registratios
or not. It can be changed at runtime via rpc command
'uac.reg_active 0|1'.
</para>
<para>The default value is 1 (active).</para>
<example>
<title>Set <varname>reg_active</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_active", 0)
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_gc_interval">
<title><varname>reg_gc_interval</varname> (int)</title>
<para>
Timer interval (in seconds) at which remote registrations are cleaned
up in case of failure or removed. When setting it take in consideration
the maximum value for retransmission timeout, this param should be greater
than it. This value also impacts how often the reload for remote
registrations table can be executed -- the RPC command will fail if
executed in less than reg_gc_interval value since the last reload.
</para>
<para>
<emphasis>
The default value is 150 seconds.
</emphasis>
</para>
<example>
<title>Set <varname>reg_gc_interval</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_gc_interval", 60)
...
</programlisting>
</example>
</section>
<section id="uac.p.reg_use_domain">
<title><varname>reg_use_domain</varname> (int)</title>
<para>
If set to 1, domain part of URIs is used by functions doing
lookup on user name.
</para>
<para>
<emphasis>Default value is <quote>0</quote>.</emphasis>
</para>
<example>
<title>Set <varname>reg_use_domain</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "reg_use_domain", 1)
...
</programlisting>
</example>
</section>
<section id="uac.p.default_socket">
<title><varname>default_socket</varname> (str)</title>
<para>
Default socket to be used for generating registration requests and sending
requests with the function uac_req_send(). Useful e.g. when several public
interfaces are available.
</para>
<para>
A send socket in the $uac_reg variable used together with the uac_req_send()
function will override this parameter. A socket value in the uacreg table will
also override the parameter for this particular entry.
</para>
<para>
<emphasis>
By default no default socket is defined, the send socket is choosen from the
<quote>tm</quote> module when the requests is send out.
</emphasis>
</para>
<para>If you want to force a certain TCP port (e.g. 5060), you will need to set
the <emphasis>tcp_reuse_port=yes</emphasis> core parameter as well.
</para>
<example>
<title>Set the <quote>default_socket</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("uac", "default_socket", "udp:192.168.0.125:5060")
...
</programlisting>
</example>
</section>
<section id="uac.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[uac:reply] block.
</para>
<para>
The function receives a string parameter with the name of the event,
the value can be: 'uac:reply'.
</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("uac", "event_callback", "ksr_uac_event")
function ksr_uac_event(evname)
KSR.info("===== uac module triggered event: " .. evname .. "\n");
return 1;
end
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Functions</title>
<section id="uac.f.uac_replace_from">
<title>
<function moreinfo="none">uac_replace_from(display,uri)</function>
</title>
<para>
Replace in FROM header the <emphasis>display</emphasis> name and
the <emphasis>URI</emphasis> part.
</para>
<para>
<emphasis>display</emphasis> and <emphasis>URI</emphasis> parameters
can include pseudo-variables.
</para>
<para>
This function can be used from REQUEST_ROUTE and from BRANCH_ROUTE.
</para>
<para>NOTE: Previous versions of this function added double quotes automatically to
display variable. That is no longer the case, if you expect that behavior, you will
have to add the quotes by yourself.
</para>
<para>
If you set restore_mode to AUTO, the URI will be modified automatically in
all subsequent requests and replies in that dialog.
</para>
<para>
There are two ways in which the AUTO mode can be achieved.
</para>
<para>
One uses the rr module and appends to the Record-Route header a parameter
containing some strings from which the original and new URI can be computed.
The problem with this mode is that it relies on the fact the parties will
send the Route exactly as it was received. In case there is a change, the
resulting URIs will not be correct.
</para>
<para>
The other one uses the dialog module to store the original and new URI.
If you already use dialog module in your configuration, this is the advisable mode.
All you need to do to use this is to call dlg_manage() before calling uac_replace_from().
It works by storing the URIs as dialog variables and registering callbacks in dialog
module for in dialog requests.
</para>
<example>
<title><function>uac_replace_from</function> usage</title>
<programlisting format="linespecific">
...
# replace both display and uri
uac_replace_from("$avp(s:display)","$avp(s:uri)");
# replace only display and do not touch uri
uac_replace_from("batman",""); # display is replaced with: batman
uac_replace_from("\"batman\"",""); # display is replaced with: "batman"
# remove display and replace uri
uac_replace_from("","sip:robin@gotham.org");
# remove display and do not touch uri
uac_replace_from("","");
...
</programlisting>
</example>
</section>
<section id="uac.f.uac_replace_from_uri">
<title>
<function moreinfo="none">uac_replace_from(uri)</function>
</title>
<para>
Replace in FROM header the <emphasis>URI</emphasis> part
without altering the display name.
</para>
<para>
<emphasis>URI</emphasis> parameter can include pseudo-variables.
</para>
<para>
This function can be used from REQUEST_ROUTE and from BRANCH_ROUTE.
</para>
<example>
<title><function>uac_replace_from</function> usage</title>
<programlisting format="linespecific">
...
uac_replace_from("sip:batman@gotham.org");
...
</programlisting>
</example>
</section>
<section id="uac.f.uac_restore_from">
<title>
<function moreinfo="none">uac_restore_from()</function>
</title>
<para>
This function will check if the FROM URI was modified and will
use the information stored in header parameter to restore
the original FROM URI value.
</para>
<para>
This function can be used from REQUEST_ROUTE.
</para>
<example>
<title><function>uac_restore_from</function> usage</title>
<programlisting format="linespecific">
...
uac_restore_from();
...
</programlisting>
</example>
</section>
<section id="uac.f.uac_replace_to">
<title>
<function moreinfo="none">uac_replace_to(display,uri)</function>
</title>
<para>
Replace in TO header the <emphasis>display</emphasis> name and
the <emphasis>URI</emphasis> part.
</para>
<para>
<emphasis>display</emphasis> and <emphasis>URI</emphasis> parameters
can include pseudo-variables.
</para>
<para>
This function can be used from REQUEST_ROUTE and from BRANCH_ROUTE.
</para>
<para>NOTE: Previous versions of this function added double quotes automatically to
display variable. That is no longer the case, if you expect that behavior, you will
have to add the quotes by yourself.
</para>
<example>
<title><function>uac_replace_to</function> usage</title>
<programlisting format="linespecific">
...
# replace both display and uri
uac_replace_to("$avp(display)","$avp(uri)");
# replace only display and do not touch uri
uac_replace_to("batman",""); # display is replaced with: batman
uac_replace_to("\"batman\"",""); # display is replaced with: "batman"
# remove display and replace uri
uac_replace_to("","sip:robin@gotham.org");
# remove display and do not touch uri
uac_replace_to("","");
...
</programlisting>
</example>
</section>
<section id="uac.f.uac_replace_to_uri">
<title>
<function moreinfo="none">uac_replace_to(uri)</function>
</title>
<para>
Replace in TO header the <emphasis>URI</emphasis> part
without altering the display name.
</para>
<para>
<emphasis>URI</emphasis> parameter can include pseudo-variables.
</para>
<para>
This function can be used from REQUEST_ROUTE and from BRANCH_ROUTE.
</para>
<para>
If you set restore_mode to AUTO, the URI will be modified automatically in
all subsequent requests and replies in that dialog.
</para>
<para>
There are two ways in which the AUTO mode can be achieved.
</para>
<para>
One uses the rr module and appends to the Record-Route header a parameter
containing some strings from which the original and new URI can be computed.
The problem with this mode is that it relies on the fact the parties will
send the Route exactly as it was received. In case there is a change, the
resulting URIs will not be correct.
</para>
<para>
The other one uses the dialog module to store the original and new URI.
If you already use dialog module in your configuration, this is the advisable mode.
All you need to do to use this is to call dlg_manage() before calling uac_replace_to().
It works by storing the URIs as dialog variables and registering callbacks in dialog
module for in dialog requests.
</para>
<example>
<title><function>uac_replace_to</function> usage</title>
<programlisting format="linespecific">
...
uac_replace_to("sip:batman@gotham.org");
...
</programlisting>
</example>
</section>
<section id="uac.f.uac_restore_to()">
<title>
<function moreinfo="none">uac_restore_to()</function>
</title>
<para>
This function will check if the TO URI was modified and will
use the information stored in header parameter to restore
the original TO URI value.
</para>
<para>
This function can be used from REQUEST_ROUTE.
</para>
<example>
<title><function>uac_restore_to</function> usage</title>
<programlisting format="linespecific">
...
uac_restore_to();
...
</programlisting>
</example>
</section>
<section id="uac.f.uac_auth">
<title>
<function moreinfo="none">uac_auth([mode])</function>
</title>
<para>
This function can be called only from failure route and will
build the authentication response header and insert it into the
request without sending anything.
</para>
<para>
If mode is set to 1, then the password has to be provided in HA1 format.
The parameter can be a static integer or a variable holding an integer value.
</para>
<para>
This function can be used from FAILURE_ROUTE.
</para>
<example>
<title><function>uac_auth</function> usage</title>
<programlisting format="linespecific">
...
modparam("uac","auth_username_avp","$avp(auser)")
modparam("uac","auth_password_avp","$avp(apass)")
modparam("uac","auth_realm_avp","$avp(arealm)")
request_route {
...
if(is_method("INVITE")) {
t_on_failure("TRUNKAUTH");
}
...
}
failure_route[TRUNKAUTH] {
if (t_is_canceled()) {
exit;
}
if(t_check_status("401|407")) {
$avp(auser) = "test";
$avp(apass) = "test";
# $avp(apass) = "36d0a02793542b4961e8348347236dbf";
# if (uac_auth("1")) {
if (uac_auth()) {
t_relay();
}
exit;
}
}
...
</programlisting>
</example>
</section>
<section id="uac.f.uac_auth_mode">
<title>
<function moreinfo="none">uac_auth_mode(vmode)</function>
</title>
<para>
This function can be called only from failure route and will
build the authentication response header and insert it into the
request without sending anything.
</para>
<para>
If mode is set to 1, then the password has to be provided in HA1 format.
The parameter can be a static integer or a variable holding an integer value.
</para>
<para>
This function can be used from FAILURE_ROUTE.
</para>
<example>
<title><function>uac_auth_mode</function> usage</title>
<programlisting format="linespecific">
...
modparam("uac","auth_username_avp","$avp(auser)")
modparam("uac","auth_password_avp","$avp(apass)")
modparam("uac","auth_realm_avp","$avp(arealm)")
request_route {
...
if(is_method("INVITE")) {
t_on_failure("TRUNKAUTH");
}
...
}
failure_route[TRUNKAUTH] {
if (t_is_canceled()) {
exit;
}
if(t_check_status("401|407")) {
$avp(auser) = "test";
$avp(apass) = "test";
# $avp(apass) = "36d0a02793542b4961e8348347236dbf";
if (uac_auth_mode("1")) {
t_relay();
}
exit;
}
}
...
</programlisting>
</example>
</section>
<section id="uac.f.uac_req_send">
<title>
<function moreinfo="none">uac_req_send()</function>
</title>
<para>
This function sends a SIP message from the configuration file.
The message is built out of $uac_req(...) pseudo-variable.
</para>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
BRANCH_ROUTE, ONREPLY_ROUTE, LOCAL_ROUTE.
</para>
<example>
<title><function>uac_req_send</function> usage</title>
<programlisting format="linespecific">
...
$uac_req(method)="OPTIONS";
$uac_req(ruri)="sip:kamailio.org";
$uac_req(furi)="sip:kamailio.org";
$uac_req(turi)="sip:kamailio.org";
$uac_req(callid)=$(mb{s.md5});
uac_req_send();
...