[asterisk-commits] kmoore: branch kmoore/retry_forbidden r399495 - /team/kmoore/retry_forbidden/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 19 13:32:49 CDT 2013


Author: kmoore
Date: Thu Sep 19 13:32:47 2013
New Revision: 399495

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399495
Log:
Add chan_sip implementation

Modified:
    team/kmoore/retry_forbidden/channels/chan_sip.c

Modified: team/kmoore/retry_forbidden/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/retry_forbidden/channels/chan_sip.c?view=diff&rev=399495&r1=399494&r2=399495
==============================================================================
--- team/kmoore/retry_forbidden/channels/chan_sip.c (original)
+++ team/kmoore/retry_forbidden/channels/chan_sip.c Thu Sep 19 13:32:47 2013
@@ -819,6 +819,7 @@
 static int global_rtpkeepalive;     /*!< Send RTP keepalives */
 static int global_reg_timeout;      /*!< Global time between attempts for outbound registrations */
 static int global_regattempts_max;  /*!< Registration attempts before giving up */
+static int global_reg_retry_403;    /*!< Treat 403 responses to registrations as 401 responses */
 static int global_shrinkcallerid;   /*!< enable or disable shrinking of caller id  */
 static int global_callcounter;      /*!< Enable call counters for all devices. This is currently enabled by setting the peer
                                      *   call-limit to INT_MAX. When we remove the call-limit from the code, we can make it
@@ -21139,6 +21140,7 @@
 	ast_cli(a->fd, "  Sub. max duration:      %d secs\n", max_subexpiry);
 	ast_cli(a->fd, "  Outbound reg. timeout:  %d secs\n", global_reg_timeout);
 	ast_cli(a->fd, "  Outbound reg. attempts: %d\n", global_regattempts_max);
+	ast_cli(a->fd, "  Outbound reg. retry 403:%d\n", global_reg_retry_403);
 	ast_cli(a->fd, "  Notify ringing state:   %s\n", AST_CLI_YESNO(sip_cfg.notifyringing));
 	if (sip_cfg.notifyringing) {
 		ast_cli(a->fd, "    Include CID:          %s%s\n",
@@ -23776,12 +23778,17 @@
 
 	switch (resp) {
 	case 401:	/* Unauthorized */
+handle_401:
 		if (p->authtries == MAX_AUTHTRIES || do_register_auth(p, req, resp)) {
 			ast_log(LOG_NOTICE, "Failed to authenticate on REGISTER to '%s@%s' (Tries %d)\n", p->registry->username, p->registry->hostname, p->authtries);
 			pvt_set_needdestroy(p, "failed to authenticate REGISTER");
 		}
 		break;
 	case 403:	/* Forbidden */
+		if (global_reg_retry_403) {
+			ast_log(LOG_NOTICE, "Handling 403 response to REGISTER as 401 for %s@%s\n", p->registry->username, p->registry->hostname);
+			goto handle_401;
+		}
 		ast_log(LOG_WARNING, "Forbidden - wrong password on authentication for REGISTER for '%s' to '%s'\n", p->registry->username, p->registry->hostname);
 		AST_SCHED_DEL_UNREF(sched, r->timeout, registry_unref(r, "reg ptr unref from handle_response_register 403"));
 		r->regstate = REG_STATE_NOAUTH;
@@ -31356,6 +31363,7 @@
 	sip_cfg.compactheaders = DEFAULT_COMPACTHEADERS;
 	global_reg_timeout = DEFAULT_REGISTRATION_TIMEOUT;
 	global_regattempts_max = 0;
+	global_reg_retry_403 = 0;
 	sip_cfg.pedanticsipchecking = DEFAULT_PEDANTIC;
 	sip_cfg.autocreatepeer = DEFAULT_AUTOCREATEPEER;
 	global_autoframing = 0;
@@ -31744,6 +31752,8 @@
 			}
 		} else if (!strcasecmp(v->name, "registerattempts")) {
 			global_regattempts_max = atoi(v->value);
+		} else if (!strcasecmp(v->name, "register_retry_403")) {
+			global_reg_retry_403 = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "bindaddr") || !strcasecmp(v->name, "udpbindaddr")) {
 			if (ast_parse_arg(v->value, PARSE_ADDR, &bindaddr)) {
 				ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);




More information about the asterisk-commits mailing list