<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi everyone<div><br></div><div>For some reason my script always thinks the call is destined for gw type 1, even when it should be type 2. Please can somebody explain why?</div><div>The call does ultimately route to the correct gw so it's just the goes_to_gw() that is misbehaving.</div><div><br></div><div>This is my route:</div><div><br></div><div><div>route[RTPPROXY] {</div><div><br></div><div>        if (is_method("BYE|CANCEL")) {</div><div>                rtpproxy_unforce();</div><div>        }</div><div><br></div><div>        if (is_method("INVITE")) {</div><div>                xlog("Processing INVITE $ru");</div><div>                if (is_from_gw("1")) {</div><div>                        xlog("Outbound Call - Send to 3rd Party...");</div><div>                        setflag(INT_TPTY);</div><div>                } else if (is_from_gw("2")) {</div><div>                        xlog("Inbound Call - Send to 3rd Party...");</div><div>                        setflag(EXT_TPTY);</div><div>                } else if (is_from_gw("3")) {</div><div>                        xlog("Call from 3rd Party. Where is it going?");</div><div>                                if (goes_to_gw("1")) {</div><div>                                        xlog("... to Asterisk");</div><div>                                        setflag(TPTY_INT);</div><div>                                } else if (goes_to_gw("2")) {</div><div>                                        xlog("... to Provider");</div><div>                                        setflag(TPTY_EXT);</div><div>                                }</div><div>                }</div><div><br></div><div>        if (isflagset(INT_TPTY)) {</div><div>                        rtpproxy_offer("corwfei");</div><div>                } else if (isflagset(EXT_TPTY)) {</div><div>                        rtpproxy_offer("corwfii");</div><div>                } else if (isflagset(TPTY_INT)) {</div><div>                        rtpproxy_offer("corfwie");</div><div>                } else if (isflagset(TPTY_EXT)) {</div><div>                        dp_translate("2","$rU/$rU");</div><div>                        xlog("Translated number to $rU");</div><div>                        rtpproxy_offer("corfwii");</div><div>                }</div><div>            }</div><div>}</div><div><br></div><div>This is my routing db:</div><div><br></div><div><div>dr gateways</div><div>+----+--------------+------+-----------------------+-------+------------+---------+------------+-------+--------+-----------------------+</div><div>| id | gwid         | type | address               | strip | pri_prefix | attrs   | probe_mode | state | socket | description           |</div><div>+----+--------------+------+-----------------------+-------+------------+---------+------------+-------+--------+-----------------------+</div><div>|  2 | BT_SDIN_BCTE |    2 | sip:xxx.xxx.xxx.xxx     |     0 | +          | PROVIDER |          2 |     0 |        | PROVIDER1           |</div><div>|  3 | BT_SDIN_GDH  |    2 | sip:xxx.xxx.xxx.xxx     |     0 | +          | PROVIDER |          2 |     0 |        | PROVIDER2    |</div><div>|  1 | BT_SDIN_LFH  |    2 | sip:xxx.xxx.xxx.xxx   |     0 | +          | PROVIDER |          2 |     0 |        | PROVIDER3  |</div><div>|  4 | BT_SDIN_SEH  |    2 | sip:xxx.xxx.xxx.xxx    |     0 | +          | PROVIDER |          2 |     0 |        | PROVIDER4 |</div><div>|  6 | PCIPAL1      |    3 | sip:xxx.xxx.xxx.xxx:3068  |     0 |            | tp      |          2 |     0 |        | 3rd Party                |</div><div>|  7 | PCIPAL2      |    3 | sip:xxx.xxx.xxx.xxx:3068 |     0 |            | tp      |          2 |     0 |        | 3rd Party                |</div><div>|  5 | TESTPBX1     |    1 | sip:xxx.xxx.xxx.xxx        |     5 | 0          | pbx     |          2 |     0 |        | Asterisk PBX          |</div><div>+----+--------------+------+-----------------------+-------+------------+---------+------------+-------+--------+-----------------------+</div><div>dr groups</div><div>dr carriers</div><div>+----+---------------+--------------------------------------------------+-------+-------+-------+----------------------------+</div><div>| id | carrierid     | gwlist                                           | flags | state | attrs | description                |</div><div>+----+---------------+--------------------------------------------------+-------+-------+-------+----------------------------+</div><div>|  1 | BT            | PROVIDER1, PROVIDER2, PROVIDER3, PROVIDER4 |     0 |     0 |       | BT SDIN                    |</div><div>|  3 | PCIPAL        | PCIPAL1,PCIPAL2                                  |     0 |     0 |       | 3rd Party                     |</div><div>|  4 | TestCustomer1 | TESTPBX1                                         |     0 |     0 |       | Test Customer 1 (Asterisk) |</div><div>+----+---------------+--------------------------------------------------+-------+-------+-------+----------------------------+</div><div>dr rules</div><div>+--------+---------+-----------------+---------+----------+---------+----------------+-------+---------------------+</div><div>| ruleid | groupid | prefix          | timerec | priority | routeid | gwlist         | attrs | description         |</div><div>+--------+---------+-----------------+---------+----------+---------+----------------+-------+---------------------+</div><div>|     14 | 0       | 427441423369030 |         |        0 |         | #TestCustomer1 |       | Route to Asterisk   |</div><div>|     19 | 0       | 441423369030    |         |        0 |         | PCIPAL1        |       | PCIPAL              |</div><div>|     29 | 0       | 724             |         |        0 |         | PCIPAL1        |       | PCIPAL              |</div><div>|     30 | 0       | 427             |         |        0 |         | #BT            |       | PCIPAL              |</div><div>|     22 | 1       |                 |         |        0 |         | #BT            |       | Default Route to BT |</div><div>+--------+---------+-----------------+---------+----------+---------+----------------+-------+---------------------+</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Mark Farmer<br><a href="mailto:farmorg@gmail.com" target="_blank">farmorg@gmail.com</a></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>