Hi all,
Need some newbie advice on how to write INVITE routing for my scenario. I
currently have kamailio+asterisk-realtime integration working in the
following way:
Outbound calls:
USER-A -> Kamailio(3.1.3) -> Asterisk(1.6.2.18) ;if dest local then
Asterisk(1.6.2.18) -> Kamailio(3.1.3) -> USER-B ;if dest not local then
Asterisk(1.6.2.18) -> SIP/PSTN
This works, though I'd prefer to use Kamailio + LCR and gateway failover as
Asterisk doesn't do this well.
Here's what I want to do: (for now, small steps)
Outbound Calls:
USER-A -> Kamailio(3.1.3) -> Asterisk(1.6.2.18) ;if dest local then
Asterisk(1.6.2.18) -> Kamailio(3.1.3) -> USER-B ;if dest not local then
Asterisk(1.6.2.18) -> Kamailio(3.1.3)+(lcr) -> SIP/PSTN
I know I have to set kamailio as a GW in asterisk instead of the PSTN GW's
and add the PSTN GW's to kamailio instead, though I'm at a loss as to how to
write the routing logic so that kamailio sends calls from asterisk to PSTN.
route[LOCATION] {
...non-INVITE check ends here...
if(route(FROMASTERISK))
{
# coming from Asterisk --- Does this mean check kamailio
local users first before continuing?
if (!lookup("location")) {
switch ($rc) {
case -1:
case -3:
t_newtran();
t_reply("404", "Not Found");
exit;
case -2:
sl_send_reply("405", "Method Not Allowed");
exit;
}
}
## -- If match 11 digits and starts with '1' or if match 10
digits and starts with [2-9]
if($rU=~"^(1\d{10})$") || if($rU=~"^([2-9]\d{9})$") {
xlog("L_INFO", " FROMASTERISK: This will
become route(NORTHAMERICA); \n");
exit; ## to be removed
} else {
xlog("L_INFO", " FROMASTERISK: This will
become route(INTERNATIONAL); \n");
exit; ## to be removed
}
# new call - send to Asterisk
route(TOASTERISK);
}
Will this logic work? I haven't determined how to write route(NORTHAMERICA)
or route(INTERNATIONAL) yet so I'm just logging to debug the logic and
syntax.
Thanks in advance.