[asterisk-commits] oej: branch oej/codename-pineapple r45352 - in /team/oej/codename-pineapple/c...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Oct 17 11:10:31 MST 2006


Author: oej
Date: Tue Oct 17 13:10:30 2006
New Revision: 45352

URL: http://svn.digium.com/view/asterisk?rev=45352&view=rev
Log:
Add the support for 423 error messages for outbound registrations to services. Thanks, tardieu!

Modified:
    team/oej/codename-pineapple/channels/chan_sip3.c
    team/oej/codename-pineapple/channels/sip3/sip3.h

Modified: team/oej/codename-pineapple/channels/chan_sip3.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/chan_sip3.c?rev=45352&r1=45351&r2=45352&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/chan_sip3.c (original)
+++ team/oej/codename-pineapple/channels/chan_sip3.c Tue Oct 17 13:10:30 2006
@@ -3056,6 +3056,7 @@
 	if (secret)
 		ast_string_field_set(reg, secret, secret);
 	reg->expire = -1;
+	reg->expiry = expiry.default_expiry;
 	reg->timeout =  -1;
 	reg->refresh = expiry.default_expiry;
 	reg->portno = porta ? atoi(porta) : 0;
@@ -5225,7 +5226,7 @@
 	
 	}
 
-	snprintf(tmp, sizeof(tmp), "%d", expiry.default_expiry);
+	snprintf(tmp, sizeof(tmp), "%d", r->expiry);
 	add_header(&req, "Expires", tmp);
 	add_header(&req, "Contact", p->our_contact);
 	add_header(&req, "Event", "registration");
@@ -9397,6 +9398,25 @@
 			ast_log(LOG_NOTICE, "Failed to authenticate on REGISTER to '%s' (tries '%d')\n", get_header(&p->initreq, "From"), p->authtries);
 			ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
 		}
+		break;
+	case 423:	/* Interval too brief */
+		r->expiry = atoi(get_header(req, "Min-Expires"));
+		ast_log(LOG_WARNING, "Got 423 Interval too brief for service %s@%s, minimum is %d seconds\n", p->registry->username, p->registry->hostname, r->expiry);
+		ast_sched_del(sched, r->timeout);
+		r->timeout = -1;
+		if (r->call) {
+			r->call = NULL;
+			ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
+		}
+		if (r->expiry > expiry.max_expiry) {
+			ast_log(LOG_WARNING, "Required expiration time from %s@%s is too high, giving up\n", p->registry->username, p->registry->hostname);
+			r->expiry = expiry.default_expiry;
+			r->regstate = REG_STATE_REJECTED;
+		} else {
+			r->regstate = REG_STATE_UNREGISTERED;
+			transmit_register(r, SIP_REGISTER, NULL, NULL);
+		}
+		manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
 		break;
 	case 479:	/* SER: Not able to process the URI - address is wrong in register*/
 		ast_log(LOG_WARNING, "Got error 479 on register to %s@%s, giving up (check config)\n", p->registry->username,p->registry->hostname);
@@ -9660,6 +9680,10 @@
 			} else	/* We can't handle this, giving up in a bad way */
 				ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
 
+			break;
+		case 423: /* Interval too brief */
+			if (sipmethod == SIP_REGISTER)
+				res = handle_response_register(p, resp, rest, req, seqno);
 			break;
 		case 481: /* Call leg does not exist */
 			if (sipmethod == SIP_INVITE) {

Modified: team/oej/codename-pineapple/channels/sip3/sip3.h
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3.h?rev=45352&r1=45351&r2=45352&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3.h (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3.h Tue Oct 17 13:10:30 2006
@@ -802,6 +802,7 @@
 	);
 	int portno;			/*!<  Optional port override */
 	int expire;			/*!< Sched ID of expiration */
+	int expiry;			/*!< Requested value for expiration time */
 	int regattempts;		/*!< Number of attempts (since the last success) */
 	int timeout; 			/*!< sched id of sip_reg_timeout */
 	int refresh;			/*!< How often to refresh */



More information about the asterisk-commits mailing list