[asterisk-commits] trunk r9507 - /trunk/channels/chan_iax2.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Feb 11 00:06:25 MST 2006


Author: markster
Date: Sat Feb 11 01:06:23 2006
New Revision: 9507

URL: http://svn.digium.com/view/asterisk?rev=9507&view=rev
Log:
Make IAX2 not try to authenticate when registration info is not changing

Modified:
    trunk/channels/chan_iax2.c

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=9507&r1=9506&r2=9507&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Sat Feb 11 01:06:23 2006
@@ -234,7 +234,8 @@
 enum {
 	IAX_STATE_STARTED = 		(1 << 0),
 	IAX_STATE_AUTHENTICATED = 	(1 << 1),
-	IAX_STATE_TBD = 		(1 << 2)
+	IAX_STATE_TBD = 		(1 << 2),
+	IAX_STATE_UNCHANGED = 		(1 << 3),
 } iax2_state;
 
 struct iax2_context {
@@ -5011,7 +5012,7 @@
 	int x;
 	int expire = 0;
 
-	ast_clear_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED);
+	ast_clear_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED | IAX_STATE_UNCHANGED);
 	iaxs[callno]->peer[0] = '\0';
 	if (ies->username)
 		ast_copy_string(peer, ies->username, sizeof(peer));
@@ -5056,6 +5057,8 @@
 			destroy_peer(p);
 		return -1;
 	}
+	if (!inaddrcmp(&p->addr, sin))
+		ast_set_flag(&iaxs[callno]->state, IAX_STATE_UNCHANGED);
 	ast_copy_string(iaxs[callno]->secret, p->secret, sizeof(iaxs[callno]->secret));
 	ast_copy_string(iaxs[callno]->inkeys, p->inkeys, sizeof(iaxs[callno]->inkeys));
 	/* Check secret against what we have on file */
@@ -7362,7 +7365,8 @@
 					auth_fail(fr.callno, IAX_COMMAND_REGREJ);
 					break;
 				}
-				if ((ast_strlen_zero(iaxs[fr.callno]->secret) && ast_strlen_zero(iaxs[fr.callno]->inkeys)) || ast_test_flag(&iaxs[fr.callno]->state, IAX_STATE_AUTHENTICATED)) {
+				if ((ast_strlen_zero(iaxs[fr.callno]->secret) && ast_strlen_zero(iaxs[fr.callno]->inkeys)) || 
+						ast_test_flag(&iaxs[fr.callno]->state, IAX_STATE_AUTHENTICATED | IAX_STATE_UNCHANGED)) {
 					if (f.subclass == IAX_COMMAND_REGREL)
 						memset(&sin, 0, sizeof(sin));
 					if (update_registry(iaxs[fr.callno]->peer, &sin, fr.callno, ies.devicetype, fd, ies.refresh))



More information about the asterisk-commits mailing list