Juha,
I have two gateways defined in the gw table and a have a few LCR rules in the lcr table. The one lcr entry is a "catch-all" which would be used if all other PSTN gateways failed.
My LCR table looks like this
'prefix','from_uri','grp_id','priority'
'321939','%321251%','1','2'
'407319','%321251%','1','2'
'%','%','2','1'
So if I dial from 3212518888 to 4073195555 then I would think at the gateway in group #1 would be used first and if it failed then the gateway in group #2 would be used.
However when next_gw() is called the following SQL is executed:
SELECT gw.ip_addr, gw.port FROM gw, lcr WHERE 'sip:3212518888@sip.mycompany.com' LIKE lcr.from_uri AND '4073195555' LIKE CONCAT(lcr.prefix, '%') AND lcr.grp_id = gw.grp_id ORDER BY CHAR_LENGTH(lcr.prefix), lcr.priority DESC, RAND()
The ORDER BY clause causes the group #2 gateway to appear first in the result set because '%' sorts before '407319'.
So should this SQL ORDER BY clause be changed to
ORDER BY CHAR_LENGTH(lcr.prefix) DESC, lcr.priority DESC, RAND()
or is there a better way to specify a "catch-all" gateway?
Regards, Paul
Java Rockx writes:
'%','%','2','1'
you didn't read the readme carefully enough. prefix is not pattern, but a prefix. so if you want a catch all rule, you have to have empty prefix, not %.
However when next_gw() is called the following SQL is executed:
SELECT gw.ip_addr, gw.port FROM gw, lcr WHERE 'sip:3212518888@sip.mycompany.com' LIKE lcr.from_uri AND '4073195555' LIKE CONCAT(lcr.prefix, '%') AND lcr.grp_id = gw.grp_id ORDER BY CHAR_LENGTH(lcr.prefix), lcr.priority DESC, RAND()
The ORDER BY clause causes the group #2 gateway to appear first in the result set because '%' sorts before '407319'.
the last gw will appear first in mysql result, but then gws are added to avps and the first will be the last.
-- juha
Thanks for clearing that up. Things make much more sense now :-)
Paul
On Sun, 20 Feb 2005 06:10:47 +0200, Juha Heinanen jh@lohi.tutpro.com wrote:
Java Rockx writes:
'%','%','2','1'
you didn't read the readme carefully enough. prefix is not pattern, but a prefix. so if you want a catch all rule, you have to have empty prefix, not %.
However when next_gw() is called the following SQL is executed:
SELECT gw.ip_addr, gw.port FROM gw, lcr WHERE 'sip:3212518888@sip.mycompany.com' LIKE lcr.from_uri AND '4073195555' LIKE CONCAT(lcr.prefix, '%') AND lcr.grp_id = gw.grp_id ORDER BY CHAR_LENGTH(lcr.prefix), lcr.priority DESC, RAND()
The ORDER BY clause causes the group #2 gateway to appear first in the result set because '%' sorts before '407319'.
the last gw will appear first in mysql result, but then gws are added to avps and the first will be the last.
-- juha