tutorials:faq:main
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:faq:main [2018/05/08 06:23] – [General] miconda | tutorials:faq:main [2021/08/27 06:11] (current) – [SIP Message Processing] miconda | ||
---|---|---|---|
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, | + | 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, |
??? 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" |
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, | 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, | ||
Line 167: | Line 167: | ||
* without applying changes | * without applying changes | ||
- | < | + | < |
append_hf(" | append_hf(" | ||
Line 179: | Line 179: | ||
* with applying changes | * with applying changes | ||
- | < | + | < |
append_hf(" | append_hf(" | ||
Line 191: | Line 191: | ||
</ | </ | ||
+ | ??? 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 " | ||
+ | |||
+ | <code c> | ||
+ | $fU = " | ||
+ | ... | ||
+ | $fU = " | ||
+ | </ | ||
+ | |||
+ | The result can be that From username is " | ||
+ | |||
+ | One solution is to use **msg_apply_changes()** in between: | ||
+ | |||
+ | <code c> | ||
+ | $fU = " | ||
+ | msg_apply_changes(); | ||
+ | ... | ||
+ | $fU = " | ||
+ | </ | ||
+ | |||
+ | 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) = " | ||
+ | ... | ||
+ | $xavp(fuser[0]) = " | ||
+ | ... | ||
+ | $fU = $xavp(fuser); | ||
+ | </ | ||
+ | |||
+ | Updating From/To headers is recommended to be done in **branch_route**, | ||
+ | |||
+ | 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(). | ||
+ | |||
+ | ??? Why body or other parts of the SIP message appear multiple times? | ||
+ | |||
+ | !!! It is practically the same reason as for multiple From/To parts. | ||
+ | |||
+ | The configuration file does an operation that changes parts in the headers or body many times. For example, if the body has two concatenated IP addresses for media stream, then likely the rtpproxy function is used twice, or, if the SDP appears two time, then the rtpengine function is used two times. | ||
+ | |||
+ | If the update has to be done many times, use **msg_apply_changes()** in between, otherwise refactor the config to perform the operation only once (e.g., the RTP relaying functions should be used in a branch_route block). | ||
??? 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 247: | ||
* add X-Peer-ID header when sending somewhere else | * add X-Peer-ID header when sending somewhere else | ||
- | < | + | < |
request_route { | request_route { | ||
... | ... | ||
Line 234: | Line 278: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | Very important is also to be aware that doing same operation many times in request_route is not overwriting the previous value, but combines them. For example, if you do two times uac_replace_from(), | ||
+ | |||
+ | <code c> | ||
+ | request_route { | ||
+ | ... | ||
+ | uac_replace_from(" | ||
+ | uac_replace_from(" | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Results in From header having the URI: **sip: | ||
+ | |||
??? How to remove a single header field when a header appears multiple times? | ??? How to remove a single header field when a header appears multiple times? | ||
Line 310: | Line 368: | ||
!!! No, //however// Kamailio can be configured to proxy media if needed. | !!! No, //however// Kamailio can be configured to proxy media if needed. | ||
- | * [[http:// | + | * [[http:// |
??? What codecs are supported by Kamailio? | ??? What codecs are supported by Kamailio? | ||
Line 502: | Line 560: | ||
??? 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 " | + | !!! If you have a variable holding a string like " |
Here is an example: | Here is an example: | ||
Line 509: | Line 567: | ||
$var(x) = " | $var(x) = " | ||
$var(i) = 0; | $var(i) = 0; | ||
+ | $var(n) = $(var(x){s.count,, | ||
- | while( $(var(x){s.select,$var(i),, | + | while( $var(i) <= $var(n) ) { |
| | ||
| | ||
Line 555: | Line 614: | ||
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 | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 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' | ||
+ | } | ||
+ | ... | ||
+ | function_returns_two(); | ||
+ | $var(rc2) = $rc; | ||
+ | if($var(rc4)==$var(rc2)) { | ||
+ | # it doesn' | ||
+ | } else { | ||
+ | # it goes here | ||
+ | } | ||
+ | ... | ||
+ | if (function_returns_four() && $rc ieq 6 ) { | ||
+ | # it doesn' | ||
+ | } else if ($rc ieq 4) { | ||
+ | # it goes here | ||
+ | } else { | ||
+ | # it doesn' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | 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, | ||
+ | |||
+ | <code c> | ||
+ | $var(x) = 1; | ||
+ | if($var(x)) { | ||
+ | # do something | ||
+ | } | ||
+ | </ | ||
??? How is the SIP request retransmission handled? | ??? How is the SIP request retransmission handled? |
tutorials/faq/main.1525760630.txt.gz · Last modified: 2018/05/08 06:23 by miconda