User Tools

Site Tools


tutorials:faq:main

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
tutorials:faq:main [2018/05/08 08:30]
miconda [SIP Message Processing]
tutorials:faq:main [2021/08/27 08:02]
miconda [Media Streams]
Line 51: Line 51:
 But note that many global parameters can be changed via RPC/MI commands without restart (e.g., TCP connecting timeout, debug level). Applying changes related to loaded modules or routing block require always a restart. But note that many global parameters can be changed via RPC/MI commands without restart (e.g., TCP connecting timeout, debug level). Applying changes related to loaded modules or routing block require always a restart.
  
-If you use a KEMI scripting language (Lua, Python, JavaScript, Squirrel), then you can reload the routing logic script without restarting Kamailio by issuing an RPC command (see KEMI interpreter modules documentation for more details: app_lua, app_python, app_python3, app_jsdt, app_sqlang).+If you use a KEMI scripting language (Lua, Python, JavaScript, Ruby, Squirrel), then you can reload the routing logic script without restarting Kamailio by issuing an RPC command (see KEMI interpreter modules documentation for more details: app_lua, app_python, app_python3, app_jsdt, app_ruby, app_sqlang).
  
 ??? What is the license of Kamailio? ??? What is the license of Kamailio?
  
-!!! Kamailio is an open source application licensed under GNU Public License version 2 (aka GPLv2). It can be used for free "as in beer".+!!! Kamailio is an open source application licensed under GNU Public License version 2 (aka GPLv2). It can be used for free "as in beer" on your infrastructure. Keep in mind that you need also distribute the source code of your changes, if you distribute it as a binary to your customer. For more information have a look to the [[https://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.html.en|GPLv2 FAQ]].
  
 Starting with end of 2008, contributions to core and several modules are done under BSD license. That means parts of it can be extracted and used under BSD license terms. But over all, when used as one application, the use must follow the terms of GPLv2, because GPLv2 is viral.  Starting with end of 2008, contributions to core and several modules are done under BSD license. That means parts of it can be extracted and used under BSD license terms. But over all, when used as one application, the use must follow the terms of GPLv2, because GPLv2 is viral. 
Line 167: Line 167:
   * without applying changes   * without applying changes
  
-<code>+<code c>
 append_hf("X-Hdr: xyz\r\n"); append_hf("X-Hdr: xyz\r\n");
  
Line 179: Line 179:
   * with applying changes   * with applying changes
  
-<code>+<code c>
 append_hf("X-Hdr: xyz\r\n"); append_hf("X-Hdr: xyz\r\n");
  
Line 191: Line 191:
 </code> </code>
  
 +??? Why parts of From/To header appear many times?
 +
 +!!! After doing header management operations, it can result that parts of From/To header are duplicated or the result is the concatenation of many values. That is related to previous question, because the changes are not applied immediately and updates to parts of headers are not a simple set operation.
 +
 +For example, if From username is "alice" and the operations in the config file are:
 +
 +<code c>
 +$fU = "bob";
 +...
 +$fU = "carol";
 +</code>
 +
 +The result can be that From username is "bobcarol".
 +
 +One solution is to use **msg_apply_changes()** in between:
 +
 +<code c>
 +$fU = "bob";
 +msg_apply_changes();
 +...
 +$fU = "carol";
 +</code>
 +
 +Another solution is to keep the value in a variable (e.g., avp or xavp) and do the operation only once, like:
 +
 +<code c>
 +$xavp(fuser) = "bob";
 +...
 +$xavp(fuser[0]) = "carol";
 +...
 +$fU = $xavp(fuser);
 +</code>
 +
 +Updating From/To headers is recommended to be done in **branch_route**, specially if it is needed to have different value for outgoing branches.
 +
 +The examples above were with assignments to $fU (can be other vars as well, such as $fu, $tU, $tu, ..), but it is the same behaviour when using functions such as uac_replace_from() or uac_replace_to().
  
 ??? How to set different header values for each destination of a SIP request? ??? How to set different header values for each destination of a SIP request?
Line 203: Line 239:
   * add X-Peer-ID header when sending somewhere else   * add X-Peer-ID header when sending somewhere else
  
-<code>+<code c>
 request_route { request_route {
   ...   ...
Line 246: Line 282:
 </code> </code>
  
-Results in From header having the URI: "sip:test1@kamailio.orgsip:test2@kamailio.org". Again, use branch_route to do the operations if you need different From header for outgoing branches.+Results in From header having the URI: **sip:test1@kamailio.orgsip:test2@kamailio.org**. Again, use branch_route to do the operations if you need different From header for outgoing branches.
  
  
Line 324: Line 360:
  
 !!! No, //however// Kamailio can be configured to proxy media if needed.  !!! No, //however// Kamailio can be configured to proxy media if needed. 
-  * [[http://www.kamailio.org/docs/modules/stable/|See rtpproxy, iptrtpproxyand mediaproxy]]+  * [[http://www.kamailio.org/docs/modules/stable/|See rtpengine, rtpproxy, lrkproxyor mediaproxy]]
  
 ??? What codecs are supported by Kamailio? ??? What codecs are supported by Kamailio?
Line 516: Line 552:
 ??? How to iterate through the items in a comma separated string? ??? How to iterate through the items in a comma separated string?
  
-!!! If you have a variable holding a string like "a,b,c,d" and want to get each character separately, you have to use a WHILE loop and {s.select,index,separator} transformationIf there is no value at the given index, then the transformation will return $nullthus you have to use a variable as index, incrementing it until you get a $null.+!!! If you have a variable holding a string like "a,b,c,d" and want to get each character separately, you have to use a WHILE loop with {s.count,separator} and {s.select,index,separator} transformations.
  
 Here is an example: Here is an example:
Line 523: Line 559:
 $var(x) = "a,b,c,d"; $var(x) = "a,b,c,d";
 $var(i) = 0; $var(i) = 0;
 +$var(n) = $(var(x){s.count,,});
  
-while( $(var(x){s.select,$var(i),,})!=$null ) {+while( $var(i<= $var(n) ) {
    xlog("token at position $var(i) is: $(var(x){s.select,$var(i),,})\n");    xlog("token at position $var(i) is: $(var(x){s.select,$var(i),,})\n");
    $var(i) = $var(i) + 1;    $var(i) = $var(i) + 1;
Line 569: Line 606:
  
 However, if return code is 0, the next action after function() is not executed. It can be used only of positive or negative response code. However, if return code is 0, the next action after function() is not executed. It can be used only of positive or negative response code.
 +
 +On the other hand, the pseudo-variables (including $rc) have to be compared as an integer, the rules for evaluating return code of the functions do not apply, for example:
 +
 +<code c>
 +$var(x) = 0;
 +if($var(x) == 0) {
 +  # do something
 +}
 +</code>
 +
 +To compare the return code of a function with a number is recommended to use the value stored in $rc, because the priority of the operators can convert function return code to internal-true or internal-false. Therefore the next approach should be used:
 +
 +<code c>
 +function_returns_four();
 +$var(rc4) = $rc;
 +if($var(rc4)==4) {
 +   # it goes here
 +} else {
 +   # it doesn't go here
 +}
 +...
 +function_returns_two();
 +$var(rc2) = $rc;
 +if($var(rc4)==$var(rc2)) {
 +   # it doesn't go here
 +} else {
 +   # it goes here
 +}
 +...
 +if (function_returns_four() && $rc ieq 6 ) {
 +   # it doesn't go here
 +} else if ($rc ieq 4) {
 +   # it goes here
 +} else {
 +   # it doesn't go here
 +}
 +</code>
 +
 +Note that $rc is overwritten by a new function call, therefore store its value in another variable (like $var(...)) if it is needed for longer time.
 +
 +For pseudo-variables, the non-zero value is evaluated to true and zero to false, for example:
 +
 +<code c>
 +$var(x) = 1;
 +if($var(x)) {
 +  # do something
 +}
 +</code>
  
 ??? How is the SIP request retransmission handled? ??? How is the SIP request retransmission handled?
tutorials/faq/main.txt ยท Last modified: 2021/08/27 08:11 by miconda