Now I have central kamailio server and (asterisk "media" servers + asterisk pstn gateway in different cities).
if (!lookup("location")) {
$var(rc) = $rc;
route(TOVOICEMAIL);
t_newtran();
switch ($var(rc)) {
case -1:
xwarn("Contact $rU not registered. Forwarding call to dispatcher");
append_hf("X-External: true\r\n");
$rU = "00"+$rU;
break;
case -3:
send_reply("404", "Not Found");
exit;
case -2:
send_reply("405", "Method Not Allowed");
exit;
}
}
......
# when routing via usrloc, log the missed calls also
if (is_method("INVITE")) {
setflag(FLT_ACCMISSED);
}
if(!ds_is_from_list()) {
route(DISPATCH);
}
route(RELAY);
So all calls going to asterisk server. Not local calls with 00 prefix.
And asterisk context:
context kamailio {
_X. => {
Noop(CALL to kamailio user ${EXTEN});
Dial(SIP/${EXTEN}@${SIPDOMAIN},60,RTt);
Hangup;
}
_00X. => {
Noop(CALL to external user ${EXTEN});
Dial(SIP/PSTN-SERVER/${EXTEN:2},60,RTt);
Hangup;
}
}
Is it right way? Maybe any better approach? How to keep route logic at kamailio, but use dispatcher asterisk to proccess the calls to pstn(all endpoints at one city to pstn asterisk at this city. In others city there are other pstn gateways)?
--
Aydar A. Kamalov