[svn-commits] bbryant: branch bbryant/iax2_rotation r115354 - /team/bbryant/iax2_rotation/c...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue May 6 12:35:57 CDT 2008


Author: bbryant
Date: Tue May  6 12:35:56 2008
New Revision: 115354

URL: http://svn.digium.com/view/asterisk?view=rev&rev=115354
Log:
Update iax rotation branch.

Modified:
    team/bbryant/iax2_rotation/channels/chan_iax2.c

Modified: team/bbryant/iax2_rotation/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/bbryant/iax2_rotation/channels/chan_iax2.c?view=diff&rev=115354&r1=115353&r2=115354
==============================================================================
--- team/bbryant/iax2_rotation/channels/chan_iax2.c (original)
+++ team/bbryant/iax2_rotation/channels/chan_iax2.c Tue May  6 12:35:56 2008
@@ -543,11 +543,8 @@
 	unsigned char iseqno;
 	/*! Last incoming sequence number we have acknowledged */
 	unsigned char aseqno;
-	/*! time_t when RENEW is sent to change encryption key ... 
-	 * XXX (document more)
-	 * TODO: figure out a way to calculate time based on
-	 * something other than time() / time_t */
-	time_t rotatetimer;
+	/*! TODO explain */
+	int rotateid;
 
 	AST_DECLARE_STRING_FIELDS(
 		/*! Peer name */
@@ -4596,8 +4593,9 @@
 	return 0;
 }
 
-static int iax2_send_rotate(struct chan_iax2_pvt *pvt) 
-{
+static int iax2_send_rotate(const void *p)
+{
+	struct chan_iax2_pvt *pvt = (struct chan_iax2_pvt *)p;
 	struct iax_ie_data ied;
 	struct MD5Context md5;
 	char challenge[11] = "";
@@ -4622,6 +4620,8 @@
 	ast_log(LOG_NOTICE, "iax2_send_rotate: sending new ecx key '%s'", dgststr);
 
 	ast_aes_encrypt_key(digest, &pvt->ecx);
+
+	pvt->rotateid = iax2_sched_add(sched, ((ast_random() % 4) + 2) * 3600000, iax2_send_rotate, pvt);
 
 	return res;
 }
@@ -4692,6 +4692,11 @@
 			sendmini = 0;
 		}
 		pvt->lastvsent = fts;
+	}
+
+	if ( f->frametype == AST_FRAME_VOICE &&  ast_test_flag(pvt, IAX_ENCRYPTED) &&
+		 ast_test_flag(pvt, IAX_KEYPOPULATED) && !pvt->rotateid) {
+		iax2_send_rotate(pvt);
 	}
 	/* Allocate an iax_frame */
 	if (now) {
@@ -4752,14 +4757,9 @@
 		else if (f->frametype == AST_FRAME_VOICE)
 			pvt->svoiceformat = f->subclass;
 		else if (f->frametype == AST_FRAME_VIDEO)
-			pvt->svideoformat = f->subclass & ~0x1;
+			pvt->svideoformat = f->subclass & ~0x1;		
 		if (ast_test_flag(pvt, IAX_ENCRYPTED)) {
 			if (ast_test_flag(pvt, IAX_KEYPOPULATED)) {
-				if (!pvt->rotatetimer <= time(NULL)) {
-					pvt->rotatetimer += ((pvt->rotatetimer) ? 0 : time(NULL)) + ((ast_random() % 3) + 2) * 3600;
-					iax2_send_rotate(pvt);
-				}
-
 				if (iaxdebug) {
 					if (fr->transfer)
 						iax_showframe(fr, NULL, 2, &pvt->transfer, fr->datalen - sizeof(struct ast_iax2_full_hdr));




More information about the svn-commits mailing list