[asterisk-commits] oej: branch oej/whitepearl-options-503-unreachable r412211 - in /team/oej/whi...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 11 11:18:23 CDT 2014


Author: oej
Date: Fri Apr 11 11:18:16 2014
New Revision: 412211

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=412211
Log:
Small hack to provide failover if a server responds with 503 to our OPTIONs ping

Modified:
    team/oej/whitepearl-options-503-unreachable/channels/chan_sip.c
    team/oej/whitepearl-options-503-unreachable/channels/sip/include/sip.h
    team/oej/whitepearl-options-503-unreachable/configs/sip.conf.sample

Modified: team/oej/whitepearl-options-503-unreachable/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/whitepearl-options-503-unreachable/channels/chan_sip.c?view=diff&rev=412211&r1=412210&r2=412211
==============================================================================
--- team/oej/whitepearl-options-503-unreachable/channels/chan_sip.c (original)
+++ team/oej/whitepearl-options-503-unreachable/channels/chan_sip.c Fri Apr 11 11:18:16 2014
@@ -18969,6 +18969,7 @@
  	ast_cli(a->fd, "  Timer B:                %d\n", global_timer_b);
 	ast_cli(a->fd, "  No premature media:     %s\n", AST_CLI_YESNO(global_prematuremediafilter));
 	ast_cli(a->fd, "  Max forwards:           %d\n", sip_cfg.default_max_forwards);
+	ast_cli(a->fd, "  Force unreachable 5xx:  %d\n", AST_CLI_YESNO(sip_cfg.force_unreachable);
 
 	ast_cli(a->fd, "\nDefault Settings:\n");
 	ast_cli(a->fd, "-----------------\n");
@@ -21649,7 +21650,11 @@
 	 * of the expressions.
 	 */
 	was_reachable = peer->lastms > 0 && peer->lastms <= peer->maxms;
-	is_reachable = pingtime <= peer->maxms;
+	if (sip_cfg.force_unreachable && resp >= 500 && resp < 600) {
+		is_reachable = FALSE;
+	} else {
+		is_reachable = pingtime <= peer->maxms;
+	}
 	statechanged = peer->lastms == 0 /* yes, unknown before */
 		|| was_reachable != is_reachable;
 
@@ -29034,6 +29039,7 @@
 	ast_copy_string(sip_cfg.default_context, DEFAULT_CONTEXT, sizeof(sip_cfg.default_context));
 	sip_cfg.default_subscribecontext[0] = '\0';
 	sip_cfg.default_max_forwards = DEFAULT_MAX_FORWARDS;
+	sip_cfg.force_unreachable = DEFAULT_FORCE_UNREACHABLE;
 	default_language[0] = '\0';
 	default_fromdomain[0] = '\0';
 	default_fromdomainport = 0;
@@ -29493,6 +29499,8 @@
 				default_maxcallbitrate = DEFAULT_MAX_CALL_BITRATE;
 		} else if (!strcasecmp(v->name, "matchexternaddrlocally") || !strcasecmp(v->name, "matchexterniplocally")) {
 			sip_cfg.matchexternaddrlocally = ast_true(v->value);
+		} else if (!strcasecmp(v->name, "forceunreachable") {
+			sip_cfg.force_unreachable = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "session-timers")) {
 			int i = (int) str2stmode(v->value);
 			if (i < 0) {

Modified: team/oej/whitepearl-options-503-unreachable/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/whitepearl-options-503-unreachable/channels/sip/include/sip.h?view=diff&rev=412211&r1=412210&r2=412211
==============================================================================
--- team/oej/whitepearl-options-503-unreachable/channels/sip/include/sip.h (original)
+++ team/oej/whitepearl-options-503-unreachable/channels/sip/include/sip.h Fri Apr 11 11:18:16 2014
@@ -58,6 +58,7 @@
 #define DEFAULT_MWI_EXPIRY           3600
 #define DEFAULT_REGISTRATION_TIMEOUT 20
 #define DEFAULT_MAX_FORWARDS         70
+#define DEFAULT_FORCE_UNREACHABLE	FALSE
 
 #define DEFAULT_AUTHLIMIT            100
 #define DEFAULT_AUTHTIMEOUT          30
@@ -716,6 +717,7 @@
 	format_t capability;        /*!< Supported codecs */
 	int tcp_enabled;
 	int default_max_forwards;    /*!< Default max forwards (SIP Anti-loop) */
+	int force_unreachable;		/*!< Force unreachable on 5xx response to SIP OPTIONS message */
 };
 
 /*! \brief The SIP socket definition */

Modified: team/oej/whitepearl-options-503-unreachable/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/oej/whitepearl-options-503-unreachable/configs/sip.conf.sample?view=diff&rev=412211&r1=412210&r2=412211
==============================================================================
--- team/oej/whitepearl-options-503-unreachable/configs/sip.conf.sample (original)
+++ team/oej/whitepearl-options-503-unreachable/configs/sip.conf.sample Fri Apr 11 11:18:16 2014
@@ -267,6 +267,9 @@
 				; Default: 100
 ;qualifypeers=1			; Number of peers in a group to be qualified at the same time
 				; Default: 1
+;forceunreachable=no		; If a server responds to OPTIONS (qualify) with a SIP 5xx response
+				; force that server to UNREACHABLE status
+				; Defaults to "no"
 ;notifymimetype=text/plain      ; Allow overriding of mime type in MWI NOTIFY
 ;buggymwi=no                    ; Cisco SIP firmware doesn't support the MWI RFC
                                 ; fully. Enable this option to not get error messages




More information about the asterisk-commits mailing list