<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style='font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif;color:#000000;'><p>Dear All,<br></p><div><br></div><div>I am working what appears to be a simple function for opensips 2.2.3, however cannot seem to get it working..<br></div><p>Essentially, extract the groupID from permissions module and add a prefix to R-URI on the egress side.<br></p><p><a rel="nofollow noreferrer" href="https://www.opensips.org/Documentation/Script-CoreFunctions-2-2#toc26">https://www.opensips.org/Documentation/Script-CoreFunctions-2-2#toc26</a><br></p><p><a rel="nofollow noreferrer" href="http://www.opensips.org/html/docs/modules/2.2.x/permissions.html#idp5689232">http://www.opensips.org/html/docs/modules/2.2.x/permissions.html#idp5689232</a><br></p><p>Config route looks like this:<br></p><div> route[relay] {<br></div><div><br></div><div> if ( get_source_group("$avp(group)") ) {<br></div><div> # do something with $avp(group)<br></div><div> xlog("group is $avp(group)\n");<br></div><div> <br></div><div> #prefix("$avp(group)");<br></div><div><br></div><div> };<br></div><div><br></div><div> #Add the string parameter in front of username in R-URI.<br></div><div> #prefix("$avp(group)");<br></div><div> #prefix("$avp(group){s.substr,0,0}");<br></div><div><br></div><div> $avp(22) = "3333#";<br></div><div> prefix("$avp(22)");<br></div><p>Prefix core function prefixes R-URI with variable name (<i>$avp(22)</i>) instead of value of "3333#".
I have tried various syntax versions that are commented out, however to no avail..<br></p><p>If I remove the quotes around the variable name:
prefix($avp(22));<br></p><p>Opensips does not startup at all, complaining about:
syntax error and bad argument, string expected<br></p><p><br></p><div><br></div><div>Am I missing something simple?
or
prefix function is simply not designed to work with variables?<br></div><p>Thank you in advance.<br></p><div><br></div></div><br></body></html>