Browse code

modules: readme files regenerated - nathelper ... [skip ci]

Kamailio Dev authored on 06/07/2021 18:46:19
Showing 1 changed files
... ...
@@ -1,850 +1 @@
1
-nathelper Module
2 1
 
3
-Maxim Sobolev
4
-
5
-   Sippy Software, Inc.
6
-
7
-Juha Heinanen
8
-
9
-   TuTPro, Inc.
10
-
11
-Edited by
12
-
13
-Maxim Sobolev
14
-
15
-Bogdan-Andrei Iancu
16
-
17
-Juha Heinanen
18
-
19
-Ovidiu Sas
20
-
21
-   Copyright © 2003-2008 Sippy Software, Inc.
22
-
23
-   Copyright © 2005 Voice Sistem SRL
24
-
25
-   Copyright © 2009 TuTPro Inc.
26
-
27
-   Copyright © 2010 VoIPEmbedded Inc.
28
-     __________________________________________________________________
29
-
30
-   Table of Contents
31
-
32
-   1. Admin Guide
33
-
34
-        1. Overview
35
-        2. NAT pinging types
36
-        3. Dependencies
37
-
38
-              3.1. Kamailio Modules
39
-              3.2. External Libraries or Applications
40
-
41
-        4. Parameters
42
-
43
-              4.1. force_socket (string)
44
-              4.2. natping_interval (integer)
45
-              4.3. ping_nated_only (integer)
46
-              4.4. natping_processes (integer)
47
-              4.5. natping_socket (string)
48
-              4.6. received_avp (str)
49
-              4.7. sipping_bflag (integer)
50
-              4.8. sipping_from (string)
51
-              4.9. sipping_method (string)
52
-              4.10. natping_disable_bflag (integer)
53
-              4.11. nortpproxy_str (string)
54
-              4.12. keepalive_timeout (int)
55
-              4.13. udpping_from_path (int)
56
-              4.14. append_sdp_oldmediaip (int)
57
-              4.15. filter_server_id (int)
58
-              4.16. nat_addr_mode (int)
59
-
60
-        5. Functions
61
-
62
-              5.1. fix_nated_contact()
63
-              5.2. fix_nated_sdp(flags [, ip_address])
64
-              5.3. add_rcv_param([flag]),
65
-              5.4. fix_nated_register()
66
-              5.5. nat_uac_test(flags)
67
-              5.6. is_rfc1918(ip_address)
68
-              5.7. add_contact_alias([ip_addr, port, proto])
69
-              5.8. handle_ruri_alias([mode])
70
-              5.9. set_contact_alias([trim])
71
-              5.10. set_alias_to_pv(target_avp)
72
-
73
-        6. Exported Pseudo Variables
74
-
75
-              6.1. $rr_count
76
-              6.2. $rr_top_count
77
-
78
-        7. RPC Commands
79
-
80
-              7.1. nathelper.enable_ping
81
-
82
-        8. Selects
83
-
84
-              8.1. @nathelper.rewrite_contact[n]
85
-
86
-   2. Frequently Asked Questions
87
-
88
-   List of Examples
89
-
90
-   1.1. Set force_socket parameter
91
-   1.2. Set natping_interval parameter
92
-   1.3. Set ping_nated_only parameter
93
-   1.4. Set natping_processes parameter
94
-   1.5. Set natping_socket parameter
95
-   1.6. Set received_avp parameter
96
-   1.7. Set sipping_bflag parameter
97
-   1.8. Set sipping_from parameter
98
-   1.9. Set sipping_method parameter
99
-   1.10. Set natping_disable_bflag parameter
100
-   1.11. Set nortpproxy_str parameter
101
-   1.12. Set keepalive_timeout parameter
102
-   1.13. Set udpping_from_path parameter
103
-   1.14. Set append_sdp_oldmediaip parameter
104
-   1.15. Set filter_server_id parameter
105
-   1.16. Set nat_addr_mode parameter
106
-   1.17. fix_nated_contact usage
107
-   1.18. fix_nated_sdp usage
108
-   1.19. add_rcv_paramer usage
109
-   1.20. fix_nated_register usage
110
-   1.21. nat_uac_test usage
111
-   1.22. is_rfc1918 usage
112
-   1.23. add_contact_alias usage
113
-   1.24. handle_ruri_alias usage
114
-   1.25. set_contact_alias usage
115
-   1.26. set_alias_to_pv usage
116
-   1.27. $rr_count usage
117
-   1.28. $rr_top_count usage
118
-   1.29. nathelper.enable_ping usage
119
-   1.30. @nathelper.rewrite_contact usage
120
-
121
-Chapter 1. Admin Guide
122
-
123
-   Table of Contents
124
-
125
-   1. Overview
126
-   2. NAT pinging types
127
-   3. Dependencies
128
-
129
-        3.1. Kamailio Modules
130
-        3.2. External Libraries or Applications
131
-
132
-   4. Parameters
133
-
134
-        4.1. force_socket (string)
135
-        4.2. natping_interval (integer)
136
-        4.3. ping_nated_only (integer)
137
-        4.4. natping_processes (integer)
138
-        4.5. natping_socket (string)
139
-        4.6. received_avp (str)
140
-        4.7. sipping_bflag (integer)
141
-        4.8. sipping_from (string)
142
-        4.9. sipping_method (string)
143
-        4.10. natping_disable_bflag (integer)
144
-        4.11. nortpproxy_str (string)
145
-        4.12. keepalive_timeout (int)
146
-        4.13. udpping_from_path (int)
147
-        4.14. append_sdp_oldmediaip (int)
148
-        4.15. filter_server_id (int)
149
-        4.16. nat_addr_mode (int)
150
-
151
-   5. Functions
152
-
153
-        5.1. fix_nated_contact()
154
-        5.2. fix_nated_sdp(flags [, ip_address])
155
-        5.3. add_rcv_param([flag]),
156
-        5.4. fix_nated_register()
157
-        5.5. nat_uac_test(flags)
158
-        5.6. is_rfc1918(ip_address)
159
-        5.7. add_contact_alias([ip_addr, port, proto])
160
-        5.8. handle_ruri_alias([mode])
161
-        5.9. set_contact_alias([trim])
162
-        5.10. set_alias_to_pv(target_avp)
163
-
164
-   6. Exported Pseudo Variables
165
-
166
-        6.1. $rr_count
167
-        6.2. $rr_top_count
168
-
169
-   7. RPC Commands
170
-
171
-        7.1. nathelper.enable_ping
172
-
173
-   8. Selects
174
-
175
-        8.1. @nathelper.rewrite_contact[n]
176
-
177
-1. Overview
178
-
179
-   This is a module to help with NAT traversal and reuse of TCP
180
-   connections. In particular, it helps symmetric UAs that don't advertise
181
-   they are symmetric and are not able to determine their public address.
182
-
183
-   The function fix_nated_contact() rewrites the “Contact” header field
184
-   with request's source address:port pair. The function fix_nated_sdp()
185
-   adds the active direction indication to SDP (flag 0x01) and updates the
186
-   source IP address too (flag 0x02). The function fix_nated_register()
187
-   exports exports the request's source address:port into an AVP to be
188
-   used during save() and should be used for “REGISTER” requests.
189
-
190
-   Note: fix_nated_contact changes the “Contact” header, thus it breaks
191
-   the RFC. Although usually this is not an issue, it may cause problems
192
-   with strict SIP clients. An alternative is to use add_contact_alias()
193
-   that together with the handle_ruri_alias() is standards conforming and
194
-   also supports reuse of TCP/TLS connections.
195
-
196
-2. NAT pinging types
197
-
198
-   Currently, the nathelper module supports two types of NAT pings:
199
-     * UDP packet - 4 bytes (zero filled) UDP packets are sent to the
200
-       contact address.
201
-          + Advantages: low bandwidth traffic, easy to generate by
202
-            Kamailio;
203
-          + Disadvantages: unidirectional traffic through NAT (inbound -
204
-            from outside to inside); As many NATs do update the bind
205
-            timeout only on outbound traffic, the bind may expire and
206
-            closed.
207
-     * SIP request - a stateless SIP request is sent to the UDP contact
208
-       address.
209
-          + Advantages: bidirectional traffic through NAT, since each PING
210
-            request from Kamailio (inbound traffic) will force the SIP
211
-            client to generate a SIP reply (outbound traffic) - the NAT
212
-            bind will be surely kept open.
213
-          + Disadvantages: higher bandwidth traffic, more expensive (as
214
-            time) to generate by Kamailio;
215
-
216
-3. Dependencies
217
-
218
-   3.1. Kamailio Modules
219
-   3.2. External Libraries or Applications
220
-
221
-3.1. Kamailio Modules
222
-
223
-   The following modules must be loaded before this module:
224
-     * usrloc module - only if the NATed contacts are to be pinged.
225
-
226
-3.2. External Libraries or Applications
227
-
228
-   The following libraries or applications must be installed before
229
-   running Kamailio with this module loaded:
230
-     * None.
231
-
232
-4. Parameters
233
-
234
-   4.1. force_socket (string)
235
-   4.2. natping_interval (integer)
236
-   4.3. ping_nated_only (integer)
237
-   4.4. natping_processes (integer)
238
-   4.5. natping_socket (string)
239
-   4.6. received_avp (str)
240
-   4.7. sipping_bflag (integer)
241
-   4.8. sipping_from (string)
242
-   4.9. sipping_method (string)
243
-   4.10. natping_disable_bflag (integer)
244
-   4.11. nortpproxy_str (string)
245
-   4.12. keepalive_timeout (int)
246
-   4.13. udpping_from_path (int)
247
-   4.14. append_sdp_oldmediaip (int)
248
-   4.15. filter_server_id (int)
249
-   4.16. nat_addr_mode (int)
250
-
251
-4.1. force_socket (string)
252
-
253
-   Socket to be used when sending NAT pings for UDP communication. If no
254
-   one specified, the OS will choose a socket.
255
-
256
-   Default value is “NULL”.
257
-
258
-   Example 1.1. Set force_socket parameter
259
-...
260
-modparam("nathelper", "force_socket", "127.0.0.1:5060")
261
-...
262
-
263
-4.2. natping_interval (integer)
264
-
265
-   Period of time in seconds between sending the NAT pings to all
266
-   currently registered UAs to keep their NAT bindings alive. Value of 0
267
-   disables this functionality.
268
-
269
-Note
270
-
271
-   Enabling the NAT pinging functionality will force the module to bind
272
-   itself to USRLOC module.
273
-
274
-   Default value is 0.
275
-
276
-   Example 1.2. Set natping_interval parameter
277
-...
278
-modparam("nathelper", "natping_interval", 10)
279
-...
280
-
281
-4.3. ping_nated_only (integer)
282
-
283
-   If this parameter is set to 1 then only contacts that have the behind
284
-   NAT “nat_bflag” flag in user location database set will get ping.
285
-
286
-   If it is 0 and sipping_bflag is not set, then the 4-bytes UDP ping is
287
-   sent to all contacts. If it is 0 and sipping_bflag parameter is set,
288
-   then SIP-request-based pinging is sent to all contacts.
289
-
290
-   Default value is 0.
291
-
292
-   Example 1.3. Set ping_nated_only parameter
293
-...
294
-modparam("nathelper", "ping_nated_only", 1)
295
-...
296
-
297
-4.4. natping_processes (integer)
298
-
299
-   How many timer processes should be created by the module for the
300
-   exclusive task of sending the NAT pings.
301
-
302
-   Default value is 1.
303
-
304
-   Example 1.4. Set natping_processes parameter
305
-...
306
-modparam("nathelper", "natping_processes", 3)
307
-...
308
-
309
-4.5. natping_socket (string)
310
-
311
-   Spoof the natping's source-ip to this address. Works only for IPv4.
312
-
313
-   Default value is NULL.
314
-
315
-   Example 1.5. Set natping_socket parameter
316
-...
317
-modparam("nathelper", "natping_socket", "192.168.1.1:5006")
318
-...
319
-
320
-4.6. received_avp (str)
321
-
322
-   The name of the Attribute-Value-Pair (AVP) used to store the URI
323
-   containing the received IP, port, and protocol. The URI is created by
324
-   fix_nated_register function of nathelper module and the attribute is
325
-   then used by the registrar to store the received parameters. Do not
326
-   forget to change the value of corresponding parameter in registrar
327
-   module if you change the value of this parameter.
328
-
329
-Note
330
-
331
-   You must set this parameter if you use fix_nated_register. In such case
332
-   you must set the parameter with same name in the “registrar” module to
333
-   same value.
334
-
335
-   Default value is "NULL" (disabled).
336
-
337
-   Example 1.6. Set received_avp parameter
338
-...
339
-modparam("nathelper", "received_avp", "$avp(i:42)")
340
-...
341
-
342
-4.7. sipping_bflag (integer)
343
-
344
-   Which branch flag should be used by the module to identify NATed
345
-   contacts for which it should perform NAT ping via a SIP request instead
346
-   of dummy UDP packet.
347
-
348
-   Default value is -1 (disabled).
349
-
350
-   Example 1.7. Set sipping_bflag parameter
351
-...
352
-modparam("nathelper", "sipping_bflag", 7)
353
-...
354
-
355
-4.8. sipping_from (string)
356
-
357
-   The parameter sets the SIP URI to be used in generating the SIP
358
-   requests for NAT ping purposes. To enable the SIP request pinging
359
-   feature, you have to set this parameter. The SIP request pinging will
360
-   be used only for requests marked so.
361
-
362
-   Default value is “NULL”.
363
-
364
-   Example 1.8. Set sipping_from parameter
365
-...
366
-modparam("nathelper", "sipping_from", "sip:pinger@siphub.net")
367
-...
368
-
369
-4.9. sipping_method (string)
370
-
371
-   The parameter sets the SIP method to be used in generating the SIP
372
-   requests for NAT ping purposes.
373
-
374
-   Default value is “OPTIONS”.
375
-
376
-   Example 1.9. Set sipping_method parameter
377
-...
378
-modparam("nathelper", "sipping_method", "INFO")
379
-...
380
-
381
-4.10. natping_disable_bflag (integer)
382
-
383
-   What branch flag should be used by the module to disable NAT pings on a
384
-   per-registration basis. If the given flag is set for a particular
385
-   registration, then no NAT pings will be sent at all, regardless of any
386
-   other conditions.
387
-
388
-   Default value is -1 (disabled).
389
-
390
-   Example 1.10. Set natping_disable_bflag parameter
391
-...
392
-modparam("nathelper", "natping_disable_bflag", 8)
393
-...
394
-
395
-4.11. nortpproxy_str (string)
396
-
397
-   The parameter sets the SDP attribute used by nathelper to mark the
398
-   packet SDP that information have already been mangled.
399
-
400
-   If empty string, no marker will be added or checked.
401
-
402
-Note
403
-
404
-   The string must be a complete SDP line, including the EOH (\r\n).
405
-
406
-   Default value is “a=nortpproxy:yes\r\n”.
407
-
408
-   Example 1.11. Set nortpproxy_str parameter
409
-...
410
-modparam("nathelper", "nortpproxy_str", "a=sdpmangled:yes\r\n")
411
-...
412
-
413
-4.12. keepalive_timeout (int)
414
-
415
-   The parameter sets the interval in seconds after which a natted contact
416
-   is removed from location table if it does not reply to SIP keepalives
417
-   (usually OPTIONS ping requests).
418
-
419
-   The features is available only for UDP contacts that are stored in
420
-   memory (not working for db only mode for usrloc module).
421
-
422
-   Keepalives are sent stateless, not using TM module. The value of this
423
-   parameter has to be few times higher than natping_interval.
424
-
425
-   Default value is “0” (feature disabled).
426
-
427
-   Example 1.12. Set keepalive_timeout parameter
428
-...
429
-modparam("nathelper", "keepalive_timeout", 120)
430
-...
431
-
432
-4.13. udpping_from_path (int)
433
-
434
-   Enable sending UDP pings (keepalives) using raw socket from Path
435
-   address.
436
-
437
-   Default value is “0” (feature disabled).
438
-
439
-   Example 1.13. Set udpping_from_path parameter
440
-...
441
-modparam("nathelper", "udpping_from_path", 1)
442
-...
443
-
444
-4.14. append_sdp_oldmediaip (int)
445
-
446
-   The parameter controls if oldmediaip field should be appended to the
447
-   SDP.
448
-
449
-   Default value is “1” (feature enabled).
450
-
451
-   Example 1.14. Set append_sdp_oldmediaip parameter
452
-...
453
-modparam("nathelper", "append_sdp_oldmediaip", 1)
454
-...
455
-
456
-4.15. filter_server_id (int)
457
-
458
-   Filter contacts by “server_id” core parameter. Use this parameter to
459
-   limit pinging. When set to “1”, only proxy instances which send packets
460
-   are those where core server_id matches server_id saved in usrloc.
461
-   Default value is “0” (disabled).
462
-
463
-   Example 1.15. Set filter_server_id parameter
464
-...
465
-modparam("nathelper", "filter_server_id", 1)
466
-...
467
-
468
-4.16. nat_addr_mode (int)
469
-
470
-   If set to 0, only default private net addresses are checked by
471
-   nat_uac_test(). If set to 1, other reserved net addresses are checked
472
-   by nat_uac_test() as well.
473
-
474
-   Default private net addresses are:
475
-     * 10.0.0.0/8
476
-     * 172.16.0.0/12
477
-     * 192.168.0.0/16
478
-     * 100.64.0.0/10 - RFC6598 - Carrier Grade NAT
479
-     * 192.0.0.0/29 - RFC7335 - IPv4 Service Continuity Prefix
480
-
481
-   Reserved net addresses are:
482
-     * 192.0.0.0/24 - RFC7335 - IETF Protocol Assignments
483
-
484
-   Default value is “1”.
485
-
486
-   Example 1.16. Set nat_addr_mode parameter
487
-...
488
-modparam("nathelper", "nat_addr_mode", 0)
489
-...
490
-
491
-5. Functions
492
-
493
-   5.1. fix_nated_contact()
494
-   5.2. fix_nated_sdp(flags [, ip_address])
495
-   5.3. add_rcv_param([flag]),
496
-   5.4. fix_nated_register()
497
-   5.5. nat_uac_test(flags)
498
-   5.6. is_rfc1918(ip_address)
499
-   5.7. add_contact_alias([ip_addr, port, proto])
500
-   5.8. handle_ruri_alias([mode])
501
-   5.9. set_contact_alias([trim])
502
-   5.10. set_alias_to_pv(target_avp)
503
-
504
-5.1.  fix_nated_contact()
505
-
506
-   Rewrites the “Contact” header to contain the request's source
507
-   address:port.
508
-
509
-   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
510
-   BRANCH_ROUTE.
511
-
512
-   Example 1.17. fix_nated_contact usage
513
-...
514
-if (search("User-Agent: Cisco ATA.*") {fix_nated_contact();};
515
-...
516
-
517
-5.2.  fix_nated_sdp(flags [, ip_address])
518
-
519
-   Alters the SDP information in order to facilitate NAT traversal. What
520
-   changes to be performed may be controlled via the “flags” parameter.
521
-   Return value is -1 if error occurred, 1 if ip's were replaced, 2 if no
522
-   ip's were replaced.
523
-
524
-   Meaning of the parameters is as follows:
525
-     * flags - the value may be a bitwise OR of the following flags:
526
-          + 0x01 - adds “a=direction:active” SDP line;
527
-          + 0x02 - rewrite media IP address (c=) with source address of
528
-            the message or the provided IP address. (a=rtcp) param will be
529
-            rewritten if exists. (the provided IP address take precedence
530
-            over the source address).
531
-          + 0x04 - adds “a=nortpproxy:yes” SDP line;
532
-          + 0x08 - rewrite IP from origin description (o=) with source
533
-            address of the message or the provided IP address. (a=rtcp)
534
-            param will be rewritten if exists. (the provided IP address
535
-            take precedence over the source address).
536
-     * ip_address - IP to be used for rewriting SDP. If not specified, the
537
-       received signalling IP will be used. The parameter allows
538
-       pseudo-variables usage. NOTE: For the IP to be used, you need to
539
-       use 0x02 or 0x08 flags, otherwise it will have no effect. Must be
540
-       IPv4 address family.
541
-
542
-   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
543
-   FAILURE_ROUTE, BRANCH_ROUTE.
544
-
545
-   Example 1.18. fix_nated_sdp usage
546
-...
547
-if (search("User-Agent: Cisco ATA.*") {fix_nated_sdp("3");};
548
-...
549
-
550
-5.3.  add_rcv_param([flag]),
551
-
552
-   Add a received parameter to the “Contact” header fields (available for
553
-   all transports) or to the Contact URI (available only for UDP traffic).
554
-
555
-   The parameter will contain the URI created from the source IP, port,
556
-   and protocol (if different than UDP) of the packet containing the SIP
557
-   message. The parameter can be then processed by another registrar. This
558
-   is useful, for example, when replicating register messages using
559
-   t_replicate function to another registrar.
560
-
561
-   Meaning of the parameters is as follows:
562
-     * flag - flags to indicate if the parameter should be added to
563
-       Contact URI or Contact header. If the flag is non-zero, the
564
-       parameter will be added to the Contact URI. If not used or equal to
565
-       zero, the parameter will go to the Contact header.
566
-
567
-   This function can be used from REQUEST_ROUTE.
568
-
569
-   Example 1.19. add_rcv_paramer usage
570
-...
571
-add_rcv_param(); # add the parameter to the Contact header
572
-....
573
-add_rcv_param("1"); # add the parameter to the Contact URI
574
-...
575
-
576
-5.4.  fix_nated_register()
577
-
578
-   The function creates a URI consisting of the source IP, port, and
579
-   protocol and stores the URI in an Attribute-Value-Pair. The URI will be
580
-   appended as "received" parameter to Contact in 200 OK and registrar
581
-   will store it in the received column in the location table.
582
-
583
-   Note: You have to set the “received_avp” parameter of the nathelper
584
-   module and the registrar module (both module parameters must have the
585
-   same value) to use this function.
586
-
587
-   This function can be used from REQUEST_ROUTE.
588
-
589
-   Example 1.20. fix_nated_register usage
590
-...
591
-fix_nated_register();
592
-...
593
-
594
-5.5.  nat_uac_test(flags)
595
-
596
-   Tries to guess if client's request originated behind a nat. The
597
-   parameter determines what heuristics is used.
598
-
599
-   Meaning of the flags is as follows:
600
-     * 1 - The “Contact” header field is searched for occurrence of
601
-       RFC1918 or RFC6598 addresses.
602
-     * 2 - the "received" test is used: address in the “Via” header is
603
-       compared against source IP address of signaling. If the “Via”
604
-       header contains no port, it uses the default SIP port 5060
605
-     * 4 - The Top Most “Via” is searched for occurrence of RFC1918 or
606
-       RFC6598 addresses
607
-     * 8 - The SDP is searched for occurrence of RFC1918 or RFC6598
608
-       addresses
609
-     * 16 - Test if the source port is different from the port in the
610
-       “Via” header. If the “Via” header contains no port, it uses the
611
-       default SIP port 5060
612
-     * 32 - Test if the source IP address of signaling is a RFC1918 or
613
-       RFC6598 address
614
-     * 64 - Test if the source connection of signaling is a WebSocket
615
-     * 128 - Test if the “Contact” header URI port differs from the source
616
-       port of the request (Warning: this is might be legal or even
617
-       intended combination in non NATted scenarios)
618
-     * 256 - Test if the SDP connection address is different from source
619
-       IP address. It will work also with multiple connection address
620
-       lines.
621
-
622
-   All flags can be bitwise combined, the test returns true if any of the
623
-   tests identified a NAT.
624
-
625
-   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
626
-   FAILURE_ROUTE, BRANCH_ROUTE.
627
-
628
-   Example 1.21. nat_uac_test usage
629
-...
630
-if(nat_uac_test("19")) {
631
-    rtpproxy_manage("co");
632
-}
633
-...
634
-
635
-5.6.  is_rfc1918(ip_address)
636
-
637
-   Determines if the address in the parameter is an rfc1918 or rfc6598
638
-   address. The parameter allows pseudo-variables usage.
639
-
640
-   This function can be used from ANY_ROUTE.
641
-
642
-   Example 1.22. is_rfc1918 usage
643
-...
644
-if(is_rfc1918("$rd")) {
645
-    # domain in r-uri is private address
646
-}
647
-...
648
-
649
-5.7.  add_contact_alias([ip_addr, port, proto])
650
-
651
-   Adds an “;alias=ip~port~transport” parameter to the contact URI
652
-   containing either received ip, port, and transport protocol or those
653
-   given as parameters. If called without parameters, “;alias” parameter
654
-   is only added if received ip, port, or transport protocol differs from
655
-   that in contact URI.
656
-
657
-   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
658
-   BRANCH_ROUTE, and LOCAL_ROUTE.
659
-
660
-   Example 1.23. add_contact_alias usage
661
-...
662
-    if (!is_present_hf("Record-Route")) {
663
-        if (!add_contact_alias("$var(src_ip)", "$Rp", "tcp")) {
664
-            xlog("L_ERR", "Error in aliasing contact $ct\n");
665
-            send_reply("400", "Bad request");
666
-            exit;
667
-        };
668
-    };
669
-...
670
-
671
-5.8.  handle_ruri_alias([mode])
672
-
673
-   Checks if the Request URI has an “alias” parameter and if so, removes
674
-   it and sets the “$du” based on its value. Note that this means that
675
-   routing of request is based on “;alias” parameter value of the Request
676
-   URI rather than the Request URI itself. If you call handle_ruri_alias()
677
-   on a request, make sure that you screen the alias parameter value of
678
-   Request URI the same way as you would screen the Request URI itself.
679
-
680
-   The optional parameter mode can be 0 to consume first alias parameter,
681
-   otherwise it consumes the last alias parameter. If the parameter mode
682
-   is not provided, it consumes the first parameter.
683
-
684
-   Returns 1 if “;alias” parameter was found and “$du” was set and the
685
-   “$ru” rewritten, 2 if the alias parameter was not found and nothing was
686
-   done, or -1 in case of error.
687
-
688
-   This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, and
689
-   LOCAL_ROUTE.
690
-
691
-   Example 1.24. handle_ruri_alias usage
692
-...
693
-    if ($du == "") {
694
-        handle_ruri_alias();
695
-        switch ($rc) {
696
-        case -1:
697
-            xlog("L_ERR", "Failed to handle alias of R-URI $ru\n");
698
-            send_reply("400", "Bad request");
699
-            exit;
700
-        case 1:
701
-            xlog("L_INFO", "Routing in-dialog $rm from $fu to $du\n");
702
-            break;
703
-        case 2:
704
-            xlog("L_INFO", "Routing in-dialog $rm from $fu to $ru\n");
705
-            break;
706
-         };
707
-    };
708
-...
709
-
710
-5.9.  set_contact_alias([trim])
711
-
712
-   Adds an “;alias=ip~port~transport” parameter to the contact URI
713
-   containing the received ip, port, and transport protocol. The new
714
-   contact URI is immediately visible to other modules in the way the
715
-   fix_nated_contact() does it.
716
-
717
-   Meaning of parameters:
718
-     * trim - by default, set_contact_alias() will not detect and trim an
719
-       already existing alias parameter. If this optional parameter is set
720
-       to "1", set_contact_alias() will trim the existing alias before
721
-       adding a new one.
722
-
723
-   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
724
-   BRANCH_ROUTE, and FAILURE_ROUTE.
725
-
726
-   Example 1.25. set_contact_alias usage
727
-...
728
-    if (!is_present_hf("Record-Route")) {
729
-        if (!set_contact_alias()) {
730
-            xlog("L_ERR", "Error in aliasing contact $ct\n");
731
-            send_reply("400", "Bad request");
732
-            exit;
733
-        };
734
-    };
735
-...
736
-
737
-5.10.  set_alias_to_pv(target_avp)
738
-
739
-   Reads “;alias=ip~port~transport” from Contact header then writes to
740
-   target pseudo-variable as a sip uri.
741
-
742
-   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
743
-   BRANCH_ROUTE, and FAILURE_ROUTE.
744
-
745
-   Example 1.26. set_alias_to_pv usage
746
-...
747
-                set_alias_to_pv("$avp(aliasuri)");
748
-...
749
-
750
-6. Exported Pseudo Variables
751
-
752
-   6.1. $rr_count
753
-   6.2. $rr_top_count
754
-
755
-6.1. $rr_count
756
-
757
-   Number of Record Routes in received SIP request or reply.
758
-
759
-   Example 1.27. $rr_count usage
760
-...
761
-    $avp(rr_count) = $rr_count;
762
-...
763
-
764
-6.2. $rr_top_count
765
-
766
-   If topmost Record Route in received SIP request or reply is a double
767
-   Record Route, value of $rr_top_count is 2. If it a single Record Route,
768
-   value of $rr_top_count is 1. If there is no Record Route(s), value of
769
-   $rr_top_count is 0.
770
-
771
-   Example 1.28. $rr_top_count usage
772
-...
773
-    if ($rr_count == $avp(rr_count) + $rr_top_count) {
774
-        route(ADD_CONTACT_ALIAS);
775
-    };
776
-...
777
-
778
-7. RPC Commands
779
-
780
-   7.1. nathelper.enable_ping
781
-
782
-7.1. nathelper.enable_ping
783
-
784
-   Enables natping if parameter value different than 0. Disables natping
785
-   if parameter value is 0.
786
-
787
-   The function takes only one parameter - a number in decimal format.
788
-
789
-   Example 1.29. nathelper.enable_ping usage
790
-...
791
-$ kamcmd nathelper.enable_ping 1
792
-...
793
-
794
-8. Selects
795
-
796
-   8.1. @nathelper.rewrite_contact[n]
797
-
798
-8.1. @nathelper.rewrite_contact[n]
799
-
800
-   Get n-th Contact value with IP:Port rewritten to source ip:port. N is
801
-   counted from 1. Only IP:port is rewritten, remaining part are left
802
-   unchanged. Full nameaddr is supported.
803
-
804
-   Example 1.30. @nathelper.rewrite_contact usage
805
-...
806
-$c = @nathelper.rewrite_contact[1];
807
-...
808
-$c2 = @nathelper.rewrite_contact[1].nameaddr.uri;
809
-
810
-Chapter 2. Frequently Asked Questions
811
-
812
-   2.1. What happened with “rtpproxy_disable” parameter?
813
-   2.2. Where can I find more about Kamailio?
814
-   2.3. Where can I post a question about this module?
815
-   2.4. How can I report a bug?
816
-
817
-   2.1.
818
-
819
-   What happened with “rtpproxy_disable” parameter?
820
-
821
-   It was removed as it became obsolete - now “rtpproxy_sock” can take
822
-   empty value to disable the rtpproxy functionality.
823
-
824
-   2.2.
825
-
826
-   Where can I find more about Kamailio?
827
-
828
-   Take a look at https://www.kamailio.org/.
829
-
830
-   2.3.
831
-
832
-   Where can I post a question about this module?
833
-
834
-   First at all check if your question was already answered on one of our
835
-   mailing lists:
836
-     * User Mailing List -
837
-       https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
838
-     * Developer Mailing List -
839
-       https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
840
-
841
-   E-mails regarding any stable Kamailio release should be sent to
842
-   <sr-users@lists.kamailio.org> and e-mails regarding development
843
-   versions should be sent to <sr-dev@lists.kamailio.org>.
844
-
845
-   2.4.
846
-
847
-   How can I report a bug?
848
-
849
-   Please follow the guidelines provided at:
850
-   https://github.com/kamailio/kamailio/issues.