[Serusers] Juha: LCR Module Change

Java Rockx javarockx at gmail.com
Sun Feb 20 04:41:09 CET 2005


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 at 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




More information about the sr-users mailing list