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.
Good luck, Phil
On Feb 19, 2008 7:16 AM, Iñaki Baz Castillo ibc@in.ilimit.es wrote:
Hi, which would be the more ellegant way to allow users to call just a few destinations (based on prefix)?
Of course I could do it simply by creating a custom table: "allowed_destinations" with columns:
[int_prefix] [description] 34 Spain 44 England ...
and latter extract the international prefix from the E164 converted RURI and do a SQL query. But I'd like to avoid using avp_db_query() function.
I've reading about PDT, LCR and CarrierRoute modules but they seems to be supposed to other aims. The most similar could be PDT but it needs to strip my prefix XD
What do you suggest? should I implement my custom method for this?
Thanks.
-- Iñaki Baz Castillo ibc@in.ilimit.es
Users mailing list Users@lists.openser.org http://lists.openser.org/cgi-bin/mailman/listinfo/users