[OpenSIPS-Users] my problems getting dialplan to work

Bradley, Todd todd.bradley at Polycom.com
Mon Jun 15 19:32:59 CEST 2009


Hi, I'm new to openSIPS and am trying to set it up with the dialplan
module, but I've had a couple problems I can't figure out. 
 
The first problem is related to how dp_translate is doing regexp
replacements. I have code like this in my route method: 
 
if (is_method("INVITE")) {
	xlog("To user is: $tu\n");
	xlog("ruri.user is: $ruri.user\n");
	xlog("avp(s:dest) is: $avp(s:dest)\n");
	dp_translate("1", "$tu/$var(tmp)");
	xlog("The variable that came out was $var(tmp)\n");
 	setflag(1); # do accounting 
}
 
And my dialplan DB table has this row for dpid 1: 
match_exp=(^06.+) 
subst_exp=(^06.+) 
repl_exp=\1 at 10.47.19.24 
 
When I send in a SIP INVITE that is to "sip:061111", I expect the
dp_translate to convert this to "sip:061111 at 10.47.19.24". But I just get
"sip:061111" back. Here's the output: 
 
To user is: sip:061111 
ruri.user is: <null> 
avp(s:dest) is: <null> 
Jun 12 13:48:55 [29901] DBG:dialplan:dp_get_ivalue: integer value 
Jun 12 13:48:55 [29901] DBG:dialplan:dp_translate_f: dpid is 2 
Jun 12 13:48:55 [29901] DBG:dialplan:dp_get_svalue: searching 22 
Jun 12 13:48:55 [29901] DBG:dialplan:dp_translate_f: input is sip:061111

Jun 12 13:48:55 [29901] DBG:dialplan:translate: regex operator testing 
Jun 12 13:48:55 [29901] DBG:dialplan:test_match: test string sip:061111
against a pattern (sip:06.+) 
Jun 12 13:48:55 [29901] DBG:dialplan:test_match: test_match:[0]
sip:061111 
Jun 12 13:48:55 [29901] DBG:dialplan:test_match: test_match:[1]
sip:061111 
Jun 12 13:48:55 [29901] DBG:dialplan:translate: found a matching rule
0xb610c1f0: pr 2, match_exp (sip:06.+) 
Jun 12 13:48:55 [29901] DBG:dialplan:test_match: test string sip:061111
against a pattern (sip:06.+) 
Jun 12 13:48:55 [29901] DBG:dialplan:test_match: test_match:[0]
sip:061111 
Jun 12 13:48:55 [29901] DBG:dialplan:test_match: test_match:[1]
sip:061111 
Jun 12 13:48:55 [29901] DBG:dialplan:dp_translate_f: input sip:061111
with dpid 2 => output sip:061111 
The variable that came out was sip:061111 
 
So it looks like \1 is indeed replaced with the part that matches the
regexp, but the rest of my replacement string (the "@10.47.19.24" part)
is ignored. Why is that? What am I doing wrong? 
 
And my second question is this: Once I fix my first mistake, what should
I do to make use of this? The behavior I want is that when the proxy
gets an INVITE to 061111, it fills in the rest of the address and then
routes it along. In this case, it should pass it along to
061111 at 10.47.19.24. 
 
Here's where my newness to openSIPS is coming to light, I think. When I
read the documentation for the dialplan module
(http://www.opensips.org/html/docs/modules/1.5.x/dialplan.html), it has
an example that leads me to believe I should be able to just do this: 
 
dp_translate("2", "$avp(s:dest)/$avp(s:dest)"); 
 
But $avp(s:dest) is null, as you can see from the output above. What
SHOULD I have in my route script to do what I'm trying to do? 
 
 
Thanks, 
Todd. 

ps.  I originally posted this question last week to the OpenSIPS web
forum, but then realized that nobody really reads the forum and all the
action is over here on the users email list.  So sorry for the sort-of
duplication.



More information about the Users mailing list