[SR-Users] Kamailio config file String Concatenation

Alex Balashov abalashov at evaristesys.com
Wed May 2 17:05:40 CEST 2018


You are correct that concatenation vs interpolation works and doesn't work in slightly inconsistent ways, for instance function string arguments vs assignment.

The $_s() transformation may help make life easier. 

On May 2, 2018 10:50:53 AM EDT, George Diamantopoulos <georgediam at gmail.com> wrote:
>Hello,
>
>I'm a a bit confused as to when string concatenation will work in
>kamailio
>config file. So far I have identified the following cases:
>
>Working:
>
>As part of the right hand side of an assignment:
>$var(x) = "string1" + "string2";
>
>String argument of some functions:
>xlog("L_ERR", "string1" + "string2" + DEFINED_STRING + '\n');
>
>Conditional Statements:
>if ( ru =~ "$" + "sip:" + $var(user) ) {
>
>Not Working:
>
>In string transformations (the fact that quotes is not part of the
>argument
>should give a hint though:
>$var(x) = $(var(y){s.replace,match,"repl1" + "repl2"});
>
>String argument of some other functions:
>append_hf_value("P-Asserted-Identity", "<" + "$var(new_pai)" + ">");
>lookup("location", "sip:$var(username)@" + SIP_REALM_DEFINITION));
>
>In module parameter definitions:
>modparam("nathelper", "sipping_from", "sip:keepalive@" +
>SIP_REALM_DEFINITION)
>
>So far, I have found this to be fairly consistent, except for use
>within
>functions. For example, string concatenation works for the second
>argument
>of xlog, but not for the string arguments of append_hf_value() or
>lookup().
>
>Is there anyway to know this for each function beforehand, or is my
>only
>choice to go through trial and error here? Thanks!
>
>BR,
>George


-- Alex

--
Sent via mobile, please forgive typos and brevity. 



More information about the sr-users mailing list