1
votes

I am working what appears to be a simple function for opensips 2.2.3, however cannot seem to get it working..

Essentially, extract the groupID from permissions module and add a prefix to R-URI on the egress side.

https://www.opensips.org/Documentation/Script-CoreFunctions-2-2#toc26

http://www.opensips.org/html/docs/modules/2.2.x/permissions.html#idp5689232

Config route looks like this:

    route[relay] {

    if ( get_source_group("$avp(group)") ) {
            # do something with $avp(group)
            xlog("group is $avp(group)\n");

    };

    #Add the string parameter in front of username in R-URI.
    #prefix("$avp(group)");
    #prefix("$avp(group){s.substr,0,0}");

    $avp(22) = "3333#";
    prefix("$avp(22)");

Prefix core function prefixes R-URI with variable name ($avp(22)) instead of value of "3333#". I have tried various syntax versions that are commented out, however to no avail..

If I remove the quotes around the variable name: prefix($avp(22));

Opensips does not startup at all, complaining about: syntax error and bad argument, string expected

Am I missing something simple? or prefix function is simply not designed to work with variables?

Thank you in advance.

1

1 Answers

0
votes

prefix() is somewhat old and unmaintained, hence it does not support variables. However, you can prepend your group to the R-URI username with:

$rU = $avp(group) + $rU;
xlog("My new R-URI is $ru.  My new R-URI username is $rU\n");