[OpenSIPS-Users] my problems getting dialplan to work

Bradley, Todd todd.bradley at Polycom.com
Tue Jun 16 17:23:35 CEST 2009


Thanks, Bogdan.  At first I definitely had my repl_exp expression wrong
due to the backslash being interpreted wrong.  But I fixed that and I
think it's right now.  Here's what I get:

mysql> select * from dialplan;
+----+------+----+----------+------------+-----------+------------+-----
-----------+-------+
| id | dpid | pr | match_op | match_exp  | match_len | subst_exp  |
repl_exp       | attrs |
+----+------+----+----------+------------+-----------+------------+-----
-----------+-------+
|  7 |    2 |  2 |        1 | (sip:06.+) |         0 | (sip:06.+) |
\1 at 10.47.19.24 |       |
+----+------+----+----------+------------+-----------+------------+-----
-----------+-------+
1 row in set (0.00 sec)


The only possibly relevant difference I see is that you have a 0 in your
attrs column, where I have a blank.  Otherwise, it looks like
everything's fine, doesn't it?  I couldn't figure out what the attrs
column was for, so I didn't insert anything into it.  According to the
docs, it's a "General attributes string to be returned in case of rule
matching" and it's a string.  Could you help explain what it's for?


Cheers,
Todd.




> -----Original Message-----
> From: users-bounces at lists.opensips.org 
> [mailto:users-bounces at lists.opensips.org] On Behalf Of 
> Bogdan-Andrei Iancu
> Sent: Monday, June 15, 2009 6:28 PM
> To: Bradley, Todd
> Cc: users at lists.opensips.org
> Subject: Re: [OpenSIPS-Users] my problems getting dialplan to work
> 
> 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:061111 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". 
> 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
> 



More information about the Users mailing list