[asterisk-commits] oej: branch oej/fixtoheader-1.4 r181648 - in /team/oej/fixtoheader-1.4: ./ ap...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 12 09:32:13 CDT 2009


Author: oej
Date: Thu Mar 12 09:31:58 2009
New Revision: 181648

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=181648
Log:
Reset automerge, fix conflict

Added:
    team/oej/fixtoheader-1.4/channels/h323/ast_ptlib.h
      - copied unchanged from r181436, branches/1.4/channels/h323/ast_ptlib.h
Modified:
    team/oej/fixtoheader-1.4/   (props changed)
    team/oej/fixtoheader-1.4/apps/app_dahdiras.c
    team/oej/fixtoheader-1.4/apps/app_macro.c
    team/oej/fixtoheader-1.4/apps/app_meetme.c
    team/oej/fixtoheader-1.4/apps/app_queue.c
    team/oej/fixtoheader-1.4/apps/app_rpt.c
    team/oej/fixtoheader-1.4/apps/app_speech_utils.c
    team/oej/fixtoheader-1.4/apps/app_voicemail.c
    team/oej/fixtoheader-1.4/autoconf/ast_check_gnu_make.m4
    team/oej/fixtoheader-1.4/autoconf/ast_check_pwlib.m4
    team/oej/fixtoheader-1.4/autoconf/ast_prog_sed.m4
    team/oej/fixtoheader-1.4/channels/chan_dahdi.c
    team/oej/fixtoheader-1.4/channels/chan_gtalk.c
    team/oej/fixtoheader-1.4/channels/chan_iax2.c
    team/oej/fixtoheader-1.4/channels/chan_local.c
    team/oej/fixtoheader-1.4/channels/chan_sip.c
    team/oej/fixtoheader-1.4/channels/h323/ast_h323.cxx
    team/oej/fixtoheader-1.4/channels/h323/ast_h323.h
    team/oej/fixtoheader-1.4/channels/h323/caps_h323.cxx
    team/oej/fixtoheader-1.4/channels/h323/caps_h323.h
    team/oej/fixtoheader-1.4/channels/h323/chan_h323.h
    team/oej/fixtoheader-1.4/channels/h323/cisco-h225.cxx
    team/oej/fixtoheader-1.4/channels/h323/cisco-h225.h
    team/oej/fixtoheader-1.4/channels/h323/compat_h323.cxx
    team/oej/fixtoheader-1.4/channels/h323/compat_h323.h
    team/oej/fixtoheader-1.4/channels/iax2-parser.h
    team/oej/fixtoheader-1.4/codecs/codec_dahdi.c
    team/oej/fixtoheader-1.4/configs/extensions.conf.sample
    team/oej/fixtoheader-1.4/configs/features.conf.sample
    team/oej/fixtoheader-1.4/configs/queues.conf.sample
    team/oej/fixtoheader-1.4/configs/voicemail.conf.sample
    team/oej/fixtoheader-1.4/configure
    team/oej/fixtoheader-1.4/configure.ac
    team/oej/fixtoheader-1.4/doc/channelvariables.txt
    team/oej/fixtoheader-1.4/formats/format_ilbc.c
    team/oej/fixtoheader-1.4/include/asterisk/astmm.h
    team/oej/fixtoheader-1.4/include/asterisk/channel.h
    team/oej/fixtoheader-1.4/include/asterisk/config.h
    team/oej/fixtoheader-1.4/include/asterisk/dahdi_compat.h
    team/oej/fixtoheader-1.4/include/asterisk/frame.h
    team/oej/fixtoheader-1.4/include/asterisk/manager.h
    team/oej/fixtoheader-1.4/include/asterisk/threadstorage.h
    team/oej/fixtoheader-1.4/include/asterisk/utils.h
    team/oej/fixtoheader-1.4/main/Makefile
    team/oej/fixtoheader-1.4/main/app.c
    team/oej/fixtoheader-1.4/main/ast_expr2.c
    team/oej/fixtoheader-1.4/main/ast_expr2.fl
    team/oej/fixtoheader-1.4/main/ast_expr2.h
    team/oej/fixtoheader-1.4/main/ast_expr2.y
    team/oej/fixtoheader-1.4/main/ast_expr2f.c
    team/oej/fixtoheader-1.4/main/asterisk.c
    team/oej/fixtoheader-1.4/main/callerid.c
    team/oej/fixtoheader-1.4/main/channel.c
    team/oej/fixtoheader-1.4/main/devicestate.c
    team/oej/fixtoheader-1.4/main/editline/configure
    team/oej/fixtoheader-1.4/main/editline/configure.in
    team/oej/fixtoheader-1.4/main/editline/np/unvis.c
    team/oej/fixtoheader-1.4/main/editline/sys.h
    team/oej/fixtoheader-1.4/main/enum.c
    team/oej/fixtoheader-1.4/main/file.c
    team/oej/fixtoheader-1.4/main/frame.c
    team/oej/fixtoheader-1.4/main/jitterbuf.c
    team/oej/fixtoheader-1.4/main/pbx.c
    team/oej/fixtoheader-1.4/main/rtp.c
    team/oej/fixtoheader-1.4/main/udptl.c
    team/oej/fixtoheader-1.4/main/utils.c
    team/oej/fixtoheader-1.4/pbx/ael/ael.tab.c
    team/oej/fixtoheader-1.4/pbx/ael/ael.y
    team/oej/fixtoheader-1.4/pbx/pbx_ael.c
    team/oej/fixtoheader-1.4/pbx/pbx_config.c
    team/oej/fixtoheader-1.4/res/res_features.c
    team/oej/fixtoheader-1.4/res/res_musiconhold.c
    team/oej/fixtoheader-1.4/res/snmp/agent.c
    team/oej/fixtoheader-1.4/utils/Makefile
    team/oej/fixtoheader-1.4/utils/expr2.testinput
    team/oej/fixtoheader-1.4/utils/muted.c

Propchange: team/oej/fixtoheader-1.4/
------------------------------------------------------------------------------
    automerge = http://www.codename-pineapple.org/

Propchange: team/oej/fixtoheader-1.4/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Mar 12 09:31:58 2009
@@ -1,1 +1,1 @@
-/branches/1.4:1-173727
+/branches/1.4:1-181615

Modified: team/oej/fixtoheader-1.4/apps/app_dahdiras.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/apps/app_dahdiras.c?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/apps/app_dahdiras.c (original)
+++ team/oej/fixtoheader-1.4/apps/app_dahdiras.c Thu Mar 12 09:31:58 2009
@@ -49,6 +49,9 @@
 #include <errno.h>
 #include <stdio.h>
 #include <fcntl.h>
+
+#include "asterisk/dahdi_compat.h"
+
 #ifdef HAVE_CAP
 #include <sys/capability.h>
 #endif /* HAVE_CAP */
@@ -60,8 +63,6 @@
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 #include "asterisk/options.h"
-
-#include "asterisk/dahdi_compat.h"
 
 static char *dahdi_app = "DAHDIRAS";
 static char *zap_app = "ZapRAS";

Modified: team/oej/fixtoheader-1.4/apps/app_macro.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/apps/app_macro.c?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/apps/app_macro.c (original)
+++ team/oej/fixtoheader-1.4/apps/app_macro.c Thu Mar 12 09:31:58 2009
@@ -477,6 +477,23 @@
 		chan->macropriority = 0;
 	}
 
+	/*!\note
+	 * This section is used to restore a behavior that we mistakenly
+	 * changed in issue #6176, then mistakenly reverted in #13962 and
+	 * #13363.  A corresponding change is made in main/pbx.c, where we
+	 * check this variable for existence, then look for the "h" extension
+	 * in that context.
+	 */
+	if (ast_check_hangup(chan) || res < 0) {
+		/* Don't need to lock the channel, as we aren't dereferencing emc.
+		 * The intent here is to grab the deepest context, without overwriting
+		 * in any above context. */
+		const char *emc = pbx_builtin_getvar_helper(chan, "EXIT_MACRO_CONTEXT");
+		if (!emc) {
+			pbx_builtin_setvar_helper(chan, "EXIT_MACRO_CONTEXT", fullmacro);
+		}
+	}
+
 	if (!strcasecmp(chan->context, fullmacro)) {
   		/* If we're leaving the macro normally, restore original information */
 		chan->priority = oldpriority;

Modified: team/oej/fixtoheader-1.4/apps/app_meetme.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/apps/app_meetme.c?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/apps/app_meetme.c (original)
+++ team/oej/fixtoheader-1.4/apps/app_meetme.c Thu Mar 12 09:31:58 2009
@@ -1502,7 +1502,6 @@
 	int ms;
 	int nfds;
 	int res;
-	int flags;
 	int retryzap;
 	int origfd;
 	int musiconhold = 0;
@@ -1728,24 +1727,13 @@
  zapretry:
 	origfd = chan->fds[0];
 	if (retryzap) {
-		fd = open(DAHDI_FILE_PSEUDO, O_RDWR);
+		/* open pseudo in non-blocking mode */
+		fd = open(DAHDI_FILE_PSEUDO, O_RDWR | O_NONBLOCK);
 		if (fd < 0) {
 			ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
 			goto outrun;
 		}
 		using_pseudo = 1;
-		/* Make non-blocking */
-		flags = fcntl(fd, F_GETFL);
-		if (flags < 0) {
-			ast_log(LOG_WARNING, "Unable to get flags: %s\n", strerror(errno));
-			close(fd);
-			goto outrun;
-		}
-		if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) {
-			ast_log(LOG_WARNING, "Unable to set flags: %s\n", strerror(errno));
-			close(fd);
-			goto outrun;
-		}
 		/* Setup buffering information */
 		memset(&bi, 0, sizeof(bi));
 		bi.bufsize = CONF_SIZE/2;
@@ -1921,12 +1909,9 @@
 						ast_waitstream(chan, "");
 			}
 
-			c = ast_waitfor_nandfds(&chan, 1, &fd, nfds, NULL, &outfd, &ms);
-			
-			
 			/* Update the struct with the actual confflags */
 			user->userflags = confflags;
-			
+
 			if (confflags & CONFFLAG_WAITMARKED) {
 				if(currentmarked == 0) {
 					if (lastmarked != 0) {
@@ -2047,6 +2032,8 @@
 			/* Perform an extra hangup check just in case */
 			if (ast_check_hangup(chan))
 				break;
+
+			c = ast_waitfor_nandfds(&chan, 1, &fd, nfds, NULL, &outfd, &ms);
 
 			if (c) {
 				char dtmfstr[2] = "";
@@ -4742,7 +4729,7 @@
 			return -1;
 		}
 		if (ast_add_extension2(context, 0 /* don't replace */, "s", 1,
-			NULL, NULL, slatrunk_app, ast_strdup(trunk->name), ast_free, sla_registrar)) {
+			NULL, NULL, slatrunk_app, ast_strdup(trunk->name), ast_free_ptr, sla_registrar)) {
 			ast_log(LOG_ERROR, "Failed to automatically create extension "
 				"for trunk '%s'!\n", trunk->name);
 			destroy_trunk(trunk);
@@ -4881,7 +4868,7 @@
 		/* The extension for when the handset goes off-hook.
 		 * exten => station1,1,SLAStation(station1) */
 		if (ast_add_extension2(context, 0 /* don't replace */, station->name, 1,
-			NULL, NULL, slastation_app, ast_strdup(station->name), ast_free, sla_registrar)) {
+			NULL, NULL, slastation_app, ast_strdup(station->name), ast_free_ptr, sla_registrar)) {
 			ast_log(LOG_ERROR, "Failed to automatically create extension "
 				"for trunk '%s'!\n", station->name);
 			destroy_station(station);
@@ -4896,7 +4883,7 @@
 			/* Extension for this line button 
 			 * exten => station1_line1,1,SLAStation(station1_line1) */
 			if (ast_add_extension2(context, 0 /* don't replace */, exten, 1,
-				NULL, NULL, slastation_app, ast_strdup(exten), ast_free, sla_registrar)) {
+				NULL, NULL, slastation_app, ast_strdup(exten), ast_free_ptr, sla_registrar)) {
 				ast_log(LOG_ERROR, "Failed to automatically create extension "
 					"for trunk '%s'!\n", station->name);
 				destroy_station(station);

Modified: team/oej/fixtoheader-1.4/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/apps/app_queue.c?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/apps/app_queue.c (original)
+++ team/oej/fixtoheader-1.4/apps/app_queue.c Thu Mar 12 09:31:58 2009
@@ -1485,6 +1485,10 @@
 static int play_file(struct ast_channel *chan, char *filename)
 {
 	int res;
+
+	if (ast_strlen_zero(filename)) {
+		return 0;
+	}
 
 	ast_stopstream(chan);
 

Modified: team/oej/fixtoheader-1.4/apps/app_rpt.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/apps/app_rpt.c?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/apps/app_rpt.c (original)
+++ team/oej/fixtoheader-1.4/apps/app_rpt.c Thu Mar 12 09:31:58 2009
@@ -260,6 +260,7 @@
 
 #include <signal.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
@@ -471,7 +472,7 @@
 	int	mode;
 	struct rpt_link mylink;
 	char param[TELEPARAMSIZE];
-	int	submode;
+	intptr_t submode;
 	pthread_t threadid;
 } ;
 
@@ -4144,7 +4145,7 @@
 		strncpy(tele->param, (char *) data, TELEPARAMSIZE - 1);
 		tele->param[TELEPARAMSIZE - 1] = 0;
 	}
-	if (mode == REMXXX) tele->submode = (int) data;
+	if (mode == REMXXX) tele->submode = (intptr_t) data;
 	insque((struct qelem *)tele, (struct qelem *)myrpt->tele.next);
 	rpt_mutex_unlock(&myrpt->lock);
         pthread_attr_init(&attr);
@@ -5098,13 +5099,14 @@
 static int function_cop(struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
 {
 	char string[16];
+	int res;
 
 	if(!param)
 		return DC_ERROR;
 	
 	switch(myatoi(param)){
 		case 1: /* System reset */
-			system("killall -9 asterisk");
+			res = system("killall -9 asterisk");
 			return DC_COMPLETE;
 
 		case 2:
@@ -7748,7 +7750,8 @@
 static int function_remote(struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
 {
 	char *s,*s1,*s2;
-	int i,j,p,r,ht,k,l,ls2,m,d,offset,offsave, modesave, defmode;
+	int i,j,r,ht,k,l,ls2,m,d,offset,offsave, modesave, defmode=0;
+	intptr_t p;
 	char multimode = 0;
 	char oc,*cp,*cp1,*cp2;
 	char tmp[20], freq[20] = "", savestr[20] = "";

Modified: team/oej/fixtoheader-1.4/apps/app_speech_utils.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/apps/app_speech_utils.c?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/apps/app_speech_utils.c (original)
+++ team/oej/fixtoheader-1.4/apps/app_speech_utils.c Thu Mar 12 09:31:58 2009
@@ -377,6 +377,8 @@
 	}
 	datastore->data = speech;
 	ast_channel_datastore_add(chan, datastore);
+
+	pbx_builtin_setvar_helper(chan, "ERROR", NULL);
 
 	ast_module_user_remove(u);
 

Modified: team/oej/fixtoheader-1.4/apps/app_voicemail.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/apps/app_voicemail.c?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/apps/app_voicemail.c (original)
+++ team/oej/fixtoheader-1.4/apps/app_voicemail.c Thu Mar 12 09:31:58 2009
@@ -107,6 +107,8 @@
 #endif
 
 #ifdef IMAP_STORAGE
+#include "asterisk/threadstorage.h"
+
 AST_MUTEX_DEFINE_STATIC(imaptemp_lock);
 static char imaptemp[1024];
 static char imapserver[48];
@@ -122,6 +124,8 @@
 
 struct vm_state;
 struct ast_vm_user;
+
+AST_THREADSTORAGE(ts_vmstate, ts_vmstate_init);
 
 static int init_mailstream (struct vm_state *vms, int box);
 static void write_file (char *filename, char *buffer, unsigned long len);
@@ -1225,6 +1229,7 @@
 		ast_mutex_lock(&vms_p->lock);
 		pgm = mail_newsearchpgm ();
 		hdr = mail_newsearchheader ("X-Asterisk-VM-Extension", (char *)(!ast_strlen_zero(vmu->imapvmshareid) ? vmu->imapvmshareid : mailbox));
+		hdr->next = mail_newsearchheader("X-Asterisk-VM-Context", (char *) S_OR(context, "default"));
 		pgm->header = hdr;
 		if (fold != 1) {
 			pgm->unseen = 1;
@@ -1569,6 +1574,7 @@
 
 	/* Check IMAP folder for Asterisk messages only... */
 	hdr = mail_newsearchheader ("X-Asterisk-VM-Extension", (!ast_strlen_zero(vmu->imapvmshareid) ? vmu->imapvmshareid : vmu->mailbox));
+	hdr->next = mail_newsearchheader("X-Asterisk-VM-Context", vmu->context);
 	pgm->header = hdr;
 	pgm->deleted = 0;
 	pgm->undeleted = 1;
@@ -1613,6 +1619,9 @@
 	mailbox = stream->mailbox;
 	user = get_user_by_mailbox(mailbox);
 	vms = get_vm_state_by_imapuser(user,2);
+	if (!vms) {
+		vms = get_vm_state_by_imapuser(user, 0);
+	}
 	if (vms) {
 		if (option_debug > 2)
 			ast_log (LOG_DEBUG, "saving mailbox message number %lu as message %d. Interactive set to %d\n",number,vms->vmArrayIndex,vms->interactive);
@@ -1827,6 +1836,9 @@
 	mailbox = stream->mailbox;
 	user = get_user_by_mailbox(mailbox);
 	vms = get_vm_state_by_imapuser(user,2);
+	if (!vms) {
+		vms = get_vm_state_by_imapuser(user, 0);
+	}
 	if (vms) {
 		if (option_debug > 2)
 			ast_log (LOG_DEBUG, "User %s usage is %lu, limit is %lu\n",user,usage,limit);
@@ -1897,6 +1909,9 @@
 {
 	struct vm_state *vms_p;
 
+	if ((vms_p = pthread_getspecific(ts_vmstate.key)) && !strcmp(vms_p->imapuser, vmu->imapuser) && !strcmp(vms_p->username, vmu->mailbox)) {
+		return vms_p;
+	}
 	if (option_debug > 4)
 		ast_log(LOG_DEBUG,"Adding new vmstate for %s\n",vmu->imapuser);
 	if (!(vms_p = ast_calloc(1, sizeof(*vms_p))))
@@ -1918,6 +1933,12 @@
 static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive)
 {
 	struct vmstate *vlist = NULL;
+
+	if (interactive) {
+		struct vm_state *vms;
+		vms = pthread_getspecific(ts_vmstate.key);
+		return vms;
+	}
 
 	ast_mutex_lock(&vmstate_lock);
 	vlist = vmstates;
@@ -1954,6 +1975,12 @@
 	struct vmstate *vlist = NULL;
 	const char *local_context = S_OR(context, "default");
 
+	if (interactive) {
+		struct vm_state *vms;
+		vms = pthread_getspecific(ts_vmstate.key);
+		return vms;
+	}
+
 	ast_mutex_lock(&vmstate_lock);
 	vlist = vmstates;
 	if (option_debug > 2) 
@@ -1963,7 +1990,7 @@
 			if (vlist->vms->username && vlist->vms->context) {
 				if (option_debug > 2)
 					ast_log(LOG_DEBUG, "	comparing mailbox %s (i=%d) to vmstate mailbox %s (i=%d)\n",mailbox,interactive,vlist->vms->username,vlist->vms->interactive);
-				if (!strcmp(vlist->vms->username,mailbox) && !(strcmp(vlist->vms->context, local_context)) && vlist->vms->interactive == interactive) {
+				if (!strcmp(vlist->vms->username,mailbox) && !(strcmp(vlist->vms->context, local_context))) {
 					if (option_debug > 2)
 						ast_log(LOG_DEBUG, "	Found it!\n");
 					ast_mutex_unlock(&vmstate_lock);
@@ -2008,9 +2035,13 @@
 			/* get a pointer to the persistent store */
 			vms->persist_vms = altvms;
 			/* Reuse the mailstream? */
+#ifdef REALLY_FAST_EVEN_IF_IT_MEANS_RESOURCE_LEAKS
 			vms->mailstream = altvms->mailstream;
-			/* vms->mailstream = NIL; */
-		}
+#else
+			vms->mailstream = NIL;
+#endif
+		}
+		return;
 	}
 
 	v = (struct vmstate *)malloc(sizeof(struct vmstate));
@@ -2042,6 +2073,10 @@
 			altvms->oldmessages = vms->oldmessages;
 			altvms->updated = 1;
 		}
+		vms->mailstream = mail_close(vms->mailstream);
+
+		/* Interactive states are not stored within the persistent list */
+		return;
 	}
 
 	ast_mutex_lock(&vmstate_lock);
@@ -7324,9 +7359,13 @@
 	adsi_begin(chan, &useadsi);
 
 #ifdef IMAP_STORAGE
+	pthread_once(&ts_vmstate.once, ts_vmstate.key_init);
+	pthread_setspecific(ts_vmstate.key, &vms);
+
 	vms.interactive = 1;
 	vms.updated = 1;
-	ast_copy_string(vms.context, vmu->context, sizeof(vms.context));
+	if (vmu)
+		ast_copy_string(vms.context, vmu->context, sizeof(vms.context));
 	vmstate_insert(&vms);
 	init_vm_state(&vms);
 #endif
@@ -7755,8 +7794,11 @@
 		free(vms.deleted);
 	if (vms.heard)
 		free(vms.heard);
+
+#ifdef IMAP_STORAGE
+	pthread_setspecific(ts_vmstate.key, NULL);
+#endif
 	ast_module_user_remove(u);
-
 	return res;
 }
 
@@ -7863,18 +7905,26 @@
 {
 	struct ast_vm_user *vmu;
 	AST_LIST_TRAVERSE(&users, vmu, list) {
-		if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mbox, vmu->mailbox))
-			break;
-		if (context && (!strcasecmp(context, vmu->context)) && (!strcasecmp(mbox, vmu->mailbox)))
-			break;
+		if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mbox, vmu->mailbox)) {
+			if (strcasecmp(vmu->context, context)) {
+				ast_log(LOG_WARNING, "\nIt has been detected that you have defined mailbox '%s' in separate\
+						\n\tcontexts and that you have the 'searchcontexts' option on. This type of\
+						\n\tconfiguration creates an ambiguity that you likely do not want. Please\
+						\n\tamend your voicemail.conf file to avoid this situation.\n", mbox);
+			}
+			ast_log(LOG_WARNING, "Ignoring duplicated mailbox %s\n", mbox);
+			return NULL;
+		}
+		if (!strcasecmp(context, vmu->context) && !strcasecmp(mbox, vmu->mailbox)) {
+			ast_log(LOG_WARNING, "Ignoring duplicated mailbox %s in context %s\n", mbox, context);
+			return NULL;
+		}
 	}
 	
-	if (!vmu) {
-		if ((vmu = ast_calloc(1, sizeof(*vmu)))) {
-			ast_copy_string(vmu->context, context, sizeof(vmu->context));
-			ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
-			AST_LIST_INSERT_TAIL(&users, vmu, list);
-		}
+	if ((vmu = ast_calloc(1, sizeof(*vmu)))) {
+		ast_copy_string(vmu->context, context, sizeof(vmu->context));
+		ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
+		AST_LIST_INSERT_TAIL(&users, vmu, list);
 	}
 	return vmu;
 }

Modified: team/oej/fixtoheader-1.4/autoconf/ast_check_gnu_make.m4
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/autoconf/ast_check_gnu_make.m4?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/autoconf/ast_check_gnu_make.m4 (original)
+++ team/oej/fixtoheader-1.4/autoconf/ast_check_gnu_make.m4 Thu Mar 12 09:31:58 2009
@@ -1,20 +1,20 @@
-AC_DEFUN([AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
-   GNU_MAKE='Not Found' ;
-   GNU_MAKE_VERSION_MAJOR=0 ;
-   GNU_MAKE_VERSION_MINOR=0 ;
+AC_DEFUN([AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK([for GNU make], [ac_cv_GNU_MAKE],
+   ac_cv_GNU_MAKE='Not Found' ;
+   ac_cv_GNU_MAKE_VERSION_MAJOR=0 ;
+   ac_cv_GNU_MAKE_VERSION_MINOR=0 ;
    for a in make gmake gnumake ; do
       if test -z "$a" ; then continue ; fi ;
       if ( sh -c "$a --version" 2> /dev/null | grep GNU  2>&1 > /dev/null ) ;  then
-         GNU_MAKE=$a ;
-         GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
-         GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
+         ac_cv_GNU_MAKE=$a ;
+         ac_cv_GNU_MAKE_VERSION_MAJOR=`$ac_cv_GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
+         ac_cv_GNU_MAKE_VERSION_MINOR=`$ac_cv_GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
          break;
       fi
    done ;
 ) ;
-if test  "x$GNU_MAKE" = "xNot Found"  ; then
+if test  "x$ac_cv_GNU_MAKE" = "xNot Found"  ; then
    AC_MSG_ERROR( *** Please install GNU make.  It is required to build Asterisk!)
    exit 1
 fi
-AC_SUBST([GNU_MAKE])
+AC_SUBST([GNU_MAKE], [$ac_cv_GNU_MAKE])
 ])

Modified: team/oej/fixtoheader-1.4/autoconf/ast_check_pwlib.m4
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/autoconf/ast_check_pwlib.m4?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/autoconf/ast_check_pwlib.m4 (original)
+++ team/oej/fixtoheader-1.4/autoconf/ast_check_pwlib.m4 Thu Mar 12 09:31:58 2009
@@ -103,12 +103,12 @@
     else
       AC_CHECK_HEADER(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
       if test "${HAS_PWLIB:-unset}" != "unset" ; then
-        AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
-        if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
-          AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
+        AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin$PATH_SEPARATOR/usr/local/share/pwlib/make)
+        PWLIB_INCDIR="/usr/local/include"
+        PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir 2>/dev/null`
+        if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
+          PWLIB_LIBDIR=`${PTLIB_CONFIG} --ptlibdir 2>/dev/null`
         fi
-        PWLIB_INCDIR="/usr/local/include"
-        PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
         if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
           if test "x$LIB64" != "x"; then
             PWLIB_LIBDIR="/usr/local/lib64"
@@ -121,9 +121,12 @@
       else
         AC_CHECK_HEADER(/usr/include/ptlib.h, HAS_PWLIB=1, )
         if test "${HAS_PWLIB:-unset}" != "unset" ; then
-          AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
+          AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/bin$PATH_SEPARATOR/usr/share/pwlib/make)
           PWLIB_INCDIR="/usr/include"
-          PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
+          PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir 2>/dev/null`
+          if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
+            PWLIB_LIBDIR=`${PTLIB_CONFIG} --ptlibdir 2>/dev/null`
+          fi
           if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
             if test "x$LIB64" != "x"; then
               PWLIB_LIBDIR="/usr/lib64"
@@ -188,8 +191,14 @@
 ])
 
 AC_DEFUN([AST_CHECK_PWLIB_VERSION], [
+	if test "x$7" != "x"; then
+	   	VNAME="$7"
+       	else
+	   	VNAME="$2_VERSION"
+	fi
+
 	if test "${HAS_$2:-unset}" != "unset"; then
-		$2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | sed -e 's/[[[:space:]]]\{1,\}/ /g' | cut -f3 -d ' ' | sed -e 's/"//g'`
+		$2_VERSION=`grep "$VNAME" ${$2_INCDIR}/$3 | sed -e 's/[[[:space:]]]\{1,\}/ /g' | cut -f3 -d ' ' | sed -e 's/"//g'`
 		$2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
 		$2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
 		$2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`

Modified: team/oej/fixtoheader-1.4/autoconf/ast_prog_sed.m4
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/autoconf/ast_prog_sed.m4?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/autoconf/ast_prog_sed.m4 (original)
+++ team/oej/fixtoheader-1.4/autoconf/ast_prog_sed.m4 Thu Mar 12 09:31:58 2009
@@ -12,7 +12,7 @@
      done
      echo "$ac_script" | sed 99q >conftest.sed
      $as_unset ac_script || ac_script=
-     _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed],
+     ifdef([_AC_PATH_PROGS_FEATURE_CHECK], [_AC_PATH_PROGS_FEATURE_CHECK], [_AC_PATH_PROG_FEATURE_CHECK])(SED, [sed gsed],
 	[_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
 		["$ac_path_SED" -f conftest.sed])])])
  SED="$ac_cv_path_SED"

Modified: team/oej/fixtoheader-1.4/channels/chan_dahdi.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/channels/chan_dahdi.c?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/channels/chan_dahdi.c (original)
+++ team/oej/fixtoheader-1.4/channels/chan_dahdi.c Thu Mar 12 09:31:58 2009
@@ -12087,13 +12087,11 @@
 	cfg = ast_config_load("users.conf");
 	if (cfg) {
 		char *cat;
-		const char *chans;
 		process_dahdi(&conf, "", ast_variable_browse(cfg, "general"), 1, 1);
 		for (cat = ast_category_browse(cfg, NULL); cat ; cat = ast_category_browse(cfg, cat)) {
 			if (!strcasecmp(cat, "general"))
 				continue;
-			chans = ast_variable_retrieve(cfg, cat, "dahdichan");
-			if (!ast_strlen_zero(chans)) {
+			if (!ast_strlen_zero(ast_variable_retrieve(cfg, cat, "dahdichan")) || !ast_strlen_zero(ast_variable_retrieve(cfg, cat, "zapchan"))) {
 				struct dahdi_chan_conf sect_conf;
 				memcpy(&sect_conf, &conf, sizeof(sect_conf));
 

Modified: team/oej/fixtoheader-1.4/channels/chan_gtalk.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/channels/chan_gtalk.c?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/channels/chan_gtalk.c (original)
+++ team/oej/fixtoheader-1.4/channels/chan_gtalk.c Thu Mar 12 09:31:58 2009
@@ -49,6 +49,7 @@
 #include <sys/signal.h>
 #include <iksemel.h>
 #include <pthread.h>
+#include <ctype.h>
 
 #ifdef HAVE_GNUTLS
 #include <gcrypt.h>
@@ -411,6 +412,7 @@
 	int pref_codec = 0;
 	int alreadysent = 0;
 	int codecs_num = 0;
+	char *lowerto = NULL;
 
 	iq = iks_new("iq");
 	gtalk = iks_new("session");
@@ -462,7 +464,14 @@
 
 	iks_insert_attrib(gtalk, "xmlns", "http://www.google.com/session");
 	iks_insert_attrib(gtalk, "type",initiator ? "initiate": "accept");
-	iks_insert_attrib(gtalk, "initiator", initiator ? from : to);
+	/* put the initiator attribute to lower case if we receive the call 
+	 * otherwise GoogleTalk won't establish the session */
+	if (!initiator) {
+	        char c;
+	        char *t = lowerto = ast_strdupa(to);
+		while (((c = *t) != '/') && (*t++ = tolower(c)));
+	}
+	iks_insert_attrib(gtalk, "initiator", initiator ? from : lowerto);
 	iks_insert_attrib(gtalk, "id", sid);
 	iks_insert_node(iq, gtalk);
 	iks_insert_node(gtalk, dcodecs);
@@ -481,6 +490,8 @@
 static int gtalk_invite_response(struct gtalk_pvt *p, char *to , char *from, char *sid, int initiator)
 {
 	iks *iq, *session, *transport;
+	char *lowerto = NULL;
+
 	iq = iks_new("iq");
 	session = iks_new("session");
 	transport = iks_new("transport");
@@ -501,7 +512,14 @@
 	ast_aji_increment_mid(p->parent->connection->mid);
 	iks_insert_attrib(session, "type", "transport-accept");
 	iks_insert_attrib(session, "id", sid);
-	iks_insert_attrib(session, "initiator", initiator ? from : to);
+	/* put the initiator attribute to lower case if we receive the call 
+	 * otherwise GoogleTalk won't establish the session */
+	if (!initiator) {
+	        char c;
+		char *t = lowerto = ast_strdupa(to);
+		while (((c = *t) != '/') && (*t++ = tolower(c)));
+	}
+	iks_insert_attrib(session, "initiator", initiator ? from : lowerto);
 	iks_insert_attrib(session, "xmlns", "http://www.google.com/session");
 	iks_insert_attrib(transport, "xmlns", "http://www.google.com/transport/p2p");
 	iks_insert_node(iq,session);
@@ -795,6 +813,7 @@
 	struct in_addr us;
 	iks *iq, *gtalk, *candidate, *transport;
 	char user[17], pass[17], preference[5], port[7];
+	char *lowerfrom = NULL;
 
 
 	iq = iks_new("iq");
@@ -873,7 +892,14 @@
 		ast_aji_increment_mid(c->mid);
 		iks_insert_attrib(gtalk, "type", "transport-info");
 		iks_insert_attrib(gtalk, "id", sid);
-		iks_insert_attrib(gtalk, "initiator", (p->initiator) ? to : from);
+		/* put the initiator attribute to lower case if we receive the call 
+		 * otherwise GoogleTalk won't establish the session */
+		if (!p->initiator) {
+		        char c;
+			char *t = lowerfrom = ast_strdupa(from);
+			while (((c = *t) != '/') && (*t++ = tolower(c)));
+		}
+		iks_insert_attrib(gtalk, "initiator", (p->initiator) ? to : lowerfrom);
 		iks_insert_attrib(gtalk, "xmlns", GOOGLE_NS);
 		iks_insert_attrib(candidate, "name", tmp->name);
 		iks_insert_attrib(candidate, "address", tmp->ip);
@@ -1074,6 +1100,7 @@
 {
 	iks *request, *session = NULL;
 	int res = -1;
+	char *lowerthem = NULL;
 
 	request = iks_new("iq");
 	if (request) {
@@ -1086,7 +1113,14 @@
 		if (session) {
 			iks_insert_attrib(session, "type", action);
 			iks_insert_attrib(session, "id", p->sid);
-			iks_insert_attrib(session, "initiator", p->initiator ? p->us : p->them);
+			/* put the initiator attribute to lower case if we receive the call 
+			 * otherwise GoogleTalk won't establish the session */
+			if (!p->initiator) {
+			        char c;
+				char *t = lowerthem = ast_strdupa(p->them);
+				while (((c = *t) != '/') && (*t++ = tolower(c)));
+			}
+			iks_insert_attrib(session, "initiator", p->initiator ? p->us : lowerthem);
 			iks_insert_attrib(session, "xmlns", "http://www.google.com/session");
 			iks_insert_node(request, session);
 			iks_send(client->connection->p, request);
@@ -1500,6 +1534,7 @@
 	struct gtalk *client = p->parent;
 	iks *iq, *gtalk, *dtmf;
 	char buffer[2] = {digit, '\0'};
+	char *lowerthem = NULL;
 	iq = iks_new("iq");
 	gtalk = iks_new("gtalk");
 	dtmf = iks_new("dtmf");
@@ -1521,7 +1556,14 @@
 	ast_aji_increment_mid(client->connection->mid);
 	iks_insert_attrib(gtalk, "xmlns", "http://jabber.org/protocol/gtalk");
 	iks_insert_attrib(gtalk, "action", "session-info");
-	iks_insert_attrib(gtalk, "initiator", p->initiator ? p->us: p->them);
+	/* put the initiator attribute to lower case if we receive the call 
+	 * otherwise GoogleTalk won't establish the session */
+	if (!p->initiator) {
+	        char c;
+	        char *t = lowerthem = ast_strdupa(p->them);
+	        while (((c = *t) != '/') && (*t++ = tolower(c)));
+	}
+	iks_insert_attrib(gtalk, "initiator", p->initiator ? p->us: lowerthem);
 	iks_insert_attrib(gtalk, "sid", p->sid);
 	iks_insert_attrib(dtmf, "xmlns", "http://jabber.org/protocol/gtalk/info/dtmf");
 	iks_insert_attrib(dtmf, "code", buffer);

Modified: team/oej/fixtoheader-1.4/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/team/oej/fixtoheader-1.4/channels/chan_iax2.c?view=diff&rev=181648&r1=181647&r2=181648
==============================================================================
--- team/oej/fixtoheader-1.4/channels/chan_iax2.c (original)
+++ team/oej/fixtoheader-1.4/channels/chan_iax2.c Thu Mar 12 09:31:58 2009
@@ -175,7 +175,7 @@
 int (*iax2_regfunk)(const char *username, int onoff) = NULL;
 
 /* Ethernet, etc */
-#define IAX_CAPABILITY_FULLBANDWIDTH 	0xFFFF
+#define IAX_CAPABILITY_FULLBANDWIDTH 	(0xFFFF & ~AST_FORMAT_AUDIO_UNDEFINED)
 /* T1, maybe ISDN */
 #define IAX_CAPABILITY_MEDBANDWIDTH 	(IAX_CAPABILITY_FULLBANDWIDTH & 	\
 					 ~AST_FORMAT_SLINEAR &			\
@@ -576,7 +576,9 @@
 	int encmethods;
 	/*! Encryption AES-128 Key */
 	aes_encrypt_ctx ecx;
-	/*! Decryption AES-128 Key */
+	/*! Decryption AES-128 Key corresponding to ecx */
+	aes_decrypt_ctx mydcx;
+	/*! Decryption AES-128 Key used to decrypt peer frames */
 	aes_decrypt_ctx dcx;
 	/*! 32 bytes of semi-random data */
 	unsigned char semirand[32];
@@ -868,6 +870,11 @@
 static struct iax2_user *build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
 static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, time_t regtime);
 static void prune_peers(void);
+static void prune_users(void);
+static int decode_frame(aes_decrypt_ctx *dcx, struct ast_iax2_full_hdr *fh, struct ast_frame *f, int *datalen);
+static int encrypt_frame(aes_encrypt_ctx *ecx, struct ast_iax2_full_hdr *fh, unsigned char *poo, int *datalen);
+static void build_ecx_key(const unsigned char *digest, struct chan_iax2_pvt *pvt);
+ 
 
 static const struct ast_channel_tech iax2_tech = {
 	.type = "IAX2",
@@ -1183,6 +1190,15 @@
 {
 	ao2_ref(peer, -1);
 	return NULL;
+}
+
+static struct iax2_user *find_user(const char *name)
+{
+	struct iax2_user tmp_user = {
+		.name = name,
+	};
+
+	return ao2_find(users, &tmp_user, OBJ_POINTER);
 }
 
 static inline struct iax2_user *user_ref(struct iax2_user *user)
@@ -2244,11 +2260,22 @@
 {
 	/* Called with iaxsl lock held, and iaxs[callno] non-NULL */
 	struct ast_iax2_full_hdr *fh = f->data;
+	struct ast_frame af;
+
+	/* if frame is encrypted. decrypt before updating it. */
+	if (f->encmethods) {
+		decode_frame(&f->mydcx, fh, &af, &f->datalen);
+	}
 	/* Mark this as a retransmission */
 	fh->dcallno = ntohs(IAX_FLAG_RETRANS | f->dcallno);
 	/* Update iseqno */
 	f->iseqno = iaxs[f->callno]->iseqno;
 	fh->iseqno = f->iseqno;
+
+	/* Now re-encrypt the frame */
+	if (f->encmethods) {
+		encrypt_frame(&f->ecx, fh, f->semirand, &f->datalen);
+	}
 	return 0;
 }
 
@@ -2345,26 +2372,44 @@
 
 static int iax2_prune_realtime(int fd, int argc, char *argv[])
 {
-	struct iax2_peer *peer;
+	struct iax2_peer *peer = NULL;
+	struct iax2_user *user = NULL;
 
 	if (argc != 4)
         return RESULT_SHOWUSAGE;
 	if (!strcmp(argv[3],"all")) {
-		reload_config();
+		prune_users();
+		prune_peers();
 		ast_cli(fd, "OK cache is flushed.\n");
-	} else if ((peer = find_peer(argv[3], 0))) {
-		if(ast_test_flag(peer, IAX_RTCACHEFRIENDS)) {
-			ast_set_flag(peer, IAX_RTAUTOCLEAR);
-			expire_registry(peer_ref(peer));
-			ast_cli(fd, "OK peer %s was removed from the cache.\n", argv[3]);
-		} else {
-			ast_cli(fd, "SORRY peer %s is not eligible for this operation.\n", argv[3]);
-		}
-		peer_unref(peer);
+		return RESULT_SUCCESS;
+	}
+	peer = find_peer(argv[3], 0);
+	user = find_user(argv[3]);
+	if (peer || user) {
+		if (peer) {
+			if (ast_test_flag(peer, IAX_RTCACHEFRIENDS)) {
+				ast_set_flag(peer, IAX_RTAUTOCLEAR);
+				expire_registry(peer_ref(peer));
+				ast_cli(fd, "Peer %s was removed from the cache.\n", argv[3]);
+			} else {
+				ast_cli(fd, "Peer %s is not eligible for this operation.\n", argv[3]);
+			}
+			peer_unref(peer);
+		}
+		if (user) {
+			if (ast_test_flag(user, IAX_RTCACHEFRIENDS)) {
+				ast_set_flag(user, IAX_RTAUTOCLEAR);
+				ast_cli(fd, "User %s was removed from the cache.\n", argv[3]);
+			} else {
+				ast_cli(fd, "User %s is not eligible for this operation.\n", argv[3]);
+			}
+			ao2_unlink(users,user);
+			user_unref(user);
+		}
 	} else {
-		ast_cli(fd, "SORRY peer %s was not found in the cache.\n", argv[3]);
-	}
-	
+		ast_cli(fd, "%s was not found in the cache.\n", argv[3]);
+	}
+
 	return RESULT_SUCCESS;
 }
 
@@ -3749,7 +3794,7 @@
 			res = AST_BRIDGE_COMPLETE;
 			break;
 		}
-		if ((f->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS)) {
+		if ((f->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS) && (f->subclass != AST_CONTROL_SRCUPDATE)) {
 			*fo = f;
 			*rc = who;
 			res =  AST_BRIDGE_COMPLETE;
@@ -3757,10 +3802,11 @@
 		}
 		other = (who == c0) ? c1 : c0;  /* the 'other' channel */
 		if ((f->frametype == AST_FRAME_VOICE) ||
-		    (f->frametype == AST_FRAME_TEXT) ||
-		    (f->frametype == AST_FRAME_VIDEO) || 
-		    (f->frametype == AST_FRAME_IMAGE) ||
-		    (f->frametype == AST_FRAME_DTMF)) {
+			(f->frametype == AST_FRAME_TEXT) ||
+			(f->frametype == AST_FRAME_VIDEO) || 
+			(f->frametype == AST_FRAME_IMAGE) ||
+			(f->frametype == AST_FRAME_DTMF) ||
+			(f->frametype == AST_FRAME_CONTROL)) {
 			/* monitored dtmf take out of the bridge.
 			 * check if we monitor the specific source.
 			 */
@@ -4260,10 +4306,19 @@
 	return 0;
 }
 
-static void build_enc_keys(const unsigned char *digest, aes_encrypt_ctx *ecx, aes_decrypt_ctx *dcx)
-{
-	aes_encrypt_key128(digest, ecx);
-	aes_decrypt_key128(digest, dcx);
+static void build_encryption_keys(const unsigned char *digest, struct chan_iax2_pvt *pvt)
+{
+	build_ecx_key(digest, pvt);
+	aes_decrypt_key128(digest, &pvt->dcx);
+}
+  
+static void build_ecx_key(const unsigned char *digest, struct chan_iax2_pvt *pvt)
+{
+	/* it is required to hold the corresponding decrypt key to our encrypt key
+	 * in the pvt struct because queued frames occasionally need to be decrypted and
+	 * re-encrypted when updated for a retransmission */
+	aes_encrypt_key128(digest, &pvt->ecx);
+	aes_decrypt_key128(digest, &pvt->mydcx);
 }
 
 static void memcpy_decrypt(unsigned char *dst, const unsigned char *src, int len, aes_decrypt_ctx *dcx)
@@ -4416,7 +4471,7 @@
 			MD5Update(&md5, (unsigned char *)iaxs[callno]->challenge, strlen(iaxs[callno]->challenge));
 			MD5Update(&md5, (unsigned char *)tmppw, strlen(tmppw));
 			MD5Final(digest, &md5);
-			build_enc_keys(digest, &iaxs[callno]->ecx, &iaxs[callno]->dcx);
+			build_encryption_keys(digest, iaxs[callno]);
 			res = decode_frame(&iaxs[callno]->dcx, fh, f, datalen);
 			if (!res) {
 				ast_set_flag(iaxs[callno], IAX_KEYPOPULATED);
@@ -4511,6 +4566,7 @@
 	fr->callno = pvt->callno;
 	fr->transfer = transfer;
 	fr->final = final;
+	fr->encmethods = 0;
 	if (!sendmini) {
 		/* We need a full frame */
 		if (seqno > -1)
@@ -4564,6 +4620,10 @@
 						iax_showframe(fr, NULL, 2, &pvt->addr, fr->datalen - sizeof(struct ast_iax2_full_hdr));
 				}
 				encrypt_frame(&pvt->ecx, fh, pvt->semirand, &fr->datalen);
+				fr->encmethods = pvt->encmethods;
+				fr->ecx = pvt->ecx;
+				fr->mydcx = pvt->mydcx;
+				memcpy(fr->semirand, pvt->semirand, sizeof(fr->semirand));
 			} else
 				ast_log(LOG_WARNING, "Supposed to send packet encrypted, but no key?\n");
 		}
@@ -5756,7 +5816,7 @@
 	return res;
 }
 
-static int authenticate(const char *challenge, const char *secret, const char *keyn, int authmethods, struct iax_ie_data *ied, struct sockaddr_in *sin, aes_encrypt_ctx *ecx, aes_decrypt_ctx *dcx)
+static int authenticate(const char *challenge, const char *secret, const char *keyn, int authmethods, struct iax_ie_data *ied, struct sockaddr_in *sin, struct chan_iax2_pvt *pvt)
 {
 	int res = -1;
 	int x;
@@ -5796,8 +5856,9 @@
 			/* If they support md5, authenticate with it.  */
 			for (x=0;x<16;x++)
 				sprintf(digres + (x << 1),  "%2.2x", digest[x]); /* safe */
-			if (ecx && dcx)
-				build_enc_keys(digest, ecx, dcx);
+			if (pvt) {
+				build_encryption_keys(digest, pvt);
+			}
 			iax_ie_append_str(ied, IAX_IE_MD5_RESULT, digres);
 			res = 0;
 		} else if (authmethods & IAX_AUTH_PLAINTEXT) {
@@ -5838,7 +5899,7 @@
 	/* Check for override RSA authentication first */
 	if (!ast_strlen_zero(override) || !ast_strlen_zero(okey)) {
 		/* Normal password authentication */
-		res = authenticate(p->challenge, override, okey, authmethods, &ied, sin, &p->ecx, &p->dcx);
+		res = authenticate(p->challenge, override, okey, authmethods, &ied, sin, p);
 	} else {
 		struct ao2_iterator i = ao2_iterator_init(peers, 0);
 		while ((peer = ao2_iterator_next(&i))) {
@@ -5849,7 +5910,7 @@

[... 7349 lines stripped ...]



More information about the asterisk-commits mailing list