[OpenSER-Users] The best way to allow just a few destinations based on prefix?

Iñaki Baz Castillo ibc at in.ilimit.es
Tue Feb 19 18:42:31 CET 2008


El Tuesday 19 February 2008 18:36:36 Phil D'Amore escribió:
> Hi Iñaki,
>
> It looks like you may have settled on a solution already but I'd like
> to add that carrierroute will do what you are looking for as well with
> a little work, as I do exactly this already.  I have some customers
> that are only allowed to call certain prefixes (more specific than
> entire countries, but same principle).
>
> What you do is create a route tree for every unique situation you
> have, and then add the allowed routes to each tree.  For your example
> it would look something like this (requires openser 1.3):
>
> route_tree table:
>
> id        carrier
> ---       ----------
> 1000    es-uk    (This name could be anything, I just made it up to
> match your prefixes)
>
> carrierroute table:
> id  carrier  scan_prefix  domain   prob  strip  rewrite_host
> rewrite_prefix  rewrite_suffix  comment
> --  ----------  ----------------  ----------   -------  ------
> -----------------     -------------------   ------------------
> --------------
> 0   1000     34              primary   1.0       0    <pstn_gw_ip>
>                                         Spain
> 1   1000     44              primary   1.0       0    <pstn_gw_ip>
>                                         England
>
> The domain is something arbitrary you make up.  I use several domains
> for failover (primary, fail1, fail2, etc) because unlike lcr,
> carrierroute doesn't handle failover gracefully at this time, so I do
> it myself in the script.
>
> In your script, you can select the route tree either by subscriber or
> some other criteria such as the source IP of the call.  To use src ip
> for example you might do something like:
>
> # Load AVPs for the client IP address
> avp_db_load("$si", "s/client_avps");
>
> # This assumes the route tree name is indicated in $avp(s:route_tree)
> # The second arg matches the domain column in carrierroute.
> if(!cr_tree_rewrite_uri("$avp(s:route_tree)", "primary")) {
>     # If the prefix is not 34 or 44, you will fall in here.  Do something
>     # about it like return SIP error, log to acc, etc.
> }
> ###
> # Assume you didn't get here unless there was a prefix match
> ###
> # HEre's a cheap way to do a blackhole route using this stuff.
> # You create a carrierroute entry and instead of a gateway host in the
> rewrite_host
> # column, just us ethe string "blackhole".  Then you can do something like
> this: if($rd == "blackhole") {
>     acc_db_request("403 Blackhole route", "acc");
>     sl_send_reply("403", "Forbidden");
> }
>
> If you are doing it based on the subscriber table, you would follow
> the docs in carrierroute module
> to extend your subscriber schema, and then use cr_user_rewrite_uri
> instead of cr_tree_rewrite_uri passing in the subscriber username and
> domain in SIP URI form, and not worry about loading an avp.
>
> I use this as part of an overall PSTN routing solution that completely
> replaced lcr for me, so I'm mentioning it in case anyone else has a
> similar situation.  In my case, I have a default route tree in
> addition to the restricted ones, that allows calls to anywhere.  YMMV,
> because if you don't need all of carrierroute's power, you might get
> away with a simpler solution.


Thanks a lot for so good info. For now it's enough valid for me the PDT module 
but in a future I will need something as you propose.

Realy thanks a lot ;)



-- 
Iñaki Baz Castillo
ibc at in.ilimit.es




More information about the sr-users mailing list