From a955afff877ff8d8a3a0ea91f2eb5f8fcdf796a1 Mon Sep 17 00:00:00 2001 From: Lum Date: Fri, 15 Apr 2011 00:51:18 +0000 Subject: [PATCH 01/36] added mod_shout into modules.conf.xml --- autoload_configs/modules.conf.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload_configs/modules.conf.xml b/autoload_configs/modules.conf.xml index 5cb1b90..c894541 100644 --- a/autoload_configs/modules.conf.xml +++ b/autoload_configs/modules.conf.xml @@ -46,6 +46,8 @@ + + From eafa96ed65622388e21f1de49b0f9df25201dc37 Mon Sep 17 00:00:00 2001 From: Lum Date: Fri, 15 Apr 2011 01:33:52 +0000 Subject: [PATCH 02/36] added shout.conf.xml for mod_shout --- autoload_configs/shout.conf.xml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 autoload_configs/shout.conf.xml diff --git a/autoload_configs/shout.conf.xml b/autoload_configs/shout.conf.xml new file mode 100644 index 0000000..3f381e6 --- /dev/null +++ b/autoload_configs/shout.conf.xml @@ -0,0 +1,8 @@ + + + + + + + + From 7af51bae6f9eafb8d3261ef4c23368657db917d2 Mon Sep 17 00:00:00 2001 From: Lum Date: Tue, 3 May 2011 00:16:58 +0000 Subject: [PATCH 03/36] added siproxy001-aa-ord to acl.conf.xml --- autoload_configs/acl.conf.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload_configs/acl.conf.xml b/autoload_configs/acl.conf.xml index c4801d5..b1e085c 100644 --- a/autoload_configs/acl.conf.xml +++ b/autoload_configs/acl.conf.xml @@ -9,6 +9,7 @@ + From d170ee25db815dc70bed7bf51108fb66cb5211c4 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 4 May 2011 10:12:18 -0700 Subject: [PATCH 04/36] tweaks to the commit --- freeswitch.xml | 38 +++++++++++++++++++++++++++------ sip_profiles/sipinterface_1.xml | 12 ++++++----- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/freeswitch.xml b/freeswitch.xml index 720124a..7211c21 100644 --- a/freeswitch.xml +++ b/freeswitch.xml @@ -1,14 +1,40 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + +
diff --git a/sip_profiles/sipinterface_1.xml b/sip_profiles/sipinterface_1.xml index 46bab36..69f9870 100644 --- a/sip_profiles/sipinterface_1.xml +++ b/sip_profiles/sipinterface_1.xml @@ -5,7 +5,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -65,11 +65,11 @@ - + - + @@ -101,7 +101,9 @@ - + + + From 7b3b8d8a5327177c911d60e782784ea5e2315cd8 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 4 May 2011 15:16:01 -0700 Subject: [PATCH 05/36] more tweaks --- autoload_configs/conference.conf.xml | 202 ++++++++-------------- autoload_configs/directory.conf.xml | 20 --- autoload_configs/event_multicast.conf.xml | 9 - autoload_configs/fifo.conf.xml | 6 - autoload_configs/ivr.conf.xml | 5 - autoload_configs/modules.conf.xml | 16 +- autoload_configs/voicemail.conf.xml | 62 ------- ivr_menus/empty.xml | 3 - 8 files changed, 78 insertions(+), 245 deletions(-) delete mode 100644 autoload_configs/directory.conf.xml delete mode 100644 autoload_configs/event_multicast.conf.xml delete mode 100644 autoload_configs/fifo.conf.xml delete mode 100644 autoload_configs/ivr.conf.xml delete mode 100644 autoload_configs/voicemail.conf.xml delete mode 100644 ivr_menus/empty.xml diff --git a/autoload_configs/conference.conf.xml b/autoload_configs/conference.conf.xml index 8b119dd..8add428 100644 --- a/autoload_configs/conference.conf.xml +++ b/autoload_configs/conference.conf.xml @@ -1,174 +1,118 @@ - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - \ No newline at end of file + diff --git a/autoload_configs/directory.conf.xml b/autoload_configs/directory.conf.xml deleted file mode 100644 index 1704d16..0000000 --- a/autoload_configs/directory.conf.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/autoload_configs/event_multicast.conf.xml b/autoload_configs/event_multicast.conf.xml deleted file mode 100644 index 846dbc2..0000000 --- a/autoload_configs/event_multicast.conf.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/autoload_configs/fifo.conf.xml b/autoload_configs/fifo.conf.xml deleted file mode 100644 index c20b6a4..0000000 --- a/autoload_configs/fifo.conf.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/autoload_configs/ivr.conf.xml b/autoload_configs/ivr.conf.xml deleted file mode 100644 index 93a4ad3..0000000 --- a/autoload_configs/ivr.conf.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/autoload_configs/modules.conf.xml b/autoload_configs/modules.conf.xml index dea1ca9..371a3a3 100644 --- a/autoload_configs/modules.conf.xml +++ b/autoload_configs/modules.conf.xml @@ -10,7 +10,6 @@ - @@ -25,40 +24,35 @@ - - - - - - - + + - + + + - - diff --git a/autoload_configs/voicemail.conf.xml b/autoload_configs/voicemail.conf.xml deleted file mode 100644 index de8f6f2..0000000 --- a/autoload_configs/voicemail.conf.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ivr_menus/empty.xml b/ivr_menus/empty.xml deleted file mode 100644 index dd68d75..0000000 --- a/ivr_menus/empty.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - From 7bd89e53422674e2f0e265c99c83e27c6a9d39a2 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 4 May 2011 15:21:34 -0700 Subject: [PATCH 06/36] even more tweaks! --- autoload_configs/modules.conf.xml | 2 +- shout.conf.xml | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 shout.conf.xml diff --git a/autoload_configs/modules.conf.xml b/autoload_configs/modules.conf.xml index 371a3a3..e4445fc 100644 --- a/autoload_configs/modules.conf.xml +++ b/autoload_configs/modules.conf.xml @@ -39,7 +39,7 @@ - + diff --git a/shout.conf.xml b/shout.conf.xml new file mode 100644 index 0000000..3f381e6 --- /dev/null +++ b/shout.conf.xml @@ -0,0 +1,8 @@ + + + + + + + + From ae5866ee799e602c575f87747bd264c2862f4180 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 4 May 2011 15:21:34 -0700 Subject: [PATCH 07/36] even more tweaks! --- autoload_configs/modules.conf.xml | 2 +- autoload_configs/shout.conf.xml | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 autoload_configs/shout.conf.xml diff --git a/autoload_configs/modules.conf.xml b/autoload_configs/modules.conf.xml index 371a3a3..e4445fc 100644 --- a/autoload_configs/modules.conf.xml +++ b/autoload_configs/modules.conf.xml @@ -39,7 +39,7 @@ - + diff --git a/autoload_configs/shout.conf.xml b/autoload_configs/shout.conf.xml new file mode 100644 index 0000000..3f381e6 --- /dev/null +++ b/autoload_configs/shout.conf.xml @@ -0,0 +1,8 @@ + + + + + + + + From aadc71bc54c389fe31b97f9fed6ecb9122b221ba Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 4 May 2011 15:25:24 -0700 Subject: [PATCH 08/36] spacing --- freeswitch.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/freeswitch.xml b/freeswitch.xml index 7211c21..7a7639a 100644 --- a/freeswitch.xml +++ b/freeswitch.xml @@ -1,5 +1,6 @@ + @@ -55,4 +56,5 @@ + From b9db680878f6f0e22c01fab58b6abf307bd38044 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 4 May 2011 15:26:20 -0700 Subject: [PATCH 09/36] hmm ok now I know amending to a push branch, not a great idea --- shout.conf.xml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 shout.conf.xml diff --git a/shout.conf.xml b/shout.conf.xml deleted file mode 100644 index 3f381e6..0000000 --- a/shout.conf.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - From 0c6cc8ea24e1e55a26a86acb530ba9505a869bb9 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 4 May 2011 15:30:16 -0700 Subject: [PATCH 10/36] NO LIMITS (well sorta) --- freeswitch.limits.conf | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 freeswitch.limits.conf diff --git a/freeswitch.limits.conf b/freeswitch.limits.conf new file mode 100644 index 0000000..f12233e --- /dev/null +++ b/freeswitch.limits.conf @@ -0,0 +1,15 @@ +freeswitch soft core unlimit +freeswitch soft data unlimit +freeswitch soft fsize unlimit +freeswitch soft memlock unlimit +freeswitch soft nofile 999999 +freeswitch soft rss unlimit +freeswitch soft stack 1024 +freeswitch soft cpu unlimit +freeswitch soft nproc unlimit +freeswitch soft as unlimit +freeswitch soft priority -11 +freeswitch soft locks unlimit +freeswitch soft sigpending unlimit +freeswitch soft msgqueue unlimit +freeswitch soft nice -11 From aae71e6c22e8b499ed224add419a59b57df2da20 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 4 May 2011 15:44:11 -0700 Subject: [PATCH 11/36] this needs to be hard to take effect --- freeswitch.limits.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freeswitch.limits.conf b/freeswitch.limits.conf index f12233e..02d3dff 100644 --- a/freeswitch.limits.conf +++ b/freeswitch.limits.conf @@ -4,7 +4,7 @@ freeswitch soft fsize unlimit freeswitch soft memlock unlimit freeswitch soft nofile 999999 freeswitch soft rss unlimit -freeswitch soft stack 1024 +freeswitch hard stack 240 freeswitch soft cpu unlimit freeswitch soft nproc unlimit freeswitch soft as unlimit From eedbaf3955a2d678ab9cb6a00ce8d74021f25a99 Mon Sep 17 00:00:00 2001 From: Lum Date: Sun, 8 May 2011 01:35:50 +0000 Subject: [PATCH 12/36] added aa cluster opensips servers to acl.conf.xml --- autoload_configs/acl.conf.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload_configs/acl.conf.xml b/autoload_configs/acl.conf.xml index c4801d5..4f19493 100644 --- a/autoload_configs/acl.conf.xml +++ b/autoload_configs/acl.conf.xml @@ -9,6 +9,8 @@ + + From 96a1e20fb291fa663de6a45a15d63412cac301da Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 11 May 2011 01:21:34 -0700 Subject: [PATCH 13/36] change the default codecs (dont include wideband) and dont try to pass dtmf directly --- freeswitch.xml | 3 ++- sip_profiles/sipinterface_1.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/freeswitch.xml b/freeswitch.xml index 7a7639a..3cd68ef 100644 --- a/freeswitch.xml +++ b/freeswitch.xml @@ -34,7 +34,8 @@ - + +
diff --git a/sip_profiles/sipinterface_1.xml b/sip_profiles/sipinterface_1.xml index 69f9870..b2cc9eb 100644 --- a/sip_profiles/sipinterface_1.xml +++ b/sip_profiles/sipinterface_1.xml @@ -97,7 +97,7 @@ - + From 906af7e306b64f01838342ad9ca8052f3d6d653f Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 11 May 2011 01:45:24 -0700 Subject: [PATCH 14/36] tweak --- freeswitch.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freeswitch.xml b/freeswitch.xml index 3cd68ef..ded6c85 100644 --- a/freeswitch.xml +++ b/freeswitch.xml @@ -35,7 +35,7 @@ - +
From ed8d02365d57cf5716728b06fb73d268b6d8c995 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 11 May 2011 01:47:57 -0700 Subject: [PATCH 15/36] make up your mind! --- freeswitch.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/freeswitch.xml b/freeswitch.xml index ded6c85..6322e4c 100644 --- a/freeswitch.xml +++ b/freeswitch.xml @@ -35,7 +35,8 @@ - + +
From 83b53a890db031dde9b512f6d4d5f57767c00a5c Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Fri, 13 May 2011 15:38:00 -0700 Subject: [PATCH 16/36] updates to ensure the ACL is checked in --- autoload_configs/acl.conf.xml | 20 ++--- opensips/opensips.cfg | 160 +++++++++++++++++++--------------- 2 files changed, 99 insertions(+), 81 deletions(-) diff --git a/autoload_configs/acl.conf.xml b/autoload_configs/acl.conf.xml index 4f19493..32c42f3 100644 --- a/autoload_configs/acl.conf.xml +++ b/autoload_configs/acl.conf.xml @@ -1,16 +1,16 @@ - - - - - + + + + + + - - - - + + + - + \ No newline at end of file diff --git a/opensips/opensips.cfg b/opensips/opensips.cfg index bc9249f..6c004b5 100644 --- a/opensips/opensips.cfg +++ b/opensips/opensips.cfg @@ -105,11 +105,12 @@ disable_tcp=no ###################################################################### ## Module Loading ###################################################################### -mpath="/usr/local/lib64/opensips/modules/" +mpath="/usr/lib64/opensips/modules/" loadmodule "memcached.so" loadmodule "signaling.so" loadmodule "sl.so" loadmodule "tm.so" +loadmodule "dialog.so" loadmodule "maxfwd.so" loadmodule "rr.so" loadmodule "path.so" @@ -117,6 +118,7 @@ loadmodule "uri.so" loadmodule "textops.so" loadmodule "usrloc.so" loadmodule "nathelper.so" +loadmodule "nat_traversal.so" loadmodule "dispatcher.so" loadmodule "mi_fifo.so" # loadmodule "mi_datagram.so" @@ -149,7 +151,7 @@ modparam("tm", "fr_timer", 5) # modparam("tm", "fr_inv_timer_avp", "$avp(i:25)") # modparam("tm", "tw_append", # "test: ua=$hdr(User-Agent) ;avp=$avp(i:10);$rb;time=$Ts") -# modparam("tm", "pass_provisional_replies", 0) +modparam("tm", "pass_provisional_replies", 1) # modparam("tm", "syn_branch", 1) # modparam("tm", "onreply_avp_mode", 0) # modparam("tm", "disable_6xx_block", 0) @@ -221,17 +223,25 @@ modparam("usrloc", "path_column", "path") ## Nathelper Module Parameters ###################################################################### # modparam("nathelper", "rtpproxy_sock", "udp:127.0.0.1:7890") -modparam("nathelper", "natping_interval", 30) -modparam("nathelper", "ping_nated_only", 1) +# modparam("nathelper", "natping_interval", 30) +# modparam("nathelper", "ping_nated_only", 1) # modparam("nathelper", "natping_processes", 3) -modparam("nathelper", "sipping_bflag", 7) -modparam("nathelper", "sipping_from", "sip:sipcheck@184.106.172.9 ") +# modparam("nathelper", "sipping_bflag", 7) +# modparam("nathelper", "sipping_from", "sip:sipcheck@184.106.157.174") # modparam("nathelper", "sipping_method", "INFO") +###################################################################### +## NAT Traversal Module Parameters +###################################################################### +modparam("nat_traversal", "keepalive_interval", 60) +modparam("nat_traversal", "keepalive_method", "OPTIONS") +modparam("nat_traversal", "keepalive_from", "sip:keepalive@ping.sip.2600hz.com") +modparam("nat_traversal", "keepalive_state_file", "/tmp/opensips_keepalive_state") + ###################################################################### ## Dispatcher Module Parameters ###################################################################### -modparam("dispatcher", "list_file", "/usr/local/etc/opensips/dispatcher.list") +modparam("dispatcher", "list_file", "/etc/opensips/dispatcher.list") modparam("dispatcher", "flags", 2) modparam("dispatcher", "use_default", 0) modparam("dispatcher", "force_dst", 1) @@ -242,7 +252,7 @@ modparam("dispatcher", "cnt_avp", "$avp(i:274)") modparam("dispatcher", "hash_pvar", "$avp(i:273)") # modparam("dispatcher", "setid_pvar", "$var(setid)") modparam("dispatcher", "ds_ping_method", "OPTIONS") -modparam("dispatcher", "ds_ping_from", "sip:sipcheck@184.106.172.9:5060") +modparam("dispatcher", "ds_ping_from", "sip:sipcheck@184.106.157.174:5060") modparam("dispatcher", "ds_ping_interval", 10) # modparam("dispatcher", "ds_ping_sock", "udp:10.80.25.168:5080") modparam("dispatcher", "ds_probing_threshhold", 3) @@ -290,11 +300,18 @@ route exit; } + if (src_ip==myself) + { + xlog("L_WARN", "Src IP [$ou] from [$si:$sp]"); + + exit; + } + xlog("L_INFO", "Received [$rm] [$ou] from [$si:$sp]"); xlog("L_DBG", " From: [$fu]"); xlog("L_DBG", " To: [$tu]"); - if (is_method("OPTIONS")) + if (is_method("OPTIONS|SUBSCRIBE")) { xlog("L_NOTICE", " Method [$rm] is not supported, sending 503 to [$si:$sp]"); @@ -305,39 +322,16 @@ route t_on_reply("1"); - if (nat_uac_test("18")) - { - xlog("L_INFO", " Source port is different from the port in Via, force rport"); - - force_rport(); - - fix_nated_contact(); - - if (has_body("application/sdp")) - { - xlog("L_INFO", " Fixing nated SDP, rewritting media and origin with [$si]"); - - fix_nated_sdp("10"); - } - - # If this leads to a sucessfull register then flag 5 will cause nat=yes to be append to the contact - # and (when appropriate) the use of the nat_compensator reply branch - setflag(5); - } + t_on_failure("1"); if (has_totag()) { - if (subst_uri('/(sip:.*);nat=yes/\1/')) - { - xlog("L_INFO", " Set reply branch for NAT compensation on this message in the existing dialog"); - - t_on_reply("nat_compensator"); - } - # sequential request withing a dialog should # take the path determined by record-routing if (loose_route()) { + append_hf("P-hint: rr-enforced\r\n"); + if (is_method("INVITE")) { # even if in most of the cases is useless, do RR for @@ -348,6 +342,13 @@ route #record_route(); } + if ((ds_is_in_list("$si", "$sp", "1") || ds_is_in_list("$si", "$sp", "2")) && is_method("ACK")) + { + xlog("L_INFO", " Stored [$tU] as belonging to media server [$fd]"); + + cache_store("memcached_callid_hash", "$tU ", "$fd", 3600); + } + # route it out to whatever destination was set by loose_route() # in $du (destination URI). route(1); @@ -430,33 +431,38 @@ route } # is not from media servers - if (!ds_is_in_list("$si", "$sp", "1") and !ds_is_in_list("$si", "$sp", "2")) - { - if(cache_fetch("memcached_callid_hash", "$ci", $avp(i:55))) + if (!ds_is_in_list("$si", "$sp", "1") && !ds_is_in_list("$si", "$sp", "2")) + { + if ($ct.fields(uri) && cache_fetch("memcached_callid_hash", "$(ct.fields(uri){uri.user})", $avp(i:55))) + { + $rd = $avp(i:55); + + xlog("L_INFO", " Reconized contact [$ct.fields(uri)] as belonging to media server [$rd]"); + } + else if (cache_fetch("memcached_callid_hash", "$ci", $avp(i:55))) { $rd = $avp(i:55); xlog("L_INFO", " Reconized call-id [$ci] as belonging to media server [$rd]"); + + if ($ct.fields(uri) && is_method("INVITE")) + { + xlog("L_INFO", " Stored [$(ct.fields(uri){uri.user})] as belonging to media server [$rd]"); + + cache_store("memcached_callid_hash", "$(ct.fields(uri){uri.user})", "$rd", 3600); + } } else { xlog("L_INFO", " Selecting domain from set 1 using round-robin"); - + ds_select_domain("1", "4"); - - t_on_failure("1"); } + + remove_hf("X-AUTH-IP"); append_hf("X-AUTH-IP: $si\r\n"); - - if (isflagset(5)) - { - xlog("L_INFO", " This contact is behind NAT, appending nat=yes to the Contact header"); - - # "nat=yes" is added to help with in-dialog re-INVITE, UPDATE, etc. - search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes'); - } - } + } # record routing if (!is_method("REGISTER|MESSAGE")) @@ -473,6 +479,8 @@ route route[1] { + route("nat_test_and_correct"); + if (!t_relay()) { xlog("L_ERR", " Unable to relay [$rm] [$ru] to [$du], sending 500"); @@ -485,40 +493,41 @@ route[1] exit; } -onreply_route[1] +route[nat_test_and_correct] { - if (t_check_status("(407)|(401)")) + if (client_nat_test("3")) { - cache_store("memcached_callid_hash", "$ci ", "$si", 60); + xlog("L_INFO", " NAT (SIP): Private IP in contact field or via address differs from source"); - xlog("L_INFO", " Stored call-id [$ci] as belonging to media server [$si]"); - } -} + force_rport(); -onreply_route[nat_compensator] -{ - xlog("L_INFO ", " Compensating reply from NATed message [$rs] [$rr]"); + if ((method=="REGISTER" || method=="SUBSCRIBE" || (method=="INVITE" && !has_totag()))) + { + xlog("L_INFO", " NAT (SIP): Activating keep alive pings"); - if (t_check_status("(407)|(401)")) - { - cache_store("memcached_callid_hash", "$ci ", "$si", 60); + nat_keepalive(); + } - xlog("L_INFO", " Stored call-id [$ci] for NATed reply as belonging to media server [$si]"); + fix_contact(); } - - if (has_body("application/sdp")) + + if (has_body("application/sdp") && nat_uac_test("8")) { - xlog("L_INFO", " Fixing nated reply SDP, rewritting media and origin with [$si]"); + xlog("L_INFO", " NAT (SDP): Private IP in SDP"); fix_nated_sdp("10"); } +} + +onreply_route[1] +{ + route("nat_test_and_correct"); - if (is_present_hf("Contact")) + if (t_check_status("(407)|(401)")) { - xlog("L_INFO", " Fixing nated reply contact header"); + cache_store("memcached_callid_hash", "$ci ", "$si", 60); - fix_nated_contact(); - #search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes'); + xlog("L_INFO", " Stored call-id [$ci] as belonging to media server [$si]"); } } @@ -535,12 +544,20 @@ failure_route[1] ds_mark_dst("p"); - if (ds_next_domain()) +# if (ds_next_domain()) + if(ds_select_domain("1", "4")) { xlog("L_ERR", " Hunting for avaliable media server..."); xlog("L_INFO", " Sent [$rm] [$ru] to [$rd]"); + if ($ct.fields(uri) && is_method("INVITE")) + { + xlog("L_INFO", " Stored [$(ct.fields(uri){uri.user})] as belonging to media server [$rd]"); + + cache_store("memcached_callid_hash", "$(ct.fields(uri){uri.user})", "$rd", 3600); + } + t_relay(); exit; @@ -555,3 +572,4 @@ failure_route[1] exit; } + From 5a6fde6555ae917593cf71c248fa863cb5ed072a Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Fri, 13 May 2011 15:40:10 -0700 Subject: [PATCH 17/36] add the second ts opensips --- autoload_configs/acl.conf.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload_configs/acl.conf.xml b/autoload_configs/acl.conf.xml index 32c42f3..41cdd73 100644 --- a/autoload_configs/acl.conf.xml +++ b/autoload_configs/acl.conf.xml @@ -6,6 +6,7 @@ + @@ -13,4 +14,4 @@ - \ No newline at end of file + From bb9df047245782b45b198c6cca7dc3aa32bec21d Mon Sep 17 00:00:00 2001 From: Darren Schreiber Date: Sat, 14 May 2011 18:29:14 -0700 Subject: [PATCH 18/36] Added support for G729 --- freeswitch.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freeswitch.xml b/freeswitch.xml index 6322e4c..86a9db1 100644 --- a/freeswitch.xml +++ b/freeswitch.xml @@ -36,7 +36,7 @@ - +
From 810dba91e6ebbcf63763e644bdb377f2a953c1d7 Mon Sep 17 00:00:00 2001 From: Lum Date: Mon, 16 May 2011 05:30:21 +0000 Subject: [PATCH 19/36] added bandwidth to acl --- autoload_configs/acl.conf.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload_configs/acl.conf.xml b/autoload_configs/acl.conf.xml index 41cdd73..8f0e317 100644 --- a/autoload_configs/acl.conf.xml +++ b/autoload_configs/acl.conf.xml @@ -7,6 +7,7 @@ + From b008b03eaf6ad579002b98d196c1edde66cc6687 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 22 Jun 2011 11:00:14 -0700 Subject: [PATCH 20/36] marker --- sip_profiles/sipinterface_1.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sip_profiles/sipinterface_1.xml b/sip_profiles/sipinterface_1.xml index b2cc9eb..16bd2e1 100644 --- a/sip_profiles/sipinterface_1.xml +++ b/sip_profiles/sipinterface_1.xml @@ -1,7 +1,7 @@ - + From 7af8765819b775d6942cd8313320028e5df5519a Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Wed, 22 Jun 2011 11:03:52 -0700 Subject: [PATCH 21/36] remove the marker --- sip_profiles/sipinterface_1.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sip_profiles/sipinterface_1.xml b/sip_profiles/sipinterface_1.xml index 16bd2e1..b2cc9eb 100644 --- a/sip_profiles/sipinterface_1.xml +++ b/sip_profiles/sipinterface_1.xml @@ -1,7 +1,7 @@ - + From 4b212331d844ad90362478fcb6e0505e44b56ca1 Mon Sep 17 00:00:00 2001 From: clement Date: Wed, 22 Jun 2011 16:52:58 -0700 Subject: [PATCH 22/36] changed the FreeSWITCH limit, FS can now handle 5000 channels and 200 calls per sec --- autoload_configs/switch.conf.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload_configs/switch.conf.xml b/autoload_configs/switch.conf.xml index 36cfed8..ad2e5d4 100644 --- a/autoload_configs/switch.conf.xml +++ b/autoload_configs/switch.conf.xml @@ -26,8 +26,8 @@ - - + + @@ -45,4 +45,4 @@ - \ No newline at end of file + From b2c03a922e93e0c5b5dae5ef2cb11b13683e0c4a Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Fri, 24 Jun 2011 14:27:32 -0700 Subject: [PATCH 23/36] WHISTLE-244: fix the loggin format, and cleaned up the failover --- opensips/opensips.cfg | 268 +++++++++++++++++++++++------------------- 1 file changed, 146 insertions(+), 122 deletions(-) diff --git a/opensips/opensips.cfg b/opensips/opensips.cfg index 6c004b5..b98207e 100644 --- a/opensips/opensips.cfg +++ b/opensips/opensips.cfg @@ -12,8 +12,8 @@ memdump=3 memlog=2 # open_files_limit=2048 server_signature=no -server_header="Server: 2600hz Trunk Store" -user_agent_header="User-Agent: 2600hz Trunk Store" +server_header="Server: 2600hz" +user_agent_header="User-Agent: 2600hz" ###################################################################### ## Core Fork Parameters @@ -137,8 +137,8 @@ modparam("sl", "enable_stats", 1) ###################################################################### ## SIP Transaction UA Module Parameters ###################################################################### -modparam("tm", "fr_timer", 5) -# modparam("tm", "fr_inv_timer", 60) +modparam("tm", "fr_timer", 2) +modparam("tm", "fr_inv_timer", 60) # modparam("tm", "wt_timer", 5) # modparam("tm", "delete_timer", 2) # modparam("tm", "T1_timer", 500) @@ -146,7 +146,7 @@ modparam("tm", "fr_timer", 5) # modparam("tm", "ruri_matching", 1) # modparam("tm", "via1_matching", 1) # modparam("tm", "unix_tx_timeout", 2) -# modparam("tm", "restart_fr_on_each_reply", 1) +modparam("tm", "restart_fr_on_each_reply", 1) # modparam("tm", "fr_timer_avp", "$avp(i:24)") # modparam("tm", "fr_inv_timer_avp", "$avp(i:25)") # modparam("tm", "tw_append", @@ -291,9 +291,14 @@ modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo") ###################################################################### route { + xlog("L_INFO", "$ci|start|recieved $oP request $rm $ou"); + xlog("L_INFO", "$ci|log|source $si:$sp"); + xlog("L_INFO", "$ci|log|from $fu"); + xlog("L_INFO", "$ci|log|to $tu"); + if (!mf_process_maxfwd_header("10")) { - xlog("L_WARN", "To many hops to [$ou] from [$si:$sp]"); + xlog("L_WARN", "$ci|end|to many hops"); sl_send_reply("483", "We refuse to process this endless imbroglio"); @@ -302,86 +307,76 @@ route if (src_ip==myself) { - xlog("L_WARN", "Src IP [$ou] from [$si:$sp]"); + xlog("L_WARN", "$ci|end|sourced from this server"); exit; } - xlog("L_INFO", "Received [$rm] [$ou] from [$si:$sp]"); - xlog("L_DBG", " From: [$fu]"); - xlog("L_DBG", " To: [$tu]"); - if (is_method("OPTIONS|SUBSCRIBE")) { - xlog("L_NOTICE", " Method [$rm] is not supported, sending 503 to [$si:$sp]"); + xlog("L_NOTICE", "$ci|end|unsupported method"); sl_send_reply("503", "Rawr!!"); exit; } - t_on_reply("1"); - t_on_failure("1"); + if (ds_is_in_list("$si", "$sp", "1") || ds_is_in_list("$si", "$sp", "2")) + { + xlog("L_INFO", "$ci|log|originated from internal source"); + + # Flag 26 marks the source as a interal server + setflag(26); + } + else + { + xlog("L_INFO", "$ci|log|originated from external source"); + } if (has_totag()) { - # sequential request withing a dialog should + # sequential request within a dialog should # take the path determined by record-routing if (loose_route()) { append_hf("P-hint: rr-enforced\r\n"); - if (is_method("INVITE")) + if (isflagset(26) && is_method("ACK")) { - # even if in most of the cases is useless, do RR for - # re-INVITEs alos, as some buggy clients do change route set - # during the dialog. - xlog("L_INFO", " Record route for loosely routed INVITE on an existing dialog"); - - #record_route(); - } - - if ((ds_is_in_list("$si", "$sp", "1") || ds_is_in_list("$si", "$sp", "2")) && is_method("ACK")) - { - xlog("L_INFO", " Stored [$tU] as belonging to media server [$fd]"); + xlog("L_INFO", "$ci|log|maintaining contact association to media server $fd"); cache_store("memcached_callid_hash", "$tU ", "$fd", 3600); } + + xlog("L_INFO", "$ci|log|forwarding based on the route set"); - # route it out to whatever destination was set by loose_route() - # in $du (destination URI). route(1); } - else + else if ( is_method("ACK") ) { - if ( is_method("ACK") ) + if ( t_check_trans() ) { - if ( t_check_trans() ) - { - # non loose-route, but stateful ACK; must be an ACK after - # a 487 or e.g. 404 from upstream server - xlog("L_INFO", " Forwarding a stateful ACK for a known dialog"); - - t_relay(); - - exit; - } - else - { - # ACK without matching transaction -> - # ignore and discard - xlog("L_NOTICE", " Recieved ACK from [$si:$sp] for unknown dialog, ignoring"); - - exit; - } - } + # non loose-route, but stateful ACK; must be an ACK after + # a 487 or e.g. 404 from upstream server + xlog("L_INFO", "$ci|log|in dialog request belongs to a known transaction"); - xlog("L_WARN", " Recieved [$rm] for a dialog but the RR is invalid, sending 486 to [$si:$sp]"); + route(1); + } + else + { + # ACK without matching transaction -> + # ignore and discard + xlog("L_NOTICE", "$ci|end|no matching transaction"); - sl_send_reply("486", "PC Load Letter"); + exit; + } } + xlog("L_WARN", "$ci|end|could not route in dialog"); + + sl_send_reply("486", "PC Load Letter"); + exit; } @@ -392,7 +387,13 @@ route # then pass it along to concerned parties if (t_check_trans()) { - t_relay(); + xlog("L_INFO", "$ci|log|request belogs to a known transaction"); + + route(1); + } + else + { + xlog("L_NOTICE", "$ci|end|no matching transaction"); } exit; @@ -402,15 +403,12 @@ route # and do standard processing of the message t_check_trans(); - # Since it is possible to suppress a second provisional response, the first one can be sent pre-emptively - sl_send_reply("100", "Thinking about it..."); - # preloaded route checking if (loose_route()) { if (!is_method("ACK")) { - xlog("L_WARN", " Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci] from [$si:$sp]"); + xlog("L_WARN", "$ci|end|initial request contained a preloaded route set"); sl_send_reply("403", "Please leave the routing up to us"); @@ -422,56 +420,58 @@ route { if (!add_path_received()) { - xlog("L_ERR", " Unable to add path for [$rm] [$tu] from [$si:$sp], sending 503"); + xlog("L_ERR", "$ci|end|unable to add path"); sl_send_reply("503", "Internal path befuddlement"); exit; } - } - - # is not from media servers - if (!ds_is_in_list("$si", "$sp", "1") && !ds_is_in_list("$si", "$sp", "2")) - { - if ($ct.fields(uri) && cache_fetch("memcached_callid_hash", "$(ct.fields(uri){uri.user})", $avp(i:55))) - { - $rd = $avp(i:55); - xlog("L_INFO", " Reconized contact [$ct.fields(uri)] as belonging to media server [$rd]"); - } - else if (cache_fetch("memcached_callid_hash", "$ci", $avp(i:55))) - { - $rd = $avp(i:55); + xlog("L_INFO", "$ci|log|added path"); + } - xlog("L_INFO", " Reconized call-id [$ci] as belonging to media server [$rd]"); + # is from media servers + if (isflagset(26)) + { + xlog("L_INFO", "$ci|log|originated from internal source"); + } + # not from media severs has a contact uri and is in memcache + else if ($ct.fields(uri) && cache_fetch("memcached_callid_hash", "$(ct.fields(uri){uri.user})", $avp(i:55))) + { + $rd = $avp(i:55); + + xlog("L_INFO", "$ci|log|contact $(ct.fields(uri){uri.user}) is associated with media server"); + } + # not from media servers and call id is in memcache + else if (cache_fetch("memcached_callid_hash", "$ci", $avp(i:55))) + { + $rd = $avp(i:55); - if ($ct.fields(uri) && is_method("INVITE")) - { - xlog("L_INFO", " Stored [$(ct.fields(uri){uri.user})] as belonging to media server [$rd]"); + xlog("L_INFO", "$ci|log|call-id is associated with media server $rd"); - cache_store("memcached_callid_hash", "$(ct.fields(uri){uri.user})", "$rd", 3600); - } - } - else + if ($ct.fields(uri) && is_method("INVITE")) { - xlog("L_INFO", " Selecting domain from set 1 using round-robin"); - - ds_select_domain("1", "4"); + xlog("L_INFO", "$ci|log|associated contact $(ct.fields(uri){uri.user}) with media server $rd"); + + cache_store("memcached_callid_hash", "$(ct.fields(uri){uri.user})", "$rd", 3600); } - - remove_hf("X-AUTH-IP"); + } + # not from media servers and no information in memcache + else + { + ds_select_domain("1", "4"); - append_hf("X-AUTH-IP: $si\r\n"); - } + xlog("L_INFO", "$ci|log|routing call to arbitrary media server"); + } # record routing if (!is_method("REGISTER|MESSAGE")) { # Record the route that this request has taken # so we remain in the signaling path - xlog("L_INFO", " Adding record route to this message"); - record_route(); + + xlog("L_INFO", "$ci|log|added this server to the route set"); } route(1); @@ -479,16 +479,33 @@ route route[1] { - route("nat_test_and_correct"); + route("nat_test_and_correct"); + + if ($(rd{ip.isip}) && (ds_is_in_list("$rd", "", "1") || ds_is_in_list("$rd", "", "2"))) + { + remove_hf("X-AUTH-IP"); + + append_hf("X-AUTH-IP: $si\r\n"); + + t_on_reply("internal_reply"); + + t_on_failure("internal_fault"); + } + else + { + t_on_reply("external_reply"); + } if (!t_relay()) { - xlog("L_ERR", " Unable to relay [$rm] [$ru] to [$du], sending 500"); + xlog("L_ERR", "$ci|end|unable to relay message"); sl_reply_error(); } - - xlog("L_INFO", " Sent [$rm] [$ru] to [$rd]"); + else + { + xlog("L_INFO", "$ci|pass|$rd"); + } exit; } @@ -497,79 +514,86 @@ route[nat_test_and_correct] { if (client_nat_test("3")) { - xlog("L_INFO", " NAT (SIP): Private IP in contact field or via address differs from source"); + xlog("L_INFO", "$ci|log|via address differs from source or RFC1918 address in contact"); force_rport(); - if ((method=="REGISTER" || method=="SUBSCRIBE" || (method=="INVITE" && !has_totag()))) - { - xlog("L_INFO", " NAT (SIP): Activating keep alive pings"); - - nat_keepalive(); - } + #xlog("L_INFO", "$ci|log|forced rport"); fix_contact(); + + #xlog("L_INFO", "$ci|log|fixed contact"); } if (has_body("application/sdp") && nat_uac_test("8")) { - xlog("L_INFO", " NAT (SDP): Private IP in SDP"); + xlog("L_INFO", "$ci|log|SDP contains a RFC1918 address"); + + #xlog("L_INFO", "$ci|log|rewrite SDP connection data with source address"); + + #xlog("L_INFO", "$ci|log|rewrite SDP origin with source address "); fix_nated_sdp("10"); } } -onreply_route[1] +onreply_route[external_reply] { + xlog("L_INFO", "$ci|start|recieved external reply $rs $rr"); + xlog("L_INFO", "$ci|log|source $si:$sp"); + + route("nat_test_and_correct"); + + xlog("L_INFO", "$ci|pass|$(si)"); +} + +onreply_route[internal_reply] +{ + xlog("L_INFO", "$ci|start|recieved internal reply $rs $rr"); + xlog("L_INFO", "$ci|log|source $si:$sp"); + route("nat_test_and_correct"); if (t_check_status("(407)|(401)")) { cache_store("memcached_callid_hash", "$ci ", "$si", 60); - xlog("L_INFO", " Stored call-id [$ci] as belonging to media server [$si]"); + xlog("L_INFO", "$ci|log|associated call-id with media server $si"); } + + xlog("L_INFO", "$ci|pass|$(si)"); } -failure_route[1] +failure_route[internal_fault] { if (t_was_cancelled()) { + xlog("L_INFO", "$ci|end|transaction was cancelled"); + exit; } if (t_check_status("(408)|(5[0-9][0-9])")) { - xlog("L_ERR", " Media server [$rd] replied with error [$rs] for [$ru], disabling"); + xlog("L_INFO", "$ci|start|recieved or generated negative reply $rm"); + xlog("L_INFO", "$ci|log|source $si:$sp"); + xlog("L_INFO", "$ci|log|status $rs"); + xlog("L_INFO", "$ci|log|reason $rr"); + + xlog("L_ERR", "$ci|log|moving media server $rd to probing mode"); ds_mark_dst("p"); -# if (ds_next_domain()) if(ds_select_domain("1", "4")) { - xlog("L_ERR", " Hunting for avaliable media server..."); - - xlog("L_INFO", " Sent [$rm] [$ru] to [$rd]"); + xlog("L_INFO", "$ci|log|routing call to arbitrary media server"); if ($ct.fields(uri) && is_method("INVITE")) { - xlog("L_INFO", " Stored [$(ct.fields(uri){uri.user})] as belonging to media server [$rd]"); + xlog("L_INFO", "$ci|log|associated contact $(ct.fields(uri){uri.user}) with media server $rd"); cache_store("memcached_callid_hash", "$(ct.fields(uri){uri.user})", "$rd", 3600); } - - t_relay(); - - exit; } } - else if(!cache_fetch("memcached_callid_hash", "$ci", $avp(i:55))) - { - xlog("L_INFO", " Failed to route call from carrier, sending 486"); - - t_reply("486", "The ratio of people to cake is too big"); - } - - exit; } - From a405743cbef50776535891265935e5f4e1564a07 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Sun, 26 Jun 2011 12:26:31 -0700 Subject: [PATCH 24/36] missing the relay in the failure branch --- opensips/opensips.cfg | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/opensips/opensips.cfg b/opensips/opensips.cfg index b98207e..92a8ce9 100644 --- a/opensips/opensips.cfg +++ b/opensips/opensips.cfg @@ -575,10 +575,8 @@ failure_route[internal_fault] if (t_check_status("(408)|(5[0-9][0-9])")) { - xlog("L_INFO", "$ci|start|recieved or generated negative reply $rm"); + xlog("L_INFO", "$ci|start|recieved or generated negative reply"); xlog("L_INFO", "$ci|log|source $si:$sp"); - xlog("L_INFO", "$ci|log|status $rs"); - xlog("L_INFO", "$ci|log|reason $rr"); xlog("L_ERR", "$ci|log|moving media server $rd to probing mode"); @@ -594,6 +592,12 @@ failure_route[internal_fault] cache_store("memcached_callid_hash", "$(ct.fields(uri){uri.user})", "$rd", 3600); } + + xlog("L_INFO", "$ci|pass|$rd"); + + t_relay(); + + exit; } } } From ccb0076c2552aefe1393b79180d1f913d1fddc7f Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Tue, 28 Jun 2011 19:11:53 -0700 Subject: [PATCH 25/36] diffs from dev --- opensips/opensips.cfg | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/opensips/opensips.cfg b/opensips/opensips.cfg index 92a8ce9..59a5e4e 100644 --- a/opensips/opensips.cfg +++ b/opensips/opensips.cfg @@ -138,7 +138,7 @@ modparam("sl", "enable_stats", 1) ## SIP Transaction UA Module Parameters ###################################################################### modparam("tm", "fr_timer", 2) -modparam("tm", "fr_inv_timer", 60) +modparam("tm", "fr_inv_timer", 120) # modparam("tm", "wt_timer", 5) # modparam("tm", "delete_timer", 2) # modparam("tm", "T1_timer", 500) @@ -146,9 +146,9 @@ modparam("tm", "fr_inv_timer", 60) # modparam("tm", "ruri_matching", 1) # modparam("tm", "via1_matching", 1) # modparam("tm", "unix_tx_timeout", 2) -modparam("tm", "restart_fr_on_each_reply", 1) -# modparam("tm", "fr_timer_avp", "$avp(i:24)") -# modparam("tm", "fr_inv_timer_avp", "$avp(i:25)") +# modparam("tm", "restart_fr_on_each_reply", 1) +modparam("tm", "fr_timer_avp", "$avp(s:final_reply_timer)") +# modparam("tm", "fr_inv_timer_avp", "$avp(s:final_reply_prov)") # modparam("tm", "tw_append", # "test: ua=$hdr(User-Agent) ;avp=$avp(i:10);$rb;time=$Ts") modparam("tm", "pass_provisional_replies", 1) @@ -267,7 +267,7 @@ modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo") ###################################################################### ## MI-Datagram Module Parameters ###################################################################### -# modparam("mi_datagram", "socket_name", "udp:10.180.180.230:8889") +# modparam("mi_datagram", "socket_name", "udp:127.0.0.1:8889") # modparam("mi_datagram", "children_count", 1) # modparam("mi_datagram", "unix_socket_mode", 0600) # modparam("mi_datagram", "unix_socket_group", "root") @@ -324,14 +324,14 @@ route if (ds_is_in_list("$si", "$sp", "1") || ds_is_in_list("$si", "$sp", "2")) { - xlog("L_INFO", "$ci|log|originated from internal source"); + xlog("L_INFO", "$ci|log|inception on-net"); - # Flag 26 marks the source as a interal server + # Flag 26 marks the source as a on-net server setflag(26); } else { - xlog("L_INFO", "$ci|log|originated from external source"); + xlog("L_INFO", "$ci|log|inception off-net"); } if (has_totag()) @@ -487,13 +487,17 @@ route[1] append_hf("X-AUTH-IP: $si\r\n"); - t_on_reply("internal_reply"); + $avp(s:final_reply_timer) = 2; + + t_on_reply("on_net_reply"); - t_on_failure("internal_fault"); + t_on_failure("on_net_fault"); } else { - t_on_reply("external_reply"); + $avp(s:final_reply_timer) = 6; + + t_on_reply("off_net_reply"); } if (!t_relay()) @@ -537,9 +541,9 @@ route[nat_test_and_correct] } } -onreply_route[external_reply] +onreply_route[off_net_reply] { - xlog("L_INFO", "$ci|start|recieved external reply $rs $rr"); + xlog("L_INFO", "$ci|start|recieved off-net reply $rs $rr"); xlog("L_INFO", "$ci|log|source $si:$sp"); route("nat_test_and_correct"); @@ -547,9 +551,9 @@ onreply_route[external_reply] xlog("L_INFO", "$ci|pass|$(si)"); } -onreply_route[internal_reply] +onreply_route[on_net_reply] { - xlog("L_INFO", "$ci|start|recieved internal reply $rs $rr"); + xlog("L_INFO", "$ci|start|recieved on-net reply $rs $rr"); xlog("L_INFO", "$ci|log|source $si:$sp"); route("nat_test_and_correct"); @@ -564,7 +568,7 @@ onreply_route[internal_reply] xlog("L_INFO", "$ci|pass|$(si)"); } -failure_route[internal_fault] +failure_route[on_net_fault] { if (t_was_cancelled()) { @@ -595,6 +599,8 @@ failure_route[internal_fault] xlog("L_INFO", "$ci|pass|$rd"); + $avp(s:final_reply_timer) = 2; + t_relay(); exit; From 7d1a3e343359102a6799702e31ac7772ee48b857 Mon Sep 17 00:00:00 2001 From: Karl Anderson Date: Sun, 17 Jul 2011 21:14:15 -0700 Subject: [PATCH 26/36] increase the volume --- autoload_configs/shout.conf.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload_configs/shout.conf.xml b/autoload_configs/shout.conf.xml index 3f381e6..a90bebf 100644 --- a/autoload_configs/shout.conf.xml +++ b/autoload_configs/shout.conf.xml @@ -2,7 +2,7 @@ - + From 2e971d05d073f2a4e3c7f0c9ae4ffe4c223e038c Mon Sep 17 00:00:00 2001 From: K Anderson Date: Tue, 2 Aug 2011 16:40:03 -0700 Subject: [PATCH 27/36] do not start g729 by default --- autoload_configs/modules.conf.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload_configs/modules.conf.xml b/autoload_configs/modules.conf.xml index e4445fc..9656049 100644 --- a/autoload_configs/modules.conf.xml +++ b/autoload_configs/modules.conf.xml @@ -28,7 +28,7 @@ - + From 7e6b7006aa33e74c82a678a8d1a2373ebbf125c7 Mon Sep 17 00:00:00 2001 From: K Anderson Date: Tue, 23 Aug 2011 13:14:48 -0700 Subject: [PATCH 28/36] added a convience function to flush memcache (requires nc to be installed) --- opensips/dispatcher.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 opensips/dispatcher.sh diff --git a/opensips/dispatcher.sh b/opensips/dispatcher.sh old mode 100644 new mode 100755 index c8f2e47..524e549 --- a/opensips/dispatcher.sh +++ b/opensips/dispatcher.sh @@ -3,7 +3,7 @@ DISPATCHER_FILE="/usr/local/etc/opensips/dispatcher.list" OSIP_CTL="/usr/local/etc/opensips/opensipsctl" fUsage () { - echo "Usage: $0 [Media Server IP] [-a active] [-i inactive] [-p probing] [-r reload]" + echo "Usage: $0 [-r reload] [-f flush] [Media Server IP] [-a active] [-i inactive] [-p probing]" exit 1 } @@ -25,6 +25,9 @@ while [ -n "$*" ]; do x-r) action="r" ;; + x-f) + action="f" + ;; x--help) fUsage ;; @@ -43,6 +46,10 @@ elif [ $action == "r" ]; then echo "# $OSIP_CTL fifo ds_reload" $OSIP_CTL fifo ds_reload exit 0 +elif [ $action == "f" ]; then + echo "# echo \"flush_all\" | nc localhost 11211" + echo "flush_all" | nc localhost 11211 + exit 0 elif grep -q $server $DISPATCHER_FILE; then echo "# $OSIP_CTL fifo ds_set_state $action `grep $server $DISPATCHER_FILE | cut -d' ' -f 1` `grep $server $DISPATCHER_FILE | cut -d' ' -f 2`" $OSIP_CTL fifo ds_set_state $action `grep $server $DISPATCHER_FILE | cut -d' ' -f 1` `grep $server $DISPATCHER_FILE | cut -d' ' -f 2` From 41fa4015702dce6057224f8db346f929616a9b7a Mon Sep 17 00:00:00 2001 From: K Anderson Date: Tue, 23 Aug 2011 13:15:11 -0700 Subject: [PATCH 29/36] added comments and fixed association bug were with maps back to itself --- opensips/opensips.cfg | 145 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 118 insertions(+), 27 deletions(-) diff --git a/opensips/opensips.cfg b/opensips/opensips.cfg index 59a5e4e..e362520 100644 --- a/opensips/opensips.cfg +++ b/opensips/opensips.cfg @@ -291,11 +291,14 @@ modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo") ###################################################################### route { + # log the basic info regarding this call xlog("L_INFO", "$ci|start|recieved $oP request $rm $ou"); xlog("L_INFO", "$ci|log|source $si:$sp"); xlog("L_INFO", "$ci|log|from $fu"); xlog("L_INFO", "$ci|log|to $tu"); + # check that hop cound for this request and make sure it is under 10 + # to prevent endless loops if (!mf_process_maxfwd_header("10")) { xlog("L_WARN", "$ci|end|to many hops"); @@ -305,6 +308,10 @@ route exit; } + # this check detemines if the opensips has routed the request to itself, + # this happens because the server is the destination of the request but + # we mangle it to send it else where. When that mangeling fails and we + # still relay it then it just comes right back to us... if (src_ip==myself) { xlog("L_WARN", "$ci|end|sourced from this server"); @@ -312,6 +319,8 @@ route exit; } + # currently we dont support subscribe in whistle so to keep the noise down + # just end the request here. For options just end the request here as well. if (is_method("OPTIONS|SUBSCRIBE")) { xlog("L_NOTICE", "$ci|end|unsupported method"); @@ -321,7 +330,9 @@ route exit; } - + # if the source IP/port are in one of the server dispatch lists + # then this request originated from one of our media servers, mark it + # as such by setting flag 26 if (ds_is_in_list("$si", "$sp", "1") || ds_is_in_list("$si", "$sp", "2")) { xlog("L_INFO", "$ci|log|inception on-net"); @@ -329,11 +340,16 @@ route # Flag 26 marks the source as a on-net server setflag(26); } + # if the request source IP/port was not in any dispatcher lists + # this this originated outside our equipment (carrier, client, ect) else { xlog("L_INFO", "$ci|log|inception off-net"); } + # if the to header has a tag attached then it implies this request + # has been processed by us before (IE: a media server has added + # its tag on the to header in prior messages) if (has_totag()) { # sequential request within a dialog should @@ -342,7 +358,9 @@ route { append_hf("P-hint: rr-enforced\r\n"); - if (isflagset(26) && is_method("ACK")) + # if the request is an ACK from our media servers with a IP in the from domain + # then bump the association + if ($(fd{ip.isip}) && isflagset(26) && is_method("ACK")) { xlog("L_INFO", "$ci|log|maintaining contact association to media server $fd"); @@ -373,6 +391,8 @@ route } } + # request with a to tag that cant be routed loosly and is not an ACK + # ignor eand discard xlog("L_WARN", "$ci|end|could not route in dialog"); sl_send_reply("486", "PC Load Letter"); @@ -380,7 +400,7 @@ route exit; } - # CANCEL processing + # if the request is to cancel a transaction process it now if (is_method("CANCEL")) { # If this cancel is part of a transaction @@ -391,6 +411,8 @@ route route(1); } + # if the cancel does not belong to a known transaction or a + # request that has not progressed outside this server dont relay it else { xlog("L_NOTICE", "$ci|end|no matching transaction"); @@ -403,7 +425,9 @@ route # and do standard processing of the message t_check_trans(); - # preloaded route checking + # Except for an ACK no request should have a route set with no to tag, this would + # indicate that the intial request has the Route headers and is likely someone trying + # to get us to send the request were they want if (loose_route()) { if (!is_method("ACK")) @@ -416,8 +440,12 @@ route } } + # If the request is a register we will pass it along but we need + # to add the path header (along with the received IP/port info) if (is_method("REGISTER")) { + # if we fail to add the path header then dont let it + # register because it will cause issues later... if (!add_path_received()) { xlog("L_ERR", "$ci|end|unable to add path"); @@ -430,19 +458,21 @@ route xlog("L_INFO", "$ci|log|added path"); } - # is from media servers + # if the request is from on of our media servers then dont change the routing if (isflagset(26)) { xlog("L_INFO", "$ci|log|originated from internal source"); } - # not from media severs has a contact uri and is in memcache + # if the request is not from our media severs but has a contact uri in memcache + # then change the routing to go to the server previously associated with it. else if ($ct.fields(uri) && cache_fetch("memcached_callid_hash", "$(ct.fields(uri){uri.user})", $avp(i:55))) { $rd = $avp(i:55); - xlog("L_INFO", "$ci|log|contact $(ct.fields(uri){uri.user}) is associated with media server"); + xlog("L_INFO", "$ci|log|contact $(ct.fields(uri){uri.user}) is associated with media server $rd"); } - # not from media servers and call id is in memcache + # if the request is not from our media severs but has a call-id in memcache + # then change the routing to go to the server previously associated with it. else if (cache_fetch("memcached_callid_hash", "$ci", $avp(i:55))) { $rd = $avp(i:55); @@ -456,15 +486,26 @@ route cache_store("memcached_callid_hash", "$(ct.fields(uri){uri.user})", "$rd", 3600); } } - # not from media servers and no information in memcache + # if the request is not from our media servers and no associations in memcache + # then try to distribute to a media server + else if (ds_select_domain("1", "4")) + { + xlog("L_INFO", "$ci|log|routing call to arbitrary media server $rd"); + } + # if no media server could be set with ds_select_domain and there is no existing + # association then we have no way to route this call, terminate else { - ds_select_domain("1", "4"); + xlog("L_ERR", "$ci|end|no servers avaliable"); - xlog("L_INFO", "$ci|log|routing call to arbitrary media server"); + sl_send_reply("486", "All servers busy"); + + exit; } - # record routing + # for all initial request (not having been processed above in the has_totag) + # that are not a register or message add this sever to the route set on the + # request so subsequent messages come through this server if (!is_method("REGISTER|MESSAGE")) { # Record the route that this request has taken @@ -481,34 +522,52 @@ route[1] { route("nat_test_and_correct"); + # if the request domain is an IP and it exists in the list of our media servers (irregardless of the port) + # then... + # 1. remove any X-AUTH-IP headers so we will be the only one to set it + # 2. set the X-AUTH-IP header for freeswitch ACLs + # 3. set the final reply timer to two seconds, so we failover faster + # 4. arm a logging branch for replies + # 5. arm a failure branch that will try another one of our media servers when possible if ($(rd{ip.isip}) && (ds_is_in_list("$rd", "", "1") || ds_is_in_list("$rd", "", "2"))) { remove_hf("X-AUTH-IP"); + xlog("L_INFO", "$ci|log|X-AUTH-IP: $si"); + append_hf("X-AUTH-IP: $si\r\n"); + xlog("L_INFO", "$ci|log|provisional reply required in 2 seconds"); + $avp(s:final_reply_timer) = 2; t_on_reply("on_net_reply"); t_on_failure("on_net_fault"); } + # if the request domain is not an IP or in our list of media servers then + # assume it is going somewhere outside our control and give that equipment + # longer to respond. Also arm a branch to log the replies else { + xlog("L_INFO", "$ci|log|provisional reply required in 6 seconds"); + $avp(s:final_reply_timer) = 6; t_on_reply("off_net_reply"); } - if (!t_relay()) + # try to send the request on its way, if it fails send back a + # stateless error to the requestor + if (t_relay()) { - xlog("L_ERR", "$ci|end|unable to relay message"); - - sl_reply_error(); + xlog("L_INFO", "$ci|pass|$rd"); } else { - xlog("L_INFO", "$ci|pass|$rd"); + xlog("L_ERR", "$ci|end|unable to relay message"); + + sl_reply_error(); } exit; @@ -516,33 +575,40 @@ route[1] route[nat_test_and_correct] { + # check if the request is from a client behind NAT, and fix if so... + # this check looks at: + # 1. if client has a private IP address (as defined by RFC1918) in the Contact field of the SIP message + # 2. if client has contacted OpenSIPS from an address that is different from the one in the Via field if (client_nat_test("3")) { xlog("L_INFO", "$ci|log|via address differs from source or RFC1918 address in contact"); + # adds the rport parameter to the first Via header force_rport(); - #xlog("L_INFO", "$ci|log|forced rport"); - + # will replace the IP and port in the Contact header with the IP and port + # the SIP message was received from fix_contact(); - - #xlog("L_INFO", "$ci|log|fixed contact"); } + # if the request has a body see if it needs NAT corrections as well, + # this check looks at: + # 8. SDP is searched for occurrence of RFC1918 addresses if (has_body("application/sdp") && nat_uac_test("8")) { xlog("L_INFO", "$ci|log|SDP contains a RFC1918 address"); - #xlog("L_INFO", "$ci|log|rewrite SDP connection data with source address"); - - #xlog("L_INFO", "$ci|log|rewrite SDP origin with source address "); - + # alters the SDP information in order to facilitate NAT traversal. + # 2. rewrite media IP address (c=) with source IP + # 8. rewrite IP from origin description (o=) with source IP fix_nated_sdp("10"); } } onreply_route[off_net_reply] { + # this branch handles replies that are comming from equipment + # outside our control, just logging and NAT corrections xlog("L_INFO", "$ci|start|recieved off-net reply $rs $rr"); xlog("L_INFO", "$ci|log|source $si:$sp"); @@ -553,11 +619,16 @@ onreply_route[off_net_reply] onreply_route[on_net_reply] { + # this branch handles replies that are comming from our + # media server, just logging and NAT corrections xlog("L_INFO", "$ci|start|recieved on-net reply $rs $rr"); xlog("L_INFO", "$ci|log|source $si:$sp"); route("nat_test_and_correct"); + # if one of our media servers has replied with a 407 or 401 associate + # this call-id with that media server so the next "initial" requests + # go to it (IE: the reply to the challenge) if (t_check_status("(407)|(401)")) { cache_store("memcached_callid_hash", "$ci ", "$si", 60); @@ -570,6 +641,8 @@ onreply_route[on_net_reply] failure_route[on_net_fault] { + # if the failure cause was due to the transaction being + # cancelled then we are complete if (t_was_cancelled()) { xlog("L_INFO", "$ci|end|transaction was cancelled"); @@ -577,6 +650,8 @@ failure_route[on_net_fault] exit; } + # if the failure case was soemthing that we should recover + # from then try to find a new media server if (t_check_status("(408)|(5[0-9][0-9])")) { xlog("L_INFO", "$ci|start|recieved or generated negative reply"); @@ -584,12 +659,24 @@ failure_route[on_net_fault] xlog("L_ERR", "$ci|log|moving media server $rd to probing mode"); + # flag the media server that failed and start sending SIP pings + # when it begins responding put it back in the lsit ds_mark_dst("p"); - if(ds_select_domain("1", "4")) + # keep track of the original request domain so we can detemine + # if ds_select_domain chooses the same domain... + $avp(s:old_rd)=$rd; + + # try to find a new media server to send the calls to, this is + # taking advantage of a bug since ds_select_domain is not supposed + # to be using in the failover branch (but it is necessary in our + # configuration). + if(ds_select_domain("1", "4") && $avp(s:old_rd) != $rd) { - xlog("L_INFO", "$ci|log|routing call to arbitrary media server"); + xlog("L_INFO", "$ci|log|routing call to arbitrary media server $rd"); + # if the request has a contact and is an INVITE then store the new + # association if ($ct.fields(uri) && is_method("INVITE")) { xlog("L_INFO", "$ci|log|associated contact $(ct.fields(uri){uri.user}) with media server $rd"); @@ -599,11 +686,15 @@ failure_route[on_net_fault] xlog("L_INFO", "$ci|pass|$rd"); + # reset the final reply timer $avp(s:final_reply_timer) = 2; + # relay the request to the new media server t_relay(); exit; } + + xlog("L_ERR", "$ci|end|no other media servers avaliable"); } } From cd5230c274f9761c73850d903f51de63853f5ba4 Mon Sep 17 00:00:00 2001 From: K Anderson Date: Wed, 7 Sep 2011 12:00:13 -0700 Subject: [PATCH 30/36] let opensips include the server hostname in the alias list so loose route can properly handle endpoints that add a Route when using a sip proxy --- opensips/opensips.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensips/opensips.cfg b/opensips/opensips.cfg index e362520..ca3bf55 100644 --- a/opensips/opensips.cfg +++ b/opensips/opensips.cfg @@ -34,7 +34,7 @@ log_name="opensips" ###################################################################### ## Aliases ###################################################################### -auto_aliases=no +auto_aliases=yes alias=localhost alias=localhost.localdomain From 2ee11948e215bdf61512fda56f940d3eb11ee1c7 Mon Sep 17 00:00:00 2001 From: K Anderson Date: Tue, 13 Sep 2011 15:14:08 -0700 Subject: [PATCH 31/36] some carriers didnt like our UA --- sip_profiles/sipinterface_1.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sip_profiles/sipinterface_1.xml b/sip_profiles/sipinterface_1.xml index b2cc9eb..0ea6450 100644 --- a/sip_profiles/sipinterface_1.xml +++ b/sip_profiles/sipinterface_1.xml @@ -44,7 +44,7 @@ - + From e73b2856ee3319f98f0744b56203e91ddbecf792 Mon Sep 17 00:00:00 2001 From: K Anderson Date: Tue, 20 Sep 2011 17:05:13 -0700 Subject: [PATCH 32/36] have opensip listen on 7000 --- opensips/opensips.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/opensips/opensips.cfg b/opensips/opensips.cfg index ca3bf55..508d348 100644 --- a/opensips/opensips.cfg +++ b/opensips/opensips.cfg @@ -42,6 +42,7 @@ alias=localhost.localdomain ## Connectivity ###################################################################### listen=udp:eth0:5060 +listen=udp:eth0:7000 # listen=udp:eth1:5060 tos=IPTOS_LOWDELAY # advertised_address=174.129.131.38 From 631ba0198b6c2e288159dc2c6a91674ce9b762ef Mon Sep 17 00:00:00 2001 From: K Anderson Date: Tue, 20 Sep 2011 17:11:09 -0700 Subject: [PATCH 33/36] also listen on tcp --- opensips/opensips.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/opensips/opensips.cfg b/opensips/opensips.cfg index 508d348..8cefa97 100644 --- a/opensips/opensips.cfg +++ b/opensips/opensips.cfg @@ -43,6 +43,8 @@ alias=localhost.localdomain ###################################################################### listen=udp:eth0:5060 listen=udp:eth0:7000 +listen=tcp:eth0:5060 +listen=tcp:eth0:7000 # listen=udp:eth1:5060 tos=IPTOS_LOWDELAY # advertised_address=174.129.131.38 From 0901e4cce67fa5510cc0e542d3dc8e15fd72cb03 Mon Sep 17 00:00:00 2001 From: K Anderson Date: Mon, 26 Sep 2011 06:39:24 -0700 Subject: [PATCH 34/36] use the opensips localcache instead of memcache --- opensips/opensips.cfg | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/opensips/opensips.cfg b/opensips/opensips.cfg index 8cefa97..6301548 100644 --- a/opensips/opensips.cfg +++ b/opensips/opensips.cfg @@ -109,7 +109,7 @@ disable_tcp=no ## Module Loading ###################################################################### mpath="/usr/lib64/opensips/modules/" -loadmodule "memcached.so" +loadmodule "localcache.so" loadmodule "signaling.so" loadmodule "sl.so" loadmodule "tm.so" @@ -128,9 +128,10 @@ loadmodule "mi_fifo.so" # loadmodule "xlog.so" ###################################################################### -## Memcached Module Parameters +## Localcache Module Parameters ###################################################################### -modparam("memcached", "server", "callid_hash = 127.0.0.1:11211") +modparam("localcache", "cache_table_size", 10) +modparam("localcache", "cache_clean_period", 120) ###################################################################### ## Stateless UA Module Parameters @@ -367,7 +368,7 @@ route { xlog("L_INFO", "$ci|log|maintaining contact association to media server $fd"); - cache_store("memcached_callid_hash", "$tU ", "$fd", 3600); + cache_store("local", "$tU", "$fd", 3600); } xlog("L_INFO", "$ci|log|forwarding based on the route set"); @@ -466,17 +467,17 @@ route { xlog("L_INFO", "$ci|log|originated from internal source"); } - # if the request is not from our media severs but has a contact uri in memcache + # if the request is not from our media severs but has a contact uri in localcache # then change the routing to go to the server previously associated with it. - else if ($ct.fields(uri) && cache_fetch("memcached_callid_hash", "$(ct.fields(uri){uri.user})", $avp(i:55))) + else if ($ct.fields(uri) && cache_fetch("local", "$(ct.fields(uri){uri.user})", $avp(i:55))) { $rd = $avp(i:55); xlog("L_INFO", "$ci|log|contact $(ct.fields(uri){uri.user}) is associated with media server $rd"); } - # if the request is not from our media severs but has a call-id in memcache + # if the request is not from our media severs but has a call-id in localcache # then change the routing to go to the server previously associated with it. - else if (cache_fetch("memcached_callid_hash", "$ci", $avp(i:55))) + else if (cache_fetch("local", "$ci", $avp(i:55))) { $rd = $avp(i:55); @@ -486,10 +487,10 @@ route { xlog("L_INFO", "$ci|log|associated contact $(ct.fields(uri){uri.user}) with media server $rd"); - cache_store("memcached_callid_hash", "$(ct.fields(uri){uri.user})", "$rd", 3600); + cache_store("local", "$(ct.fields(uri){uri.user})", "$rd", 3600); } } - # if the request is not from our media servers and no associations in memcache + # if the request is not from our media servers and no associations in localcache # then try to distribute to a media server else if (ds_select_domain("1", "4")) { @@ -634,7 +635,7 @@ onreply_route[on_net_reply] # go to it (IE: the reply to the challenge) if (t_check_status("(407)|(401)")) { - cache_store("memcached_callid_hash", "$ci ", "$si", 60); + cache_store("local", "$ci", "$si", 60); xlog("L_INFO", "$ci|log|associated call-id with media server $si"); } @@ -684,7 +685,7 @@ failure_route[on_net_fault] { xlog("L_INFO", "$ci|log|associated contact $(ct.fields(uri){uri.user}) with media server $rd"); - cache_store("memcached_callid_hash", "$(ct.fields(uri){uri.user})", "$rd", 3600); + cache_store("local", "$(ct.fields(uri){uri.user})", "$rd", 3600); } xlog("L_INFO", "$ci|pass|$rd"); From cf81d7687cb291c851142f519c14e6a980749947 Mon Sep 17 00:00:00 2001 From: K Anderson Date: Fri, 30 Sep 2011 15:37:10 -0700 Subject: [PATCH 35/36] new opensips fixing bug with failover and transfer, also futhering the removal of memcache helpers --- opensips/dispatcher.sh | 4 - opensips/{opensips.cfg => opensips.tmp} | 244 ++++++++++++++++++------ 2 files changed, 181 insertions(+), 67 deletions(-) rename opensips/{opensips.cfg => opensips.tmp} (75%) diff --git a/opensips/dispatcher.sh b/opensips/dispatcher.sh index 524e549..50ae2ee 100755 --- a/opensips/dispatcher.sh +++ b/opensips/dispatcher.sh @@ -46,10 +46,6 @@ elif [ $action == "r" ]; then echo "# $OSIP_CTL fifo ds_reload" $OSIP_CTL fifo ds_reload exit 0 -elif [ $action == "f" ]; then - echo "# echo \"flush_all\" | nc localhost 11211" - echo "flush_all" | nc localhost 11211 - exit 0 elif grep -q $server $DISPATCHER_FILE; then echo "# $OSIP_CTL fifo ds_set_state $action `grep $server $DISPATCHER_FILE | cut -d' ' -f 1` `grep $server $DISPATCHER_FILE | cut -d' ' -f 2`" $OSIP_CTL fifo ds_set_state $action `grep $server $DISPATCHER_FILE | cut -d' ' -f 1` `grep $server $DISPATCHER_FILE | cut -d' ' -f 2` diff --git a/opensips/opensips.cfg b/opensips/opensips.tmp similarity index 75% rename from opensips/opensips.cfg rename to opensips/opensips.tmp index 6301548..b023b36 100644 --- a/opensips/opensips.cfg +++ b/opensips/opensips.tmp @@ -1,3 +1,4 @@ +## TEMPLATE RENDER CMD: sed "s|{{SIP_IP}}|184.106.171.135|g;s|{{SIP_PORT}}|5060|g;s|{{SIP_TLS_PORT}}|5061|g" opensips.tmp > opensips.cfg ###################################################################### ## Core Parameters ###################################################################### @@ -41,14 +42,13 @@ alias=localhost.localdomain ###################################################################### ## Connectivity ###################################################################### -listen=udp:eth0:5060 +listen=udp:eth0:{{SIP_PORT}} listen=udp:eth0:7000 -listen=tcp:eth0:5060 +listen=tcp:eth0:{{SIP_PORT}} listen=tcp:eth0:7000 -# listen=udp:eth1:5060 tos=IPTOS_LOWDELAY -# advertised_address=174.129.131.38 -# advertised_port=5060 +# advertised_address={{SIP_IP}} +# advertised_port={{SIP_PORT}} mcast_loopback=no mcast_ttl=1 mhomed=0 @@ -85,7 +85,7 @@ disable_tcp=no ## TLS ###################################################################### # disable_tls=no -# listen=tls:your_IP:5061 +# listen=tls:{{SIP_IP}}:{{SIP_TLS_PORT}} # tls_verify_server=1 # tls_verify_client=1 # tls_require_client_certificate=0 @@ -231,7 +231,7 @@ modparam("usrloc", "path_column", "path") # modparam("nathelper", "ping_nated_only", 1) # modparam("nathelper", "natping_processes", 3) # modparam("nathelper", "sipping_bflag", 7) -# modparam("nathelper", "sipping_from", "sip:sipcheck@184.106.157.174") +# modparam("nathelper", "sipping_from", "sip:sipcheck@{{SIP_IP}}:{{SIP_PORT}}") # modparam("nathelper", "sipping_method", "INFO") ###################################################################### @@ -239,7 +239,7 @@ modparam("usrloc", "path_column", "path") ###################################################################### modparam("nat_traversal", "keepalive_interval", 60) modparam("nat_traversal", "keepalive_method", "OPTIONS") -modparam("nat_traversal", "keepalive_from", "sip:keepalive@ping.sip.2600hz.com") +modparam("nat_traversal", "keepalive_from", "sip:keepalive@{{SIP_IP}}:{{SIP_PORT}}") modparam("nat_traversal", "keepalive_state_file", "/tmp/opensips_keepalive_state") ###################################################################### @@ -256,9 +256,9 @@ modparam("dispatcher", "cnt_avp", "$avp(i:274)") modparam("dispatcher", "hash_pvar", "$avp(i:273)") # modparam("dispatcher", "setid_pvar", "$var(setid)") modparam("dispatcher", "ds_ping_method", "OPTIONS") -modparam("dispatcher", "ds_ping_from", "sip:sipcheck@184.106.157.174:5060") +modparam("dispatcher", "ds_ping_from", "sip:sipcheck@{{SIP_IP}}:{{SIP_PORT}}") modparam("dispatcher", "ds_ping_interval", 10) -# modparam("dispatcher", "ds_ping_sock", "udp:10.80.25.168:5080") +# modparam("dispatcher", "ds_ping_sock", "udp:{{SIP_IP}}:{{SIP_PORT}}") modparam("dispatcher", "ds_probing_threshhold", 3) modparam("dispatcher", "ds_probing_mode", 0) modparam("dispatcher", "options_reply_codes", "501, 403, 404, 400") @@ -337,8 +337,8 @@ route # if the source IP/port are in one of the server dispatch lists # then this request originated from one of our media servers, mark it # as such by setting flag 26 - if (ds_is_in_list("$si", "$sp", "1") || ds_is_in_list("$si", "$sp", "2")) - { + if (ds_is_in_list("$si", "$sp", "1")) + { xlog("L_INFO", "$ci|log|inception on-net"); # Flag 26 marks the source as a on-net server @@ -364,13 +364,13 @@ route # if the request is an ACK from our media servers with a IP in the from domain # then bump the association - if ($(fd{ip.isip}) && isflagset(26) && is_method("ACK")) - { - xlog("L_INFO", "$ci|log|maintaining contact association to media server $fd"); + #if ($(fd{ip.isip}) && isflagset(26) && is_method("ACK")) + #{ + #cache_store("local", "$tU", "$fd", 3600); + + #xlog("L_INFO", "$ci|log|maintaining contact association to media server $fd"); + #} - cache_store("local", "$tU", "$fd", 3600); - } - xlog("L_INFO", "$ci|log|forwarding based on the route set"); route(1); @@ -467,44 +467,156 @@ route { xlog("L_INFO", "$ci|log|originated from internal source"); } + else + { + if (ds_select_domain("1", "4")) + { + xlog("L_INFO", "$ci|log|loaded media server list"); + } + # if no media server could be set with ds_select_domain then there are no + # active servers, no need to conitnue + else + { + xlog("L_ERR", "$ci|end|no servers avaliable"); + + sl_send_reply("486", "All servers busy"); + + exit; + } + } + # if the request is not from our media severs but has a contact uri in localcache # then change the routing to go to the server previously associated with it. - else if ($ct.fields(uri) && cache_fetch("local", "$(ct.fields(uri){uri.user})", $avp(i:55))) + if ($ct.fields(uri) && cache_fetch("local", "$(ct.fields(uri){uri.user})", $avp(i:55))) { - $rd = $avp(i:55); - - xlog("L_INFO", "$ci|log|contact $(ct.fields(uri){uri.user}) is associated with media server $rd"); + xlog("L_INFO", "$ci|log|contact $(ct.fields(uri){uri.user}) is associated with media server $avp(i:55)"); + + # if the dispatcher list (in 271) does not start with + # the request domain/port that we are sending this call + # to, re-order the list so that it does + if($(avp(i:271)[0]) != $avp(i:55)) + { + # create a index var for our loop (arrays are start at 0 and this is a count) + $var(i) = $avp(i:274) - 1; + + # loop over the dispatcher list + while($var(i) > 0) + { + # if this element in the dispatch list is the same + # as the call destination + if($(avp(i:271)[$var(i)]) == $avp(i:55)) + { + # replace it with the first element of the list + $(avp(i:271)[$(var(i))]) = $(avp(i:271)[0]); + + # break out of the loop + $var(i) = -1; + } + + $var(i) = $var(i) - 1; + } + + # handles the case were we only have two servers + # and the one that we are locked to has failed + if ($var(i) >= 0) + { + xlog("L_INFO", "$ci|log|associated media server is inactive, moving to $rd"); + + # leave the randomly choosen server as the destination and + # overwrite the cache + cache_store("local", "$(ct.fields(uri){uri.user})", "sip:$rd:$rp", 3600); + + cache_store("local", "$ci", "sip:$rd:$rp", 3600); + } + # the server we are locked to is in the active server list from then + # dispatcher so re-arrange the list to try it first + else + { + xlog("L_INFO", "$ci|log|re-ordering the dispatcher list to keep associated server first"); + + # set the first element of the list to the destination + $(avp(i:271)[0]) = $avp(i:55); + + # set the domain for this request (server IP to route to) + $rd = $(avp(i:55){uri.host}); + + # set the port for this request (server IP to route to) + $rp = $(avp(i:55){uri.port}); + } + } } # if the request is not from our media severs but has a call-id in localcache # then change the routing to go to the server previously associated with it. else if (cache_fetch("local", "$ci", $avp(i:55))) { - $rd = $avp(i:55); + xlog("L_INFO", "$ci|log|call-id is associated with media server $avp(i:55)"); + + # if the dispatcher list (in 271) does not start with + # the request domain/port that we are sending this call + # to, re-order the list so that it does + if($(avp(i:271)[0]) != $avp(i:55)) + { + # create a index var for our loop (arrays are start at 0 and this is a count) + $var(i) = $avp(i:274) - 1; + + # loop over the dispatcher list + while($var(i) > 0) + { + # if this element in the dispatch list is the same + # as the call destination + if($(avp(i:271)[$var(i)]) == $avp(i:55)) + { + # replace it with the first element of the list + $(avp(i:271)[$(var(i))]) = $(avp(i:271)[0]); + + # break out of the loop + $var(i) = -1; + } + + $var(i) = $var(i) - 1; + } + + # handles the case were we only have two servers + # and the one that we are locked to has failed + if ($var(i) >= 0) + { + xlog("L_INFO", "$ci|log|associated media server is inactive, moving to $rd"); - xlog("L_INFO", "$ci|log|call-id is associated with media server $rd"); + # leave the randomly choosen server as the destination and + # overwrite the cache + cache_store("local", "$(ct.fields(uri){uri.user})", "sip:$rd:$rp", 3600); + + cache_store("local", "$ci", "sip:$rd:$rp", 3600); + } + # the server we are locked to is in the active server list from then + # dispatcher so re-arrange the list to try it first + else + { + xlog("L_INFO", "$ci|log|re-ordering the dispatcher list to keep associated server first"); + + # set the first element of the list to the destination + $(avp(i:271)[0]) = $avp(i:55); + + # set the domain for this request (server IP to route to) + $rd = $(avp(i:55){uri.host}); + + # set the port for this request (server IP to route to) + $rp = $(avp(i:55){uri.port}); + } + } if ($ct.fields(uri) && is_method("INVITE")) { - xlog("L_INFO", "$ci|log|associated contact $(ct.fields(uri){uri.user}) with media server $rd"); + cache_store("local", "$(ct.fields(uri){uri.user})", "sip:$rd:$rp", 3600); - cache_store("local", "$(ct.fields(uri){uri.user})", "$rd", 3600); + xlog("L_INFO", "$ci|log|associated contact $(ct.fields(uri){uri.user}) with media server sip:$rd:$rp"); } } # if the request is not from our media servers and no associations in localcache - # then try to distribute to a media server - else if (ds_select_domain("1", "4")) - { - xlog("L_INFO", "$ci|log|routing call to arbitrary media server $rd"); - } - # if no media server could be set with ds_select_domain and there is no existing - # association then we have no way to route this call, terminate + # then used the distribute list as is else { - xlog("L_ERR", "$ci|end|no servers avaliable"); - - sl_send_reply("486", "All servers busy"); - - exit; + xlog("L_INFO", "$ci|log|routing call to arbitrary media server $rd:$rp"); } # for all initial request (not having been processed above in the has_totag) @@ -533,7 +645,7 @@ route[1] # 3. set the final reply timer to two seconds, so we failover faster # 4. arm a logging branch for replies # 5. arm a failure branch that will try another one of our media servers when possible - if ($(rd{ip.isip}) && (ds_is_in_list("$rd", "", "1") || ds_is_in_list("$rd", "", "2"))) + if ($(rd{ip.isip}) && ds_is_in_list("$rd", "", "1")) { remove_hf("X-AUTH-IP"); @@ -565,7 +677,7 @@ route[1] # stateless error to the requestor if (t_relay()) { - xlog("L_INFO", "$ci|pass|$rd"); + xlog("L_INFO", "$ci|pass|$rd:$rp"); } else { @@ -618,7 +730,7 @@ onreply_route[off_net_reply] route("nat_test_and_correct"); - xlog("L_INFO", "$ci|pass|$(si)"); + xlog("L_INFO", "$ci|pass|$(si):$(sp)"); } onreply_route[on_net_reply] @@ -633,14 +745,14 @@ onreply_route[on_net_reply] # if one of our media servers has replied with a 407 or 401 associate # this call-id with that media server so the next "initial" requests # go to it (IE: the reply to the challenge) - if (t_check_status("(407)|(401)")) + if (t_check_status("(407)|(401)") && $(si{ip.isip}) && ds_is_in_list("$si", "", "1")) { - cache_store("local", "$ci", "$si", 60); + cache_store("local", "$ci", "sip:$si:$sp", 3600); - xlog("L_INFO", "$ci|log|associated call-id with media server $si"); + xlog("L_INFO", "$ci|log|associated call-id with media server sip:$si:$sp"); } - xlog("L_INFO", "$ci|pass|$(si)"); + xlog("L_INFO", "$ci|pass|$(si):$(sp)"); } failure_route[on_net_fault] @@ -661,44 +773,50 @@ failure_route[on_net_fault] xlog("L_INFO", "$ci|start|recieved or generated negative reply"); xlog("L_INFO", "$ci|log|source $si:$sp"); - xlog("L_ERR", "$ci|log|moving media server $rd to probing mode"); + xlog("L_ERR", "$ci|log|moving media server $rd:$rp to probing mode"); # flag the media server that failed and start sending SIP pings # when it begins responding put it back in the lsit ds_mark_dst("p"); - # keep track of the original request domain so we can detemine - # if ds_select_domain chooses the same domain... - $avp(s:old_rd)=$rd; + # ensure the endpoint is not locked to a failed server + cache_remove("local", "$(ct.fields(uri){uri.user})"); + cache_remove("local", "$ci"); - # try to find a new media server to send the calls to, this is - # taking advantage of a bug since ds_select_domain is not supposed - # to be using in the failover branch (but it is necessary in our - # configuration). - if(ds_select_domain("1", "4") && $avp(s:old_rd) != $rd) + # try to find a new media server to send the call to + if(ds_next_domain()) { - xlog("L_INFO", "$ci|log|routing call to arbitrary media server $rd"); + xlog("L_INFO", "$ci|log|routing call to next media server $rd:$rp"); + + # store the new callid association + cache_store("local", "$ci", "sip:$rd:$rp", 3600); # if the request has a contact and is an INVITE then store the new # association if ($ct.fields(uri) && is_method("INVITE")) { - xlog("L_INFO", "$ci|log|associated contact $(ct.fields(uri){uri.user}) with media server $rd"); + cache_store("local", "$(ct.fields(uri){uri.user})", "sip:$rd:$rp", 3600); - cache_store("local", "$(ct.fields(uri){uri.user})", "$rd", 3600); + xlog("L_INFO", "$ci|log|associated contact $(ct.fields(uri){uri.user}) with media server sip:$rd:$rp"); } - xlog("L_INFO", "$ci|pass|$rd"); + xlog("L_INFO", "$ci|pass|$rd:$rp"); # reset the final reply timer $avp(s:final_reply_timer) = 2; - # relay the request to the new media server - t_relay(); + t_on_reply("on_net_reply"); - exit; - } + t_on_failure("on_net_fault"); - xlog("L_ERR", "$ci|end|no other media servers avaliable"); + # relay the request to the new media server + t_relay(); + + exit(); + } + else + { + xlog("L_ERR", "$ci|end|no other media servers avaliable"); + } } } From 079ddedd5653ec2165e9b58df290ef46872915ee Mon Sep 17 00:00:00 2001 From: K Anderson Date: Mon, 3 Oct 2011 12:52:34 -0700 Subject: [PATCH 36/36] further tweaks to opensips conf --- opensips/opensips.tmp | 144 ++++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 62 deletions(-) diff --git a/opensips/opensips.tmp b/opensips/opensips.tmp index b023b36..b1aee30 100644 --- a/opensips/opensips.tmp +++ b/opensips/opensips.tmp @@ -122,6 +122,7 @@ loadmodule "textops.so" loadmodule "usrloc.so" loadmodule "nathelper.so" loadmodule "nat_traversal.so" +loadmodule "uac_redirect.so" loadmodule "dispatcher.so" loadmodule "mi_fifo.so" # loadmodule "mi_datagram.so" @@ -242,6 +243,15 @@ modparam("nat_traversal", "keepalive_method", "OPTIONS") modparam("nat_traversal", "keepalive_from", "sip:keepalive@{{SIP_IP}}:{{SIP_PORT}}") modparam("nat_traversal", "keepalive_state_file", "/tmp/opensips_keepalive_state") +###################################################################### +## UAC Redirect Module Parameters +###################################################################### +modparam("uac_redirect", "default_filter", "accept") +# modparam("uac_redirect", "deny_filter", NULL) +# modparam("uac_redirect", "accept_filter", NULL) +# modparam("uac_redirect", "acc_function", "acc_log_request") +# modparam("uac_redirect", "acc_db_table", "acc") + ###################################################################### ## Dispatcher Module Parameters ###################################################################### @@ -316,7 +326,7 @@ route # this happens because the server is the destination of the request but # we mangle it to send it else where. When that mangeling fails and we # still relay it then it just comes right back to us... - if (src_ip==myself) + if (src_ip==myself) { xlog("L_WARN", "$ci|end|sourced from this server"); @@ -337,18 +347,20 @@ route # if the source IP/port are in one of the server dispatch lists # then this request originated from one of our media servers, mark it # as such by setting flag 26 - if (ds_is_in_list("$si", "$sp", "1")) + if (ds_is_in_list("$si", "", "1")) { - xlog("L_INFO", "$ci|log|inception on-net"); + xlog("L_INFO", "$ci|log|internal inception (from media server)"); - # Flag 26 marks the source as a on-net server + # Flag 26 marks the source as a on-net server setflag(26); + + setbflag(26); } # if the request source IP/port was not in any dispatcher lists # this this originated outside our equipment (carrier, client, ect) else { - xlog("L_INFO", "$ci|log|inception off-net"); + xlog("L_INFO", "$ci|log|external inception"); } # if the to header has a tag attached then it implies this request @@ -364,7 +376,7 @@ route # if the request is an ACK from our media servers with a IP in the from domain # then bump the association - #if ($(fd{ip.isip}) && isflagset(26) && is_method("ACK")) + #if ($(fd{ip.isip}) && isflagset(26) && is_method("ACK")) #{ #cache_store("local", "$tU", "$fd", 3600); @@ -373,7 +385,7 @@ route xlog("L_INFO", "$ci|log|forwarding based on the route set"); - route(1); + route(correct_transmit_and_die); } else if ( is_method("ACK") ) { @@ -383,7 +395,7 @@ route # a 487 or e.g. 404 from upstream server xlog("L_INFO", "$ci|log|in dialog request belongs to a known transaction"); - route(1); + route(correct_transmit_and_die); } else { @@ -413,9 +425,9 @@ route { xlog("L_INFO", "$ci|log|request belogs to a known transaction"); - route(1); + route(correct_transmit_and_die); } - # if the cancel does not belong to a known transaction or a + # if the cancel does not belong to a known transaction or a # request that has not progressed outside this server dont relay it else { @@ -448,7 +460,7 @@ route # to add the path header (along with the received IP/port info) if (is_method("REGISTER")) { - # if we fail to add the path header then dont let it + # if we fail to add the path header then dont let it # register because it will cause issues later... if (!add_path_received()) { @@ -462,12 +474,9 @@ route xlog("L_INFO", "$ci|log|added path"); } - # if the request is from on of our media servers then dont change the routing - if (isflagset(26)) - { - xlog("L_INFO", "$ci|log|originated from internal source"); - } - else + # if the request is not from a media server it must be for one, load a list of + # currently active servers + if (!isflagset(26)) { if (ds_select_domain("1", "4")) { @@ -479,15 +488,15 @@ route { xlog("L_ERR", "$ci|end|no servers avaliable"); - sl_send_reply("486", "All servers busy"); + sl_send_reply("503", "The cake is a lie!"); exit; } } - # if the request is not from our media severs but has a contact uri in localcache + # if the request is not from our media severs but has a contact uri in localcache # then change the routing to go to the server previously associated with it. - if ($ct.fields(uri) && cache_fetch("local", "$(ct.fields(uri){uri.user})", $avp(i:55))) + if ($ct.fields(uri) && cache_fetch("local", "$(ct.fields(uri){uri.user})", $avp(i:55))) { xlog("L_INFO", "$ci|log|contact $(ct.fields(uri){uri.user}) is associated with media server $avp(i:55)"); @@ -545,7 +554,7 @@ route } } } - # if the request is not from our media severs but has a call-id in localcache + # if the request is not from our media severs but has a call-id in localcache # then change the routing to go to the server previously associated with it. else if (cache_fetch("local", "$ci", $avp(i:55))) { @@ -605,16 +614,16 @@ route } } - if ($ct.fields(uri) && is_method("INVITE")) + if ($ct.fields(uri) && is_method("INVITE")) { cache_store("local", "$(ct.fields(uri){uri.user})", "sip:$rd:$rp", 3600); xlog("L_INFO", "$ci|log|associated contact $(ct.fields(uri){uri.user}) with media server sip:$rd:$rp"); } } - # if the request is not from our media servers and no associations in localcache + # if the request is not from our media servers and no associations in localcache # then used the distribute list as is - else + else if (!isflagset(26)) { xlog("L_INFO", "$ci|log|routing call to arbitrary media server $rd:$rp"); } @@ -631,22 +640,32 @@ route xlog("L_INFO", "$ci|log|added this server to the route set"); } - route(1); + route(correct_transmit_and_die); } -route[1] +route[correct_transmit_and_die] { - route("nat_test_and_correct"); + # if the request is from a media server then assume it is going somewhere + # outside our control and give that equipment longer to respond. + # Also arm a branch to log the replies + if (isflagset(26) || isbflagset(26)) + { + xlog("L_INFO", "$ci|log|provisional reply required in 6 seconds"); + + $avp(s:final_reply_timer) = 6; - # if the request domain is an IP and it exists in the list of our media servers (irregardless of the port) - # then... + t_on_reply("external_reply"); + } + # otherwise the request must be for a media server # 1. remove any X-AUTH-IP headers so we will be the only one to set it # 2. set the X-AUTH-IP header for freeswitch ACLs # 3. set the final reply timer to two seconds, so we failover faster # 4. arm a logging branch for replies # 5. arm a failure branch that will try another one of our media servers when possible - if ($(rd{ip.isip}) && ds_is_in_list("$rd", "", "1")) + else { + route("nat_test_and_correct"); + remove_hf("X-AUTH-IP"); xlog("L_INFO", "$ci|log|X-AUTH-IP: $si"); @@ -657,23 +676,19 @@ route[1] $avp(s:final_reply_timer) = 2; - t_on_reply("on_net_reply"); + t_on_reply("internal_reply"); - t_on_failure("on_net_fault"); + t_on_failure("internal_fault"); } - # if the request domain is not an IP or in our list of media servers then - # assume it is going somewhere outside our control and give that equipment - # longer to respond. Also arm a branch to log the replies - else - { - xlog("L_INFO", "$ci|log|provisional reply required in 6 seconds"); - $avp(s:final_reply_timer) = 6; + route("logged_relay"); - t_on_reply("off_net_reply"); - } + exit; +} - # try to send the request on its way, if it fails send back a +route[logged_relay] +{ + # try to send the request on its way, if it fails send back a # stateless error to the requestor if (t_relay()) { @@ -685,8 +700,6 @@ route[1] sl_reply_error(); } - - exit; } route[nat_test_and_correct] @@ -695,21 +708,21 @@ route[nat_test_and_correct] # this check looks at: # 1. if client has a private IP address (as defined by RFC1918) in the Contact field of the SIP message # 2. if client has contacted OpenSIPS from an address that is different from the one in the Via field - if (client_nat_test("3")) + if (client_nat_test("3")) { xlog("L_INFO", "$ci|log|via address differs from source or RFC1918 address in contact"); # adds the rport parameter to the first Via header force_rport(); - # will replace the IP and port in the Contact header with the IP and port + # will replace the IP and port in the Contact header with the IP and port # the SIP message was received from fix_contact(); } # if the request has a body see if it needs NAT corrections as well, # this check looks at: - # 8. SDP is searched for occurrence of RFC1918 addresses + # 8. SDP is searched for occurrence of RFC1918 addresses if (has_body("application/sdp") && nat_uac_test("8")) { xlog("L_INFO", "$ci|log|SDP contains a RFC1918 address"); @@ -721,27 +734,28 @@ route[nat_test_and_correct] } } -onreply_route[off_net_reply] +onreply_route[external_reply] { # this branch handles replies that are comming from equipment # outside our control, just logging and NAT corrections - xlog("L_INFO", "$ci|start|recieved off-net reply $rs $rr"); + xlog("L_INFO", "$ci|start|recieved external reply $rs $rr"); xlog("L_INFO", "$ci|log|source $si:$sp"); route("nat_test_and_correct"); xlog("L_INFO", "$ci|pass|$(si):$(sp)"); + + # if the reply is not dropped (only provisional replies can be), + # it will be injected and processed by the transaction engine. } -onreply_route[on_net_reply] +onreply_route[internal_reply] { # this branch handles replies that are comming from our # media server, just logging and NAT corrections - xlog("L_INFO", "$ci|start|recieved on-net reply $rs $rr"); + xlog("L_INFO", "$ci|start|recieved internal reply $rs $rr"); xlog("L_INFO", "$ci|log|source $si:$sp"); - route("nat_test_and_correct"); - # if one of our media servers has replied with a 407 or 401 associate # this call-id with that media server so the next "initial" requests # go to it (IE: the reply to the challenge) @@ -753,13 +767,16 @@ onreply_route[on_net_reply] } xlog("L_INFO", "$ci|pass|$(si):$(sp)"); + + # if the reply is not dropped (only provisional replies can be), + # it will be injected and processed by the transaction engine. } -failure_route[on_net_fault] +failure_route[internal_fault] { # if the failure cause was due to the transaction being # cancelled then we are complete - if (t_was_cancelled()) + if (t_was_cancelled()) { xlog("L_INFO", "$ci|end|transaction was cancelled"); @@ -770,7 +787,7 @@ failure_route[on_net_fault] # from then try to find a new media server if (t_check_status("(408)|(5[0-9][0-9])")) { - xlog("L_INFO", "$ci|start|recieved or generated negative reply"); + xlog("L_INFO", "$ci|start|recieved or generated negative reply (>=300)"); xlog("L_INFO", "$ci|log|source $si:$sp"); xlog("L_ERR", "$ci|log|moving media server $rd:$rp to probing mode"); @@ -793,7 +810,7 @@ failure_route[on_net_fault] # if the request has a contact and is an INVITE then store the new # association - if ($ct.fields(uri) && is_method("INVITE")) + if ($ct.fields(uri) && is_method("INVITE")) { cache_store("local", "$(ct.fields(uri){uri.user})", "sip:$rd:$rp", 3600); @@ -805,13 +822,13 @@ failure_route[on_net_fault] # reset the final reply timer $avp(s:final_reply_timer) = 2; - t_on_reply("on_net_reply"); + t_on_reply("internal_reply"); - t_on_failure("on_net_fault"); + t_on_failure("internal_fault"); - # relay the request to the new media server + # relay the request to the new media server t_relay(); - + exit(); } else @@ -819,4 +836,7 @@ failure_route[on_net_fault] xlog("L_ERR", "$ci|end|no other media servers avaliable"); } } -} + + # if no new branch is generated or no reply is forced over, by default, + # the winning reply will be sent back to UAC. +} \ No newline at end of file