Hi,

Thanks but I tried that and whatever I tried I could not get it to
work. I don't know whether I have misunderstood what you meant?


With this setup:
+------+----+----------+----------------+-------------+-------------+-------------+
| dpid | pr | match_op | match_exp      | match_flags | subst_exp   | repl_exp  
  |
+------+----+----------+----------------+-------------+-------------+-------------+
|  100 |  1 |        1 | (;user=phone)? |           1 | ;user=phone | 
;user=phone |
+------+----+----------+----------------+-------------+-------------+-------------+

I got this:

# opensips-cli -x mi dp_reload
"OK"
# opensips-cli -x mi dp_translate 100 "+12...@sip.com;food=beans"
ERROR: command 'dp_translate' returned: 404: No translation
# opensips-cli -x mi dp_translate 100 "+12...@sip.com;user=phone"
{
    "Output": ";user=phone",
    "ATTRIBUTES": ""
}


and with this setup:

+------+----+----------+----------------+-------------+----------------+-------------+
| dpid | pr | match_op | match_exp      | match_flags | subst_exp      | 
repl_exp    |
+------+----+----------+----------------+-------------+----------------+-------------+
|  100 |  1 |        1 | (;user=phone)? |           1 | (;user=phone)? | 
;user=phone |
+------+----+----------+----------------+-------------+----------------+-------------+

I got this:

# opensips-cli -x mi dp_reload
"OK"
# opensips-cli -x mi dp_translate 100 "+12...@sip.com;food=beans"
{
    "Output": ";user=phone",
    "ATTRIBUTES": ""
}
# opensips-cli -x mi dp_translate 100 "+12...@sip.com;user=phone"
{
    "Output": ";user=phone",
    "ATTRIBUTES": ""
}

but also realised that if it had matched, I would have no control over
where in the URI it would have added the extra text, so I'm wondering
that my two rule approach is perhaps the best way for what I'm doing
anyway.

Cheers,
Kingsley.

On Wed, 2021-04-21 at 12:47 +0300, Bogdan-Andrei Iancu wrote:
> Hi Kingsley,
> 
> You could try with a single rule, like optional matching the param (like 
> "(;user=phone)?") and in subst + repl part do not include the param 
> inside the \1 parenthesis, having it added all the time in the repl part.
> 
> Still you need a more complex matching if you have multiple params, not 
> only the "user" one.
> 
> Regards,
> 
> Bogdan-Andrei Iancu
> 
> OpenSIPS Founder and Developer
>    https://www.opensips-solutions.com
> OpenSIPS Bootcamp 2021 online
>    https://opensips.org/training/OpenSIPS_eBootcamp_2021/
> 
> On 4/20/21 8:16 PM, Kingsley Tart wrote:
> > Hi,
> > 
> > I want a DP ruleset to ensure that ";user=phone" is in the SIP URI,
> > ie
> > if it is not there, add it, but if it is already there, do nothing.
> > 
> > I've managed to do this with two lines, but is there a more
> > efficient
> > way?
> > 
> > This is what I have in the dialplan table in this ruleset?
> > 
> > +----+----------+-------------+-------------+-----------+--------
> > -------+
> > > pr | match_op | match_exp   | match_flags | subst_exp |
> > > repl_exp      |
> > 
> > +----+----------+-------------+-------------+-----------+--------
> > -------+
> > >  1 |        1 | ;user=phone |           1 | (.+)      |
> > > \1            |
> > >  2 |        1 | .           |           1 | (.+)      |
> > > \1;user=phone |
> > 
> > +----+----------+-------------+-------------+-----------+--------
> > -------+
> > 
> 
> 


_______________________________________________
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to