Module: sip-router Branch: master Commit: 023381eb3eb199eeaa40e59197264977409b5534 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=023381eb...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Wed May 25 23:44:22 2011 +0200
kamailio.cfg: added two new define options
- WITH_BLOCK3XX - block 3xx replies - WITH_VOICEMAIL - redirect call to voicemail server on not found, busy or no answer
---
etc/kamailio.cfg | 81 +++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 62 insertions(+), 19 deletions(-)
diff --git a/etc/kamailio.cfg b/etc/kamailio.cfg index decfd0f..7a545db 100644 --- a/etc/kamailio.cfg +++ b/etc/kamailio.cfg @@ -68,6 +68,14 @@ # block if more than 16 requests in 2 seconds and ban for 300 seconds) # - define WITH_ANTIFLOOD # +# *** To block 3XX redirect replies execute: +# - define WITH_BLOCK3XX +# +# *** To enable VoiceMail routing execute: +# - define WITH_VOICEMAIL +# - set the value of voicemail.srv_ip +# - adjust the value of voicemail.srv_port +# # *** To enhance accounting execute: # - enable mysql # - define WITH_ACCDB @@ -170,6 +178,13 @@ enable_tls=yes pstn.gw_ip = "" desc "PSTN GW Address" #!endif
+#!ifdef WITH_VOICEMAIL +# VoiceMail Routing on offline, busy or no answer +# +# - by default Voicemail server IP is empty to avoid misrouting +voicemail.srv_ip = "" desc "VoiceMail IP Address" +voicemail.srv_port = "5060" desc "VoiceMail Port" +#!endif
####### Modules Section ########
@@ -586,15 +601,18 @@ route[LOCATION] { alias_db_lookup("dbaliases"); #!endif
+ $avp(oexten) = $rU; if (!lookup("location")) { - switch ($rc) { + $var(rc) = $rc; + route(TOVOICEMAIL); + t_newtran(); + switch ($var(rc)) { case -1: case -3: - t_newtran(); - t_reply("404", "Not Found"); + send_reply("404", "Not Found"); exit; case -2: - sl_send_reply("405", "Method Not Allowed"); + send_reply("405", "Method Not Allowed"); exit; } } @@ -784,8 +802,7 @@ route[PSTN] {
# XMLRPC routing #!ifdef WITH_XMLRPC -route[XMLRPC] -{ +route[XMLRPC] { # allow XMLRPC from localhost if ((method=="POST" || method=="GET") && (src_ip==127.0.0.1)) { @@ -802,6 +819,29 @@ route[XMLRPC] } #!endif
+# route to voicemail server +route[TOVOICEMAIL] { +#!ifdef WITH_VOICEMAIL + if(!is_method("INVITE")) + return; + + # check if VoiceMail server IP is defined + if (strempty($sel(cfg_get.voicemail.srv_ip))) { + xlog("SCRIPT: VoiceMail rotuing enabled but IP not defined\n"); + return; + } + if($avp(oexten)==$null) + return; + + $ru = "sip:" + $avp(oexten) + "@" + $sel(cfg_get.voicemail.srv_ip) + + $sel(cfg_get.voicemail.srv_port); + route(RELAY); + exit; +#!endif + + return; +} + # Sample branch router branch_route[BRANCH_ONE] { xdbg("new branch at $ru\n"); @@ -834,17 +874,20 @@ failure_route[FAIL_ONE] { exit; }
- # uncomment the following lines if you want to block client - # redirect based on 3xx replies. - ##if (t_check_status("3[0-9][0-9]")) { - ## t_reply("404","Not found"); - ## exit; - ##} - - # uncomment the following lines if you want to redirect the failed - # calls to a different new destination - ##if (t_check_status("486|408")) { - ## sethostport("192.168.2.100:5060"); - ## t_relay(); - ##} +#!ifdef WITH_BLOCK3XX + # block call redirect based on 3xx replies. + if (t_check_status("3[0-9][0-9]")) { + t_reply("404","Not found"); + exit; + } +#!endif + +#!ifdef WITH_VOICEMAIL + # serial forking + # - route to voicemail on busy or no answer (timeout) + if (t_check_status("486|408")) { + route(TOVOICEMAIL); + exit; + } +#!endif }