From 8594c3ad51c154f7e02afeb4e5c30dc324f79c98 Mon Sep 17 00:00:00 2001 From: lazedo Date: Tue, 24 Feb 2015 19:34:53 +0000 Subject: [PATCH 1/2] KAZOO-3308 call-park redirect in kamailio --- kamailio/default.cfg | 15 +++++++++++++++ kamailio/dispatcher-role.cfg | 16 ++++++++++++++++ kamailio/local.cfg | 1 + 3 files changed, 32 insertions(+) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 0a35470..b4e78b3 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -530,6 +530,14 @@ route[EXTERNAL_TO_INTERNAL_RELAY] } #!endif + #!ifdef CALL-PARK-REDIRECT-ROLE + if(is_method("REFER")) { + $avp(refer_to) = $hdr(Refer-To); + $avp(refer_to_uri) = $rt; + $avp(referred_by) = $hdr(Referred-By); + } + #!endif + remove_hf_re("^X-.*"); append_hf("X-AUTH-IP: $si\r\n"); @@ -578,6 +586,13 @@ onreply_route[INTERNAL_REPLY] setflag(FLAG_SESSION_PROGRESS); } + #!ifdef CALL-PARK-REDIRECT-ROLE + if (is_method("REFER") && $T_reply_code == "202" ) { + $sht(park=>$(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain})) = "sip:" + $(ct{tobody.uri}{uri.host}) + ":" + $(ct{tobody.uri}{uri.port}); + xlog("L_INFO", "PARK $(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain}) = sip:$(ct{tobody.uri}{uri.host}):$(ct{tobody.uri}{uri.port})"); + } + #!endif + if ($rs < 300) { xlog("L_INFO", "$ci|pass|$T_req($si):$T_req($sp)"); } diff --git a/kamailio/dispatcher-role.cfg b/kamailio/dispatcher-role.cfg index d5e99b2..c15bf0f 100644 --- a/kamailio/dispatcher-role.cfg +++ b/kamailio/dispatcher-role.cfg @@ -1,6 +1,10 @@ ######## Generic Hash Table container in shared memory ######## modparam("htable", "htable", "failover=>size=16;autoexpire=120") +#!ifdef CALL-PARK-REDIRECT-ROLE +modparam("htable", "htable", "park=>size=4;autoexpire=600") +#!endif + ####### Dispatcher module ######## loadmodule "dispatcher.so" modparam("dispatcher", "list_file", "/etc/kazoo/kamailio/dbtext/dispatcher") @@ -69,6 +73,7 @@ route[DISPATCHER_FIND_ROUTES] #!endif if (is_method("INVITE")) { + if($hdr(Replaces)!= $null) { $var(replaced_call_id) = $(hdr(Replaces){s.select,0,;}); xlog("L_INFO", "$ci|log|replaces call-id $var(replaced_call_id)"); @@ -82,6 +87,17 @@ route[DISPATCHER_FIND_ROUTES] } } } + + ##### CALL-PARK #### + #!ifdef CALL-PARK-REDIRECT-ROLE + if($(ru{uri.user}) =~ "\*3" && $sht(park=>$(ru{uri.user})@$(ru{uri.domain})) != $null) { + $du = $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})); + $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})) = $null; + xlog("L_INFO", "$ci|log|redirecting park request to $du"); + return; + } + #!endif + } if (!ds_select_dst("$var(ds_group)", "0") || $(avp(ds_dst)[0]) == $null) { diff --git a/kamailio/local.cfg b/kamailio/local.cfg index e6534ce..5c4f2ca 100644 --- a/kamailio/local.cfg +++ b/kamailio/local.cfg @@ -18,6 +18,7 @@ debug = L_INFO # # #!trydef TLS-ROLE # # #!trydef ANTIFLOOD-ROLE # # #!trydef MESSAGE-ROLE +# # #!trydef CALL-PARK-REDIRECT-ROLE ################################################################################ ## SERVER INFORMATION From 1cba6cade53b6e5bf2eb654f5663cec320d78364 Mon Sep 17 00:00:00 2001 From: lazedo Date: Tue, 24 Feb 2015 20:09:29 +0000 Subject: [PATCH 2/2] KAZOO-3308 call-park enabled --- kamailio/default.cfg | 6 ++---- kamailio/dispatcher-role.cfg | 5 ----- kamailio/local.cfg | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index b4e78b3..11bbbaa 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -530,13 +530,12 @@ route[EXTERNAL_TO_INTERNAL_RELAY] } #!endif - #!ifdef CALL-PARK-REDIRECT-ROLE + ##### CALL-PARK #### if(is_method("REFER")) { $avp(refer_to) = $hdr(Refer-To); $avp(refer_to_uri) = $rt; $avp(referred_by) = $hdr(Referred-By); } - #!endif remove_hf_re("^X-.*"); append_hf("X-AUTH-IP: $si\r\n"); @@ -586,12 +585,11 @@ onreply_route[INTERNAL_REPLY] setflag(FLAG_SESSION_PROGRESS); } - #!ifdef CALL-PARK-REDIRECT-ROLE + ##### CALL-PARK #### if (is_method("REFER") && $T_reply_code == "202" ) { $sht(park=>$(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain})) = "sip:" + $(ct{tobody.uri}{uri.host}) + ":" + $(ct{tobody.uri}{uri.port}); xlog("L_INFO", "PARK $(avp(refer_to_uri){uri.user})@$(avp(refer_to_uri){uri.domain}) = sip:$(ct{tobody.uri}{uri.host}):$(ct{tobody.uri}{uri.port})"); } - #!endif if ($rs < 300) { xlog("L_INFO", "$ci|pass|$T_req($si):$T_req($sp)"); diff --git a/kamailio/dispatcher-role.cfg b/kamailio/dispatcher-role.cfg index c15bf0f..9cee94e 100644 --- a/kamailio/dispatcher-role.cfg +++ b/kamailio/dispatcher-role.cfg @@ -1,9 +1,6 @@ ######## Generic Hash Table container in shared memory ######## modparam("htable", "htable", "failover=>size=16;autoexpire=120") - -#!ifdef CALL-PARK-REDIRECT-ROLE modparam("htable", "htable", "park=>size=4;autoexpire=600") -#!endif ####### Dispatcher module ######## loadmodule "dispatcher.so" @@ -89,14 +86,12 @@ route[DISPATCHER_FIND_ROUTES] } ##### CALL-PARK #### - #!ifdef CALL-PARK-REDIRECT-ROLE if($(ru{uri.user}) =~ "\*3" && $sht(park=>$(ru{uri.user})@$(ru{uri.domain})) != $null) { $du = $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})); $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})) = $null; xlog("L_INFO", "$ci|log|redirecting park request to $du"); return; } - #!endif } diff --git a/kamailio/local.cfg b/kamailio/local.cfg index 5c4f2ca..e6534ce 100644 --- a/kamailio/local.cfg +++ b/kamailio/local.cfg @@ -18,7 +18,6 @@ debug = L_INFO # # #!trydef TLS-ROLE # # #!trydef ANTIFLOOD-ROLE # # #!trydef MESSAGE-ROLE -# # #!trydef CALL-PARK-REDIRECT-ROLE ################################################################################ ## SERVER INFORMATION