Professional Documents
Culture Documents
2.A�adir
#!define WITH_ASTERISK
...
#!ifndef DBURL
#!ifdef WITH_ASTERISK
#!define DBASTURL "mysql://asterisk:asterisk_password@localhost/asterisk"
#!endif
#!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
...
...
#!ifdef WITH_VOICEMAIL
..
#!endif
#!ifdef WITH_ASTERISK
asterisk.bindip = "192.168.178.25" desc "Asterisk IP Address"
asterisk.bindport = "5080" desc "Asterisk Port"
kamailio.bindip = "192.168.178.25" desc "Kamailio IP Address"
kamailio.bindport = "5060" desc "Kamailio Port"
#!endif
...
#!ifdef WITH_DEBUG
...
#!endif
#!ifdef WITH_ASTERISK
loadmodule "uac.so"
#!endif
...
#!ifdef WITH_ASTERISK
modparam("auth_db", "user_column", "name")
modparam("auth_db", "password_column", "sippasswd")
modparam("auth_db", "db_url", DBASTURL)
modparam("auth_db", "version_table", 0)
#!else
modparam("auth_db", "db_url", DBURL)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "use_domain", MULTIDOMAIN)
#!endif
#!endif
# ----- alias_db params -----
#!ifdef WITH_ASTERISK
route(REGFWD);
#!endif
exit;
}
...
# User location service
route[LOCATION] {
...
#!ifdef WITH_ALIASDB
...
#!endif
#!ifdef WITH_ASTERISK
if(is_method("INVITE") && (!route(FROMASTERISK))) {
# if new call from out there - send to Asterisk
# - non-INVITE request are routed directly by Kamailio
# - traffic from Asterisk is routed also directy by Kamailio
route(TOASTERISK);
exit;
}
#!endif
$avp(oexten) = $rU;
if (!lookup("location")) {
...
#!ifdef WITH_ASTERISK
# do not auth traffic from Asterisk - trusted!
if(route(FROMASTERISK))
return;
#!endif
...
if (is_method("REGISTER") || from_uri==myself)
{
# authenticate requests
#!ifdef WITH_ASTERISK
if (!auth_check("$fd", "sipusers", "1")) {
#!else
if (!auth_check("$fd", "subscriber", "1")) {
#!endif
if (!auth_check("$fd", "subscriber", "1")) {
auth_challenge("$fd", "0");
exit;
}
# user authenticated - remove auth header
if(!is_method("REGISTER|PUBLISH"))
...
route[NATDETECT] {
..
# RTPProxy control and singaling updates for NAT traversal
route[NATMANAGE] {
...
# Routing to foreign domains
route[SIPOUT] {
..
# PSTN GW routing
route[PSTN] {
...
# XMLRPC routing
#!ifdef WITH_XMLRPC
route[XMLRPC] {
...
# Routing to voicemail server
route[TOVOICEMAIL] {
...
#!ifdef WITH_VOICEMAIL
# serial forking
# - route to voicemail on busy or no answer (timeout)
if (t_check_status("486|408")) {
$du = $null;
route(TOVOICEMAIL);
exit;
}
#!endif
}
#!ifdef WITH_ASTERISK
# Test if coming from Asterisk
route[FROMASTERISK] {
if($si==$sel(cfg_get.asterisk.bindip)
&& $sp==$sel(cfg_get.asterisk.bindport))
return 1;
return -1;
}
# Send to Asterisk
route[TOASTERISK] {
$du = "sip:" + $sel(cfg_get.asterisk.bindip) + ":"
+ $sel(cfg_get.asterisk.bindport);
route(RELAY);
exit;
}