Browse Source

support associations in the backup list and fix issue with redirect when challenged

3.17
karl anderson 12 years ago
parent
commit
d6f9581d9b
2 changed files with 53 additions and 42 deletions
  1. +22
    -24
      kamailio/default.cfg
  2. +31
    -18
      kamailio/dispatcher-role.cfg

+ 22
- 24
kamailio/default.cfg View File

@ -154,6 +154,7 @@ loadmodule "textopsx.so"
######## Generic Hash Table container in shared memory ######## ######## Generic Hash Table container in shared memory ########
loadmodule "htable.so" loadmodule "htable.so"
modparam("htable", "htable", "associations=>size=16;autoexpire=7200") modparam("htable", "htable", "associations=>size=16;autoexpire=7200")
modparam("htable", "htable", "redirects=>size=16;autoexpire=5")
######## Pseudo-Variables module ######## ######## Pseudo-Variables module ########
loadmodule "pv.so" loadmodule "pv.so"
@ -311,7 +312,6 @@ route[HANDLE_MOVE_REQUEST]
{ {
if (is_method("INVITE") && $rU == "*6683*") { if (is_method("INVITE") && $rU == "*6683*") {
$var(contact_uri) = $(ct{tobody.user}) + "@" + $(ct{tobody.host}); $var(contact_uri) = $(ct{tobody.user}) + "@" + $(ct{tobody.host});
$var(from_uri) = @from.uri.user + "@" + @from.uri.host;
if ($sht(associations=>$var(contact_uri)) != $null) { if ($sht(associations=>$var(contact_uri)) != $null) {
$sht(associations=>$var(contact_uri)) = $null; $sht(associations=>$var(contact_uri)) = $null;
@ -319,12 +319,6 @@ route[HANDLE_MOVE_REQUEST]
with media server $sht(associations=>$var(contact_uri))"); with media server $sht(associations=>$var(contact_uri))");
} }
if ($sht(associations=>$var(from_uri)) != $null) {
$sht(associations=>$var(from_uri)) = $null;
xlog("L_INFO", "$ci|log|removed from association for $var(from_uri)
with media server $sht(associations=>$var(from_uri))");
}
send_reply("503", "Removed association"); send_reply("503", "Removed association");
exit; exit;
@ -476,14 +470,18 @@ onreply_route[INTERNAL_REPLY]
xlog("L_INFO", "$ci|start|recieved internal reply $T_reply_code $rr"); xlog("L_INFO", "$ci|start|recieved internal reply $T_reply_code $rr");
xlog("L_INFO", "$ci|log|source $si:$sp"); xlog("L_INFO", "$ci|log|source $si:$sp");
if (t_check_status("(180)|(183)|(200)")) {
xlog("L_INFO", "$ci|log|call setup, only listening for redirects");
setflag(FLAG_SESSION_PROGRESS);
if ($avp(AVP_REDIRECT_KEY) != $null) {
xlog("L_INFO", "$ci|log|removing redirect mapping for $avp(AVP_REDIRECT_KEY)");
$sht(associations=>$avp(AVP_REDIRECT_KEY)) = $null;
if (is_method("INVITE") &&
!isflagset(FLAG_SESSION_PROGRESS) &&
t_check_status("(180)|(183)|(200)")
) {
if ($avp(AVP_REDIRECT_KEY) != $null &&
$sht(redirects=>$avp(AVP_REDIRECT_KEY)) != $null
) {
xlog("L_INFO", "$ci|log|removing redirect mapping $avp(AVP_REDIRECT_KEY)");
$sht(redirects=>$avp(AVP_REDIRECT_KEY)) = $null;
} }
xlog("L_INFO", "$ci|log|call setup, now ignoring abnormal termination");
setflag(FLAG_SESSION_PROGRESS);
} }
if ($rs < 300) { if ($rs < 300) {
@ -508,19 +506,19 @@ failure_route[INTERNAL_FAULT]
} }
# Handle redirects # Handle redirects
$var(redirect) = @from.uri.user + "@" + @from.uri.host + "->"
+ @contact.uri.user + "@" + @contact.uri.host;
if (t_check_status("302")) { if (t_check_status("302")) {
$var(redirect) = @from.uri.user + "@" + @from.uri.host + "->"
+ $T_rpl($(ct{tobody.user})) + "@" + $T_rpl($(ct{tobody.host}));
if($T_rpl($hdr(X-Redirect-Server)) != $null) { if($T_rpl($hdr(X-Redirect-Server)) != $null) {
$sht(associations=>$var(redirect)) = $T_rpl($hdr(X-Redirect-Server));
xlog("L_INFO", "$ci|log|stored redirect mapping for $var(redirect) to $T_rpl($hdr(X-Redirect-Server))");
$sht(redirects=>$var(redirect)) = $T_rpl($hdr(X-Redirect-Server));
xlog("L_INFO", "$ci|log|stored redirect mapping $var(redirect) to $T_rpl($hdr(X-Redirect-Server))");
} }
add_rcv_param("1");
} else if (!t_check_status("407")) {
xlog("L_INFO", "$ci|log|removing redirect mapping for $var(redirect)");
$sht(associations=>$var(redirect)) = $null;
} else if (!t_check_status("407") &&
$avp(AVP_REDIRECT_KEY) != $null &&
$sht(redirects=>$avp(AVP_REDIRECT_KEY)) != $null
) {
xlog("L_INFO", "$ci|log|removing redirect mapping $avp(AVP_REDIRECT_KEY)");
$sht(redirects=>$avp(AVP_REDIRECT_KEY)) = $null;
} }
remove_hf_re("X-.*"); remove_hf_re("X-.*");


+ 31
- 18
kamailio/dispatcher-role.cfg View File

@ -50,7 +50,7 @@ route[DISPATCHER_FIND_ROUTES]
$du = $sht(failover=>$ci::current); $du = $sht(failover=>$ci::current);
return; return;
} }
$var(ds_group) = 1; $var(ds_group) = 1;
#!ifndef PRESENCE-ROLE #!ifndef PRESENCE-ROLE
@ -81,19 +81,20 @@ route[DISPATCHER_FIND_ROUTES]
} }
$var(contact_uri) = $(ct{tobody.user}) + "@" + $(ct{tobody.host}); $var(contact_uri) = $(ct{tobody.user}) + "@" + $(ct{tobody.host});
$var(redirect) = @from.uri.user + "@" + @from.uri.host + "->"
+ @ruri.user + "@" + @ruri.host;
if ($sht(associations=>$var(redirect)) != $null) {
$var(association) = $var(redirect);
$var(prefered_route) = $sht(associations=>$var(association));
xlog("L_INFO", "$ci|log|found redirect mapping for $var(redirect) and associated with media server $var(prefered_route)");
route(DISPATCHER_REORDER_ROUTES);
$avp(AVP_REDIRECT_KEY) = $var(redirect);
$var(redirect) = @from.uri.user + "@" + @from.uri.host + "->"
+ @ruri.user + "@" + @ruri.host;
if ($sht(redirects=>$var(redirect)) != $null) {
$var(prefered_route) = $sht(redirects=>$var(redirect));
xlog("L_INFO", "$ci|log|found redirect for $var(redirect)");
if (route(DISPATCHER_REORDER_ROUTES)) {
$avp(AVP_REDIRECT_KEY) = $var(redirect);
}
} else if ($sht(associations=>$var(contact_uri)) != $null) { } else if ($sht(associations=>$var(contact_uri)) != $null) {
$var(association) = $var(contact_uri);
$var(prefered_route) = $sht(associations=>$var(association));
xlog("L_INFO", "$ci|log|contact uri $var(contact_uri) associated with media server $var(prefered_route)");
route(DISPATCHER_REORDER_ROUTES);
$var(prefered_route) = $sht(associations=>$var(contact_uri));
xlog("L_INFO", "$ci|log|found association for contact uri $var(contact_uri)");
if (!route(DISPATCHER_REORDER_ROUTES)) {
$sht(associations=>$var(association)) = $null;
}
} }
} }
@ -110,9 +111,20 @@ route[DISPATCHER_REORDER_ROUTES]
$var(i) = $var(i) + 1; $var(i) = $var(i) + 1;
} }
if ($var(ds_group) == 1 && !$var(found) && ds_select_dst("2", "0")) {
$var(i) = 0;
while($(avp(ds_dst)[$var(i)]) != $null) {
if($(avp(ds_dst)[$var(i)]) == $var(prefered_route)) {
xlog("L_INFO", "$ci|log|found associated media server in backup list");
$var(found) = 1;
break;
}
}
}
if ($var(found)) { if ($var(found)) {
xlog("L_INFO", "$ci|log|re-ordering the dispatcher list to keep associated server first");
xlog("L_INFO", "$ci|log|re-ordering the dispatcher list to maintain association with $var(prefered_route)");
$(avp(ds_dst)[*]) = $null; $(avp(ds_dst)[*]) = $null;
@ -127,10 +139,11 @@ route[DISPATCHER_REORDER_ROUTES]
$(avp(tmp_ds_dst)[*]) = $null; $(avp(tmp_ds_dst)[*]) = $null;
} else { } else {
xlog("L_INFO", "$ci|log|associated media server is inactive, moving to $rd");
$sht(associations=>$var(association)) = $null;
xlog("L_INFO", "$ci|log|associated media server $var(prefered_route) is inactive, moving to $rd");
return -1;
} }
return 1;
} }
route[DISPATCHER_NEXT_ROUTE] route[DISPATCHER_NEXT_ROUTE]


Loading…
Cancel
Save