From 2bfeb079fb0d4621da08a98460bde592ddff262f Mon Sep 17 00:00:00 2001 From: Luis Azedo Date: Tue, 19 Sep 2023 11:47:07 +0100 Subject: [PATCH] add support for kamailio 5.7 * adds dispatcher for branch 5.7 * use bflags registration --- kamailio/accounting-role.cfg | 6 +- kamailio/default.cfg | 3 - kamailio/dispatcher-role-5.7.cfg | 456 +++++++++++++++++++++++++++++++ kamailio/flags.cfg | 24 +- kamailio/kamailio.cfg | 3 - kamailio/registrar-role.cfg | 4 +- kamailio/sip_trace-role.cfg | 3 + 7 files changed, 478 insertions(+), 21 deletions(-) create mode 100644 kamailio/dispatcher-role-5.7.cfg diff --git a/kamailio/accounting-role.cfg b/kamailio/accounting-role.cfg index 71988497..b4d2ffed 100644 --- a/kamailio/accounting-role.cfg +++ b/kamailio/accounting-role.cfg @@ -12,10 +12,10 @@ modparam("acc", "early_media", 0) modparam("acc", "report_ack", 0) modparam("acc", "report_cancels", 1) modparam("acc", "detect_direction", 0) -modparam("acc", "log_flag", 7) +modparamx("acc", "log_flag", $flag(FLAG_ACC)) modparam("acc", "log_level", 2) -modparam("acc", "log_missed_flag", 8) -modparam("acc", "failed_transaction_flag", 9) +modparamx("acc", "log_missed_flag", $flag(FLAG_ACCMISSED)) +modparamx("acc", "failed_transaction_flag", $flag(FLAG_ACCFAILED)) modparam("acc", "log_extra", "src_user=$fU;src_domain=$fd;src_ip=$si;" "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd") diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 00c8baa8..4f8b9284 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -94,9 +94,6 @@ loadmodule "uac.so" loadmodule "avp.so" loadmodule "avpops.so" -######## UAC Redirection module ######## -loadmodule "uac_redirect.so" - #### json rpc #### loadmodule "jsonrpcs.so" diff --git a/kamailio/dispatcher-role-5.7.cfg b/kamailio/dispatcher-role-5.7.cfg new file mode 100644 index 00000000..6e2a75c5 --- /dev/null +++ b/kamailio/dispatcher-role-5.7.cfg @@ -0,0 +1,456 @@ +### DISPATCHER ROLE #### + +#!trydef KZ_DISPATCHER_PROBE_MODE 1 +#!trydef DISPATCHER_ADD_SERVERS 1 +#!trydef DISPATCHER_ADD_SECONDARY_IP 1 +#!trydef DISPATCHER_SECONDARY_IP_GROUP 3 +#!trydef DISPATCHER_ALG 0 +#!trydef KZ_DISPATCHER_HASH_SIZE 8 +#!trydef KZ_DISPATCHER_REHASH_MAX 4 +#!trydef KZ_DISPATCHER_ADD_FLAGS 9 +#!trydef KZ_DISPATCHER_PRIMARY_GROUP 1 +#!trydef KZ_DISPATCHER_SECONDARY_GROUP 2 +#!trydef KZ_DISPATCHER_CLASSIFY_GROUP 3 +#!trydef KZ_DISPATCHER_ALTNET1_PRIMARY_GROUP 51 +#!trydef KZ_DISPATCHER_ALTNET1_SECONDARY_GROUP 52 +#!trydef KZ_DISPATCHER_ALTNET2_PRIMARY_GROUP 53 +#!trydef KZ_DISPATCHER_ALTNET2_SECONDARY_GROUP 54 +#!trydef KZ_DISPATCHER_PRESENCE_PRIMARY_GROUP 10 +#!trydef KZ_DISPATCHER_PRESENCE_SECONDARY_GROUP 11 +#!trydef KZ_DISPATCHER_REGISTRAR_PRIMARY_GROUP 20 +#!trydef KZ_DISPATCHER_REGISTRAR_SECONDARY_GROUP 21 +#!trydef KZ_DISPATCHER_MAX_RETRIES 2 +#!trydef KZ_DISPATCHER_ROUTE_ASSOCIATED_MEDIA 1 +#!trydef KZ_DISPATCHER_CLASSIFY_FLAGS 2 +#!trydef KZ_DISPATCHER_PRINT_ROUTES 1 +#!trydef KZ_DISPATCHER_PING_INTERVAL 10 +#!trydef KZ_DISPATCHER_PROBING_THRESHOLD 3 + + +kazoo.dispatcher_auto_add = DISPATCHER_ADD_SERVERS descr "adds media servers reported by ecallmgr" +kazoo.dispatcher_add_secondary_ip = DISPATCHER_ADD_SECONDARY_IP descr "adds internal ip from media servers reported by ecallmgr" +kazoo.dispatcher_add_secondary_ip_group = DISPATCHER_SECONDARY_IP_GROUP descr "sets the group where to add internal ip from media servers reported by ecallmgr" +kazoo.dispatcher_algorithm = DISPATCHER_ALG descr "dispatcher algorithm to use" +kazoo.dispatcher_primary_group = KZ_DISPATCHER_PRIMARY_GROUP descr "dispatcher primary group" +kazoo.dispatcher_secondary_group = KZ_DISPATCHER_SECONDARY_GROUP descr "dispatcher secondary group" +kazoo.dispatcher_max_retries = KZ_DISPATCHER_MAX_RETRIES descr "max number of retries for media servers" +kazoo.dispatcher_route_to_associated_media = KZ_DISPATCHER_ROUTE_ASSOCIATED_MEDIA descr "routes to associated media for atxfer" +kazoo.dispatcher_classify_flags = KZ_DISPATCHER_CLASSIFY_FLAGS descr "dispatch classifier flags" +kazoo.dispatcher_print_routes = KZ_DISPATCHER_PRINT_ROUTES descr "should we log the selected routes" + +####### Dispatcher module ######## +loadmodule "dispatcher.so" +modparam("dispatcher", "db_url", "KAZOO_DB_URL") +modparam("dispatcher", "flags", 2) +modparam("dispatcher", "use_default", 0) +modparam("dispatcher", "force_dst", 1) +modparam("dispatcher", "hash_pvar", "$avp(ds_grp)") +modparam("dispatcher", "setid_pvname", "$var(ds_setid)") +modparam("dispatcher", "attrs_pvname", "$var(ds_attrs)") +modparam("dispatcher", "uri_pvname", "$var(ds_uri)") +modparam("dispatcher", "ds_ping_method", "OPTIONS") +modparam("dispatcher", "ds_ping_interval", KZ_DISPATCHER_PING_INTERVAL) +modparam("dispatcher", "ds_probing_threshold", KZ_DISPATCHER_PROBING_THRESHOLD) +modparam("dispatcher", "ds_probing_mode", KZ_DISPATCHER_PROBE_MODE) +modparam("dispatcher", "ds_ping_reply_codes", "501,403,404,400,200") +modparam("dispatcher", "ds_ping_from", "sip:sipcheck@MY_HOSTNAME") +modparam("dispatcher", "xavp_dst", "ds_dst") +modparam("dispatcher", "xavp_ctx", "ds_ctx") +modparam("dispatcher", "xavp_dst_mode", 2) +modparam("dispatcher", "ds_hash_size", KZ_DISPATCHER_HASH_SIZE) +modparam("dispatcher", "ds_rehash_max", KZ_DISPATCHER_REHASH_MAX) + +## Dispatcher Groups: +## 1 - Primary media servers +## 2 - Backup media servers +## 3 - Alternate media server IPs (used only for classification) +## 10 - Presence servers (if not locally handled) +## 20 - Registrar servers (if not locally handled) + + +modparam("rtimer", "timer", "name=dispatcher_reload;interval=20;mode=1;") +modparam("rtimer", "exec", "timer=dispatcher_reload;route=DISPATCHER_RELOAD") + +####### Dispatcher Logic ######## +route[CLASSIFY_SOURCE_DISPATCHER] +{ + route_if_exists("DISPATCHER_CUSTOM_NETWORK_CLASSIFY"); + + if (!isflagset(FLAG_NETWORK_CLASSIFIED)) { + if (!is_myself("$ou")) { + $var(classify_dispatcher_flag) = $(sel(cfg_get.kazoo.dispatcher_classify_flags){s.int}); + if (ds_is_from_list(KZ_DISPATCHER_PRIMARY_GROUP, "$var(classify_dispatcher_flag)") || + ds_is_from_list(KZ_DISPATCHER_SECONDARY_GROUP, "$var(classify_dispatcher_flag)") || + ds_is_from_list(KZ_DISPATCHER_CLASSIFY_GROUP, "$var(classify_dispatcher_flag)") || + ds_is_from_list(KZ_DISPATCHER_ALTNET1_PRIMARY_GROUP, "$var(classify_dispatcher_flag)") || + ds_is_from_list(KZ_DISPATCHER_ALTNET1_SECONDARY_GROUP, "$var(classify_dispatcher_flag)") || + ds_is_from_list(KZ_DISPATCHER_ALTNET2_PRIMARY_GROUP, "$var(classify_dispatcher_flag)") || + ds_is_from_list(KZ_DISPATCHER_ALTNET2_SECONDARY_GROUP, "$var(classify_dispatcher_flag)") || + ds_is_from_list(KZ_DISPATCHER_PRESENCE_PRIMARY_GROUP, "$var(classify_dispatcher_flag)") || + ds_is_from_list(KZ_DISPATCHER_PRESENCE_SECONDARY_GROUP, "$var(classify_dispatcher_flag)") || + ds_is_from_list(KZ_DISPATCHER_REGISTRAR_PRIMARY_GROUP, "$var(classify_dispatcher_flag)") || + ds_is_from_list(KZ_DISPATCHER_REGISTRAR_SECONDARY_GROUP, "$var(classify_dispatcher_flag)") || + ($hdr(X-FS-Core-UUID) != $null && $sht(media=>$hdr(X-FS-Core-UUID)) != $null)) { + setflag(FLAG_INTERNALLY_SOURCED); + setflag(FLAG_NETWORK_CLASSIFIED); + } + } + } +} + +# Take the routes from dispatcher - hash over callid +# If prefered route defined, reorder the destinations +route[DISPATCHER_FIND_ROUTES] +{ + + $var(ds_primary_group) = $(sel(cfg_get.kazoo.dispatcher_primary_group){s.int}); + $var(ds_backup_group) = $(sel(cfg_get.kazoo.dispatcher_secondary_group){s.int}); + + #!ifndef PRESENCE_ROLE + if (is_method("SUBSCRIBE")) { + $var(ds_primary_group) = KZ_DISPATCHER_PRESENCE_PRIMARY_GROUP; + $var(ds_backup_group) = KZ_DISPATCHER_PRESENCE_SECONDARY_GROUP; + } + #!endif + + #!ifndef REGISTRAR_ROLE + if (is_method("REGISTER")) { + $var(ds_primary_group) = KZ_DISPATCHER_REGISTRAR_PRIMARY_GROUP; + $var(ds_backup_group) = KZ_DISPATCHER_REGISTRAR_SECONDARY_GROUP; + } + #!endif + + $var(ds_alg) = $sel(cfg_get.kazoo.dispatcher_algorithm); + + routes(DISPATCHER_SELECT_ROUTES); + + routes(DISPATCHER_SELECT_OVERRIDE); + + route(DISPATCHER_SELECT_ROUTES); +} + +route[DISPATCHER_SELECT_ROUTES] +{ + $var(ds_group) = $var(ds_primary_group); + + if($var(ds_backup_group) != 0 && ds_list_exists("$var(ds_backup_group)")) { + $var(ds_rule) = $_s($var(ds_primary_group)=$var(ds_alg);$var(ds_backup_group)=$var(ds_alg)); + } else { + $var(ds_rule) = $_s($var(ds_primary_group)=$var(ds_alg)); + } + + ds_select_routes("$var(ds_rule)", "2"); + if ($xavp(ds_ctx=>cnt) == 0) { + xlog("L_WARN", "end - no servers available in primary ($var(ds_primary_group)) or backup group ($var(ds_backup_group))\n"); + send_reply("480", "All servers busy"); + exit; + } + + route(PRINT_ROUTES); + + route(DISPATCHER_CHECK_PREFERRED_ROUTE); + + $avp(ds_group) = $xavp(ds_dst=>grp); + $avp(ds_retries) = 0; + ds_set_dst(); + + routes(DISPATCHER_ROUTES_SELECTED); +} + +route[DISPATCHER_CHECK_PREFERRED_ROUTE] +{ + $var(preferred_route) = 0; + + $var(user_source) = $(ct{tobody.user}) + "@" + $si + ":" + $sp; + if ($sht(associations=>$var(user_source)) != $null) { + if($sel(cfg_get.kazoo.dispatcher_route_to_associated_media) == 1) { + $var(prefered_route) = $sht(associations=>$var(user_source)); + xlog("L_INFO", "found association for contact uri $var(user_source)\n"); + route(DISPATCHER_PREFERRED_ROUTE); + append_hf("X-Preferred-Media: true\r\n"); + $var(preferred_route) = 1; + } + $sht(associations=>$var(user_source)) = $null; + } + + if (isflagset(FLAG_REGISTERED_ENDPOINT) && $var(preferred_route) == 0) { + $var(user_source) = $xavp(ulrcd=>ruid); + if ($sht(associations=>$var(user_source)) != $null) { + if($sel(cfg_get.kazoo.dispatcher_route_to_associated_media) == 1) { + $var(prefered_route) = $sht(associations=>$var(user_source)); + xlog("L_INFO", "found association for ruri $var(user_source)\n"); + route(DISPATCHER_PREFERRED_ROUTE); + append_hf("X-Preferred-Media: true\r\n"); + } + $sht(associations=>$var(user_source)) = $null; + } + } +} + +route[DISPATCHER_PREFERRED_ROUTE] +{ + if(!ds_is_from_list(-1, 6, "$var(prefered_route)")) { + xlog("L_INFO", "associated media server $var(prefered_route) is inactive, moving to $xavp(ds_dst=>uri)\n"); + return -1; + } + + xlog("L_INFO", "re-ordering the dispatcher list to maintain association with $var(prefered_route)\n"); + + $var(i) = 0; + while($var(i) < $xavp(ds_ctx=>cnt)) { + if($xavp(ds_dst[$var(i)]=>uri) == $var(prefered_route)) { + $xavp(ds_dst[$var(i)]=>*) = $null; + } + $var(i) = $var(i) + 1; + } + + $xavp(ds_dst=>uri) = $var(prefered_route); + $xavp(ds_dst[0]=>grp) = $var(ds_setid); + $xavp(ds_dst[0]=>attrs) = $var(ds_attrs); + + return 1; +} + +route[PRINT_ROUTES] +{ + if($sel(cfg_get.kazoo.dispatcher_print_routes) == 0) return; + + $var(i) = 0; + while($xavp(ds_dst[$var(i)]=>uri) != $null) { + xlog("L_INFO", "group $xavp(ds_dst[$var(i)]=>grp) => $xavp(ds_dst[$var(i)]=>uri) => zone $(xavp(ds_dst[$var(i)]=>attrs){param.value,zone})\n"); + $var(i) = $var(i) + 1; + } + +} + +# Try next destinations in failure route +route[DISPATCHER_NEXT_ROUTE] +{ + if(!route_if_exists("DISPATCHER_CUSTOM_NEXT_ROUTE")) { + if($avp(ds_retries) >= $sel(cfg_get.kazoo.dispatcher_max_retries)) return; + + $avp(ds_retries) = $avp(ds_retries) + 1; + if(ds_next_dst()) { + xlog("L_INFO", "routing call to next media server $du\n"); + + # setflag(FLAG_SKIP_NAT_CORRECTION); + + # relay the request to the next destination + route(RELAY); + + exit; + } + } +} + +event_route[dispatcher:dst-down] +{ + $ki = $uuid(g); + xlog("L_WARNING", "destination $ru is down\n"); +} + +event_route[dispatcher:dst-up] +{ + $ki = $uuid(g); + xlog("L_NOTICE", "destination $ru is up\n"); +} + +route[MEDIA_SERVER_UP_DISPATCHER] +{ + if($sel(cfg_get.kazoo.dispatcher_auto_add) == 1) { + $var(SetId) = 1; + if($var(Zone) != "MY_AMQP_ZONE") { + $var(SetId) = 2; + } + + $var(MediaUrlBack) = $var(MediaUrl); + + #!ifdef WITH_INTERNAL_LISTENER + $var(dispatcher_socket) = $_s(socket=PROTO_INTERNAL;); + $var(MediaUrl) = $_s($var(MediaUrl);transport=$def(INTERNAL_PROTO)); + #!else + $var(dispatcher_socket) = ""; + #!endif + $var(flags) = KZ_DISPATCHER_ADD_FLAGS; + $var(attrs) = $_s($var(dispatcher_socket)zone=$var(Zone);profile=$var(MediaProfile);duid=$(var(MediaUrl){s.corehash, MEDIA_SERVERS_HASH_SIZE});node=$var(MediaName)); + $var(skip_dispatcher_insert) = 0; + routes(DISPATCHER_MEDIA_CHECK); + route(DISPATCHER_INSERT_DB); + + if($sel(cfg_get.kazoo.dispatcher_add_secondary_ip) == 1) { + $var(MediaUrl) = $var(MediaUrlBack); + if($var(MediaIP) != "" && $var(MediaIP) != $(var(MediaUrl){uri.host})) { + #!ifdef WITH_INTERNAL_LISTENER + $var(MediaUrl) = $_s($(var(MediaUrl){uri.scheme}):$var(MediaIP):$(var(MediaUrl){uri.port});transport=$def(INTERNAL_PROTO)); + #!else + $var(MediaUrl) = $_s($(var(MediaUrl){uri.scheme}):$var(MediaIP):$(var(MediaUrl){uri.port})); + #!endif + $var(attrs) = $_s($var(dispatcher_socket)zone=$var(Zone);profile=$var(MediaProfile);duid=$(var(MediaUrl){s.corehash, MEDIA_SERVERS_HASH_SIZE});node=$var(MediaName)); + $var(SetId) = $sel(cfg_get.kazoo.dispatcher_add_secondary_ip_group); + $var(skip_dispatcher_insert) = 0; + routes(DISPATCHER_MEDIA_CHECK); + route(DISPATCHER_INSERT_DB); + } + } + + $var(MediaUrl) = $var(MediaUrlBack); + } else { + xlog("L_DEBUG", "dispatcher_auto_add not enabled ($sel(cfg_get.kazoo.dispatcher_auto_add)) processing $var(MediaUrl) in $var(Zone)\n"); + } +} + +route[DISPATCHER_INSERT_DB] +{ + if ($var(skip_dispatcher_insert) == 1) return; + xlog("L_DEBUG", "trying to insert $var(MediaUrl) from node $var(MediaName) => KZQ_CHECK_MEDIA_SERVER_INSERT\n"); + if (sql_query("exec", "KZQ_CHECK_MEDIA_SERVER_INSERT") > 0) { + if($sqlrows(exec) > 0) { + $shv(dispatcher_reload) = 1; + xlog("L_INFO", "inserted $var(MediaUrl) from node $var(MediaName)\n"); + } else { + $var(Query) = $_s(select count(*) as count from dispatcher where destination = '$var(MediaUrl)'); + $var(exists) = 0; + if (sql_xquery("exec", "$var(Query)", "dst") == 1) { + if ($xavp(dst) != $null) { + if ($xavp(dst=>count) > 0) { + $var(exists) = 1; + } + } + pv_unset("$xavp(dst)"); + } + if ($var(exists) == 0) { + xlog("L_WARNING", "insert failed for $var(MediaUrl) from node $var(MediaName) => KZQ_CHECK_MEDIA_SERVER_INSERT\n"); + } + } + } else { + xlog("L_WARNING", "insert failed for $var(MediaUrl) from node $var(MediaName) => KZQ_CHECK_MEDIA_SERVER_INSERT\n"); + } +} + +#!ifndef KZ_DISABLE_DISPATCHER_MEDIA_REMOVE +route[MEDIA_SERVER_DOWN_DISPATCHER] +{ + xlog("L_INFO", "media server $var(MediaUrl) down, deleting\n"); + $var(Query) = $_s(delete from dispatcher where destination like '$var(MediaUrl)%'); + xlog("L_INFO", "media server $var(MediaUrl) down, => $var(Query)\n"); + if (sql_query("exec", "$var(Query)") > 0) { + if($sqlrows(exec) > 0) { + $shv(dispatcher_reload) = 1; + xlog("L_INFO", "removed $var(MediaUrl) from dispatcher\n"); + } else { + xlog("L_INFO", "media server $var(MediaUrl) down, rows $sqlrows(exec)\n"); + } + } else { + xlog("L_INFO", "delete failed for media server $var(MediaUrl)\n"); + } +} +#!endif + +route[DISPATCHER_RELOAD] +{ + $ki = $uuid(g); + if($shv(dispatcher_reload) == 1) { + xlog("L_WARNING", "reloading dispatcher table\n"); + ds_reload(); + }; + $shv(dispatcher_reload) = 0; +} + +event_route[dispatcher:reloaded] +{ + routes(DISPATCHER_RELOADED); +} + +route[DISPATCHER_STATUS] +{ + jsonrpc_exec('{"jsonrpc": "2.0", "method": "dispatcher.list", "id": 1}'); + $var(Sets) = $(jsonrpl(body){kz.json, result.NRSETS}); + $var(i) = 0; + $var(ds_groups_json)=""; + $var(Sep1) = ""; + while($var(i) < $var(Sets)) { + $var(Set) = $(jsonrpl(body){kz.json, result.RECORDS[$var(i)].SET}); + $var(SetCount) = $(var(Set){kz.json.count,TARGETS}); + $var(Sep2)=""; + $var(ds_group_json)=""; + $var(c) = 0; + while($var(c) < $var(SetCount)) { + $var(Dest) = $(var(Set){kz.json,TARGETS[$var(c)].DEST}); + $var(record) = $_s("$(var(Dest){kz.json,URI})" : {"destination" : "$(var(Dest){kz.json,URI})", "flags" : "$(var(Dest){kz.json,FLAGS})", "priority" : $(var(Dest){kz.json,PRIORITY}), "attrs" : "$(var(Dest){kz.json,ATTRS.BODY})"}); + $var(ds_group_json) = $var(ds_group_json) + $var(Sep2) + $var(record); + $var(Sep2) = ","; + $var(c) = $var(c) + 1; + } + $var(ds_groups_json) = $var(ds_groups_json) + $var(Sep1) + $_s("$(var(Set){kz.json,ID})" : { $var(ds_group_json) }); + $var(Sep1)=", "; + $var(i) = $var(i) + 1; + } +} + +route[KZ_LOCAL_OPTIONS_INTERNAL] +{ + $var(uri) = $_s($(ru{uri.scheme}):$(ru{uri.host}):$(ru{uri.port})); + if ($sht(media=>$var(uri)::uuid) != $null) { + append_hf("X-Proxy-Core-UUID: $shv(kz_proxy_core_uuid)\r\n"); + } +} + +route[ROUTE_TO_EXTERNAL_DISPATCHER_GROUP] +{ + if ($hdr(X-KAZOO-Dispatcher-Group) == $null) { + return; + } + + $var(ds_primary_group) = $(hdr(X-KAZOO-Dispatcher-Group){s.int}); + $vn(dispatcher_route) = $hdr(X-KAZOO-Dispatcher-Route); + + xlog("L_INFO", "routing to group $hdr(X-KAZOO-Dispatcher-Group) : $hdr(X-KAZOO-Dispatcher-Route)\n"); + + if ($vn(dispatcher_route) != $null) { + xlog("L_DEBUG", "running $_s($vn(dispatcher_route)_BEFORE_DISPATCHER)\n"); + route_if_exists($_s($vn(dispatcher_route)_BEFORE_DISPATCHER)); + } + + route(DISPATCHER_SELECT_ROUTES); + + if ($vn(dispatcher_route) != $null) { + xlog("L_DEBUG", "running $_s($vn(dispatcher_route)_AFTER_DISPATCHER)\n"); + route_if_exists($_s($vn(dispatcher_route)_AFTER_DISPATCHER)); + $xavp(cr=>dispatcher_route) = $vn(dispatcher_route); + } + + setflag(FLAG_OUTBOUND_DISPATCHER); +} + +route[ROUTE_TO_EXTERNAL_DISPATCHER_ROUTE] +{ + if ($hdr(X-KAZOO-Dispatcher-Route) == $null) { + return; + } + + if ($hdr(X-KAZOO-Dispatcher-Group) != $null) { + return; + } + + xlog("L_INFO", "using route $hdr(X-KAZOO-Dispatcher-Route)\n"); + + if (!check_route_exists($_s($hdr(X-KAZOO-Dispatcher-Route)))) { + xlog("L_ERROR", "route $hdr(X-KAZOO-Dispatcher-Route) not found\n"); + send_reply("404", "not found"); + exit; + }; + + route($_s($hdr(X-KAZOO-Dispatcher-Route))); + + $xavp(cr=>dispatcher_route) = $hdr(X-KAZOO-Dispatcher-Route); + + setflag(FLAG_OUTBOUND_DISPATCHER); +} + +route[ROUTE_TO_INTERNAL_DISPATCHER] +{ + route(DISPATCHER_FIND_ROUTES); +} + + +# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab diff --git a/kamailio/flags.cfg b/kamailio/flags.cfg index 6ae200bd..3b30d8f8 100644 --- a/kamailio/flags.cfg +++ b/kamailio/flags.cfg @@ -3,24 +3,28 @@ flags FLAG_INTERNALLY_SOURCED, FLAG_ASSOCIATE_SERVER, - FLAG_SKIP_NAT_CORRECTION, FLAG_ASSOCIATE_USER, FLAG_TRUSTED_SOURCE, FLAG_TRUSTED_PROXY, FLAG_TRUSTED_PARTNER, FLAG_SESSION_PROGRESS, - FLAG_SIP_TRACE, FLT_T38, FLT_NATS, - FLAG_LOCAL_REQUEST, - FLAG_LOCAL_ROUTE, - FLAG_NETWORK_CLASSIFIED, - FLAG_MANUAL_ALIAS, - FLAG_RECORD_ROUTE_ADDED, FLAG_AUTHORIZED, FLAG_REGISTERED_ENDPOINT, - FLAG_SKIP_NAT_MANAGE, - FLAG_SKIP_NAT_ALIAS, FLAG_OUTBOUND_DISPATCHER, + FLAG_SKIP_NAT_CORRECTION, + FLAG_SKIP_NAT_ALIAS, + FLAG_SKIP_NAT_MANAGE, + FLAG_RECORD_ROUTE_ADDED, FLAG_PICKUP_NO_EARLY_ONLY, - FLAG_SKIP_INITIAL_RECORD_ROUTE; + FLAG_SKIP_INITIAL_RECORD_ROUTE, + FLAG_MANUAL_ALIAS, + FLAG_LOCAL_REQUEST, + FLAG_LOCAL_ROUTE, + FLAG_NETWORK_CLASSIFIED; + +bflags + FLB_NATB, + FLB_KEEP_ALIVE, + FLB_UAC_REDIRECT; diff --git a/kamailio/kamailio.cfg b/kamailio/kamailio.cfg index 10dc960c..e9d14bd5 100644 --- a/kamailio/kamailio.cfg +++ b/kamailio/kamailio.cfg @@ -20,9 +20,6 @@ #!define AVP_ASSOCIATE_CONTACT "associate_contact" #!define AVP_REDIRECT_KEY "redirect_key" -#!define FLB_NATB 1 -#!define FLB_KEEP_ALIVE 2 -#!define FLB_UAC_REDIRECT 3 #!define TRUSTED_ADR_GROUP 1 ################ diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index fc37fd28..3ea45773 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -89,7 +89,7 @@ loadmodule "auth.so" loadmodule "usrloc.so" modparam("usrloc", "db_update_as_insert", 0) modparam("usrloc", "use_domain", 1) -modparam("usrloc", "nat_bflag", FLB_NATB) +modparamx("usrloc", "nat_bflag", $bflag(FLB_NATB)) modparam("usrloc", "db_url", "KAZOO_DB_URL") modparam("usrloc", "db_mode", REGISTRAR_DB_MODE) @@ -113,7 +113,7 @@ modparam("usrloc", "close_expired_tcp", REGISTRAR_CLOSE_EXPIRED_TCP) modparam("usrloc", "ka_mode", KZ_REGISTRAR_KEEP_ALIVE_MODE) modparam("usrloc", "ka_from", "sip:registrar@MY_HOSTNAME") modparam("usrloc", "ka_interval", KZ_REGISTRAR_KEEP_ALIVE_INTERVAL) -modparam("usrloc", "ka_flag", FLB_KEEP_ALIVE) +modparamx("usrloc", "ka_flag", $bflag(FLB_KEEP_ALIVE)) ####### SIP Registrar implementation module ########## loadmodule "registrar.so" diff --git a/kamailio/sip_trace-role.cfg b/kamailio/sip_trace-role.cfg index 93b0fc1d..d7698920 100644 --- a/kamailio/sip_trace-role.cfg +++ b/kamailio/sip_trace-role.cfg @@ -12,6 +12,9 @@ #!trydef SIP_TRACE_URI "sip:127.0.0.1:9060" #!trydef HEP_CAPTURE_ID 1 +flags + FLAG_SIP_TRACE; + ############################################################## ## Kamailio siptrace settings configuration examples at runtime ## kamcmd siptrace.status on