[asterisk-commits] dvossel: branch dvossel/iax2keyrotation_trunk r175554 - /team/dvossel/iax2key...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 13 11:13:01 CST 2009


Author: dvossel
Date: Fri Feb 13 11:13:01 2009
New Revision: 175554

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=175554
Log:
keyrotation compatibility update. 

Modified:
    team/dvossel/iax2keyrotation_trunk/channels/chan_iax2.c
    team/dvossel/iax2keyrotation_trunk/channels/iax2.h

Modified: team/dvossel/iax2keyrotation_trunk/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/team/dvossel/iax2keyrotation_trunk/channels/chan_iax2.c?view=diff&rev=175554&r1=175553&r2=175554
==============================================================================
--- team/dvossel/iax2keyrotation_trunk/channels/chan_iax2.c (original)
+++ team/dvossel/iax2keyrotation_trunk/channels/chan_iax2.c Fri Feb 13 11:13:01 2009
@@ -4042,7 +4042,7 @@
 	struct iax_ie_data ied = {
 		.pos = 0,	
 	};
-
+	
 	ast_mutex_lock(&iaxsl[pvt->callno]);
 
 	pvt->keyrotateid = 
@@ -5006,7 +5006,6 @@
 		pvt->keyrotateid != -1 ? "" : "no "
 	);
 #endif
-
 	if (pvt->keyrotateid == -1 && f->frametype == AST_FRAME_VOICE && IAX_CALLENCRYPTED(pvt)) {
 		if (ast_test_flag(pvt, IAX_NOKEYROTATE)) {
 			pvt->keyrotateid = -2;
@@ -6313,6 +6312,9 @@
 	/* Select exactly one common encryption if there are any */
 	p->encmethods &= enc;
 	if (p->encmethods) {
+		if (!(p->encmethods & IAX_ENCRYPT_KEYROTATE)){ /* if key rotation is not supported, turn off keyrotation. */
+			p->keyrotateid = -2;
+		}
 		if (p->encmethods & IAX_ENCRYPT_AES128)
 			p->encmethods = IAX_ENCRYPT_AES128;
 		else
@@ -10718,7 +10720,7 @@
 			} else if (!strcasecmp(v->name, "auth")) {
 				peer->authmethods = get_auth_methods(v->value);
 			} else if (!strcasecmp(v->name, "encryption")) {
-				peer->encmethods = get_encrypt_methods(v->value);
+				peer->encmethods |= get_encrypt_methods(v->value);
 				if (!peer->encmethods) {
 					ast_clear_flag(peer, IAX_FORCE_ENCRYPT);
 				}
@@ -10726,16 +10728,18 @@
 				if (ast_false(v->value)) {
 					ast_clear_flag(peer, IAX_FORCE_ENCRYPT);
 				} else {
-					peer->encmethods = get_encrypt_methods(v->value);
+					peer->encmethods |= get_encrypt_methods(v->value);
 					if (peer->encmethods) {
 						ast_set_flag(peer, IAX_FORCE_ENCRYPT);
 					}
 				}
 			} else if (!strcasecmp(v->name, "keyrotate")) {
-				if (ast_false(v->value))
+				if (ast_false(v->value)) {
 					ast_set_flag(peer, IAX_NOKEYROTATE);
-				else
+				} else {
+					peer->encmethods |= IAX_ENCRYPT_KEYROTATE;
 					ast_clear_flag(peer, IAX_NOKEYROTATE);
+				}
 			} else if (!strcasecmp(v->name, "transfer")) {
 				if (!strcasecmp(v->value, "mediaonly")) {
 					ast_set_flags_to(peer, IAX_NOTRANSFER|IAX_TRANSFERMEDIA, IAX_TRANSFERMEDIA);	
@@ -10990,7 +10994,7 @@
 			} else if (!strcasecmp(v->name, "auth")) {
 				user->authmethods = get_auth_methods(v->value);
 			} else if (!strcasecmp(v->name, "encryption")) {
-				user->encmethods = get_encrypt_methods(v->value);
+				user->encmethods |= get_encrypt_methods(v->value);
 				if (!user->encmethods) {
 					ast_clear_flag(user, IAX_FORCE_ENCRYPT);
 				}
@@ -10998,16 +11002,18 @@
 				if (ast_false(v->value)) {
 					ast_clear_flag(user, IAX_FORCE_ENCRYPT);
 				} else {
-					user->encmethods = get_encrypt_methods(v->value);
+					user->encmethods |= get_encrypt_methods(v->value);
 					if (user->encmethods) {
 						ast_set_flag(user, IAX_FORCE_ENCRYPT);
 					}
 				}
 			} else if (!strcasecmp(v->name, "keyrotate")) {
-				if (ast_false(v->value))
+				if (ast_false(v->value)) {
 					ast_set_flag(user, IAX_NOKEYROTATE);
-				else
+				} else {
+					user->encmethods = IAX_ENCRYPT_KEYROTATE;
 					ast_clear_flag(user, IAX_NOKEYROTATE);
+				}
 			} else if (!strcasecmp(v->name, "transfer")) {
 				if (!strcasecmp(v->value, "mediaonly")) {
 					ast_set_flags_to(user, IAX_NOTRANSFER|IAX_TRANSFERMEDIA, IAX_TRANSFERMEDIA);	
@@ -11272,7 +11278,6 @@
 	/* Reset Global Flags */
 	memset(&globalflags, 0, sizeof(globalflags));
 	ast_set_flag(&globalflags, IAX_RTUPDATE);
-	ast_set_flag(&globalflags, IAX_NOKEYROTATE); /* turn off key rotate by default since it breaks backwards compatibility at the moment. */
 #ifdef SO_NO_CHECK
 	nochecksums = 0;
 #endif
@@ -11381,7 +11386,7 @@
 		} else if (!strcasecmp(v->name, "authdebug")) {
 			authdebug = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "encryption")) {
-				iax2_encryption = get_encrypt_methods(v->value);
+				iax2_encryption |= get_encrypt_methods(v->value);
 				if (!iax2_encryption) {
 					ast_clear_flag((&globalflags), IAX_FORCE_ENCRYPT);
 				}
@@ -11389,16 +11394,18 @@
 			if (ast_false(v->value)) {
 				ast_clear_flag((&globalflags), IAX_FORCE_ENCRYPT);
 			} else {
-				iax2_encryption = get_encrypt_methods(v->value);
+				iax2_encryption |= get_encrypt_methods(v->value);
 				if (iax2_encryption) {
 					ast_set_flag((&globalflags), IAX_FORCE_ENCRYPT);
 				}
 			}
 		} else if (!strcasecmp(v->name, "keyrotate")) {
-			if (ast_false(v->value))
+			if (ast_false(v->value)) {
 				ast_set_flag((&globalflags), IAX_NOKEYROTATE);
-			else
+			} else {
+				iax2_encryption |= IAX_ENCRYPT_KEYROTATE; 
 				ast_clear_flag((&globalflags), IAX_NOKEYROTATE);
+			}
 		} else if (!strcasecmp(v->name, "transfer")) {
 			if (!strcasecmp(v->value, "mediaonly")) {
 				ast_set_flags_to((&globalflags), IAX_NOTRANSFER|IAX_TRANSFERMEDIA, IAX_TRANSFERMEDIA);	

Modified: team/dvossel/iax2keyrotation_trunk/channels/iax2.h
URL: http://svn.digium.com/svn-view/asterisk/team/dvossel/iax2keyrotation_trunk/channels/iax2.h?view=diff&rev=175554&r1=175553&r2=175554
==============================================================================
--- team/dvossel/iax2keyrotation_trunk/channels/iax2.h (original)
+++ team/dvossel/iax2keyrotation_trunk/channels/iax2.h Fri Feb 13 11:13:01 2009
@@ -187,6 +187,7 @@
 #define IAX_AUTH_RSA				(1 << 2)
 
 #define IAX_ENCRYPT_AES128			(1 << 0)
+#define IAX_ENCRYPT_KEYROTATE			(1 << 1)
 
 #define IAX_META_TRUNK				1		/*!< Trunk meta-message */
 #define IAX_META_VIDEO				2		/*!< Video frame */




More information about the asterisk-commits mailing list