[Freeswitch-users] mod_lcr

Chris Graham chrisg.lists at gmail.com
Mon May 16 19:14:14 MSD 2011


Hi All,
I am having an issue with mod_lcr, when I query from the CLI it
returns the expected values as per:

freeswitch at internal> lcr 0112341234 peak
 | Digit Match | Carrier | Rate     | Codec | CID Regexp | Limit |
Dialstring
       |
 | 011         | Telkom  | 0.32000  |       |            |       |
[lcr_carrier=Telkom,lcr_rate=0.32000]sofia/gateway/pp-ast-trunk-01/0112341234
|
freeswitch at internal> 2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:1687
data passed to lcr is [0112341234 peak]
2011-05-16 17:06:19.847934 [WARNING] mod_lcr.c:1731 Using default CID
[18005551212]
2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:836 Has NPA NXX: [1 == 1]
2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:771 0112341234 doesn't
appear to be a NANP number
2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:852 intra routing
[state:0 lata:0] so rate field is [rate]
2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:872 we have an event
2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:896 SQL:  SELECT l.digits
AS lcr_digits, c.carrier_name AS lcr_carrier_name, l.rate AS
lcr_rate_field, cg.prefix AS lcr_gw_prefix, cg.suffix AS
lcr_gw_suffix, l.lead_strip AS lcr_lead_strip, l.trail_strip AS
lcr_trail_strip, l.prefix AS lcr_prefix, l.suffix AS lcr_suffix,
cg.codec AS lcr_codec, l.cid AS lcr_cid FROM lcr l JOIN carriers c ON
l.carrier_id=c.id JOIN carrier_gateway cg ON c.id=cg.carrier_id WHERE
c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND digits IN
(0112341234, 011234123, 01123412, 0112341, 011234, 01123, 0112, 011,
01, 0) AND CURRENT_TIMESTAMP BETWEEN date_start AND date_end ORDER BY
digits DESC,  rate,  quality DESC,  reliability DESC, rand();
2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:337 Returning Dialstring
[lcr_carrier=Telkom,lcr_rate=0.32000]sofia/gateway/pp-ast-trunk-01/0112341234
2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:664 Adding Telkom to head of list
2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:337 Returning Dialstring
[lcr_carrier=Neotel,lcr_rate=0.32000]sofia/gateway/pp-ast-trunk-01/0112341234
2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:682 Ignoring Duplicate
route for termination point (sofia/gateway/pp-ast-trunk-01/:)
2011-05-16 17:06:19.847934 [DEBUG] mod_lcr.c:337 Returning Dialstring
[lcr_carrier=Telkom,lcr_rate=0.32000]sofia/gateway/pp-ast-trunk-01/0112341234


When calling from the dialplan, it fails with:

2011-05-16 17:08:33.100261 [DEBUG] mod_lcr.c:1563 intrastate channel
var is [undef]
2011-05-16 17:08:33.100261 [DEBUG] mod_lcr.c:1566 Select routes based
on interstate rates
2011-05-16 17:08:33.100261 [DEBUG] mod_lcr.c:1585 LCR Lookup on $1
using profile peak
2011-05-16 17:08:33.100261 [DEBUG] mod_lcr.c:836 Has NPA NXX: [1 == 1]
2011-05-16 17:08:33.100261 [DEBUG] mod_lcr.c:771 $1 doesn't appear to
be a NANP number
2011-05-16 17:08:33.100261 [DEBUG] mod_lcr.c:852 intra routing
[state:0 lata:0] so rate field is [rate]
2011-05-16 17:08:33.100261 [DEBUG] mod_lcr.c:857 we have a session
2011-05-16 17:08:33.100261 [DEBUG] mod_lcr.c:896 SQL:  SELECT l.digits
AS lcr_digits, c.carrier_name AS lcr_carrier_name, l.rate AS
lcr_rate_field, cg.prefix AS lcr_gw_prefix, cg.suffix AS
lcr_gw_suffix, l.lead_strip AS lcr_lead_strip, l.trail_strip AS
lcr_trail_strip, l.prefix AS lcr_prefix, l.suffix AS lcr_suffix,
cg.codec AS lcr_codec, l.cid AS lcr_cid FROM lcr l JOIN carriers c ON
l.carrier_id=c.id JOIN carrier_gateway cg ON c.id=cg.carrier_id WHERE
c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND digits IN
(1) AND CURRENT_TIMESTAMP BETWEEN date_start AND date_end ORDER BY
digits DESC,  rate,  quality DESC,  reliability DESC, rand();
EXECUTE sofia/internal/1000 at 192.168.16.136 bridge()
2011-05-16 17:08:33.100261 [NOTICE] switch_core_state_machine.c:189
sofia/internal/1000 at 192.168.16.136 has executed the last dialplan
instruction, hanging up.


The xml entry called:

        <extension name="Test">
                <condition field="destination_number" expression="^0112341234$">
                        <action application="lcr" data="$1 peak"/>
                        <action application="bridge" data="${lcr_auto_route}"/>
                </condition>
        </extension>


My custom query:

        <profile name="peak">
                <param name="custom_sql" value="
SELECT l.digits AS lcr_digits, c.carrier_name AS lcr_carrier_name,
l.rate AS lcr_rate_field, cg.prefix AS lcr_gw_prefix, cg.suffix AS
lcr_gw_suffix, l.lead_strip AS lcr_lead_strip, l.trail_strip AS
lcr_trail_strip, l.prefix AS lcr_prefix, l.suffix AS lcr_suffix,
cg.codec AS lcr_codec, l.cid AS lcr_cid FROM lcr l JOIN carriers c ON
l.carrier_id=c.id JOIN carrier_gateway cg ON c.id=cg.carrier_id WHERE
c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND digits IN
(${lcr_query_expanded_digits}) AND CURRENT_TIMESTAMP BETWEEN
date_start AND date_end ORDER BY digits DESC,  rate,  quality DESC,
reliability DESC, rand();
"/>
        </profile>

Thanks in advance,
Chris



More information about the FreeSWITCH-users mailing list