[OpenSIPS-Users] my problems getting dialplan to work

Brett Nemeroff brett at nemeroff.com
Tue Jun 16 02:45:48 CEST 2009


You know, first time I used the "fantastic" dialplan module it didn't work..
When I went back and did a select * from dialplan, I noticed that what was
IN the table wasn't anything like what I put into the table.
Seems that because of all the crazy PCRE symbols, there was quite a bit of
escaping that needed to be done for it to get into the table properly. So,
try that.. check the actual contents in the table and see if it's what is
expected..


On Mon, Jun 15, 2009 at 7:27 PM, Bogdan-Andrei Iancu <bogdan at voice-system.ro
> wrote:

> 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.+) |
> \1 at 10.47.19.24 | 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:061111 at 10.47.19.24 <sip%3A061111 at 10.47.19.24>
> -------------sip:061111 at 10.47.19.24 <sip%3A061111 at 10.47.19.24>
>
> 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.+)
> > 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<sip%3A061111 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.
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.opensips.org
> > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> >
> >
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.opensips.org/pipermail/users/attachments/20090615/c94ab817/attachment.htm 


More information about the Users mailing list