Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved out opensips content to the new `ccnq3-opensips-latest` package.

  • Loading branch information...
commit 31f6bf3fd7e71e8a741c824f4ce12f593cc556c3 1 parent f6be2fe
@shimaore authored
Showing with 4 additions and 3,447 deletions.
  1. +0 −113 common/opensips/compiler.coffee
  2. +0 −53 common/opensips/complete.json
  3. +0 −51 common/opensips/conference.json
  4. +0 −86 common/opensips/default.json
  5. +0 −52 common/opensips/emergency.json
  6. +0 −13 common/opensips/fragments/authenticate-disabled.cfg
  7. +0 −181 common/opensips/fragments/authenticate.cfg
  8. +0 −24 common/opensips/fragments/authenticate.modules
  9. +0 −5 common/opensips/fragments/avpops_db.modules
  10. +0 −5 common/opensips/fragments/db_http.modules
  11. +0 −181 common/opensips/fragments/forwarder.cfg
  12. +0 −65 common/opensips/fragments/generic.cfg
  13. +0 −80 common/opensips/fragments/generic.modules
  14. +0 −55 common/opensips/fragments/generic.variables
  15. +0 −22 common/opensips/fragments/invite-emergency.cfg
  16. +0 −170 common/opensips/fragments/invite-outbound-proxy.cfg
  17. +0 −47 common/opensips/fragments/invite-registrar.cfg
  18. +0 −22 common/opensips/fragments/invite-router-local.cfg
  19. +0 −227 common/opensips/fragments/invite-router.cfg
  20. +0 −118 common/opensips/fragments/invite-trunk-drouting.cfg
  21. +0 −23 common/opensips/fragments/invite-trunk-drouting.modules
  22. +0 −175 common/opensips/fragments/invite.cfg
  23. +0 −36 common/opensips/fragments/invite.modules
  24. +0 −11 common/opensips/fragments/loose-route-disabled.cfg
  25. +0 −87 common/opensips/fragments/loose-route.cfg
  26. +0 −127 common/opensips/fragments/mediaproxy.cfg
  27. +0 −7 common/opensips/fragments/mediaproxy.modules
  28. +0 −137 common/opensips/fragments/nat.cfg
  29. +0 −14 common/opensips/fragments/nat.modules
  30. +0 −173 common/opensips/fragments/non-loose-route.cfg
  31. +0 −6 common/opensips/fragments/non-loose-route.modules
  32. +0 −18 common/opensips/fragments/nonat.cfg
  33. +0 −123 common/opensips/fragments/register-colocated.cfg
  34. +0 −18 common/opensips/fragments/register-colocated.modules
  35. +0 −19 common/opensips/fragments/register-ignore.cfg
  36. +0 −12 common/opensips/fragments/register-none.cfg
  37. +0 −49 common/opensips/fragments/register-registrar.cfg
  38. +0 −20 common/opensips/fragments/register-registrar.modules
  39. +0 −50 common/opensips/fragments/register-router.cfg
  40. +0 −88 common/opensips/fragments/registrant.cfg
  41. +0 −16 common/opensips/fragments/registrant.modules
  42. +0 −331 common/opensips/fragments/routing-lineside.cfg
  43. +0 −28 common/opensips/fragments/routing-trunkside-transparent.cfg
  44. +0 −26 common/opensips/fragments/toolbox.cfg
  45. +0 −11 common/opensips/fragments/usrloc_db.modules
  46. +0 −8 common/opensips/local-vars.json.example
  47. +0 −10 common/opensips/make-doc.sh
  48. +0 −26 common/opensips/make.coffee
  49. +0 −54 common/opensips/outbound-proxy.json
  50. +0 −58 common/opensips/registrant.json
  51. +0 −2  debian/ccnq3-munin-opensips.install
  52. +0 −34 debian/ccnq3-opensips.init
  53. +0 −2  debian/ccnq3-opensips.install
  54. +0 −52 debian/ccnq3-opensips.postinst
  55. +4 −25 debian/control
  56. +0 −1  debian/rules
View
113 common/opensips/compiler.coffee
@@ -1,113 +0,0 @@
-#!/usr/bin/env coffee
-# compiler.coffee -- merge OpenSIPS configuration fragments
-
-fs = require 'fs'
-path = require 'path'
-
-macros_cfg = (t,params) ->
-
- # Evaluate parameters after macro substitution
- t = t.replace /// \b define \s+ (\w+) \b ///g, (str,$1) ->
- params[$1] = 1
- return ''
- t = t.replace /// \b undef \s+ (\w+) \b ///g, (str,$1) ->
- params[$1] = 0
- return ''
-
- # Since we don't use a real (LR) parser, these are sorted by match order.
- conditionals = ->
- t = t.replace ///
- \b if \s+ not \s+ (\w+) \b
- ([\s\S]*?)
- \b end \s+ if \s+ not \s+ \1 \b
- ///g, (str,$1,$2) -> if not params[$1] then $2 else ''
- t = t.replace ///
- \b if \s+ (\w+) \s+ is \s+ not \s+ (\w+) \b
- ([\s\S]*?)
- \b end \s+ if \s+ \1 \s+ is \s+ not \s+ \2 \b
- ///g, (str,$1,$2,$3) -> if params[$1] isnt $2 then $3 else ''
- t = t.replace ///
- \b if \s+ (\w+) \s+ is \s+ (\w+) \b
- ([\s\S]*?)
- \b end \s+ if \s+ \1 \s+ is \s+ \2 \b
- ///g, (str,$1,$2,$3) -> if params[$1] is $2 then $3 else ''
- t = t.replace ///
- \b if \s+ (\w+) \b
- ([\s\S]*?)
- \b end \s+ if \s+ \1 \b
- ///g, (str,$1,$2) -> if params[$1] then $2 else ''
-
- do conditionals
- do conditionals
-
- # Substitute parameters
- t = t.replace /// \$ \{ (\w+) \} ///g, (str,$1) ->
- if params[$1]?
- return params[$1]
- else
- console.log "Undefined #{$1}"
- return str
-
- return t
-
-do test = ->
- verify = (t,m,p) ->
- (require 'assert').strictEqual t, macros_cfg m, p
- verify 'var is 3', 'var is ${var}', var:3
- verify 'var is this', 'var is ${var}', var:'this'
- verify ' yes ', 'if it yes end if it', it:1
- verify ' yes ', 'if not it yes end if not it', it:0
- verify '', 'if it is 0 yes end if it is 0', it:1
- verify ' yes ', 'if it is bob yes end if it is bob', it:'bob'
- # verify ' yes ', 'if it is 0 yes end if it is 0', it:0 # fails: strings vs number
- verify ' yes ', 'if it is not bob yes end if it is not bob', it:'bar'
-
-### compile_cfg
-
- Build OpenSIPS configuration from fragments.
-
-###
-
-compile_cfg = (base_dir,params) ->
-
- recipe = params.recipe
-
- result =
- """
- #
- # Automatically generated configuration file.
- # #{params.comment}
- #
-
- """
-
- for extension in ['variables','modules','cfg']
- for building_block in recipe
- file = path.join base_dir, 'fragments', "#{building_block}.#{extension}"
- try
- fragment = "\n## --- Start #{file} --- ##\n\n"
- fragment += fs.readFileSync file
- fragment += "\n## --- End #{file} --- ##\n\n"
- result += fragment
- return macros_cfg result, params
-
-###
-
- configure_opensips
- Subtitute configuration variables in a complete OpenSIPS configuration file
- (such as one generated by compile_cfg).
-
-###
-
-configure_opensips = (params) ->
-
- # Handle special parameters specially
- escape_listen = (_) -> "listen=#{_}\n"
-
- params.listen = params.listen.map(escape_listen).join '' if params.listen?
-
- cfg_text = compile_cfg params.opensips_base_lib, params
-
- fs.writeFileSync params.runtime_opensips_cfg, cfg_text
-
-module.exports = configure_opensips
View
53 common/opensips/complete.json
@@ -1,53 +0,0 @@
-{
- "comment":"Model for a complete proxy that does it all (almost).",
-
- "recipe":[
- "generic",
- "db_http",
- "domain_db",
- "usrloc_db",
- "avpops_db",
- "toolbox",
- "authenticate",
- "nat",
- "mediaproxy",
- "invite-router",
- "invite",
- "invite-trunk-drouting",
- "loose-route",
- "non-loose-route",
- "routing-lineside",
- "routing-trunkside-transparent",
- "register-colocated",
- "forwarder"
- ],
-
- "opensips_base_lib": ".",
- "model": "complete",
- "runtime_opensips_cfg": "/etc/opensips/opensips.cfg",
-
- "db_url": "http://127.0.0.1:34340/",
-
- "proxy_ip": "",
- "proxy_port": 5060,
- "internal_ip": "",
- "external_ip": "",
-
- "authentication": "database",
- "skip_uac_auth": 1,
- "mp_allowed": 1,
- "mp_always": 0,
- "debug": 0,
-
- "radius_config": "",
- "inv_timeout": 90,
- "dialog_timeout": 28800,
-
- "challenge": "",
-
- "sort_order": 1,
-
- "lineside_extra_info": "$pr $si $sp -> $Ri $Rp $json(src_endpoint/endpoint) $au $ad $ar $ci $ru $fu $tu $ua",
-
- "ok":true
-}
View
51 common/opensips/conference.json
@@ -1,51 +0,0 @@
-{
- "comment":"Open proxy with media relay (SBC)",
-
- "recipe":[
- "generic",
- "domain_db",
- "db_http",
- "toolbox",
- "authenticate-disabled",
- "nat",
- "mediaproxy",
- "register-ignore",
- "invite",
- "invite-router-local",
- "loose-route",
- "non-loose-route",
- "forwarder"
- ],
-
- "opensips_base_lib": ".",
- "model": "conference",
- "runtime_opensips_cfg": "/etc/opensips/opensips.cfg",
-
- "db_url": "http://127.0.0.1:34340/",
-
- "ignore_dest_domain": 1,
- "ignore_account": 1,
- "ignore_location": 1,
- "ignore_routing_data": 1,
- "skip_lineside": 1,
-
- "proxy_ip": "",
- "proxy_port": 5060,
- "internal_ip": "",
- "external_ip": "",
-
- "local_port": 5064,
-
- "authentication": "",
- "skip_uac_auth": 1,
- "mp_allowed": 1,
- "mp_always": 1,
- "debug": 0,
-
- "inv_timeout": 90,
- "dialog_timeout": 28800,
-
- "sort_order": 1,
-
- "ok":true
-}
View
86 common/opensips/default.json
@@ -1,86 +0,0 @@
-{
- "comment default": "Lists default values (not specific to a profile). There's no reason to modify these.",
-
- "mpath": "/usr/lib/opensips/modules/",
- "uac_vsf": "vsf",
- "max_hops": "10",
- "children": 30,
- "fork": "yes",
- "log_stderror": "no",
-
- "comment bflag": "Branch flags",
- "bflag_request_mp_callee": 6,
- "bflag_cfb_used": 9,
- "bflag_cfda_used": 10,
- "bflag_auth_attempted": 11,
- "bflag_in_progress": 18,
-
- "comment flag": "Transaction flags",
- "flag_request_mp_callee": 6,
- "flag_request_mp_caller": 7,
- "flag_failed_transaction": 12,
- "flag_dest_domain_set": 16,
- "flag_sock": 18,
- "flag_register_authenticated": 20,
- "flag_tcp_persistent": 21,
- "flag_trunk_routing": 22,
- "flag_has_forwarding": 23,
-
- "comment dflag": "Dialog flags",
- "dflag_cleanup_headers": 1,
-
- "sbc_own_originator": 1,
- "sbc_own_outbound": 2,
- "sbc_csr_outbound": 10,
-
- "sbc_own_upstream": 1,
-
- "comment dflag": "Dialog flags",
- "dflag_mediaproxy": 8,
- "dflag_mediaproxy_engaged": 9,
-
- "auth_table": "subscriber",
- "usrloc_table": "location",
-
- "usrloc_flags": "f",
-
- "fifo_path": "/tmp/opensips_fifo",
- "mi_port": 30000,
-
- "cache_cleanup": 30,
- "cache_timeout": 45,
-
- "voicemail_notifier": "",
-
- "default_expires": 3600,
- "min_expires": 300,
- "max_expires": 7200,
-
- "rate_limit_interval": 10,
- "rate_limit_invite": 50,
- "rate_limit_latency": 60,
- "rate_limit": false,
-
- "dlg_match_mode": 1,
- "fix_invalid_dialogs": false,
- "ignore_broken_register": false,
- "register_check_ip": true,
- "notify": null,
-
- "ignore_static_endpoints": false,
-
- "use_domain_outbound_route": false,
- "use_endpoint_outbound_route": true,
- "use_default_outbound_route": false,
-
- "options_200": false,
-
- "short_fr_timer": 2,
- "long_fr_timer": 4,
-
- "max_contacts": 0,
-
- "sip_warning": 1,
-
- "ok":true
-}
View
52 common/opensips/emergency.json
@@ -1,52 +0,0 @@
-{
- "comment":"Model for an emergency server.",
-
- "recipe":[
- "generic",
- "toolbox",
- "avpops_db",
- "domain_db",
- "db_http",
- "nonat",
- "authenticate",
- "invite-emergency",
- "non-loose-route",
- "loose-route-disabled",
- "register-none"
- ],
-
- "opensips_base_lib": ".",
- "model": "complete",
- "runtime_opensips_cfg": "/tmp/emergency.cfg",
-
- "db_url": "http://127.0.0.1:34340/",
-
- "proxy_ip": "",
- "proxy_port": 5060,
- "internal_ip": "",
- "external_ip": "",
-
- "authentication": "database",
- "skip_uac_auth": 1,
- "mp_allowed": 1,
- "mp_always": 0,
- "debug": 0,
-
- "inv_timeout": 90,
- "dialog_timeout": 28800,
-
- "challenge": "",
-
- "sort_order": 1,
-
- "proxy_port": 5072,
- "fifo_path": "/tmp/emergency_server_fifo",
- "mi_port": 30012,
-
- "sip_domain_name": "bypassed",
- "skip_domain_check": 1,
-
- "children": 20,
-
- "ok":true
-}
View
13 common/opensips/fragments/authenticate-disabled.cfg
@@ -1,13 +0,0 @@
-# Name: authenticate-disabled
-# Group: authenticate
-# Description: replacement module for `authenticate` when no authorization/authentication is desired.
-
-route[authenticate] {
- xlog("L_DBG","-- authenticate -- disabled\n");
-}
-route[authenticate_check] {
- xlog("L_DBG","-- authenticate_check -- disabled\n");
-}
-route[authenticate_register] {
- xlog("L_DBG","-- authenticate_register -- disabled\n");
-}
View
181 common/opensips/fragments/authenticate.cfg
@@ -1,181 +0,0 @@
-# Name: authenticate
-# Group: authenticate
-# Description: authenticate INVITE or REGISTER; populates `src_endpoint` based on IP or username
-# Parameters:
-# authentication: `radius` or `database`
-
-define need_avp_db
-
-route[authenticate] {
-
- $avp(endpoint) := null;
- if(!cache_fetch("local","endpoint $si",$avp(endpoint))) {
- if(!avp_db_load("$si","$avp(endpoint)")) {
- $avp(endpoint) := '{}';
- }
- cache_store("local","endpoint $si","$avp(endpoint)",${cache_timeout});
- }
-
- $json(src_endpoint) := $avp(endpoint);
- $avp(endpoint) := null;
-
- if ignore_static_endpoints
- # Only process inbound_sbc
- if($json(src_endpoint/inbound_sbc)) {
- xlog("L_DBG","-- route(authenticate): inbound_sbc at $si\n");
- } else {
- $avp(endpoint) := '{}';
- $json(src_endpoint) := $avp(endpoint);
- $avp(endpoint) := null;
- }
- end if ignore_static_endpoints
-
- switch($json(src_endpoint/sbc)) {
-
- case ${sbc_own_originator}:
-
- # This type of SBC must provide us with a Sock-Info header,
- # similar to one we would get by doing a add_sock_hdr("Sock-Info") ,
- # or with a RURI parameter "source" that contains the IP address of the actual originator.
- $var(host_info) = null;
-
- xlog("L_DBG","-- route(authenticate): Forwarding SBC $si, RURI $ru, trying header Sock-Info = $(hdr(Sock-Info))\n");
- $var(host_info) = $(hdr(Sock-Info){uri.host});
- xlog("L_DBG","-- route(authenticate): Forwarding SBC $si, host_info = $var(host_info)\n");
- if($var(host_info) == null) {
- xlog("L_DBG","-- route(authenticate): Forwarding SBC $si, trying URI param source = $(ru{uri.param,source})\n");
- $var(host_info) = $(ru{uri.param,source}); # See client-ocs-sbc.
- }
- if($var(host_info) == null) {
- t_reply("503", "Missing source information");
- }
-
- # Replace the src_endpoint data with the data for the source specified by host_info.
- $avp(endpoint) := null;
- if(!cache_fetch("local","endpoint $var(host_info)",$avp(endpoint))) {
- if(!avp_db_load("$var(host_info)","$avp(endpoint)")) {
- $avp(endpoint) := '{}';
- }
- cache_store("local","endpoint $var(host_info)","$avp(endpoint)",${cache_timeout});
- }
-
- $json(src_endpoint) := $avp(endpoint);
- $avp(endpoint) := null;
-
- # And re-authenticate the new endpoint.
- route(authenticate_check); # Authenticate customer
- break;
-
- # Other SBCs are trusted (and the record is valid since we got a value for the "sbc" field).
- case ${sbc_own_outbound}:
- case ${sbc_csr_outbound}:
- xlog("L_DBG","-- route(authenticate): Not authenticating an SBC\n");
- break;
-
- default:
- xlog("L_DBG","-- route(authenticate): Using socket source IP = $si\n");
- route(authenticate_check); # Authenticate customer
- }
-
- if( $json(src_endpoint/disabled) == "true" ) {
- t_reply("503", "Disabled");
- exit;
- }
-
-}
-
-# -----------------------------------------------------------------
-# UAC Authentication (customer-side, "untrusted")
-# -----------------------------------------------------------------
-
-route[authenticate_check] {
- xlog("L_DBG","-- route(authenticate_check): Customer device from $si\n");
-
- # Check whether this is a customer-side trunk (S2S).
- if(!$json(src_endpoint/endpoint)) {
- xlog("L_DBG","-- route(authenticate): Authorizing source $si\n");
-
- if authentication is radius
- if (!radius_proxy_authorize("${challenge}")) {
- proxy_challenge("${challenge}","0");
- exit;
- }
- end if authentication is radius
-
- if authentication is database
- if (!proxy_authorize("${challenge}","${auth_table}")) {
- $var(code) = $retcode;
- xlog("L_DBG","-- route(authenticate): proxy_authorize failed: $var(code)\n");
- proxy_challenge("${challenge}","0");
- exit;
- }
- end if authentication is database
-
- if($json(src_endpoint/bypass_from_auth) == "true") {
- xlog("L_DBG","-- route(authenticate): not checking From username $fu against Authentication ID $aU@$ar\n");
- } else {
- if (!db_check_from()) {
- t_reply("403", "Use From=Authentication-ID");
- exit;
- }
- }
-
- $avp(endpoint) := null;
- $var(endpoint_key) = $aU+"@"+$ar;
- if(!cache_fetch("local","endpoint $var(endpoint_key)",$avp(endpoint))) {
- if(!avp_db_load("$var(endpoint_key)","$avp(endpoint)")) {
- $avp(endpoint) := '{}';
- }
- cache_store("local","endpoint $var(endpoint_key)","$avp(endpoint)",${cache_timeout});
- }
-
- consume_credentials();
-
- if(is_avp_set("$avp(endpoint)")) {
- $json(src_endpoint) := $avp(endpoint);
- } else {
- $json(src_endpoint) = null;
- }
- $avp(endpoint) := null;
-
- if(!$json(src_endpoint/endpoint)) {
- t_reply("500", "Invalid source endpoint");
- exit;
- }
-
- if($json(src_endpoint/require_same_auth) == "true") {
- if( $si == $json(src_endpoint/user_ip) ) {
- xlog("L_DBG","-- route(authenticate): require_same_auth: $si matches with expected source IP\n");
- } else {
- xlog("L_DBG","-- route(authenticate): require_same_auth: $si does not match with expected $json(src_endpoint/user_ip)\n");
- t_reply("403","Incorrect source IP");
- exit;
- }
- }
-
- xlog("L_DBG","-- route(authenticate): Customer device $(json(src_endpoint)).\n");
- }
-}
-
-route[authenticate_register] {
- xlog("L_DBG","-- authenticate_register -- Customer device from $si\n");
-
- if authentication is radius
- if (!radius_www_authorize("${challenge}")) {
- xlog("L_DBG", "-- authenticate_register -- Device $si ($fu) failed to register\n");
- www_challenge("${challenge}","0");
- exit;
- }
- end if authentication is radius
-
- if authentication is database
- if (!www_authorize("${challenge}","${auth_table}")) {
- xlog("L_DBG", "-- authenticate_register -- Device $si ($fu) failed to register\n");
- www_challenge("${challenge}","0");
- exit;
- };
- end if authentication is database
-
- consume_credentials();
-
-}
View
24 common/opensips/fragments/authenticate.modules
@@ -1,24 +0,0 @@
-# authenticate.modules -- modules and configuration for authentication
-
-loadmodule "auth.so"
-modparam("auth", "rpid_prefix", "") # Default value, explicited
-modparam("auth", "rpid_suffix", ";party=calling;id-type=subscriber;screen=yes") # Default value, explicited
-modparam("auth", "nonce_expire", 60)
-
-# testing
-# SJPhone breaks otherwise
-modparam("auth", "disable_nonce_check", 1)
-# /testing
-
-if authentication is database
- loadmodule "auth_db.so"
- modparam("auth_db", "db_url", "${db_url}")
- modparam("auth_db", "calculate_ha1", 0) # calculate_ha1 MUST be 0 in production
- modparam("auth_db", "use_domain", 1)
-end if authentication is database
-
-if authentication is radius
- loadmodule "auth_radius.so"
- modparam("auth_radius", "radius_config", "${radius_config}")
- modparam("auth_radius", "service_type", 15)
-end if authentication is radius
View
5 common/opensips/fragments/avpops_db.modules
@@ -1,5 +0,0 @@
-# -- avpops --
-modparam("avpops", "db_url", "${db_url}")
-modparam("avpops", "avp_table", "avpops")
-modparam("avpops", "use_domain", 1)
-modparam("avpops", "buf_size", 4096) # 4096 bytes to store JSON data
View
5 common/opensips/fragments/db_http.modules
@@ -1,5 +0,0 @@
-loadmodule "db_http.so"
-modparam("db_http", "field_delimiter","\t")
-modparam("db_http", "row_delimiter","\n")
-modparam("db_http", "quote_delimiter","\"")
-modparam("db_http", "timeout", 60000)
View
181 common/opensips/fragments/forwarder.cfg
@@ -1,181 +0,0 @@
-# Name: forwarder
-# Description: Default message forwarder (for anything except ACK, PRACK, CANCEL and UPDATE); adds var-based headers and forward messages using t_relay()
-
-# -------------------------------------------------------------------
-# Default Message Forwarder (anything except ACK/PRACK/CANCEL/UPDATE)
-# -------------------------------------------------------------------
-
-# Note: in most cases (except from failure_route), a call to route(initial_forwarder) should be preceded by a call to route(update_media_proxy).
-
-define has_forwarder
-
-route[cleanup_headers] {
- xlog("L_DBG","-- route(cleanup_headers)\n");
- remove_hf("X-CCNQ3-Number-Domain");
- remove_hf("X-CCNQ3-Extra");
- remove_hf("X-CCNQ3-Location");
- remove_hf("X-CCNQ3-MediaProxy");
- remove_hf("X-CCNQ3-Attrs");
-}
-
-route[initial_forwarder] {
- xlog("L_DBG","-- route(initial_forwarder) Processing $rm $ru\n");
-
- if do_not_forward_register
- if(is_method("REGISTER")) {
- t_reply("500","Unsupported REGISTER");
- exit;
- }
- end if do_not_forward_register
-
- if not ignore_dest_domain
- if($(avp(dest_domain))) {
- xlog("L_DBG","-- route(initial_forwarder) Using destination $(avp(dest_domain))\n");
- $rd = $(avp(dest_domain));
- }
- end if not ignore_dest_domain
-
- if( $var(cleanup_headers) ) {
- route(cleanup_headers);
- if has_dialog_module
- set_dlg_flag("${dflag_cleanup_headers}");
- end if has_dialog_module
- }
-
- remove_hf("P-Charge-Info");
- if not ignore_account
- if($(avp(account))) {
- # Add a P-Charge-Info header.
- # The username part is the account, while the domain part is copied from the RURI.
- append_hf("P-Charge-Info: sip:$(avp(account){s.escape.user})@$rd\r\n");
- }
- end if not ignore_account
-
- if not ignore_location
- #
- # # Use emergency location data if provided in the call
- # $var(location) = $(hdr(X-CCNQ3-Location));
- #
-
- # Use the number's location if it is available.
- # Otherwise use the subscriber's / endpoint location if it is available.
- if($json(src_number/location)) {
- $var(location) = $json(src_number/location);
- remove_hf("X-CCNQ3-Location");
- append_hf("X-CCNQ3-Location: $json(src_number/location)\r\n");
- } else {
- if($json(src_endpoint/location)) {
- $var(location) = $json(src_endpoint/location);
- remove_hf("X-CCNQ3-Location");
- append_hf("X-CCNQ3-Location: $json(src_endpoint/location)\r\n");
- }
- }
- end if not ignore_location
-
- if not ignore_routing_data
- xlog("L_DBG","-- route(initial_forwarder) -- Location = $var(location)\n");
-
- if( $var(location) && avp_db_load("$(var(location))","$(avp(location))") ) {
- $json(location) := $avp(location);
- remove_hf("X-CCNQ3-Routing");
- append_hf("X-CCNQ3-Routing: $json(location/routing_data)\r\n");
- }
- end if not ignore_routing_data
-
- if not ignore_rule_attrs
- if($json(dr_rule_attrs/cdr)) {
- remove_hf("X-CCNQ3-Attrs");
- append_hf("X-CCNQ3-Attrs: $json(dr_rule_attrs/cdr)\r\n");
- }
- end if not ignore_rule_attrs
-
- if not ignore_extra_info
- if($avp(extra_info)) {
- append_hf("X-CCNQ3-Extra: $avp(extra_info)\r\n");
- }
- end if not ignore_extra_info
-
- if not ignore_number_domain
- if($var(number_domain)) {
- remove_hf("X-CCNQ3-Number-Domain");
- append_hf("X-CCNQ3-Number-Domain: $var(number_domain)\r\n");
- }
- end if not ignore_number_domain
-
- if not ignore_masking
- # Insert a Privacy: id header if true.
- if($json(src_number/privacy) == "true") {
- remove_hf("Privacy");
- append_hf("Privacy: id\r\n");
- }
- # Insert a PAID header if non-empty.
- if($json(src_number/asserted_number)) {
- remove_hf("P-Asserted-Identity");
- append_hf("P-Asserted-Identity: <$json(src_number/asserted_number)@$fd>\r\n");
- }
- end if not ignore_masking
-
- serialize_branches(1);
-
- route(forwarder);
-}
-
-route[forwarder] {
- xlog("L_DBG","-- forwarder -- t_relay $rm $ru\n");
-
- if has_dialog_module
- if( is_dlg_flag_set("${dflag_cleanup_headers}") ) {
- route(cleanup_headers);
- }
- end if has_dialog_module
-
- if do_not_forward_register
- if(is_method("REGISTER")) {
- t_reply("500","Unsupported REGISTER");
- exit;
- }
- end if do_not_forward_register
-
- if (!t_relay("0x01")) { # Prevent dup 100
- if mediaproxy
- # t_relay failed, check if we need to stop mediaproxy
- if (is_method("INVITE")) {
- route(stop_media_proxy); # End media session
- };
- end if mediaproxy
- t_reply("500","Transmission failure");
- }
- exit;
-}
-
-# -----------------------------------------------------------------
-# Forward ACK, PRACK, CANCEL, and UPDATE
-# -----------------------------------------------------------------
-
-route[forwarder_progress]
-{
- xlog("L_DBG","-- forwarder-progress -- ACK/PRACK/CANCEL/UPDATE Processing $rm $ru\n");
-
- if(!t_check_trans()) {
- xlog("L_DBG", "-- forwarder-progress -- Dropping mis-routed $rm (481)\n");
- # Can't send a reply to an ACK
- if(!is_method("ACK")) {
- t_reply("481", "Call/Transaction Does Not Exist");
- }
- exit;
- }
-
- xlog("L_DBG", "-- forwarder-progress -- t_relay $rm $ru\n");
- if(!t_relay("0x01")) { # Prevent dup 100
- # t_relay failed, check if we need to stop mediaproxy
- if (is_method("ACK")) {
- xlog("L_DBG", "-- forwarder-progress -- t_relay failed, dropping ACK\n");
- if mediaproxy
- route(stop_media_proxy); # End media session
- end if mediaproxy
- } else { # Can't send a reply to an ACK
- t_reply("500","Transmission failure");
- }
- }
- exit;
-}
View
65 common/opensips/fragments/generic.cfg
@@ -1,65 +0,0 @@
-# Name: generic.cfg
-# Required
-# Description: main route statement
-
-# ROUTING
-
-startup_route {
- xlog("L_DBG","-- startup_route()\n");
- if notify
- subscribe_event("E_CORE_THRESHOLD","${notify}");
- subscribe_event("E_CORE_PKG_THRESHOLD","${notify}");
- subscribe_event("E_CORE_SHM_THRESHOLD","${notify}");
- if pike_event
- subscribe_event("E_PIKE_BLOCKED","${notify}");
- end if pike_event
-
- subscribe_event("E_SCRIPT_REPORT","${notify}");
-
- $avp(event-names) := null;
- $avp(event-values) := null;
- $avp(event-names) = "event";
- $avp(event-values) = "startup";
- raise_event("E_SCRIPT_REPORT",$avp(event-names),$avp(event-values));
-
- end if notify
-}
-
-route
-{
- route(initialize);
-
- xlog("L_DBG","-- route() -- $rm -- From: $fu -- To: $tu -- RURI: $ru\n");
-
- if(loose_route()) {
- route(loose_route_handler);
- exit;
- } else {
- $avp(domain) := null;
- if( $rd == "${sip_domain_name}" ) {
- $avp(domain) = "${sip_domain_name}";
- }
- if support_alternate_domains
- else {
- # Cache the domains we support.
- if(!cache_fetch("local","domain $rd",$avp(domain))) {
- avp_db_load("$rd","$avp(domain)");
- cache_store("local","domain $rd","$avp(domain)",${cache_timeout});
- }
- }
- end if support_alternate_domains
-
- if skip_domain_check
- $avp(domain) = 'no-such-domain';
- end if skip_domain_check
-
- # Check whether the domain is local.
- if(is_avp_set("$avp(domain)")) {
- route(non_loose_route_handler);
- exit;
- } else {
- route(non_local_uri_handler);
- exit;
- }
- }
-}
View
80 common/opensips/fragments/generic.modules
@@ -1,80 +0,0 @@
-# generic.modules -- shared modules and configuration
-
-## ------- Modules ---------- ##
-
-loadmodule "cachedb_local.so"
-modparam("cachedb_local", "cache_clean_period", ${cache_cleanup})
-modparam("cachedb_local", "cache_table_size", 12)
-
-# -- JSON --
-loadmodule "json.so"
-
-# -- MI --
-if fifo_path
-loadmodule "mi_fifo.so"
-modparam("mi_fifo","fifo_name", "${fifo_path}")
-end if fifo_path
-
-loadmodule "mi_datagram.so"
-modparam("mi_datagram", "socket_name", "udp:127.0.0.1:${mi_port}")
-
-# -- Common --
-loadmodule "sl.so"
-loadmodule "tm.so"
-
-# Timeout for Final reply for INVITE after provisional msg (1xx).
-# This is e.g. the time we wait for ringing before trying the next route.
-modparam("tm", "fr_inv_timer", ${inv_timeout})
-# default is 120
-# Same, as an AVP
-modparam("tm", "fr_inv_timer_avp", "$(avp(inv_timer))")
-# noisy_ctimer: Recommended by Gafachi, probably makes sense in this application
-# modparam("tm", "noisy_ctimer", 1)
-
-# For better interaction with broken (pre-3261) devices, turn these off.
-# modparam("tm", "ruri_matching", 0)
-# modparam("tm", "via1_matching", 0)
-
-# Timeout for Final reply for request or ACK for negative INVITE reply
-# This is the time we wait to failover if a carrier is dead, basically.
-# 6 seconds is one ring cycle.
-
-if use_shorter_fr_timer
- modparam("tm", "fr_timer", ${short_fr_timer})
-end if use_shorter_fr_timer
-
-if not use_shorter_fr_timer
- modparam("tm", "fr_timer", ${long_fr_timer})
-end if not use_shorter_fr_timer
-
-
-loadmodule "rr.so"
-
-loadmodule "maxfwd.so"
-loadmodule "uri.so"
-loadmodule "textops.so"
-loadmodule "sipmsgops.so"
-
-# -- signaling --
-loadmodule "signaling.so"
-
-if rate_limit
- loadmodule "ratelimit.so"
- modparam("ratelimit", "timer_interval", ${rate_limit_interval})
- modparam("ratelimit", "default_algorithm", "RED")
- if rate_limit_cache
- # e.g. "redis://127.0.0.1/"
- modparam("ratelimit", "cachedb_url", "${rate_limit_cache}")
- modparam("ratelimit", "db_prefix", "ratelimit_")
- end if rate_limit_cache
-end if rate_limit
-
-# -- avpops --
-# Note: see also avpops_db.modules for additional configuration.
-loadmodule "avpops.so"
-
-if notify
- loadmodule "event_rabbitmq.so"
-end if notify
-
-loadmodule "statistics.so"
View
55 common/opensips/fragments/generic.variables
@@ -1,55 +0,0 @@
-# generic.variables -- shared variables
-
-#
-# For OpenSIPS 1.10
-#
-
-# What IP address to listen onto; no statement == listen on all interfaces
-if proxy_ip
-listen=${proxy_ip}
-end if proxy_ip
-
-if proxy_port
-port=${proxy_port}
-end if proxy_port
-
-# Additionally can support multiple listen statements
-if listen
-${listen}
-end if listen
-
-## ------- Variables ---------- ##
-
-# Debug level (syslog)
-debug=${debug}
-# Fork is yes for normal use
-fork=${fork}
-# Do not log to STDERR
-log_stderror=${log_stderror}
-
-# Children=4 or higher (in production)
-children=${children}
-
-# Suppress any warnings about our IP not being in the DNS server
-dns=no
-rev_dns=no
-dns_use_search_list=no
-# This is now the default in 1.3.
-disable_dns_blacklist=yes
-
-dns_try_ipv6=yes
-
-mpath="${mpath}"
-
-server_header="Server: ccnq3 ${model} proxy"
-user_agent_header="User-Agent: ccnq3 ${model} proxy"
-
-if sip_domain_name
-alias="${sip_domain_name}"
-end if sip_domain_name
-
-event_pkg_threshold = 90
-event_shm_threshold = 90
-
-log_name="opensips-${model}"
-sip_warning=${sip_warning}
View
22 common/opensips/fragments/invite-emergency.cfg
@@ -1,22 +0,0 @@
-# Name: invite-emergency
-# Group: invite_handlers
-# Description: INVITE handler for an emergency call router
-
-route[invite_handler]
-{
- if( is_present_hf("X-CCNQ3-Routing") ) {
- $var(emergency_key) = $rU + '#' + $hdr(X-CCNQ3-Routing);
- } else {
- $var(emergency_key) = $rU;
- }
-
- if(avp_db_load("$var(emergency_key)","$avp(emergency)")) {
- $json(emergency) := $avp(emergency);
- $avp(emergency) := null;
- append_to_reply("Contact: sip:$json(emergency/destination)@$json(src_endpoint/emergency_domain)\r\n");
- t_reply("302","Found");
- } else {
- append_to_reply("X-CCNQ3-Emergency-Key: $var(emergency_key)\r\n");
- sl_send_reply("404","Not found");
- }
-}
View
170 common/opensips/fragments/invite-outbound-proxy.cfg
@@ -1,170 +0,0 @@
-# Name: invite-outbound-proxy
-# Group: invite_handlers
-# Description: INVITE handler for an outbound-proxy
-
-define use_drouting
-define skip_lineside
-define use_shorter_fr_timer
-
-define need_avp_db
-
-route[invite_handler]
-{
- xlog("L_DBG","-- invite-outbound-proxy -- $ru\n");
-
- t_on_failure("1");
- t_on_reply("1");
-
- # Need to be able to route based on:
- # - calling number + called number
- # - called number
- # - calling number
- # For the outbound-proxy, needs to be able to do LCR.
- # See http://www.opensips.org/html/docs/modules/1.5.x/drouting.html
-
- # Attempt to find a local number first.
- # Alternatively, use Carrier ENUM.
- $avp(number) := null;
- if(!cache_fetch("local","number $rU",$avp(number))) {
- if(!avp_db_load("$rU","$avp(number)")) {
- $avp(number) := '{}';
- }
- cache_store("local","number $rU","$avp(number)",${cache_timeout});
- }
-
- $json(dst_number) := $avp(number);
- $avp(number) := null;
-
- if($json(dst_number/inbound_uri)) {
- xlog("L_DBG","-- invite-oubound-proxy -- Using local inbound_uri\n");
- $ru = $json(dst_number/inbound_uri);
- setflag(${flag_trunk_routing});
- t_on_branch("1");
- route(initial_forwarder); # Forward
- return;
- }
-
- if use_registrant
- $avp(number) := null;
- if(!cache_fetch("local","number $fU",$avp(number))) {
- if(!avp_db_load("$fU","$avp(number)")) {
- $avp(number) := '{}';
- }
- cache_store("local","number $fU","$avp(number)",${cache_timeout});
- }
-
- $json(src_number) := $avp(number);
- $avp(number) := null;
-
- if($json(src_number/registrant_password)) {
- append_hf("X-CCNQ3-Registrant-Password: $(json(src_number/registrant_password))\r\n");
- }
- if($json(src_number/registrant_realm)) {
- append_hf("X-CCNQ3-Registrant-Realm: $(json(src_number/registrant_realm))\r\n");
- }
- if($json(src_number/registrant_remote_ipv4)) {
- append_hf("X-CCNQ3-Registrant-Target: $(json(src_number/registrant_remote_ipv4))\r\n");
- }
- end if use_registrant
-
- if not use_registrant
- $json(src_number) := '{}';
- end if not use_registrant
-
- # Only outbound SBCs may route calls.
- switch($json(src_endpoint/sbc)) {
- case ${sbc_own_outbound}:
- case ${sbc_csr_outbound}:
- break;
- default:
- t_reply("403","Routing Forbidden");
- exit;
- }
-
- route(lookup_src);
-
- # LCR
- route(invite_trunk_drouting);
-
- # Invalid destination
- # Used to be 502, but it prevents progress (no route might be due to database error
- # or during OpenSIPS startup with a very large database).
- t_reply("503", "No route");
- exit;
-}
-
-route[lookup_src]
-{
- # -- Outbound call
- if($json(src_endpoint/endpoint)) {
- $(avp(src_type)) = "ONNET";
-
- if( $json(src_endpoint/src_disabled) == "true" ) {
- t_reply("403", "Administratively Forbidden");
- exit;
- }
-
- if not ignore_dest_domain
- if( (! isflagset(${flag_dest_domain_set}))
- && $json(src_endpoint/dest_domain) ) {
- setflag(${flag_dest_domain_set});
- }
- end if not ignore_dest_domain
-
- if( $json(src_endpoint/user_force_mp) == "true" ) {
- xlog("L_DBG","-- invite-outbound-proxy -- Force MediaProxy for $(json(src_endpoint/endpoint))\n");
- setflag(${flag_request_mp_caller}); # force MP for caller
- }
-
- # Account selection
- avp_delete("$(avp(account))");
-
- switch($json(src_endpoint/sbc)) {
- case ${sbc_own_outbound}:
- # Trust the account information provided by this internal SBC.
- if($(hdr(P-Charge-Info))) {
- $avp(account) = $(hdr(P-Charge-Info){uri.user}{s.unescape.user});
- }
- break;
-
- case ${sbc_csr_outbound}:
- # Check the customer-provided account against a list of authorized accounts.
- if(!$(hdr(P-Charge-Info))) {
- t_reply("403","Missing P-Charge-Info header");
- exit;
- }
-
- $avp(account) = $(hdr(P-Charge-Info){uri.user}{s.unescape.user});
-
- $avp(account_forwarder_key) = "$avp(account)@$json(src_endpoint/endpoint)";
- $avp(account_forwarder) := null;
- if(!cache_fetch("local","account_forwarder $avp(account_forwarder_key)",$avp(account_forwarder))) {
- if(!avp_db_load("$avp(account_forwarder_key)","$avp(account_forwarder)")) {
- $avp(account_forwarder) := '{}';
- }
- cache_store("local","account_forwarder $avp(account_forwarder_key)","$avp(account_forwarder)",${cache_timeout});
- }
-
- $json(account_forwarder) := $avp(account_forwarder);
- $avp(account_forwarder) := null;
-
- if( ! $json(account_forwarder/account) ) {
- t_reply("403","Invalid P-Charge-Info header");
- exit;
- }
- break;
-
- default:
- # Use the endpoint's account information.
- $avp(account) = $json(src_endpoint/account);
- }
- #/ Account selection
-
- # Max call duration
- if( $json(src_endpoint/dialog_timer) ) {
- $avp(dialog_timer) = $json(src_endpoint/dialog_timer);
- }
-
- xlog("L_DBG","-- invite-outbound-proxy -- Customer device $(json(src_endpoint)) with account $(avp(account)).\n");
- }
-}
View
47 common/opensips/fragments/invite-registrar.cfg
@@ -1,47 +0,0 @@
-# Name: invite-registrar
-# Group: invite_handlers
-# Description: INVITE handler for a standalone registrar (UNTESTED)
-
-define need_avp_db
-
-route[invite_handler]
-{
- if(lookup("${usrloc_table}")) {
- t_reply("302","User found");
- exit;
- }
-
- switch ($retcode) {
- # No contact found
- case -1:
- # Contact found, method not supported.
- case -2:
- # Internal error
- case -3:
- if( $(avp(cfnr)) ) {
- $ru = $(avp(cfnr));
- t_reply("302","Call forward not registered");
- exit;
- }
-
- if( $json(dst_endpoint/user_srv) ) {
- $ru = "sip:" + $var(a) + "@" + $json(dst_endpoint/user_srv);
- $rp = ""; # Clear port
- t_reply("302","User SRV");
- exit;
- }
-
- if( $json(dst_endpoint/user_ip) ) {
- $ru = "sip:" + $var(a) + "@" + $json(dst_endpoint/user_ip);
- if( $json(dst_endpoint/user_port) ) {
- $rp = $json(dst_endpoint/user_port);
- }
- t_reply("302","User IP");
- exit;
- }
-
- t_reply("404", "Not Found");
- exit;
- break;
- };
-}
View
22 common/opensips/fragments/invite-router-local.cfg
@@ -1,22 +0,0 @@
-# Name: invite-router-local
-# Group: invite_handlers
-# Description: INVITE handler for a router that forwards to a static server.
-
-route[invite_handler]
-{
- xlog("L_DBG","-- invite-router-local -- $ru\n");
-
- t_on_failure("1");
- t_on_reply("1");
-
- $ru = "sip:"+$rU+"@${local_ipv4}:${local_port}";
-
- # The forwarder module will complain otherwise.
- $json(src_number) = '{}';
-
- if mediaproxy
- route(update_media_proxy);
- end if mediaproxy
- route(initial_forwarder);
- exit;
-}
View
227 common/opensips/fragments/invite-router.cfg
@@ -1,227 +0,0 @@
-# Name: invite-router
-# Group: invite_handlers
-# Description: INVITE handler for a generic router
-
-# -----------------------------------------------------------------
-# INVITE Message Handler
-# -----------------------------------------------------------------
-
-define need_avp_db
-
-route[invite_handler]
-{
- xlog("L_DBG","-- invite-router -- $ru\n");
-
- t_on_failure("1");
- t_on_reply("1");
-
- # Attempt to locate the `number_domain` of the calling number,
- # assuming it is a local (on-net) number.
- if($json(src_endpoint/number_domain)) {
- xlog("L_DBG","-- invite-router -- src_number uses (endpoint) number_domain $json(src_endpoint/number_domain)\n");
- $var(number_domain) = $json(src_endpoint/number_domain);
- }
-
- # Locate the source "local number" record.
- $avp(number) := null;
- $var(local_number) = $fU+"@"+$var(number_domain);
- if(!cache_fetch("local","number $var(local_number)",$avp(number))) {
- if(!avp_db_load("$var(local_number)","$avp(number)")) {
- $avp(number) := '{}';
- }
- cache_store("local","number $var(local_number)","$avp(number)",${cache_timeout});
- }
-
- $json(src_number) := $avp(number);
- $avp(number) := null;
-
- if rate_limit
- if( $json(src_number/rate_limit) ) {
- if(!rl_check( "number_$json(src_number/number)", "$json(src_number/rate_limit)" )) {
- xlog("L_DBG","-- invite-router -- Calling Number Rate Limit Exceeded --\n");
-
- if notify
- $avp(event-names) := null;
- $avp(event-values) := null;
- $avp(event-names) = "event";
- $avp(event-values) = "calling_number_rate_limit_exceeded";
- $avp(event-names) = "number";
- $avp(event-values) = "$json(src_number/number)";
- $avp(event-names) = "limit";
- $avp(event-values) = "$json(src_number/rate_limit)";
- $avp(event-names) = "ip";
- $avp(event-values) = "$si";
- raise_event("E_SCRIPT_REPORT",$avp(event-names),$avp(event-values));
- end if notify
-
- append_to_reply("Retry-After: ${rate_limit_latency}");
- sl_send_reply("503","Calling Number Rate Limit Exceeded");
- exit;
- }
- }
- if( $json(src_endpoint/rate_limit) ) {
- if(!rl_check( "endpoint_$json(src_endpoint/endpoint)", "$json(src_endpoint/rate_limit)" )) {
- append_to_reply("Retry-After: ${rate_limit_latency}");
- sl_send_reply("503","Calling Endpoint Rate Limit Exceeded");
-
- xlog("L_DBG","-- invite-router -- Calling Endpoint Rate Limit Exceeded --\n");
- $avp(event-names) := null;
- $avp(event-values) := null;
- $avp(event-names) = "event";
- $avp(event-values) = "calling_endpoint_rate_limit_exceeded";
- $avp(event-names) = "endpoint";
- $avp(event-values) = "$json(src_endpoint/endpoint)";
- $avp(event-names) = "limit";
- $avp(event-values) = "$json(src_endpoint/rate_limit)";
- $avp(event-names) = "ip";
- $avp(event-values) = "$si";
- raise_event("E_SCRIPT_REPORT",$avp(event-names),$avp(event-values));
- exit;
- }
- }
- end if rate_limit
-
- if( $json(src_number/max_channels) ) {
- set_dlg_profile("number","$json(src_number/number)");
- get_profile_size("number","$json(src_number/number)","$avp(size)");
- if($avp(size) > $json(src_number/max_channels)) {
- sl_send_reply("503","Calling Number Out-of-Channels");
-
- xlog("L_DBG","-- invite-router -- Calling Number Out-of-Channels --\n");
- $avp(event-names) := null;
- $avp(event-values) := null;
- $avp(event-names) = "event";
- $avp(event-values) = "calling_number_out_of_channels";
- $avp(event-names) = "number";
- $avp(event-values) = "$json(src_number/number)";
- $avp(event-names) = "max_channels";
- $avp(event-values) = "$json(src_number/max_channels)";
- $avp(event-names) = "current_channels";
- $avp(event-values) = "$avp(size)";
- $avp(event-names) = "ip";
- $avp(event-values) = "$si";
- raise_event("E_SCRIPT_REPORT",$avp(event-names),$avp(event-values));
- exit;
- }
- }
- if( $json(src_endpoint/max_channels) ) {
- set_dlg_profile("endpoint","$json(src_endpoint/endpoint)");
- get_profile_size("endpoint","$json(src_endpoint/endpoint)","$avp(size)");
- if($avp(size) > $json(src_endpoint/max_channels)) {
- sl_send_reply("503","Calling Endpoint Out-of-Channels");
-
- xlog("L_DBG","-- invite-router -- Calling Endpoint Out-of-Channels --\n");
- $avp(event-names) := null;
- $avp(event-values) := null;
- $avp(event-names) = "event";
- $avp(event-values) = "calling_endpoint_out_of_channels";
- $avp(event-names) = "endpoint";
- $avp(event-values) = "$json(src_endpoint/endpoint)";
- $avp(event-names) = "max_channels";
- $avp(event-values) = "$json(src_endpoint/max_channels)";
- $avp(event-names) = "current_channels";
- $avp(event-values) = "$avp(size)";
- $avp(event-names) = "ip";
- $avp(event-values) = "$si";
- raise_event("E_SCRIPT_REPORT",$avp(event-names),$avp(event-values));
- exit;
- }
- }
-
-
- route(lookup_src);
-
- if($avp(src_type) == "ONNET") {
-
- if try_line_side
- if($json(src_endpoint/allow_onnet) == "true") {
- route(try_line_side);
- }
- end if try_line_side
-
- if try_trunk_side
- route(try_trunk_side);
- end if try_trunk_side
-
- t_reply("404", "Destination Not Found");
- exit;
- }
-
- # From Off-net
- if try_line_side
- route(try_line_side);
- end if try_line_side
-
- t_reply("404", "Line Not Found");
- exit;
-}
-
-route[lookup_src]
-{
-
- # -- Inbound SBC
- if($json(src_endpoint/inbound_sbc) == ${sbc_own_upstream}) {
- $(avp(src_type)) = "PSTN";
- # Also trust the charging information, if any (normally none is present).
- avp_delete("$(avp(account))");
- $avp(account) = $(hdr(P-Charge-Info){uri.user}{s.unescape.user});
- return;
- }
-
- # -- Outbound call, coming from line-side
- if($json(src_endpoint/endpoint)) {
- $(avp(src_type)) = "ONNET";
- if lineside_extra_info
- avp_printf("$(avp(extra_info))", "${lineside_extra_info}");
- end if lineside_extra_info
-
- if( $json(src_endpoint/src_disabled) == "true" ) {
- t_reply("403", "Administratively Forbidden");
- exit;
- }
-
- if not ignore_dest_domain
- if( (! isflagset(${flag_dest_domain_set}))
- && $json(src_endpoint/dest_domain) ) {
- setflag(${flag_dest_domain_set});
- }
- end if not ignore_dest_domain
-
- if( $json(src_endpoint/user_force_mp) == "true" ) {
- xlog("L_DBG","-- invite-router -- Force MediaProxy for $(json(src_endpoint/endpoint))\n");
- setflag(${flag_request_mp_caller}); # force MP for caller
- }
-
- if( $json(src_endpoint/check_from) == "true" ) {
- xlog("L_DBG","-- invite-router -- Checking From username\n");
- if( $json(src_number/endpoint) != $json(src_endpoint/endpoint) ) {
- t_reply("403", "From Username is not listed");
- exit;
- }
- }
-
- # Account selection
- avp_delete("$(avp(account))");
-
- switch($json(src_endpoint/sbc)) {
- case ${sbc_own_outbound}:
- # Trust the account information provided by this internal SBC.
- if($(hdr(P-Charge-Info))) {
- $avp(account) = $(hdr(P-Charge-Info){uri.user}{s.unescape.user});
- }
- break;
-
- default:
- # Use the endpoint's account information.
- $avp(account) = $json(src_endpoint/account);
- }
- #/ Account selection
-
- # Max call duration
- if( $json(src_endpoint/dialog_timer) ) {
- $avp(dialog_timer) = $json(src_endpoint/dialog_timer);
- }
-
- xlog("L_DBG","-- invite-router -- Customer device $(json(src_endpoint)) with account $(avp(account)).\n");
- }
-}
View
118 common/opensips/fragments/invite-trunk-drouting.cfg
@@ -1,118 +0,0 @@
-# Name: invite-trunk-side
-# DescriptioN: Failover using drouting
-
-# -----------------------------------------------------------------
-# INVITE Message Handler
-# -----------------------------------------------------------------
-
-define use_drouting
-
-route[invite_trunk_drouting]
-{
- xlog("L_DBG","-- route(invite_trunk_drouting)\n");
-
- $var(original_ru) = $ru;
-
- # remove any (transport,account,..) params from the RURI
- # ($rP contains current transport protocol)
- $var(clean_ru) = "sip:"+$rU+"@"+$rd+":"+$rp;
-
- if use_endpoint_outbound_route
- if($(json(src_endpoint/outbound_route)) != null) {
- $avp(outbound_route) = $(json(src_endpoint/outbound_route));
- }
- end if use_endpoint_outbound_route
-
- if use_default_outbound_route
- if($avp(outbound_route) == null) {
- $avp(outbound_route) = ${default_outbound_route};
- }
- end if use_default_outbound_route
-
- if use_domain_outbound_route
- if(!cache_fetch("local","domain $rd",$avp(domain))) {
- if(!avp_db_load("$rd","$avp(domain)")) {
- $avp(domain) := '{}';
- }
- cache_store("local","domain $rd","$avp(domain)",${cache_timeout});
- }
-
- $json(domain) := $avp(domain);
- if($json(domain/outbound_route) != null) {
- $avp(outbound_route) = $json(domain/outbound_route);
- }
- end if use_domain_outbound_route
-
- $var(route_ok) = 0;
-
- if special_drouting
- route(special_drouting);
- end if special_drouting
-
- $ru = $var(clean_ru);
-
- if($var(route_ok) == 0) {
- if( do_routing("")
- || ($(avp(outbound_route)) != null && do_routing("$(avp(outbound_route))")) ) {
- $var(route_ok) = 1;
- }
- }
-
- if($var(route_ok) == 1) {
- # Interpret attr fields as JSON
- if( !$avp(dr_rule_attrs) ) {
- $avp(dr_rule_attrs) := '{}';
- }
- if( !$avp(dr_carrier_attrs) ) {
- $avp(dr_carrier_attrs) := '{}';
- }
- if( !$avp(dr_gw_attrs) ) {
- $json(dr_gw_attrs) := '{}';
- }
- $json(dr_rule_attrs) := $avp(dr_rule_attrs);
- $json(dr_carrier_attrs) := $avp(dr_carrier_attrs);
- $json(dr_gw_attrs) := $avp(dr_gw_attrs);
- $avp(dr_rule_attrs) := null;
- $avp(dr_carrier_attrs) := null;
- $avp(dr_gw_attrs) := null;
-
- # Force send through
- if internal_ip
- force_send_socket(${internal_ip});
- end if internal_ip
-
- xlog("L_DBG","-- route(invite_trunk_drouting): do_routing was successful: $ru\n");
- setflag(${flag_trunk_routing});
- t_on_branch("1");
- route(trunk_attributes);
- if mediaproxy
- route(update_media_proxy); # Start MP if needed
- end if mediaproxy
- route(initial_forwarder); # Forward
- exit;
- }
-
- $ru = $var(original_ru);
-}
-
-route[trunk_attributes]
-{
- xlog("L_DBG","-- route(trunk_attributes)\n");
- if($json(dr_rule_attrs/force_mp)) {
- xlog("L_DBG","-- route(trunk_attributes) -- forcing MediaProxy for route\n");
- setflag(${flag_request_mp_callee}); # force MP for callee
- }
- if not skip_uac_auth
- # Per-provider authentication
- xlog("L_DBG","-- route(trunk_attributes) -- gathering authentication\n");
- $avp(uac_realm) = $json(dr_gw_attrs/realm);
- $avp(uac_username) = $json(dr_gw_attrs/username);
- $avp(uac_password) = $json(dr_gw_attrs/password);
- end if not skip_uac_auth
-
-}
-
-branch_route[1]
-{
- xlog("L_DBG","-- branch_route(1) Processing $rm $ru\n");
-}
View
23 common/opensips/fragments/invite-trunk-drouting.modules
@@ -1,23 +0,0 @@
-loadmodule "drouting.so"
-modparam("drouting", "db_url", "${db_url}")
-modparam("drouting", "drd_table", "dr_gateways")
-modparam("drouting", "drr_table", "dr_rules")
-modparam("drouting", "drg_table", "dr_groups")
-modparam("drouting", "drc_table", "dr_carriers")
-
-modparam("drouting", "gw_attrs_avp", '$avp(dr_gw_attrs)')
-modparam("drouting", "rule_attrs_avp", '$avp(dr_rule_attrs)')
-modparam("drouting", "carrier_attrs_avp", '$avp(dr_carrier_attrs)')
-
-modparam("drouting", "gw_id_avp", '$avp(dr_gw_id)')
-modparam("drouting", "rule_id_avp", '$avp(dr_rule_id)')
-modparam("drouting", "carrier_id_avp", '$avp(dr_carrier_id)')
-
-modparam("drouting", "rule_prefix_avp", '$avp(dr_rule_prefix)')
-
-modparam("drouting", "ruri_avp", '$avp(dr_ruri)')
-modparam("drouting", "force_dns", 0) # Allows for SRV, etc.
-modparam("drouting", "use_domain", 1) # default
-modparam("drouting", "persistent_state", 0)
-
-# TODO: consider the probing_* parameters
View
175 common/opensips/fragments/invite.cfg
@@ -1,175 +0,0 @@
-# Name: invite
-# Description: modules and configuration shared by all forwarding INVITE modules
-
-#
-# This code is only used by recipes where we forward the INVITE.
-# If the INVITE is terminated locally (e.g. with a 302/404 pair)
-# then there is no need to use this code in a recipe.
-#
-
-onreply_route[1]
-{
- xlog("L_DBG","-- onreply_route(1) -- $si -- $mb\n");
-
- # In-progress flag
- if( t_check_status("[12][0-9][0-9]") ) {
- setbflag(${bflag_in_progress});
- }
-
- # SDP mangling: Linksys SPA2102 improper SDP
- replace_body_all("a=rtpmap:18 G729a/8000", "a=rtpmap:18 G729/8000");
-
- # On call forwarding we cannot accept the initial 183.
- # Substitute with 180 (done in INVITE).
- if( t_check_status("183") && isflagset(${flag_has_forwarding}) ) {
- drop;
- }
-
- if mediaproxy
- route(media_proxy_reply_handler); # MP on-reply
- end if mediaproxy
- if has_onreply_nat
- route(onreply_nat);
- end if has_onreply_nat
-}
-
-# -----------------------------------------------------------------
-# Failure route
-# -----------------------------------------------------------------
-
-failure_route[1]
-{
- xlog("L_DBG","-- failure_route(1) -- $rm $ru\n");
-
- if(!is_method("INVITE")) {
- return;
- }
-
- # For fax negotiation 488 might be a normal outcome.
- if(!t_check_status("488")) {
- xlog("L_DBG","-- failure_route(1) -- Ignoring 488\n");
- if mediaproxy
- route(stop_media_proxy); # End media session
- end if mediaproxy
- }
-
- if(t_was_cancelled() || t_check_status("504")) {
- xlog("L_DBG","-- failure_route(1): conversation was canceled.\n");
- return;
- }
-
- # Handle redirects
- if( t_check_status("302") ) {
- get_redirects("6:2"); # max_total:max_branch, reason
- serialize_branches(1);
- route(forwarder);
- exit;
- }
-
- if not skip_uac_auth
- if($avp(uac_realm)) {
- # Check whether we were supposed to authenticate (uac_auth)
- if( t_check_status("40[17]") ) {
- # Already attempted.
- # Note: this breaks if we failover (e.g. SRV or multiple DNS As)
- if(isbflagset(${bflag_auth_attempted})) {
- xlog("L_DBG","-- failure_route(1): uac_auth already attempted.\n");
- t_reply("503","Authentication failed");
- exit;
- }
-
- xlog("L_DBG","-- failure_route(1): Attempting uac_auth.\n");
- if(uac_auth()) {
- setbflag(${bflag_auth_attempted});
- t_on_failure("1");
- route(forwarder);
- exit;
- }
-
- xlog("L_ERR","ERROR -- failure_route(1): uac_auth() failed on $rm $ru\n");
- exit;
- }
- }
-
- resetbflag(${bflag_auth_attempted});
- end if not skip_uac_auth
-
- # Trunk-side processing
- if( isflagset(${flag_trunk_routing}) ) {
-
- # Don't failover on busy, loop detected, incomplete address, or not found
- # Note: 480 used to be here but since it is used as catch-all by FS it is better to progress on it.
- if( t_check_status("48[67241]|40[34]|60[0-9]") ) {
- xlog("L_DBG","-- failure_route(1): trunk: no progress on busy, loop, incomplete, forbidden, not found\n");
- return;
- }
-
- }
-
- # Process failure cases
- if (next_branches()) {
- t_on_failure("1");
- route(forwarder);
- exit;
- }
-
- if use_drouting
- if (next_routing()) {
- t_on_failure("1");
- route(trunk_attributes);
- if mediaproxy
- route(update_media_proxy);
- end if mediaproxy
- route(forwarder);
- exit;
- }
- end if use_drouting
-
- # Trunk-side processing
- if( isflagset(${flag_trunk_routing}) ) {
-
- # Ring no Answer
- if( isbflagset(${bflag_in_progress}) && t_check_status("408") ) {
- xlog("L_DBG","-- failure_route(1): trunk: no answer\n");
- t_reply("486","No Answer");
- return;
- }
-
- }
-
- if not skip_lineside
- # Line-side processing
-
- # On 486 Busy Here use CFB
- if( t_check_status("486") ) {
- xlog("L_DBG","-- Attempting CFB\n");
- if( $avp(cfb) ) {
- if mediaproxy
- route(stop_media_proxy);
- end if mediaproxy
- $ru = $avp(cfb);
- serialize_branches(1);
- t_reply("302","Call Forward Busy");
- exit;
- }
-
- # No CFB, forward along
- t_reply("486","Busy Here");
- return;
- }
-
- # Other errors trigger CFDA
- xlog("L_DBG","-- Attempting CFDA\n");
- if( $avp(cfda) ) {
- if mediaproxy
- route(stop_media_proxy);
- end if mediaproxy
- $ru = $avp(cfda);
- serialize_branches(1);
- t_reply("302","Call Forward Didnt Answer");
- exit;
- }
- end if not skip_lineside
-
- # No alternate found.
-}
View
36 common/opensips/fragments/invite.modules
@@ -1,36 +0,0 @@
-# invite.modules -- modules and configuration shared by all forwarding INVITE modules
-
-if not skip_uac_auth
- loadmodule "uac_auth.so"
- modparam("uac_auth","auth_realm_avp", "$(avp(uac_realm))")
- modparam("uac_auth","auth_username_avp", "$(avp(uac_username))")
- modparam("uac_auth","auth_password_avp", "$(avp(uac_password))")
-
- loadmodule "uac.so"
- modparam("uac","rr_store_param", "${UAC_VSF}")
-end if not skip_uac_auth
-
-loadmodule "uac_redirect.so"
-
-loadmodule "dialog.so"
-define has_dialog_module
-modparam("dialog", "enable_stats", 1) # default 1
-
-# Dialog matching
-modparam("dialog", "rr_param", "dlg") # default did
-modparam("dialog", "dlg_match_mode", ${dlg_match_mode}) # default 0 (match on rr_param only); 1 = match on rr_param, use SIP (RFC3261) matching as fallback
-
-# timeout/BYE
-modparam("dialog", "default_timeout", ${dialog_timeout}) # default 43200 (12h)
-# Set maximum duration of dialog (=call)
-modparam("dialog", "timeout_avp", "$avp(dialog_timer)")
-modparam("dialog", "dlg_extra_hdrs", "X-CCNQ3-Reason: Call too long\r\n")
-
-modparam("dialog", "profiles_with_value", "endpoint ; number ; account")
-# modparam("dialog", "cachedb_url", "redis://127.0.0.1")
-
-modparam("dialog", "db_mode", 0) # No database of dialogs
-
-# modparam("dialog", "profiles_with_value", "")
-# modparam("dialog", "profiles_no_value", "")
-
View
11 common/opensips/fragments/loose-route-disabled.cfg
@@ -1,11 +0,0 @@
-# Name: loose-route-disabled
-# Group: loose-route
-# Description: no handling of loose-routed messages
-
-# -----------------------------------------------------------------
-# Loose Route Section
-# -----------------------------------------------------------------
-
-route[loose_route_handler] {
- xlog("L_DBG","-- loose-route-handler DISABLED -- LR $rm From: $fu To: $tu RURI: $ru\n");
-}
View
87 common/opensips/fragments/loose-route.cfg
@@ -1,87 +0,0 @@
-# Name: loose-route
-# Group: loose-route
-# Description: handler for loose-routed messages
-
-# -----------------------------------------------------------------
-# Loose Route Section
-# -----------------------------------------------------------------
-
-route[loose_route_handler] {
- xlog("L_DBG","-- loose-route-handler -- LR $rm From: $fu To: $tu RURI: $ru\n");
-
- ## --- NAT
-
- route(lr_nat);
-
- if(is_method("INVITE") || is_method("REFER") || is_method("UPDATE")) {
- if(!has_totag()) {
- t_reply("403", "Forbidden 1");
- exit;
- }
- }
-
- if(has_totag()) {
- if($DLG_status==NULL) {
- xlog("L_DBG","-- LR: to_tag but no dialog\n");
- if(!is_method("ACK")) {
- t_reply("403", "No such dialog");
- }
- exit;
- }
-
- if(!validate_dialog()) {
- if fix_invalid_dialogs
- fix_route_dialog();
- end if fix_invalid_dialogs
- if not fix_invalid_dialogs
- if(!is_method("ACK")) {
- t_reply("403", "Invalid dialog");
- }
- exit;
- end if not fix_invalid_dialogs
- }
-
- xlog("L_DBG","-- LR: Validated Dialog\n");
- }
-
- if(!is_method("ACK")) {
- sl_send_reply("100", "Trying");
- }
-
- if(is_method("INVITE")) {
- t_on_reply("2");
- }
-
- ## On re-INVITE via ocs-sbc we do not get the proper fields.
- ## Disabling for now until I figure out how to do this properly.
- # if(is_method("INVITE")) {
- # route(authenticate);
- # }
-
- ## --- Media
- if mediaproxy
- route(media_proxy_method_handler);
- end if mediaproxy
-
- if(is_method("ACK") || is_method("CANCEL") || is_method("PRACK")) {
- route(forwarder_progress); # Route ACK/PRACK/CANCEL/UPDATE
- } else {
- route(forwarder);
- }
-}
-
-
-onreply_route[2]
-{
- xlog("L_DBG","-- onreply_route(2) -- $si -- $mb\n");
-
- # SDP mangling: Linksys SPA2102 improper SDP
- replace_body_all("a=rtpmap:18 G729a/8000", "a=rtpmap:18 G729/8000");
-
- if mediaproxy
- route(media_proxy_reply_handler); # MP on-reply
- end if mediaproxy
- if has_onreply_nat
- route(onreply_nat);
- end if has_onreply_nat
-}
View
127 common/opensips/fragments/mediaproxy.cfg
@@ -1,127 +0,0 @@
-# Name: mediaproxy
-# Group: mediaproxy
-# Description: handler for MediaProxy (SDP with NAT)
-
-define mediaproxy
-
-# -----------------------------------------------------------------
-# Media Proxy / RTP Proxy handling
-# -----------------------------------------------------------------
-
-route[start_media_proxy]
-{
- xlog("L_DBG","-- start_media_proxy --\n");
-
- if not mp_allowed
- xlog("L_DBG","-- start_media_proxy -- Media Proxy is not allowed.\n");
- return;
- end if not mp_allowed
-
- if mp_allowed
- if( is_dlg_flag_set("${dflag_mediaproxy_engaged}") ) {
- xlog("L_DBG","-- start_media_proxy -- bypassing media_proxy\n");
- return;
- }
-
- if( is_present_hf("X-CCNQ3-MediaProxy") ) {
- xlog("L_DBG","-- start_media_proxy -- media_proxy already engaged on another proxy\n");
- set_dlg_flag("${dflag_mediaproxy_engaged}");
- return;
- }
-
- remove_hf("X-CCNQ3-MediaProxy");
- append_hf("X-CCNQ3-MediaProxy: on\r\n");
-
- if( use_media_proxy() ) {
- xlog("L_DBG","-- start_media_proxy -- media_proxy OK\n");
- set_dlg_flag("${dflag_mediaproxy}");
- } else {
- xlog("L_DBG","-- start_media_proxy -- media_proxy failed or not needed\n");
- }
- end if mp_allowed
-}
-
-route[stop_media_proxy]
-{
- xlog("L_DBG","-- stop_media_proxy --\n");
-
- if not mp_allowed
- xlog("L_DBG","-- stop_media_proxy -- Media proxy is not allowed.\n");
- return;
- end if not mp_allowed
-
- if mp_allowed
- if( is_dlg_flag_set("${dflag_mediaproxy}")) {
- end_media_session();
- reset_dlg_flag("${dflag_mediaproxy}");
- }
- end if mp_allowed
-}
-
-# -----------------------------------------------------------------
-# Reply-codes handler for NAT traversal
-# -----------------------------------------------------------------
-
-route[media_proxy_method_handler]
-{
- xlog("L_DBG","-- media_proxy_method_handler --\n");
-
- if( is_method("INVITE") || is_method("ACK") ) {
- route(update_media_proxy);
- }
- if(is_method("BYE") || is_method("CANCEL")) {
- route(stop_media_proxy);
- }
-}
-
-route[media_proxy_reply_handler] # Reply handler for MediaProxy
-{
- xlog("L_DBG","-- media_proxy_reply_handler --\n");
-
- # Update the mediaproxy information if needed.
- if(t_check_status("180|183|2[0-9][0-9]")) {
- route(update_media_proxy); # Update media session
- }
- # Don't tear-down on error, we might fail over.
-}
-
-# -----------------------------------------------------------------
-# A RURI may contain a "mp=yes" param to force usage of MP
-# Note: This is independent from having mp=yes added to Record-Route
-# params (and provided back by endpoints in Route params).
-# -----------------------------------------------------------------
-
-route[media_proxy_in_ruri] {
-
- xlog("L_DBG","-- media_proxy_in_ruri --\n");
-
- # If the URI contains ";mp=yes" then force MediaProxy.
- if($(ru{uri.param,mp}) == "yes") {
- xlog("L_DBG","-- media_proxy_in_ruri -- MediaProxy requested in RURI\n");
- setflag(${flag_request_mp_callee}); # force MP for callee
- }
-
-}
-
-
-route[update_media_proxy]
-{
- xlog("L_DBG","-- update_media_proxy --\n");
-
- if( ${mp_always} ||
- is_dlg_flag_set("${dflag_mediaproxy}") ||
- isflagset(${flag_request_mp_callee}) ||
- isbflagset(${bflag_request_mp_callee}) ||
- isflagset(${flag_request_mp_caller})
- ) {
- if( search("^Content-Length:")
- && !search("^Content-Length:[ ]*0")
- ) {
- route(start_media_proxy);
- } else {
- xlog("L_DBG","-- update_media_proxy -- Media Proxy required but no SDP found\n");
- }
- } else {
- xlog("L_DBG","-- update_media_proxy -- Skipping Media Proxy\n");
- }
-}
View
7 common/opensips/fragments/mediaproxy.modules
@@ -1,7 +0,0 @@
-# mediaproxy.modules -- modules and configuration for mediaproxy.cfg
-
-loadmodule "mediaproxy.so"
-
-modparam("mediaproxy","mediaproxy_socket", "/var/run/mediaproxy/dispatcher.sock")
-# modparam("mediaproxy","sip_asymmetrics","/usr/local/etc/openser/sip-clients")
-# modparam("mediaproxy","rtp_asymmetrics","/usr/local/etc/openser/rtp-clients")
View
137 common/opensips/fragments/nat.cfg
@@ -1,137 +0,0 @@
-# Name: nat
-# Group: nat
-# Description: handler for messages originating or terminating behind NAT
-
-# -----------------------------------------------------------------
-# NAT Traversal Section
-# -----------------------------------------------------------------
-
-route[nlr_nat]
-{
- xlog("L_DBG","-- nlr_nat -- NAT tests for NLR $rm\n");
-
- if(is_method("CANCEL")||is_method("PRACK")||is_method("UPDATE")) {
- route(lr_detect_nat);
- return;
- }
- if(is_method("ACK")) {
- route(ack_nat);
- return;
- }
- route(initial_nat);
-}
-
-route[nat_keepalive] {
- if(is_method("REGISTER")||is_method("SUBSCRIBE")||is_method("INVITE")) {
- if(proto==UDP) { nat_keepalive(); }
- }
-}
-
-route[initial_nat] # NAT traversal for initial INVITE/SUBSCRIBE/NOTIFY/OPTIONS
-{
- xlog("L_DBG","-- initial_nat -- NAT tests for initial $rm\n");
-
- # NAT tests:
- # NAT test 1 = RFC1918 IP in Contact ?
- # NAT test 2 = From address != 1st Via
- if (client_nat_test("3") && !search("^Record-Route:")) {
- xlog("L_DBG","-- initial_nat-- $rm sender is NATed\n");
-
- # Record what we found.
- # (For IPv6 at this time we always proxy media if we can.)
- setflag(${flag_request_mp_caller});
-
- if(af!=INET6) {
- # NAT detected
- force_rport();
- route(nat_keepalive);
- }
- fix_contact();
- }
-}
-
-
-route[lr_nat] # NAT traversal for loose-routed messages
-{
- xlog("L_DBG","-- lr_nat -- NAT tests for LR $rm\n");
-
- if(is_method("INVITE")) {
- # This might be overkill
- route(initial_nat);
- return;
- }
- if(is_method("ACK")) {
- route(ack_nat);
- return;
- }
- route(lr_detect_nat);
-}
-
-route[lr_detect_nat] {
- xlog("L_DBG","-- lr_detect_nat --\n");
-
- # NAT test 1 = RFC1918 IP in Contact ?
- # NAT test 2 = From address != 1st Via ?
- if (client_nat_test("3")) {
- xlog("L_DBG","-- lr_detect_nat -- $rm sender is NATed\n");
-
- # XXX Shouldn't we set some flag somewhere?
-
- if(af!=INET6) {
- # NAT detected
- force_rport();
- route(nat_keepalive);
- }
- fix_contact();
- }
-}
-
-
-route[ack_nat] {
- xlog("L_DBG","-- ack_nat --\n");
-
- # Handle NAT on ACK
- xlog("L_DBG","-- ack_nat\n");
- if(isflagset(${flag_request_mp_caller})) {
- if(af!=INET6) {
- force_rport();
- route(nat_keepalive);
- }
- }
- if (client_nat_test("11")) {
- fix_contact();
- }
-}
-
-define has_register_nat
-route[register_nat] {
- xlog("L_DBG","-- register_nat --\n");
-
- # NAT test 1 = RFC1918 IP in Contact ?
- # NAT test 2 = From address != 1st Via ?
- # NAT test 4 = RFC1918 in top Via ?
- if (client_nat_test("7") && !search("^Contact:[ ]*\*")) {
- xlog("L_DBG","-- register_nat: Registering device is NATed\n");
- setbflag(${bflag_request_mp_callee}); # endpoint is NATed (stored in the database by registrar)
- if(af!=INET6) {
- force_rport();
- route(nat_keepalive);
- if(proto==TCP) {
- setflag(${flag_tcp_persistent}); # tcp_persistent_flag
- }
- }
- $avp(received_avp) = $source_uri;
- };
-}
-
-define has_onreply_nat
-route[onreply_nat] {
-
- xlog("L_DBG","-- onreply_nat --\n");
-
- # NAT test 1 = RFC1918 IP in Contact ?
- if( client_nat_test("1") ) {
- fix_contact();
- }
-
-}
View
14 common/opensips/fragments/nat.modules
@@ -1,14 +0,0 @@
-# nat.modules -- modules and configuration required by nat.cfg
-
-loadmodule "nat_traversal.so"
-
-modparam("nat_traversal", "keepalive_interval", 30)
-modparam("nat_traversal", "keepalive_method", "OPTIONS")
-
-# nat_uac_test 1 = RFC1918 IP in Contact?
-# nat_uac_test 2 = IP in Via = src_ip ("received" test)
-# nat_uac_test 4 = RFC1918 IP in Via?
-# nat_uac_test 8 = RFC1918 IP in SDP?
-# nat_uac_test 16= Via src_port = src_port ("rport" test)
-
-modparam("nat_traversal", "keepalive_state_file", "/var/run/opensips/keepalive_state")
View
173 common/opensips/fragments/non-loose-route.cfg
@@ -1,173 +0,0 @@
-# Name: non-loose-route
-# Group: non-loose-route
-# Description: handler for out-of-dialog (non loose-routed) messages
-
-# -----------------------------------------------------------------
-# Out-of-Dialog messages
-# -----------------------------------------------------------------
-
-# With local URI
-
-route[non_loose_route_handler] {
- xlog("L_DBG","-- non_loose_route_handler -- NLR $rm $ru (Call-ID $ci)\n");
-
- if rate_limit_invite
- define pike_event
- if( is_method("INVITE") && !pike_check_req() ) {
- append_to_reply("Retry-After: ${rate_limit_latency}");
- sl_send_reply("503","Service Unavailable");
- exit;
- }
- end if rate_limit_invite
-
- ## --- NAT
-
- route(nlr_nat);
-
- # I believe these cannot be NLR in our config.
- if( is_method("BYE") || is_method("REFER") || is_method("UPDATE") ) {
- t_reply("403", "Forbidden");
- exit;
- }
-
- if(is_method("OPTIONS")) {
- if options_200
- append_hf("Allow: INVITE, ACK, CANCEL, OPTIONS, BYE\r\n");
- t_reply("200","OK");
- end if options_200
- if not options_200
- t_reply("405","Method not allowed");
- end if not options_200
- exit;
- }
-
- if(has_totag()) {
- if not has_dialog_module
- t_reply("403", "No such dialog");
- exit;
- end if not has_dialog_module
-
- if has_dialog_module
- if($DLG_status==NULL) {
- xlog("L_DBG","-- NLR: to_tag but no dialog\n");
-
- # NLR ACK without dialog will happen if the original INVITE gets
- # a negative response: the dialog is deleted when the 4xx|5xx
- # response is received.
- # forwarder_progress uses check_trans() for these cases.
-
- if has_forwarder
- if(is_method("ACK") || is_method("CANCEL") || is_method("PRACK")) {
- route(forwarder_progress); # Route ACK/PRACK/CANCEL/UPDATE
- exit;
- }
- end if has_forwarder
-
- if ignore_broken_register
- if(is_method("REGISTER")) {
- xlog("L_DBG","-- ignoring broken REGISTER\n");
- } else {
- end if ignore_broken_register
-
- t_reply("403", "No such dialog");
- exit;
-
- if ignore_broken_register
- }
- end if ignore_broken_register
-
- } else {
- if(!validate_dialog()) {
- if(!is_method("ACK")) {
- t_reply("403", "Invalid dialog");
- }
- exit;
- }