Hi Andrea,
We've been testing with your patch and so far no major breaks. Seems to us that only use load_gw("X") the prefix is inserted. And also with load_gw("x") we will have weighted call distribution. Now we would like to have the prefix added to the gateways but not the call distribution. Can you tell us how to configure that?
Thanks
Ray
-----Original Message----- From: serdev-bounces@iptel.org [mailto:serdev-bounces@lists.iptel.org] On Behalf Of Andreas Granig Sent: Tuesday, March 08, 2005 8:25 PM To: 'serdev@lists.iptel.org'; 'serusers@lists.iptel.org' Subject: [Serdev] LCR-module extension for GW prefixes
Hi all,
I've extended Juha's LCR module to support prefixes for gateways. We use it for prefix-based setting of the bearer capability on our gateways.
Note that the attached patch is against Juha's backport for rel_0_9_0 at http://tutpro.com/tmp/lcr-0.9.0.tgz because we've no CVS-HEAD running here.
It works as follows:
In the new table gw_cap you can define capabilities and their corresponding prefix, like:
mysql root@ser> select * from gw_cap; +--------+-----------+------------+----------------------+ | cap_id | cap_value | cap_prefix | cap_description | +--------+-----------+------------+----------------------+ | 1 | 1 | | default phone trunk | | 2 | 1 | 01 | prefixed phone trunk | | 3 | 2 | 02 | prefixed fax trunk | +--------+-----------+------------+----------------------+ 3 rows in set (0.00 sec)
In this case the cap_value of "1" means phone-capabilites, "2" means fax-capabilities.
The table gw_grp is extended with an additional column cap_id.
mysql root@ser> select * from gw_grp; +--------+-------------------------+--------+ | grp_id | grp_name | cap_id | +--------+-------------------------+--------+ | 1 | priority_1_phone | 1 | | 2 | priority_1_phone_prefix | 2 | | 3 | priority_1_fax_prefix | 3 | | 4 | priority_2_phone | 1 | | 5 | priority_2_phone_prefix | 2 | | 6 | priority_3_phone_prefix | 2 | +--------+-------------------------+--------+ 6 rows in set (0.00 sec)
In ser.cfg you can then load the gateways for example like this if you use different gateways/trunks for phone and fax:
if( /* phone call */) { if(!load_gws("1")) { sl_send_reply("500", "Internal server error, unable to load phone gateways"); break; } } else /* fax call */ { if(!load_gws("2")) { sl_send_reply("500", "Internal server error, unable to load fax gateways"); break; } }
The usage of next_gw() is as usual.
Also note that the gateway selection algorithm changes when you use load_gws("x") instead of load_gws(): The latter always selects the gateways with highest priority first. The new one uses the priority value as weight, so also gateways with lower priority are chosen. Hit ratio for 5000 rounds is as follows:
priority-1-gw-1: 35% priority-2-gw-1: 14% priority-2-gw-3: 14% priority-2-gw-2: 14% priority-2-gw-4: 14% priority-3-gw-1: 9%
Looking forward for comments/fixes/improvements, Andy