From 70a3a6fa9570b68cbab6ca8ee5ee838acf5d9ba3 Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 10 Jan 2019 05:58:48 +0000 Subject: [PATCH] flag AOR usage and move route to registrar-role --- kamailio/default.cfg | 21 +-------------------- kamailio/registrar-role.cfg | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/kamailio/default.cfg b/kamailio/default.cfg index cd97b70..ade6840 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -683,26 +683,7 @@ route[INTERNAL_TO_EXTERNAL_RELAY] #!endif #!ifdef REGISTRAR_ROLE - if ($hdr(X-KAZOO-AOR) != $null) { - xlog("L_INFO", "$ci|log|using AOR $hdr(X-KAZOO-AOR)\n"); - if ($hdr(X-KAZOO-INVITE-FORMAT) == "contact") { - if(lookup("location", "$hdr(X-KAZOO-AOR)") > 0){ - xlog("L_INFO", "$ci|end|routing to contact $ru\n"); - } else { - xlog("L_INFO", "$ci|end|lookup for AOR $hdr(X-KAZOO-AOR) failed\n"); - sl_send_reply("410", "Not registered"); - exit; - } - } else if (reg_fetch_contacts("location", "$hdr(X-KAZOO-AOR)", "callee")) { - $du = $(ulc(callee=>received)); - $fs = $(ulc(callee=>socket)); - xlog("L_INFO", "$ci|log|routing $hdr(X-KAZOO-AOR) to $du via $fs\n"); - } else { - xlog("L_INFO", "$ci|end|user is not registered\n"); - sl_send_reply("410", "Not registered"); - exit; - } - } + route(REGISTRAR_ROUTE_TO_AOR); #!endif remove_hf_re("^X-.*"); diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index aaacade..978dc3f 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -480,4 +480,32 @@ event_route[usrloc:contact-expired] #!include_file "registrar-sync-role.cfg" #!endif +route[REGISTRAR_ROUTE_TO_AOR] +{ + if ($hdr(X-KAZOO-AOR) == $null) { + return(); + } + + xlog("L_INFO", "$ci|log|using AOR $hdr(X-KAZOO-AOR)\n"); + setflag(FLAG_AOR); + if ($hdr(X-KAZOO-INVITE-FORMAT) == "contact") { + if(lookup("location", "$hdr(X-KAZOO-AOR)") > 0){ + xlog("L_INFO", "$ci|end|routing to contact $ru\n"); + handle_ruri_alias(); + } else { + xlog("L_INFO", "$ci|end|lookup for AOR $hdr(X-KAZOO-AOR) failed\n"); + sl_send_reply("410", "Not registered"); + exit; + } + } else if (reg_fetch_contacts("location", "$hdr(X-KAZOO-AOR)", "callee")) { + $du = $(ulc(callee=>received)); + $fs = $(ulc(callee=>socket)); + xlog("L_INFO", "$ci|log|routing $hdr(X-KAZOO-AOR) to $du via $fs\n"); + } else { + xlog("L_INFO", "$ci|end|user is not registered\n"); + sl_send_reply("410", "Not registered"); + exit; + } +} + # vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab