[OpenSIPS-Users] Routing Based on $si and $Ri
Bogdan-Andrei Iancu
bogdan at opensips.org
Wed Aug 5 12:17:10 CEST 2015
Hi Trevor,
The proper (as syntax) way of doing the lookup should be:
dp_translate("1","$si_$Ri/$var(out)",$avp(foo))
Also, instead of using the attr, you can use directly the repl_exp to
return some value.
In terms of processing and unpacking the returned value, better use
transformations. And to really simplify things, use ';' as separator
rather than ',' (to have a string similar to a list of parameters:
attrs: route=2;forced_socket=41.213.100.200
$var(my_route) = $(avp(foo){param.value,route});
See:
http://www.opensips.org/Documentation/Script-Tran-2-1#toc52
Regards,
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com
On 05.08.2015 12:44, Trevor Steyn wrote:
> Ho Bogdan,
>
> Thanks for this just want to make sure i am doing this the right way
>
> So im my thinking i have the following tables in dialplan
>
> *************************** 1. row ***************************
> id: 6
> dpid: 1
> pr: 1
> match_op: 0
> match_exp: 196.2.97.165_41.213.100.100
> match_flags: 0
> subst_exp:
> repl_exp:
> timerec:
> disabled: 0
> attrs: route=2,forced_socket=41.213.100.200
> *************************** 2. row ***************************
> id: 4
> dpid: 1
> pr: 1
> match_op: 0
> match_exp: 196.2.97.165_41.213.100.200
> match_flags: 0
> subst_exp:
> repl_exp: \2
> timerec:
> disabled: 0
> attrs: route=1,forced_socket=41.213.100.100
>
>
> In my script I will have something like this
>
> if (dp_translate("1",/$si+"_"+$Ri,$avp(foo)) {
> Do some routing
> }
>
> Is this the way you envisioned doing this, Also what is the correct way
> to to get seperate AVP's for the attributes column i have not been able
> to find the answer to this i currently manually get the attributes avp
>
> Lets say my attributes column has the following
> route="1";somethingelse="random"
>
> I currently get the route by using avp_subst like so
> avp_subst("$avp(foo)/$avp(string_custom_route)/",
> '/.*Route=[^"]*"([^"]*).*/\1/');
>
> then i use ///$avp(string_custom_route)/ to route the call, I feel like
> this is not good practice if you could guide me here i would appreciate it
> as i have tried finding examples with no avail.
>
> Regards
> Trevor Steyn
>
> /
> On 05/08/2015 09:50, Bogdan-Andrei Iancu wrote:
>> Hi Trevor,
>>
>> Why not using the dialplan module which allows you do operate with
>> custom data, it does regexp search and caching too.
>>
>> Regards,
>> Bogdan-Andrei Iancu
>> OpenSIPS Founder and Developer
>> http://www.opensips-solutions.com
>> On 04.08.2015 21:32, Trevor Steyn wrote:
>>> Hi All,
>>>
>>> I would like to be able to route calls based on Source IP and
>>> Destination IP (always one of opensips IPs), As usual there are many
>>> ways to skin a cat,
>>> My first thought was to have a table such as the address table but
>>> modify the IP field to a concatenation of $si and $RI
>>>
>>> so you would have a table like this
>>>
>>>
>>> *************************** 1. row ***************************
>>> id: 6
>>> grp: 1
>>> ip: 196.2.97.165_41.213.100.100
>>> mask: 32
>>> port: 0
>>> proto: udp
>>> pattern:
>>> context_info: Route=2;Forced_Socket=41.213.100.200
>>>
>>> So in the route script i would do something like this
>>>
>>> /check_cource_address("1",$si+"_"+$Ri) /
>>>
>>> Obviously i cannot just do this with the permissions module as it
>>> wont accept this in the IP field as it expects a valid IP,
>>> So before i go down that road i was wondering if anyone knows an out
>>> of the box way i can do this without impacting performance, I could
>>> easily use avp_ops for this but as far as i can see it does a db
>>> query for every transaction, this is not something that needs to be
>>> called for every new sip transaction it should be loaded into memory
>>> at startup.
>>>
>>> Your thoughts would be appreciated I would just like to be pointed in
>>> the right (Best possible way to do this) direction.
>>>
>>> Regards
>>> Trevor Steyn
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
More information about the Users
mailing list