Browse Source

allow header removal when sending to AOR

we want to send some headers (default is P-* and R-*)
to carriers but not to devices
master
lazedo 6 years ago
parent
commit
8aa9fac0e3
1 changed files with 37 additions and 2 deletions
  1. +37
    -2
      kamailio/default.cfg

+ 37
- 2
kamailio/default.cfg View File

@ -151,6 +151,9 @@ modparam("rr", "enable_full_lr", RR_FULL_LR)
modparam("rr", "enable_double_rr", RR_DOUBLE_RR) modparam("rr", "enable_double_rr", RR_DOUBLE_RR)
modparam("rr", "force_send_socket", RR_FORCE_SOCKET) modparam("rr", "force_send_socket", RR_FORCE_SOCKET)
######## Kamailio dialog module ########
loadmodule "dialog.so"
######## Max-Forward processor module ######## ######## Max-Forward processor module ########
loadmodule "maxfwd.so" loadmodule "maxfwd.so"
modparam("maxfwd", "max_limit", 50) modparam("maxfwd", "max_limit", 50)
@ -593,6 +596,11 @@ route[PREPARE_INITIAL_REQUESTS]
exit(); exit();
} }
if(is_method("INVITE"))
{
dlg_manage();
}
if (is_method("UPDATE")) { if (is_method("UPDATE")) {
xlog("L_WARN", "$ci|end|update outside dialog not allowed\n"); xlog("L_WARN", "$ci|end|update outside dialog not allowed\n");
send_reply("403", "Dialog does not exist"); send_reply("403", "Dialog does not exist");
@ -685,6 +693,12 @@ route[INTERNAL_TO_EXTERNAL_RELAY]
} }
#!endif #!endif
if (dlg_isflagset(FLT_AOR)) {
if($sel(cfg_get.kazoo.aor_strip_headers) == 1) {
xlog("L_INFO", "$ci|log|INTERNAL TO EXTERNAL AOR REMOVE HDR\n");
remove_hf_re($sel(cfg_get.kazoo.aor_strip_headers_regex));
}
}
t_on_reply("EXTERNAL_REPLY"); t_on_reply("EXTERNAL_REPLY");
@ -770,6 +784,13 @@ onreply_route[INTERNAL_REPLY]
setflag(FLAG_SESSION_PROGRESS); setflag(FLAG_SESSION_PROGRESS);
} }
if (dlg_isflagset(FLT_AOR)) {
if($sel(cfg_get.kazoo.aor_strip_headers) == 1) {
xlog("L_INFO", "$ci|log|INTERNAL TO EXTERNAL REPLY AOR REMOVE HDR\n");
remove_hf_re($sel(cfg_get.kazoo.aor_strip_headers_regex));
}
}
if ($rs < 300) { if ($rs < 300) {
xlog("L_INFO", "$ci|pass|$T_req($si):$T_req($sp)\n"); xlog("L_INFO", "$ci|pass|$T_req($si):$T_req($sp)\n");
} }
@ -880,6 +901,16 @@ onsend_route {
} }
} }
#!trydef STRIP_HEADERS_TO_AOR 1
#!trydef STRIP_HEADERS_TO_AOR_REGEX "^P-.*|^R-.*"
kazoo.aor_strip_headers = STRIP_HEADERS_TO_AOR desc "should we remove headers when sending to AOR"
kazoo.aor_strip_headers_regex = STRIP_HEADERS_TO_AOR_REGEX desc "regex used to remove headers before sending to AOR"
#!trydef AOR_NOT_SUBSCRIBED_APPEND_REASON
#!trydef AOR_NOT_SUBSCRIBED_REASON Reason: Q.850; cause=20;text="Subscriber Absent"
route[ROUTE_TO_AOR] route[ROUTE_TO_AOR]
{ {
if ($hdr(X-KAZOO-AOR) == $null) { if ($hdr(X-KAZOO-AOR) == $null) {
@ -887,22 +918,26 @@ route[ROUTE_TO_AOR]
} }
xlog("L_INFO", "$ci|log|using AOR $hdr(X-KAZOO-AOR)\n"); xlog("L_INFO", "$ci|log|using AOR $hdr(X-KAZOO-AOR)\n");
dlg_setflag(FLT_AOR);
if ($hdr(X-KAZOO-INVITE-FORMAT) == "contact") { if ($hdr(X-KAZOO-INVITE-FORMAT) == "contact") {
if(lookup("location", "$hdr(X-KAZOO-AOR)") > 0){ if(lookup("location", "$hdr(X-KAZOO-AOR)") > 0){
xlog("L_INFO", "$ci|end|routing to contact $ru\n"); xlog("L_INFO", "$ci|end|routing to contact $ru\n");
$avp(aor) = $hdr(X-KAZOO-AOR);
handle_ruri_alias(); handle_ruri_alias();
} else { } else {
xlog("L_INFO", "$ci|end|lookup for AOR $hdr(X-KAZOO-AOR) failed\n"); xlog("L_INFO", "$ci|end|lookup for AOR $hdr(X-KAZOO-AOR) failed\n");
sl_send_reply("410", "Not registered");
append_to_reply("$def(AOR_NOT_SUBSCRIBED_REASON)\r\n");
sl_send_reply("480", "Not registered");
exit; exit;
} }
} else if (reg_fetch_contacts("location", "$hdr(X-KAZOO-AOR)", "callee")) { } else if (reg_fetch_contacts("location", "$hdr(X-KAZOO-AOR)", "callee")) {
$du = $(ulc(callee=>received)); $du = $(ulc(callee=>received));
$fs = $(ulc(callee=>socket)); $fs = $(ulc(callee=>socket));
xlog("L_INFO", "$ci|log|routing $hdr(X-KAZOO-AOR) to $du via $fs\n"); xlog("L_INFO", "$ci|log|routing $hdr(X-KAZOO-AOR) to $du via $fs\n");
$avp(aor) = $hdr(X-KAZOO-AOR);
} else { } else {
xlog("L_INFO", "$ci|end|user is not registered\n"); xlog("L_INFO", "$ci|end|user is not registered\n");
append_to_reply("$def(AOR_NOT_SUBSCRIBED_REASON)\r\n");
sl_send_reply("410", "Not registered"); sl_send_reply("410", "Not registered");
exit; exit;
} }


Loading…
Cancel
Save