Hi Bradley, I re-made your case with:
mysql> select * from dialplan; +----+------+----+----------+------------+-----------+------------+----------------+-------+ | id | dpid | pr | match_op | match_exp | match_len | subst_exp | repl_exp | attrs | +----+------+----+----------+------------+-----------+------------+----------------+-------+ | 1 | 1 | 0 | 1 | (sip:06.+) | 0 | (sip:06.+) | \[email protected] | 0 | +----+------+----+----------+------------+-----------+------------+----------------+-------+ 1 row in set (0.00 sec) and in script: $var(x) = "sip:061111"; dp_translate("1", "$var(x)/$var(tmp)"); xlog("-------------$var(tmp)\n"); The output was: Jun 16 03:22:34 [7921] DBG:dialplan:dp_get_ivalue: integer value Jun 16 03:22:34 [7921] DBG:dialplan:dp_translate_f: dpid is 1 Jun 16 03:22:34 [7921] DBG:dialplan:dp_get_svalue: searching 78 Jun 16 03:22:34 [7921] DBG:dialplan:dp_translate_f: input is sip:061111 Jun 16 03:22:34 [7921] DBG:dialplan:translate: regex operator testing Jun 16 03:22:34 [7921] DBG:dialplan:test_match: test string sip:061111 against a pattern (sip:06.+) Jun 16 03:22:34 [7921] DBG:dialplan:test_match: test_match:[0] sip:061111 Jun 16 03:22:34 [7921] DBG:dialplan:test_match: test_match:[1] sip:061111 Jun 16 03:22:34 [7921] DBG:dialplan:translate: found a matching rule 0xb56744c0: pr 0, match_exp (sip:06.+) Jun 16 03:22:34 [7921] DBG:dialplan:test_match: test string sip:061111 against a pattern (sip:06.+) Jun 16 03:22:34 [7921] DBG:dialplan:test_match: test_match:[0] sip:061111 Jun 16 03:22:34 [7921] DBG:dialplan:test_match: test_match:[1] sip:061111 Jun 16 03:22:34 [7921] DBG:dialplan:dp_translate_f: input sip:061111 with dpid 1 => output sip:[email protected] -------------sip:[email protected] Which looks pretty ok ... Maybe there is something something in the correct data in DB..... Regards, Bogdan Bradley, Todd wrote: > 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.+) > [email protected] > > When I send in a SIP INVITE that is to "sip:061111", I expect the > dp_translate to convert this to "sip:[email protected]". 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 > [email protected]. > > 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. > > _______________________________________________ > Users mailing list > [email protected] > http://lists.opensips.org/cgi-bin/mailman/listinfo/users > > _______________________________________________ Users mailing list [email protected] http://lists.opensips.org/cgi-bin/mailman/listinfo/users
