Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uac_replace_XXX() treating input string as a literal some of the time #811

Open
mishehu opened this issue Feb 26, 2016 · 7 comments
Open
Assignees
Milestone

Comments

@mishehu
Copy link

mishehu commented Feb 26, 2016

This affects 2.1.2 hash c846598 running on Centos 6.

If I have the following in my opensips.cfg file:

$var(newTo) = "sip:$rU@$var(someVar)";
uac_replace_to("$var(newTo)");

What I end up with in the actual SIP is a To header that looks like this:

To: "Foo" sip:$rU@$var(someVar)

I spoke with Bogdan briefly about this on IRC, and he confirms that the uac_replace_XXX functions should be feeding the input through pv_printf_s() and it should replace the $rU and the $var(someVar) with their respective values. He said this might be a bug, so here I am. :-)

@mishehu
Copy link
Author

mishehu commented Mar 8, 2016

I'd like to add that running xlog() with the input of "sip:$rU@$var(someVar)" does in fact show up in the logs with the variables both being evaluated properly, such that it will show as:

sip:12345@PLANETDRUIDIA

instead of the behavior that we're seeing in uac_replace_xxx() .

@bogdan-iancu
Copy link
Member

@mishehu , it may be an misunderstanding on how you construct strings from variables.
Instead of
$var(newTo) = "sip:$rU@$var(someVar)";
(where the input is simply evaluated as string)
the correct way (if you want to have variables evaluated is:
$var(newTo) = "sip:"+$rU+"@"+$var(someVar);

Please confirm that the above works for you ; or if there are any other issues.

Regards,
Bogdan

@bogdan-iancu bogdan-iancu self-assigned this Mar 15, 2016
@bogdan-iancu bogdan-iancu added this to the 2.2 milestone Mar 15, 2016
@mishehu
Copy link
Author

mishehu commented Mar 15, 2016

Yes, obviously $var(newTo) = "sip:" + $rU + "@" + $var(someVar); works. Like I was explaining, I need to accommodate patterns that can't be standardized. How does one enter:

"sip:" + $rU + "@" + $var(someVar);
"sip:" + $var(foo) + $var(bar) + "@" + $var(someVar);
...

Into the dialplan database? These values are not known in advance. That's the ultimate goal here.

@bogdan-iancu
Copy link
Member

@mishehu , if I get it right, you want to take this FMT string (like "sip:$rU@$var(someVar)" ) from somewhere (DB, etc) and than use it to evaluate it ; like you load that fmt string from DB and you use it for building the new TO header. Is this correct ?

@mishehu
Copy link
Author

mishehu commented Mar 16, 2016

That is correct. Dialplan module seemed to be the most fitting for what we needed, since we're already making use of dialplan. I didn't see another module that would be able to do this. Any guidance would be appreciated... or perhaps this issue is not a bug but an RFE (request for enhancement) ?

@bogdan-iancu
Copy link
Member

Yes, I guess this is more like a feature request than a bug. Maybe, for generic usage, we can evaluate a new string transformation to evaluate the FMT from a variable.....

@mishehu
Copy link
Author

mishehu commented Mar 18, 2016

That would not be a bad idea. It would possibly be something many other folks would find useful. My time is a bit limited right now, but I will try to see if I can work up a patch for it unless somebody else here finds it equally useful and beats me to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants