No subject


Thu Jul 12 09:23:04 CDT 2007


(closes issue #9256)
Reported by: cmaj
Patches:
      amd-dont-wait-too-long-for-frames-take3.diff.txt uploaded by cmaj (license 111)
Tested by: cmaj, skygreg, ZX81, rjain


........

................
r101694 | russell | 2008-01-31 17:34:11 -0700 (Thu, 31 Jan 2008) | 16 lines

Merged revisions 101693 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r101693 | russell | 2008-01-31 18:32:49 -0600 (Thu, 31 Jan 2008) | 8 lines

Add some more sanity checking on IAX2 dial strings for the case that no peer
or hostname was provided, which is the one part of the dial string that is
absolutely required.  If it's not there, bail out.

(closes issue #11897)
Reported by sokhapkin
Patch by me

........

................
r101739 | russell | 2008-01-31 23:14:29 -0700 (Thu, 31 Jan 2008) | 2 lines

Get rid of a goto where there was no extra cleanup happening at the exit point

................
r101745 | russell | 2008-01-31 23:20:24 -0700 (Thu, 31 Jan 2008) | 2 lines

reduce a level of indentation

................
r101746 | russell | 2008-01-31 23:27:41 -0700 (Thu, 31 Jan 2008) | 2 lines

simplify some code, tweak formatting, and reduce indentation

................
r101773 | tilghman | 2008-02-01 09:01:22 -0700 (Fri, 01 Feb 2008) | 10 lines

Merged revisions 101772 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r101772 | tilghman | 2008-02-01 09:55:58 -0600 (Fri, 01 Feb 2008) | 2 lines

Compatibility fix for OpenWRT (reported by Brian Capouch via the mailing list)

........

................
r101819 | russell | 2008-02-01 10:26:31 -0700 (Fri, 01 Feb 2008) | 12 lines

Merged revisions 101818 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r101818 | russell | 2008-02-01 11:23:47 -0600 (Fri, 01 Feb 2008) | 4 lines

Don't overwrite the last character of a line if it's not a newline.  This would
happen if the last line in the file doesn't have a newline.
(pointed out by Qwell)

........

................
r101821 | russell | 2008-02-01 10:28:06 -0700 (Fri, 01 Feb 2008) | 8 lines

Blocked revisions 101820 via svnmerge

........
r101820 | russell | 2008-02-01 11:27:02 -0600 (Fri, 01 Feb 2008) | 1 line

off by one error
........

................
r101823 | qwell | 2008-02-01 10:44:32 -0700 (Fri, 01 Feb 2008) | 3 lines

Move an feof() call to before the fgets().
This would have exited the loop early if you had an authentication file with no newline at the end.

................
r101824 | tilghman | 2008-02-01 11:08:44 -0700 (Fri, 01 Feb 2008) | 2 lines

Clarify the pooling functionality by changing the config file keyword

................
r101869 | qwell | 2008-02-01 11:24:52 -0700 (Fri, 01 Feb 2008) | 1 line

Comparison, not set :)  Thanks mvanbaak.
................
r101873 | tilghman | 2008-02-01 11:45:31 -0700 (Fri, 01 Feb 2008) | 7 lines

Fix multi, when using the LIKE query.
(closes issue #11889)
 Reported by: jmls
 Patches: 
       res_config_curl.patch uploaded by jmls (license 141)
 Tested by: jmls

................
r101895 | tilghman | 2008-02-01 12:44:39 -0700 (Fri, 01 Feb 2008) | 10 lines

Merged revisions 101894 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r101894 | tilghman | 2008-02-01 13:36:12 -0600 (Fri, 01 Feb 2008) | 2 lines

Change detection of getifaddrs to use AST_C_COMPILE_CHECK, backported from trunk (as suggested by kpfleming)

........

................

Modified:
    team/murf/bug11210/   (props changed)
    team/murf/bug11210/CHANGES
    team/murf/bug11210/apps/app_amd.c
    team/murf/bug11210/apps/app_authenticate.c
    team/murf/bug11210/apps/app_channelredirect.c
    team/murf/bug11210/apps/app_queue.c
    team/murf/bug11210/channels/chan_agent.c
    team/murf/bug11210/channels/chan_iax2.c
    team/murf/bug11210/channels/chan_sip.c
    team/murf/bug11210/configs/res_odbc.conf.sample
    team/murf/bug11210/configure
    team/murf/bug11210/configure.ac
    team/murf/bug11210/funcs/func_realtime.c
    team/murf/bug11210/include/asterisk/autoconfig.h.in
    team/murf/bug11210/main/acl.c
    team/murf/bug11210/main/file.c
    team/murf/bug11210/main/pbx.c
    team/murf/bug11210/main/translate.c
    team/murf/bug11210/res/res_config_curl.c
    team/murf/bug11210/res/res_monitor.c
    team/murf/bug11210/res/res_odbc.c

Propchange: team/murf/bug11210/
------------------------------------------------------------------------------
    automerge = yes

Propchange: team/murf/bug11210/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/murf/bug11210/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/murf/bug11210/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Feb  1 16:31:25 2008
@@ -1,1 +1,1 @@
-/trunk:1-101330
+/trunk:1-101942

Modified: team/murf/bug11210/CHANGES
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/CHANGES?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/CHANGES (original)
+++ team/murf/bug11210/CHANGES Fri Feb  1 16:31:25 2008
@@ -356,7 +356,6 @@
      direct options to the app.
   * AMD() has a new "maximum word length" option. "show application AMD" from the CLI
      for more details
-  * New application RTPpage() that pages SIP phones with unicast or multicast RTP streams
 
 Music On Hold Changes
 ---------------------

Modified: team/murf/bug11210/apps/app_amd.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/apps/app_amd.c?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/apps/app_amd.c (original)
+++ team/murf/bug11210/apps/app_amd.c Fri Feb  1 16:31:25 2008
@@ -93,19 +93,22 @@
 static int dfltSilenceThreshold     = 256;
 static int dfltMaximumWordLength    = 5000; /* Setting this to a large default so it is not used unless specify it in the configs or command line */
 
+/* Set to the lowest ms value provided in amd.conf or application parameters */
+static int dfltMaxWaitTimeForFrame  = 50;
+
 static void isAnsweringMachine(struct ast_channel *chan, void *data)
 {
 	int res = 0;
 	struct ast_frame *f = NULL;
 	struct ast_dsp *silenceDetector = NULL;
-	int dspsilence = 0, readFormat, framelength;
+	int dspsilence = 0, readFormat, framelength = 0;
 	int inInitialSilence = 1;
 	int inGreeting = 0;
 	int voiceDuration = 0;
 	int silenceDuration = 0;
 	int iTotalTime = 0;
 	int iWordsCount = 0;
-	int currentState = STATE_IN_SILENCE;
+	int currentState = STATE_IN_WORD;
 	int previousState = STATE_IN_SILENCE;
 	int consecutiveVoiceDuration = 0;
 	char amdCause[256] = "", amdStatus[256] = "";
@@ -124,6 +127,7 @@
 	int maximumNumberOfWords = dfltMaximumNumberOfWords;
 	int silenceThreshold     = dfltSilenceThreshold;
 	int maximumWordLength	 = dfltMaximumWordLength;
+	int maxWaitTimeForFrame  = dfltMaxWaitTimeForFrame;
 
 	AST_DECLARE_APP_ARGS(args,
 			     AST_APP_ARG(argInitialSilence);
@@ -165,6 +169,20 @@
 		ast_debug(1, "AMD using the default parameters.\n");
 	}
 
+	/* Find lowest ms value, that will be max wait time for a frame */
+	if (maxWaitTimeForFrame > initialSilence)
+		maxWaitTimeForFrame = initialSilence;
+	if (maxWaitTimeForFrame > greeting)
+		maxWaitTimeForFrame = greeting;
+	if (maxWaitTimeForFrame > afterGreetingSilence)
+		maxWaitTimeForFrame = afterGreetingSilence;
+	if (maxWaitTimeForFrame > totalAnalysisTime)
+		maxWaitTimeForFrame = totalAnalysisTime;
+	if (maxWaitTimeForFrame > minimumWordLength)
+		maxWaitTimeForFrame = minimumWordLength;
+	if (maxWaitTimeForFrame > betweenWordsSilence)
+		maxWaitTimeForFrame = betweenWordsSilence;
+
 	/* Now we're ready to roll! */
 	ast_verb(3, "AMD: initialSilence [%d] greeting [%d] afterGreetingSilence [%d] "
 		"totalAnalysisTime [%d] minimumWordLength [%d] betweenWordsSilence [%d] maximumNumberOfWords [%d] silenceThreshold [%d] maximumWordLength [%d] \n",
@@ -192,7 +210,8 @@
 	ast_dsp_set_threshold(silenceDetector, silenceThreshold);
 
 	/* Now we go into a loop waiting for frames from the channel */
-	while ((res = ast_waitfor(chan, totalAnalysisTime)) > -1) {
+	while ((res = ast_waitfor(chan, 2 * maxWaitTimeForFrame)) > -1) {
+
 		/* If we fail to read in a frame, that means they hung up */
 		if (!(f = ast_read(chan))) {
 			ast_verb(3, "AMD: Channel [%s]. HANGUP\n", chan->name);
@@ -201,9 +220,13 @@
 			break;
 		}
 
-		if (f->frametype == AST_FRAME_VOICE) {
+		if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_NULL || f->frametype == AST_FRAME_CNG) {
 			/* If the total time exceeds the analysis time then give up as we are not too sure */
-			framelength = (ast_codec_get_samples(f) / DEFAULT_SAMPLES_PER_MS);
+			if (f->frametype == AST_FRAME_VOICE)
+				framelength = (ast_codec_get_samples(f) / DEFAULT_SAMPLES_PER_MS);
+			else
+				framelength += 2 * maxWaitTimeForFrame;
+
 			iTotalTime += framelength;
 			if (iTotalTime >= totalAnalysisTime) {
 				ast_verb(3, "AMD: Channel [%s]. Too long...\n", chan->name );
@@ -214,9 +237,14 @@
 			}
 
 			/* Feed the frame of audio into the silence detector and see if we get a result */
-			dspsilence = 0;
-			ast_dsp_silence(silenceDetector, f, &dspsilence);
-			if (dspsilence) {
+			if (f->frametype != AST_FRAME_VOICE)
+				dspsilence += 2 * maxWaitTimeForFrame;
+			else {
+				dspsilence = 0;
+				ast_dsp_silence(silenceDetector, f, &dspsilence);
+			}
+
+			if (dspsilence > 0) {
 				silenceDuration = dspsilence;
 				
 				if (silenceDuration >= betweenWordsSilence) {
@@ -238,6 +266,7 @@
 					ast_frfree(f);
 					strcpy(amdStatus , "MACHINE");
 					sprintf(amdCause , "INITIALSILENCE-%d-%d", silenceDuration, initialSilence);
+					res = 1;
 					break;
 				}
 				
@@ -247,6 +276,7 @@
 					ast_frfree(f);
 					strcpy(amdStatus , "HUMAN");
 					sprintf(amdCause , "HUMAN-%d-%d", silenceDuration, afterGreetingSilence);
+					res = 1;
 					break;
 				}
 				
@@ -274,6 +304,7 @@
 					ast_frfree(f);
 					strcpy(amdStatus , "MACHINE");
 					sprintf(amdCause , "MAXWORDS-%d-%d", iWordsCount, maximumNumberOfWords);
+					res = 1;
 					break;
 				}
 				
@@ -282,6 +313,7 @@
 					ast_frfree(f);
 					strcpy(amdStatus , "MACHINE");
 					sprintf(amdCause , "LONGGREETING-%d-%d", voiceDuration, greeting);
+					res = 1;
 					break;
 				}
 				

Modified: team/murf/bug11210/apps/app_authenticate.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/apps/app_authenticate.c?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/apps/app_authenticate.c (original)
+++ team/murf/bug11210/apps/app_authenticate.c Fri Feb  1 16:31:25 2008
@@ -119,70 +119,84 @@
 	for (retries = 0; retries < 3; retries++) {
 		if ((res = ast_app_getdata(chan, prompt, passwd, maxdigits, 0)) < 0)
 			break;
+
 		res = 0;
-		if (arglist.password[0] == '/') {
-			if (ast_test_flag(&flags,OPT_DATABASE)) {
-				char tmp[256];
-				/* Compare against a database key */
-				if (!ast_db_get(arglist.password + 1, passwd, tmp, sizeof(tmp))) {
-					/* It's a good password */
-					if (ast_test_flag(&flags,OPT_REMOVE))
-						ast_db_del(arglist.password + 1, passwd);
-					break;
-				}
-			} else {
-				/* Compare against a file */
-				FILE *f;
-				char buf[256] = "", md5passwd[33] = "", *md5secret = NULL;
-				
-				if (!(f = fopen(arglist.password, "r"))) {
-					ast_log(LOG_WARNING, "Unable to open file '%s' for authentication: %s\n", arglist.password, strerror(errno));
-					continue;
-				}
-
-				while (!feof(f)) {
-					fgets(buf, sizeof(buf), f);
-					if (!feof(f) && !ast_strlen_zero(buf)) {
-						buf[strlen(buf) - 1] = '\0';
-						if (ast_test_flag(&flags,OPT_MULTIPLE)) {
-							md5secret = strchr(buf, ':');
-							if (md5secret == NULL)
-								continue;
-							*md5secret = '\0';
-							md5secret++;
-							ast_md5_hash(md5passwd, passwd);
-							if (!strcmp(md5passwd, md5secret)) {
-								if (ast_test_flag(&flags,OPT_ACCOUNT))
-									ast_cdr_setaccount(chan, buf);
-								break;
-							}
-						} else {
-							if (!strcmp(passwd, buf)) {
-								if (ast_test_flag(&flags,OPT_ACCOUNT))
-									ast_cdr_setaccount(chan, buf);
-								break;
-							}
-						}
-					}
-				}
-				fclose(f);
-				if (!ast_strlen_zero(buf)) {
-					if (ast_test_flag(&flags,OPT_MULTIPLE)) {
-						if (md5secret && !strcmp(md5passwd, md5secret))
-							break;
-					} else {
-						if (!strcmp(passwd, buf))
-							break;
-					}
-				}
-			}
-		} else {
+
+		if (arglist.password[0] != '/') {
 			/* Compare against a fixed password */
 			if (!strcmp(passwd, arglist.password)) 
 				break;
 		}
+
+		if (ast_test_flag(&flags,OPT_DATABASE)) {
+			char tmp[256];
+			/* Compare against a database key */
+			if (!ast_db_get(arglist.password + 1, passwd, tmp, sizeof(tmp))) {
+				/* It's a good password */
+				if (ast_test_flag(&flags,OPT_REMOVE))
+					ast_db_del(arglist.password + 1, passwd);
+				break;
+			}
+		} else {
+			/* Compare against a file */
+			FILE *f;
+			char buf[256] = "", md5passwd[33] = "", *md5secret = NULL;
+				
+			if (!(f = fopen(arglist.password, "r"))) {
+				ast_log(LOG_WARNING, "Unable to open file '%s' for authentication: %s\n", arglist.password, strerror(errno));
+				continue;
+			}
+
+			for (;;) {
+				size_t len;
+
+				if (feof(f))
+					break;
+
+				fgets(buf, sizeof(buf), f);
+
+				if (ast_strlen_zero(buf))
+					continue;
+
+				len = strlen(buf) - 1;
+				if (buf[len - 1] == '\n')
+					buf[len - 1] = '\0';
+
+				if (ast_test_flag(&flags, OPT_MULTIPLE)) {
+					md5secret = buf;
+					strsep(&md5secret, ":");
+					if (!md5secret)
+						continue;
+					ast_md5_hash(md5passwd, passwd);
+					if (!strcmp(md5passwd, md5secret)) {
+						if (ast_test_flag(&flags,OPT_ACCOUNT))
+							ast_cdr_setaccount(chan, buf);
+						break;
+					}
+				} else {
+					if (!strcmp(passwd, buf)) {
+						if (ast_test_flag(&flags, OPT_ACCOUNT))
+							ast_cdr_setaccount(chan, buf);
+						break;
+					}
+				}
+			}
+
+			fclose(f);
+
+			if (!ast_strlen_zero(buf)) {
+				if (ast_test_flag(&flags, OPT_MULTIPLE)) {
+					if (md5secret && !strcmp(md5passwd, md5secret))
+						break;
+				} else {
+					if (!strcmp(passwd, buf))
+						break;
+				}
+			}
+		}
 		prompt = "auth-incorrect";
 	}
+
 	if ((retries < 3) && !res) {
 		if (ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE)) 
 			ast_cdr_setaccount(chan, passwd);

Modified: team/murf/bug11210/apps/app_channelredirect.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/apps/app_channelredirect.c?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/apps/app_channelredirect.c (original)
+++ team/murf/bug11210/apps/app_channelredirect.c Fri Feb  1 16:31:25 2008
@@ -63,19 +63,18 @@
 
 	if (ast_strlen_zero(args.channel) || ast_strlen_zero(args.label)) {
 		ast_log(LOG_WARNING, "%s requires an argument (channel,[[context,]exten,]priority)\n", app);
-		goto quit;
+		return -1;
 	}
 
 	chan2 = ast_get_channel_by_name_locked(args.channel);
 	if (!chan2) {
 		ast_log(LOG_WARNING, "No such channel: %s\n", args.channel);
-		goto quit;
+		return -1;
 	}
 
 	res = ast_parseable_goto(chan2, args.label);
 
 	ast_channel_unlock(chan2);
-quit:
 
 	return res;
 }

Modified: team/murf/bug11210/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/apps/app_queue.c?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/apps/app_queue.c (original)
+++ team/murf/bug11210/apps/app_queue.c Fri Feb  1 16:31:25 2008
@@ -1427,13 +1427,32 @@
 
 	/* Create a new queue if an in-core entry does not exist yet. */
 	if (!q) {
+		struct ast_variable *tmpvar = NULL;
 		if (!(q = alloc_queue(queuename)))
 			return NULL;
 		ao2_lock(q);
 		clear_queue(q);
 		q->realtime = 1;
+		/*Before we initialize the queue, we need to set the strategy, so that linear strategy
+		 * will allocate the members properly
+		 */
+		for (tmpvar = queue_vars; tmpvar; tmpvar = tmpvar->next) {
+			if (!strcasecmp(tmpvar->name, "strategy")) {
+				q->strategy = strat2int(tmpvar->value);
+				if (q->strategy < 0) {
+					ast_log(LOG_WARNING, "'%s' isn't a valid strategy for queue '%s', using ringall instead\n",
+					tmpvar->value, q->name);
+					q->strategy = QUEUE_STRATEGY_RINGALL;
+				}
+				break;
+			}
+		}
+		/* We traversed all variables and didn't find a strategy */
+		if (!tmpvar)
+			q->strategy = QUEUE_STRATEGY_RINGALL;
 		init_queue(q);		/* Ensure defaults for all parameters not set explicitly. */
 		ao2_link(queues, q);
+		ast_variables_destroy(tmpvar);
 	}
 
 	memset(tmpbuf, 0, sizeof(tmpbuf));
@@ -1462,10 +1481,10 @@
 
 	while ((interface = ast_category_browse(member_config, interface))) {
 		rt_handle_member_record(q, interface,
-			ast_variable_retrieve(member_config, interface, "membername"),
+			S_OR(ast_variable_retrieve(member_config, interface, "membername"),interface),
 			ast_variable_retrieve(member_config, interface, "penalty"),
 			ast_variable_retrieve(member_config, interface, "paused"),
-			ast_variable_retrieve(member_config, interface, "state_interface"));
+			S_OR(ast_variable_retrieve(member_config, interface, "state_interface"),interface));
 	}
 
 	/* Delete all realtime members that have been deleted in DB. */
@@ -1576,7 +1595,7 @@
 			S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface),
 			ast_variable_retrieve(member_config, interface, "penalty"),
 			ast_variable_retrieve(member_config, interface, "paused"),
-			ast_variable_retrieve(member_config, interface, "state_interface"));
+			S_OR(ast_variable_retrieve(member_config, interface, "state_interface"), interface));
 	}
 
 	/* Delete all realtime members that have been deleted in DB. */
@@ -4983,7 +5002,7 @@
 			} else
 				new = 0;
 			if (q) {
-				const char *tmpvar;
+				const char *tmpvar = NULL;
 				if (!new)
 					ao2_lock(q);
 				/* Check if a queue with this name already exists */

Modified: team/murf/bug11210/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_agent.c?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/channels/chan_agent.c (original)
+++ team/murf/bug11210/channels/chan_agent.c Fri Feb  1 16:31:25 2008
@@ -1507,6 +1507,7 @@
 	long logintime;
 	int ret = -1; /* Return -1 if no agent if found */
 
+	AST_LIST_LOCK(&agents);
 	AST_LIST_TRAVERSE(&agents, p, list) {
 		if (!strcasecmp(p->agent, agent)) {
 			ret = 0;
@@ -1526,6 +1527,7 @@
 			break;
 		}
 	}
+	AST_LIST_UNLOCK(&agents);
 
 	return ret;
 }
@@ -1592,20 +1594,26 @@
 
 static char *complete_agent_logoff_cmd(const char *line, const char *word, int pos, int state)
 {
+	char *ret = NULL;
+
 	if (pos == 2) {
 		struct agent_pvt *p;
 		char name[AST_MAX_AGENT];
 		int which = 0, len = strlen(word);
 
+		AST_LIST_LOCK(&agents);
 		AST_LIST_TRAVERSE(&agents, p, list) {
 			snprintf(name, sizeof(name), "Agent/%s", p->agent);
-			if (!strncasecmp(word, name, len) && p->loginstart && ++which > state)
-				return ast_strdup(name);
-		}
+			if (!strncasecmp(word, name, len) && p->loginstart && ++which > state) {
+				ret = ast_strdup(name);
+				break;
+			}
+		}
+		AST_LIST_UNLOCK(&agents);
 	} else if (pos == 3 && state == 0) 
 		return ast_strdup("soft");
 	
-	return NULL;
+	return ret;
 }
 
 /*!
@@ -2242,6 +2250,9 @@
 	return res;
 }
 
+/*!
+ * \note This function expects the agent list to be locked
+ */
 static struct agent_pvt *find_agent(char *agentid)
 {
 	struct agent_pvt *cur;
@@ -2277,7 +2288,10 @@
 	if (!args.item)
 		args.item = "status";
 
+	AST_LIST_LOCK(&agents);
+
 	if (!(agent = find_agent(args.agentid))) {
+		AST_LIST_UNLOCK(&agents);
 		ast_log(LOG_WARNING, "Agent '%s' not found!\n", args.agentid);
 		return -1;
 	}
@@ -2303,6 +2317,8 @@
 	} else if (!strcasecmp(args.item, "exten"))
 		ast_copy_string(buf, agent->loginchan, len);	
 
+	AST_LIST_UNLOCK(&agents);
+
 	return 0;
 }
 

Modified: team/murf/bug11210/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_iax2.c?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/channels/chan_iax2.c (original)
+++ team/murf/bug11210/channels/chan_iax2.c Fri Feb  1 16:31:25 2008
@@ -3422,8 +3422,9 @@
 		if (var && sin) {
 			for (tmp = var; tmp; tmp = tmp->next) {
 				if (!strcasecmp(tmp->name, "host")) {
-					struct in_addr sin2 = { 0, };
+					struct in_addr sin2;
 					struct ast_dnsmgr_entry *dnsmgr = NULL;
+					memset(&sin2, 0, sizeof(sin2));
 					if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
 						/* No match */
 						ast_variables_destroy(var);
@@ -3534,8 +3535,9 @@
 		if (var) {
 			for (tmp = var; tmp; tmp = tmp->next) {
 				if (!strcasecmp(tmp->name, "host")) {
-					struct in_addr sin2 = { 0, };
+					struct in_addr sin2;
 					struct ast_dnsmgr_entry *dnsmgr = NULL;
+					memset(&sin2, 0, sizeof(sin2));
 					if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
 						/* No match */
 						ast_variables_destroy(var);
@@ -3832,6 +3834,11 @@
 	memset(&pds, 0, sizeof(pds));
 	tmpstr = ast_strdupa(dest);
 	parse_dial_string(tmpstr, &pds);
+
+	if (ast_strlen_zero(pds.peer)) {
+		ast_log(LOG_WARNING, "No peer provided in the IAX2 dial string '%s'\n", dest);
+		return -1;
+	}
 
 	if (!pds.exten)
 		pds.exten = defaultrdest;
@@ -10072,16 +10079,15 @@
 	tmpstr = ast_strdupa(data);
 	parse_dial_string(tmpstr, &pds);
 
+	if (ast_strlen_zero(pds.peer)) {
+		ast_log(LOG_WARNING, "No peer provided in the IAX2 dial string '%s'\n", (char *) data);
+		return NULL;
+	}
+	       
 	memset(&cai, 0, sizeof(cai));
 	cai.capability = iax2_capability;
 
 	ast_copy_flags(&cai, &globalflags, IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
-
-	if (!pds.peer) {
-		ast_log(LOG_WARNING, "No peer given\n");
-		return NULL;
-	}
-	       
 	
 	/* Populate our address from the given */
 	if (create_addr(pds.peer, NULL, &sin, &cai)) {
@@ -11488,6 +11494,11 @@
 	tmpstr = ast_strdupa(data);
 	parse_dial_string(tmpstr, &pds);
 
+	if (ast_strlen_zero(pds.peer)) {
+		ast_log(LOG_WARNING, "No peer provided in the IAX2 dial string '%s'\n", data);
+		return -1;
+	}
+
 	/* Populate our address from the given */
 	if (create_addr(pds.peer, NULL, &sin, &cai))
 		return -1;
@@ -11927,8 +11938,11 @@
 
 	memset(&pds, 0, sizeof(pds));
 	parse_dial_string(tmp, &pds);
-	if (ast_strlen_zero(pds.peer))
+
+	if (ast_strlen_zero(pds.peer)) {
+		ast_log(LOG_WARNING, "No peer provided in the IAX2 dial string '%s'\n", (char *) data);
 		return res;
+	}
 	
 	ast_debug(3, "Checking device state for device %s\n", pds.peer);
 

Modified: team/murf/bug11210/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_sip.c?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/channels/chan_sip.c (original)
+++ team/murf/bug11210/channels/chan_sip.c Fri Feb  1 16:31:25 2008
@@ -1503,6 +1503,7 @@
 	struct sip_st_cfg stimer;	/*!<  SIP Session-Timers */
 	int timer_t1;			/*!<  The maximum T1 value for the peer */
 	int timer_b;			/*!<  The maximum timer B (transaction timeouts) */
+	int deprecated_username; /*!< If it's a realtime peer, are they using the deprecated "username" instead of "defaultuser" */
 };
 
 
@@ -2013,7 +2014,7 @@
 static int handle_common_options(struct ast_flags *flags, struct ast_flags *mask, struct ast_variable *v);
 
 /* Realtime device support */
-static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey);
+static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey, int deprecated_username);
 static struct sip_user *realtime_user(const char *username);
 static void update_peer(struct sip_peer *p, int expiry);
 static struct ast_variable *get_insecure_variable_from_config(struct ast_config *config);
@@ -3465,7 +3466,7 @@
 	that name and store that in the "regserver" field in the sippeers
 	table to facilitate multi-server setups.
 */
-static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *defaultuser, const char *fullcontact, int expirey)
+static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *defaultuser, const char *fullcontact, int expirey, int deprecated_username)
 {
 	char port[10];
 	char ipaddr[INET_ADDRSTRLEN];
@@ -3494,11 +3495,11 @@
 	if (fc)
 		ast_update_realtime(tablename, "name", peername, "ipaddr", ipaddr,
 			"port", port, "regseconds", regseconds,
-			"defaultuser", defaultuser, fc, fullcontact, syslabel, sysname, NULL); /* note fc and syslabel _can_ be NULL */
+			deprecated_username ? "username" : "defaultuser", defaultuser, fc, fullcontact, syslabel, sysname, NULL); /* note fc and syslabel _can_ be NULL */
 	else
 		ast_update_realtime(tablename, "name", peername, "ipaddr", ipaddr,
 			"port", port, "regseconds", regseconds,
-			"defaultuser", defaultuser, syslabel, sysname, NULL); /* note syslabel _can_ be NULL */
+			deprecated_username ? "username" : "defaultuser", defaultuser, syslabel, sysname, NULL); /* note syslabel _can_ be NULL */
 }
 
 /*! \brief Automatically add peer extension to dial plan */
@@ -3629,7 +3630,7 @@
 	int rtcachefriends = ast_test_flag(&p->flags[1], SIP_PAGE2_RTCACHEFRIENDS);
 	if (sip_cfg.peer_rtupdate &&
 	    (p->is_realtime || rtcachefriends)) {
-		realtime_update_peer(p->name, &p->addr, p->username, rtcachefriends ? p->fullcontact : NULL, expiry);
+		realtime_update_peer(p->name, &p->addr, p->username, rtcachefriends ? p->fullcontact : NULL, expiry, p->deprecated_username);
 	}
 }
 
@@ -3698,8 +3699,9 @@
 			if (var) {
 				for (tmp = var; tmp; tmp = tmp->next) {
 					if (!strcasecmp(var->name, "host")) {
-						struct in_addr sin2 = { 0, };
+						struct in_addr sin2;
 						struct ast_dnsmgr_entry *dnsmgr = NULL;
+						memset(&sin2, 0, sizeof(sin2));
 						if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) {
 							/* No match */
 							ast_variables_destroy(var);
@@ -9592,7 +9594,7 @@
 
 	if (!sip_cfg.ignore_regexpire) {
 		if (peer->rt_fromcontact)
-			ast_update_realtime(tablename, "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", "defaultuser", "", "regserver", "", NULL);
+			ast_update_realtime(tablename, "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", peer->deprecated_username ? "username" : "defaultuser", "", "regserver", "", NULL);
 		else 
 			ast_db_del("SIP/Registry", peer->name);
 	}
@@ -18410,8 +18412,10 @@
 	AST_LIST_TRAVERSE(&threadl, th, list) {
 		if ((s->sin_family == th->ser->requestor.sin_family) &&
 			(s->sin_addr.s_addr == th->ser->requestor.sin_addr.s_addr) &&
-			(s->sin_port == th->ser->requestor.sin_port)) 
+			(s->sin_port == th->ser->requestor.sin_port))  {
+				AST_LIST_UNLOCK(&threadl);
 				return th->ser;
+			}
 	}
 	AST_LIST_UNLOCK(&threadl);
 	return NULL;
@@ -19963,6 +19967,7 @@
 	char callback[256] = "";
 	struct sip_peer tmp_peer;
 	const char *srvlookup = NULL;
+	static int deprecation_warning = 1;
 	
 	if (!realtime) {
 		/* Note we do NOT use find_peer here, to avoid realtime recursion */
@@ -20106,8 +20111,15 @@
 			peer->callingpres = ast_parse_caller_presentation(v->value);
 			if (peer->callingpres == -1)
 				peer->callingpres = atoi(v->value);
-		} else if (!strcasecmp(v->name, "username") | !strcmp(v->name, "defaultuser")) {	/* "username" is deprecated */
+		} else if (!strcasecmp(v->name, "username") || !strcmp(v->name, "defaultuser")) {	/* "username" is deprecated */
 			ast_copy_string(peer->username, v->value, sizeof(peer->username));
+			if (!strcasecmp(v->name, "username")) {
+				if (deprecation_warning) {
+					ast_log(LOG_NOTICE, "The 'username' field for sip peers has been deprecated in favor of the term 'defaultuser'\n");
+					deprecation_warning = 0;
+				}
+				peer->deprecated_username = 1;
+			}
 		} else if (!strcasecmp(v->name, "language")) {
 			ast_copy_string(peer->language, v->value, sizeof(peer->language));
 		} else if (!strcasecmp(v->name, "regexten")) {

Modified: team/murf/bug11210/configs/res_odbc.conf.sample
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/configs/res_odbc.conf.sample?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/configs/res_odbc.conf.sample (original)
+++ team/murf/bug11210/configs/res_odbc.conf.sample Fri Feb  1 16:31:25 2008
@@ -4,8 +4,9 @@
 ; Note that all environmental variables can be seen by all connections,
 ; so you can't have different values for different connections.
 [ENV]
-INFORMIXSERVER => my_special_database
-INFORMIXDIR => /opt/informix
+;INFORMIXSERVER => my_special_database
+;INFORMIXDIR => /opt/informix
+;ORACLE_HOME => /home/oracle
 
 ; All other sections are arbitrary names for database connections.
 
@@ -15,6 +16,7 @@
 ;username => myuser
 ;password => mypass
 pre-connect => yes
+;
 ; What should we execute to ensure that our connection is still alive?  The
 ; statement should return a non-zero value in the first field of its first
 ; record.  The default is "select 1".
@@ -34,17 +36,18 @@
 ;idlecheck => 3600
 
 ; Certain servers, such as MS SQL Server and Sybase use the TDS protocol, which
-; limits the number of active queries per connection to 1.  By setting up pools
-; of connections, Asterisk can be made to work with these servers.
+; limits the number of active queries per connection to 1.  By telling res_odbc
+; not to share connections, Asterisk can be made to work with these servers.
 [sqlserver]
 enabled => no
 dsn => mickeysoft
-pooling => yes
+share_connections => no
 limit => 5
 username => oscar
 password => thegrouch
 pre-connect => yes
 sanitysql => select count(*) from systables
+;
 ; Many databases have a default of '\' to escape special characters.  MS SQL
 ; Server does not.
 backslash_is_escape => no

Modified: team/murf/bug11210/configure.ac
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/configure.ac?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/configure.ac (original)
+++ team/murf/bug11210/configure.ac Fri Feb  1 16:31:25 2008
@@ -571,6 +571,8 @@
 AST_EXT_LIB_CHECK([STRTOD], [c], [strtod], [stdlib.h])
 AST_EXT_LIB_CHECK([FLOOR], [m], [floor])
 AST_EXT_LIB_CHECK([CEIL], [m], [ceil])
+
+AST_C_COMPILE_CHECK([GETIFADDRS], [struct ifaddrs *p; getifaddrs(&p)], [ifaddrs.h])
 
 GSM_INTERNAL="yes"
 AC_SUBST(GSM_INTERNAL)

Modified: team/murf/bug11210/funcs/func_realtime.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/funcs/func_realtime.c?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/funcs/func_realtime.c (original)
+++ team/murf/bug11210/funcs/func_realtime.c Fri Feb  1 16:31:25 2008
@@ -68,10 +68,11 @@
 
 	head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, NULL);
 
-	if (!head)
+	if (!head) {
 		if (chan)
 			ast_autoservice_stop(chan);
 		return -1;
+	}
 
 	resultslen = 0;
 	n = 0;

Modified: team/murf/bug11210/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/include/asterisk/autoconfig.h.in?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/include/asterisk/autoconfig.h.in (original)
+++ team/murf/bug11210/include/asterisk/autoconfig.h.in Fri Feb  1 16:31:25 2008
@@ -296,6 +296,12 @@
 
 /* Define to 1 if you have the `gethostname' function. */
 #undef HAVE_GETHOSTNAME
+
+/* Define if your system has the GETIFADDRS headers. */
+#undef HAVE_GETIFADDRS
+
+/* Define GETIFADDRS headers version */
+#undef HAVE_GETIFADDRS_VERSION
 
 /* Define to 1 if you have the `getloadavg' function. */
 #undef HAVE_GETLOADAVG

Modified: team/murf/bug11210/main/acl.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/main/acl.c?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================
--- team/murf/bug11210/main/acl.c (original)
+++ team/murf/bug11210/main/acl.c Fri Feb  1 16:31:25 2008
@@ -37,7 +37,7 @@
 #if defined(SOLARIS)
 #include <sys/sockio.h>
 #include <net/if.h>
-#else
+#elif defined(HAVE_GETIFADDRS)
 #include <ifaddrs.h>
 #endif
 
@@ -47,6 +47,12 @@
 #include "asterisk/lock.h"
 #include "asterisk/srv.h"
 
+#if (!defined(SOLARIS) && !defined(HAVE_GETIFADDRS))
+static int get_local_address(struct in_addr *ourip)
+{
+	return -1;
+}
+#else
 static void score_address(const struct sockaddr_in *sin, struct in_addr *best_addr, int *best_score)
 {
 	const char *address;
@@ -200,6 +206,8 @@
 		memcpy(ourip, &best_addr, sizeof(*ourip));
 	return res;
 }
+#endif /* HAVE_GETIFADDRS */
+
 /* Free HA structure */
 void ast_free_ha(struct ast_ha *ha)
 {

Modified: team/murf/bug11210/main/file.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/main/file.c?view=diff&rev=101987&r1=101986&r2=101987
==============================================================================

[... 184 lines stripped ...]



More information about the svn-commits mailing list