Browse code

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

Kamailio Dev authored on 16/04/2020 10:01:17
Showing 1 changed files
... ...
@@ -1,2 +1,837 @@
1
+nathelper Module
1 2
 
3
+Maxim Sobolev
2 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()
70
+              5.9. set_contact_alias()
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()
161
+        5.9. set_contact_alias()
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 “behind_NAT”
284
+   flag in user location database set will get ping.
285
+
286
+   If it is 0 and sipping_flag is not set, then the 4-bytes UDP ping is
287
+   sent to all contacts. If it is 0 and sipping_flag 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()
501
+   5.9. set_contact_alias()
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 (the provide IP address
529
+            take precedence over the source address).
530
+          + 0x04 - adds “a=nortpproxy:yes” SDP line;
531
+          + 0x08 - rewrite IP from origin description (o=) with source
532
+            address of the message or the provided IP address (the provide
533
+            IP address take precedence over the source address).
534
+     * ip_address - IP to be used for rewriting SDP. If not specified, the
535
+       received signalling IP will be used. The parameter allows
536
+       pseudo-variables usage. NOTE: For the IP to be used, you need to
537
+       use 0x02 or 0x08 flags, otherwise it will have no effect.
538
+
539
+   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
540
+   FAILURE_ROUTE, BRANCH_ROUTE.
541
+
542
+   Example 1.18. fix_nated_sdp usage
543
+...
544
+if (search("User-Agent: Cisco ATA.*") {fix_nated_sdp("3");};
545
+...
546
+
547
+5.3.  add_rcv_param([flag]),
548
+
549
+   Add a received parameter to the “Contact” header fields (available for
550
+   all transports) or to the Contact URI (available only for UDP traffic).
551
+
552
+   The parameter will contain the URI created from the source IP, port,
553
+   and protocol (if different than UDP) of the packet containing the SIP
554
+   message. The parameter can be then processed by another registrar. This
555
+   is useful, for example, when replicating register messages using
556
+   t_replicate function to another registrar.
557
+
558
+   Meaning of the parameters is as follows:
559
+     * flag - flags to indicate if the parameter should be added to
560
+       Contact URI or Contact header. If the flag is non-zero, the
561
+       parameter will be added to the Contact URI. If not used or equal to
562
+       zero, the parameter will go to the Contact header.
563
+
564
+   This function can be used from REQUEST_ROUTE.
565
+
566
+   Example 1.19. add_rcv_paramer usage
567
+...
568
+add_rcv_param(); # add the parameter to the Contact header
569
+....
570
+add_rcv_param("1"); # add the parameter to the Contact URI
571
+...
572
+
573
+5.4.  fix_nated_register()
574
+
575
+   The function creates a URI consisting of the source IP, port, and
576
+   protocol and stores the URI in an Attribute-Value-Pair. The URI will be
577
+   appended as "received" parameter to Contact in 200 OK and registrar
578
+   will store it in the received column in the location table.
579
+
580
+   Note: You have to set the “received_avp” parameter of the nathelper
581
+   module and the registrar module (both module parameters must have the
582
+   same value) to use this function.
583
+
584
+   This function can be used from REQUEST_ROUTE.
585
+
586
+   Example 1.20. fix_nated_register usage
587
+...
588
+fix_nated_register();
589
+...
590
+
591
+5.5.  nat_uac_test(flags)
592
+
593
+   Tries to guess if client's request originated behind a nat. The
594
+   parameter determines what heuristics is used.
595
+
596
+   Meaning of the flags is as follows:
597
+     * 1 - The “Contact” header field is searched for occurrence of
598
+       RFC1918 or RFC6598 addresses.
599
+     * 2 - the "received" test is used: address in the “Via” header is
600
+       compared against source IP address of signaling. If the “Via”
601
+       header contains no port, it uses the default SIP port 5060
602
+     * 4 - The Top Most “Via” is searched for occurrence of RFC1918 or
603
+       RFC6598 addresses
604
+     * 8 - The SDP is searched for occurrence of RFC1918 or RFC6598
605
+       addresses
606
+     * 16 - Test if the source port is different from the port in the
607
+       “Via” header. If the “Via” header contains no port, it uses the
608
+       default SIP port 5060
609
+     * 32 - Test if the source IP address of signaling is a RFC1918 or
610
+       RFC6598 address
611
+     * 64 - Test if the source connection of signaling is a WebSocket
612
+     * 128 - Test if the “Contact” header URI port differs from the source
613
+       port of the request (Warning: this is might be legal or even
614
+       intended combination in non NATted scenarios)
615
+     * 256 - Test if the SDP connection address is different from source
616
+       IP address. It will work also with multiple connection address
617
+       lines.
618
+
619
+   All flags can be bitwise combined, the test returns true if any of the
620
+   tests identified a NAT.
621
+
622
+   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
623
+   FAILURE_ROUTE, BRANCH_ROUTE.
624
+
625
+   Example 1.21. nat_uac_test usage
626
+...
627
+if(nat_uac_test("19")) {
628
+    rtpproxy_manage("co");
629
+}
630
+...
631
+
632
+5.6.  is_rfc1918(ip_address)
633
+
634
+   Determines if the address in the parameter is an rfc1918 or rfc6598
635
+   address. The parameter allows pseudo-variables usage.
636
+
637
+   This function can be used from ANY_ROUTE.
638
+
639
+   Example 1.22. is_rfc1918 usage
640
+...
641
+if(is_rfc1918("$rd")) {
642
+    # domain in r-uri is private address
643
+}
644
+...
645
+
646
+5.7.  add_contact_alias([ip_addr, port, proto])
647
+
648
+   Adds an “;alias=ip~port~transport” parameter to the contact URI
649
+   containing either received ip, port, and transport protocol or those
650
+   given as parameters. If called without parameters, “;alias” parameter
651
+   is only added if received ip, port, or transport protocol differs from
652
+   that in contact URI.
653
+
654
+   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
655
+   BRANCH_ROUTE, and LOCAL_ROUTE.
656
+
657
+   Example 1.23. add_contact_alias usage
658
+...
659
+    if (!is_present_hf("Record-Route")) {
660
+        if (!add_contact_alias("$var(src_ip)", "$Rp", "tcp")) {
661
+            xlog("L_ERR", "Error in aliasing contact $ct\n");
662
+            send_reply("400", "Bad request");
663
+            exit;
664
+        };
665
+    };
666
+...
667
+
668
+5.8.  handle_ruri_alias()
669
+
670
+   Checks if the Request URI has an “alias” parameter and if so, removes
671
+   it and sets the “$du” based on its value. Note that this means that
672
+   routing of request is based on “;alias” parameter value of the Request
673
+   URI rather than the Request URI itself. If you call handle_ruri_alias()
674
+   on a request, make sure that you screen the alias parameter value of
675
+   Request URI the same way as you would screen the Request URI itself.
676
+
677
+   Returns 1 if “;alias” parameter was found and “$du” was set and the
678
+   “$ru” rewritten, 2 if the alias parameter was not found and nothing was
679
+   done, or -1 in case of error.
680
+
681
+   This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, and
682
+   LOCAL_ROUTE.
683
+
684
+   Example 1.24. handle_ruri_alias usage
685
+...
686
+    if ($du == "") {
687
+        handle_ruri_alias();
688
+        switch ($rc) {
689
+        case -1:
690
+            xlog("L_ERR", "Failed to handle alias of R-URI $ru\n");
691
+            send_reply("400", "Bad request");
692
+            exit;
693
+        case 1:
694
+            xlog("L_INFO", "Routing in-dialog $rm from $fu to $du\n");
695
+            break;
696
+        case 2:
697
+            xlog("L_INFO", "Routing in-dialog $rm from $fu to $ru\n");
698
+            break;
699
+         };
700
+    };
701
+...
702
+
703
+5.9.  set_contact_alias()
704
+
705
+   Adds an “;alias=ip~port~transport” parameter to the contact URI
706
+   containing the received ip, port, and transport protocol. The new
707
+   contact URI is immediately visible to other modules in the way the
708
+   fix_nated_contact() does it.
709
+
710
+   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
711
+   BRANCH_ROUTE, and FAILURE_ROUTE.
712
+
713
+   Example 1.25. set_contact_alias usage
714
+...
715
+    if (!is_present_hf("Record-Route")) {
716
+        if (!set_contact_alias()) {
717
+            xlog("L_ERR", "Error in aliasing contact $ct\n");
718
+            send_reply("400", "Bad request");
719
+            exit;
720
+        };
721
+    };
722
+...
723
+
724
+5.10.  set_alias_to_pv(target_avp)
725
+
726
+   Reads “;alias=ip~port~transport” from Contact header then writes to
727
+   target pseudo-variable as a sip uri.
728
+
729
+   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
730
+   BRANCH_ROUTE, and FAILURE_ROUTE.
731
+
732
+   Example 1.26. set_alias_to_pv usage
733
+...
734
+                set_alias_to_pv("$avp(aliasuri)");
735
+...
736
+
737
+6. Exported Pseudo Variables
738
+
739
+   6.1. $rr_count
740
+   6.2. $rr_top_count
741
+
742
+6.1. $rr_count
743
+
744
+   Number of Record Routes in received SIP request or reply.
745
+
746
+   Example 1.27. $rr_count usage
747
+...
748
+    $avp(rr_count) = $rr_count;
749
+...
750
+
751
+6.2. $rr_top_count
752
+
753
+   If topmost Record Route in received SIP request or reply is a double
754
+   Record Route, value of $rr_top_count is 2. If it a single Record Route,
755
+   value of $rr_top_count is 1. If there is no Record Route(s), value of
756
+   $rr_top_count is 0.
757
+
758
+   Example 1.28. $rr_top_count usage
759
+...
760
+    if ($rr_count == $avp(rr_count) + $rr_top_count) {
761
+        route(ADD_CONTACT_ALIAS);
762
+    };
763
+...
764
+
765
+7. RPC Commands
766
+
767
+   7.1. nathelper.enable_ping
768
+
769
+7.1. nathelper.enable_ping
770
+
771
+   Enables natping if parameter value different than 0. Disables natping
772
+   if parameter value is 0.
773
+
774
+   The function takes only one parameter - a number in decimal format.
775
+
776
+   Example 1.29. nathelper.enable_ping usage
777
+...
778
+$ kamcmd nathelper.enable_ping 1
779
+...
780
+
781
+8. Selects
782
+
783
+   8.1. @nathelper.rewrite_contact[n]
784
+
785
+8.1. @nathelper.rewrite_contact[n]
786
+
787
+   Get n-th Contact value with IP:Port rewritten to source ip:port. N is
788
+   counted from 1. Only IP:port is rewritten, remaining part are left
789
+   unchanged. Full nameaddr is supported.
790
+
791
+   Example 1.30. @nathelper.rewrite_contact usage
792
+...
793
+$c = @nathelper.rewrite_contact[1];
794
+...
795
+$c2 = @nathelper.rewrite_contact[1].nameaddr.uri;
796
+
797
+Chapter 2. Frequently Asked Questions
798
+
799
+   2.1. What happened with “rtpproxy_disable” parameter?
800
+   2.2. Where can I find more about Kamailio?
801
+   2.3. Where can I post a question about this module?
802
+   2.4. How can I report a bug?
803
+
804
+   2.1.
805
+
806
+   What happened with “rtpproxy_disable” parameter?
807
+
808
+   It was removed as it became obsolete - now “rtpproxy_sock” can take
809
+   empty value to disable the rtpproxy functionality.
810
+
811
+   2.2.
812
+
813
+   Where can I find more about Kamailio?
814
+
815
+   Take a look at https://www.kamailio.org/.
816
+
817
+   2.3.
818
+
819
+   Where can I post a question about this module?
820
+
821
+   First at all check if your question was already answered on one of our
822
+   mailing lists:
823
+     * User Mailing List -
824
+       https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
825
+     * Developer Mailing List -
826
+       https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
827
+
828
+   E-mails regarding any stable Kamailio release should be sent to
829
+   <sr-users@lists.kamailio.org> and e-mails regarding development
830
+   versions should be sent to <sr-dev@lists.kamailio.org>.
831
+
832
+   2.4.
833
+
834
+   How can I report a bug?
835
+
836
+   Please follow the guidelines provided at:
837
+   https://github.com/kamailio/kamailio/issues.