[asterisk-commits] branch oej/res_auth r18127 - in /team/oej/res_auth: ./ apps/ channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Apr 6 23:43:46 MST 2006


Author: oej
Date: Fri Apr  7 01:43:41 2006
New Revision: 18127

URL: http://svn.digium.com/view/asterisk?rev=18127&view=rev
Log:
Reset, resolve, go

Modified:
    team/oej/res_auth/   (props changed)
    team/oej/res_auth/Makefile
    team/oej/res_auth/apps/app_amd.c
    team/oej/res_auth/apps/app_meetme.c
    team/oej/res_auth/channels/chan_sip.c

Propchange: team/oej/res_auth/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Propchange: team/oej/res_auth/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.

Propchange: team/oej/res_auth/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/oej/res_auth/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Apr  7 01:43:41 2006
@@ -1,1 +1,1 @@
-/trunk:1-17930
+/trunk:1-18126

Modified: team/oej/res_auth/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/res_auth/Makefile?rev=18127&r1=18126&r2=18127&view=diff
==============================================================================
--- team/oej/res_auth/Makefile (original)
+++ team/oej/res_auth/Makefile Fri Apr  7 01:43:41 2006
@@ -15,23 +15,33 @@
 
 # Create OPTIONS variable
 OPTIONS=
+
 # If cross compiling, define these to suit
-# CROSS_COMPILE=/opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-
-# CROSS_COMPILE_BIN=/opt/montavista/pro/devkit/arm/xscale_be/bin/
-# CROSS_COMPILE_TARGET=/opt/montavista/pro/devkit/arm/xscale_be/target
+#CROSS_COMPILE=/opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-
+#CROSS_COMPILE_BIN=/opt/montavista/pro/devkit/arm/xscale_be/bin/
+#CROSS_COMPILE_TARGET=/opt/montavista/pro/devkit/arm/xscale_be/target
+#CROSS_ARCH=Linux
+#CROSS_PROC=arm
+#SUB_PROC=xscale # or maverick
+
+# Pentium Pro Optimize
+#PROC=i686
+
+# Pentium & VIA processors optimize
+#PROC=i586
+
+#PROC=k6
+#PROC=ppc
+
 CC=$(CROSS_COMPILE)gcc
 HOST_CC=gcc
-# CROSS_ARCH=Linux
-# CROSS_PROC=arm
-# SUB_PROC=xscale # or maverick
 
 ifeq ($(CROSS_COMPILE),)
   OSARCH=$(shell uname -s)
-  OSREV=$(shell uname -r)
-  MARCH=$(shell uname -m)
+  PROC?=$(shell uname -m)
 else
   OSARCH=$(CROSS_ARCH)
-  OSREV=$(CROSS_REV)
+  PROC=$(CROSS_PROC)
 endif
 
 PWD=$(shell pwd)
@@ -40,13 +50,13 @@
 MAKETOPLEVEL?=$(MAKELEVEL)
 
 ifneq ($(findstring dont-optimize,$(MAKECMDGOALS)),dont-optimize)
-######### More GSM codec optimization
-######### Uncomment to enable MMXTM optimizations for x86 architecture CPU's
-######### which support MMX instructions.  This should be newer pentiums,
-######### ppro's, etc, as well as the AMD K6 and K7.  
+# More GSM codec optimization
+# Uncomment to enable MMXTM optimizations for x86 architecture CPU's
+# which support MMX instructions.  This should be newer pentiums,
+# ppro's, etc, as well as the AMD K6 and K7.  
 #K6OPT  = -DK6OPT
 
-#Tell gcc to optimize the code
+# Tell gcc to optimize the code
 OPTIMIZE+=-O6
 else
   # Stack backtraces, while useful for debugging, are incompatible with optimizations
@@ -55,14 +65,13 @@
   endif
 endif
 
-#Overwite config files on "make samples"
+# Overwite config files on "make samples"
 OVERWRITE=y
 
-#Include debug and macro symbols in the executables (-g) and profiling info (-pg)
+# Include debug and macro symbols in the executables (-g) and profiling info (-pg)
 DEBUG=-g3 #-pg
 
-#Set NOCRYPTO to yes if you do not want to have crypto support or 
-#dependencies
+# Set NOCRYPTO to yes if you do not want to have crypto support or dependencies
 #NOCRYPTO=yes
 
 # If you are running a radio application, define RADIO_RELAX so that the DTMF
@@ -71,20 +80,11 @@
 
 # If you don't have a lot of memory (e.g. embedded Asterisk), define LOW_MEMORY
 # to reduce the size of certain static buffers
-
 #ifneq ($(CROSS_COMPILE),)
 #OPTIONS += -DLOW_MEMORY
 #endif
 
-ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/radiusclient-ng.h),)
-  AUTH_LDFLAGS+=-DHAVE_RADIUS_CLIENT_H
-  AUTH_LDLIBS+=-lradiusclient-ng	
-endif
-
-
-#
 # Asterisk SMDI integration
-#
 WITH_SMDI = 1
 
 # Optional debugging parameters
@@ -108,7 +108,7 @@
 # Files are copied here temporarily during the install process
 # For example, make DESTDIR=/tmp/asterisk woud put things in
 # /tmp/asterisk/etc/asterisk
-# XXX watch out, put no spaces or comments after the value
+# !!! Watch out, put no spaces or comments after the value !!!
 DESTDIR?=
 #DESTDIR?=/tmp/asterisk
 
@@ -159,16 +159,7 @@
 # Define this to use files larger than 2GB (useful for sound files longer than 37 hours and logfiles)
 ASTCFLAGS+=-D_FILE_OFFSET_BITS=64
 
-# Pentium Pro Optimize
-#PROC=i686
-
-# Pentium & VIA processors optimize
-#PROC=i586
-
-#PROC=k6
-#PROC=ppc
-
-#Uncomment this to use the older DSP routines
+# Uncomment this to use the older DSP routines
 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
 
 # Determine by a grep 'DocumentRoot' of your httpd.conf file
@@ -191,12 +182,6 @@
 endif
 
 ifeq ($(OSARCH),Linux)
-  ifeq ($(CROSS_COMPILE),)
-    PROC?=$(shell uname -m)
-  else
-    PROC=$(CROSS_PROC)
-  endif
-
   ifeq ($(PROC),x86_64)
     # You must have GCC 3.4 to use k8, otherwise use athlon
     PROC=k8
@@ -250,7 +235,6 @@
 ASTOBJ=-o asterisk
 
 ifeq ($(findstring BSD,$(OSARCH)),BSD)
-  PROC=$(shell uname -m)
   ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
 endif
 
@@ -318,7 +302,6 @@
   ASTLINK=
   LIBS+=-lpthread -lncurses -lm -lresolv
   ASTSBINDIR=$(MODULES_DIR)
-  PROC=$(shell uname -m)
 endif
 
 ifndef WITHOUT_ZAPTEL
@@ -405,12 +388,12 @@
   ASTLINK=-Wl,-dynamic
   SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
   # Mac on Intel CoreDuo does not need poll compatibility layer
-  ifneq ($(MARCH),i386)
+  ifneq ($(PROC),i386)
     OBJS+=poll.o
     ASTCFLAGS+=-DPOLLCOMPAT
   endif
 else
-#These are used for all but Darwin
+# These are used for all but Darwin
   ASTLINK=-Wl,-E 
   SOLINK=-shared -Xlinker -x
   ifeq ($(findstring BSD,$(OSARCH)),BSD)
@@ -979,11 +962,9 @@
 	@echo " +            $(MAKE) uninstall-all             +"  
 	@echo " +-------------------------------------------+"  
 
-
 uninstall-all: _uninstall
 	rm -rf $(DESTDIR)$(ASTLIBDIR)
 	rm -rf $(DESTDIR)$(ASTVARLIBDIR)
 	rm -rf $(DESTDIR)$(ASTSPOOLDIR)
 	rm -rf $(DESTDIR)$(ASTETCDIR)
 	rm -rf $(DESTDIR)$(ASTLOGDIR)
-

Modified: team/oej/res_auth/apps/app_amd.c
URL: http://svn.digium.com/view/asterisk/team/oej/res_auth/apps/app_amd.c?rev=18127&r1=18126&r2=18127&view=diff
==============================================================================
--- team/oej/res_auth/apps/app_amd.c (original)
+++ team/oej/res_auth/apps/app_amd.c Fri Apr  7 01:43:41 2006
@@ -91,7 +91,7 @@
 
 static void isAnsweringMachine(struct ast_channel *chan, void *data)
 {
-	int res = 0;
+	int res = 0, ret = 0;
 
 	struct ast_frame *f = NULL;
 
@@ -136,8 +136,8 @@
 			     AST_APP_ARG(argMaximumNumberOfWords);
 			     AST_APP_ARG(argSilenceThreshold);
 	);
-
-	ast_verbose(VERBOSE_PREFIX_3 "AMD: %s %s %s (Fmt: %d)\n", chan->name ,chan->cid.cid_ani, chan->cid.cid_rdnis, chan->readformat);
+	if (option_verbose > 2)
+		ast_verbose(VERBOSE_PREFIX_3 "AMD: %s %s %s (Fmt: %d)\n", chan->name ,chan->cid.cid_ani, chan->cid.cid_rdnis, chan->readformat);
 
 	/* Lets parse the arguments. */
 	if (ast_strlen_zero(data)) {
@@ -180,8 +180,9 @@
 	}
 
 	/* Now we're ready to roll! */
-
-	ast_verbose(VERBOSE_PREFIX_3 "AMD: initialSilence [%d] greeting [%d] afterGreetingSilence [%d] "
+	
+	if (option_verbose > 2)
+		ast_verbose(VERBOSE_PREFIX_3 "AMD: initialSilence [%d] greeting [%d] afterGreetingSilence [%d] "
 		"totalAnalysisTime [%d] minimumWordLength [%d] betweenWordsSilence [%d] maximumNumberOfWords [%d] silenceThreshold [%d] \n",
 				initialSilence, greeting, afterGreetingSilence, totalAnalysisTime,
 				minimumWordLength, betweenWordsSilence, maximumNumberOfWords, silenceThreshold );
@@ -204,42 +205,45 @@
 	}
 	ast_dsp_set_threshold(silenceDetector, silenceThreshold );
 
-	while (ast_waitfor(chan, -1) > -1)
+	while ((ret = ast_waitfor(chan, totalAnalysisTime)))
 	{
-		f = ast_read(chan);
-		if (!f ) {
-			/* No Frame: Called Party Must Have Dropped */
-			ast_verbose(VERBOSE_PREFIX_3 "AMD: HANGUP\n");
-			ast_log(LOG_DEBUG, "Got hangup\n");
+		if (ret < 0 || !(f = ast_read(chan))) {
+			/* No Frame OR Error on ast_waitfor : Called Party Must Have Dropped */
+			if (option_verbose > 2)
+				ast_verbose(VERBOSE_PREFIX_3 "AMD: HANGUP\n");
+			if (option_debug)
+				ast_log(LOG_DEBUG, "Got hangup\n");
 			strcpy(amdStatus , "HANGUP" );
 			strcpy(amdCause , "" );
 			break;
 		}
-		framelength = (ast_codec_get_samples(f) / 8);
-		iTotalTime += framelength;
-		if (iTotalTime >= totalAnalysisTime ) {
-			ast_verbose(VERBOSE_PREFIX_3 "AMD: Channel [%s]. Too long...\n", chan->name );
-			ast_frfree(f);
-			strcpy(amdStatus , "NOTSURE" );
-			sprintf(amdCause , "TOOLONG-%d", iTotalTime );
-			break;
-		}
 		if (f->frametype == AST_FRAME_VOICE ) {
+			framelength = (ast_codec_get_samples(f) / DEFAULT_SAMPLES_PER_MS);
+			iTotalTime += framelength;
+			if (iTotalTime >= totalAnalysisTime ) {
+				if (option_verbose > 2)	
+					ast_verbose(VERBOSE_PREFIX_3 "AMD: Channel [%s]. Too long...\n", chan->name );
+				ast_frfree(f);
+				strcpy(amdStatus , "NOTSURE" );
+				sprintf(amdCause , "TOOLONG-%d", iTotalTime );
+				break;
+			}
 			dspsilence = 0;
 			ast_dsp_silence(silenceDetector, f, &dspsilence);
 			if (dspsilence ) {
 				silenceDuration = dspsilence;
-				/* ast_verbose(VERBOSE_PREFIX_3 "AMD: %d SILENCE: silenceDuration:%d afterGreetingSilence:%d inGreeting:%d\n", currentState, silenceDuration, afterGreetingSilence, inGreeting ); */
 				if (silenceDuration >= betweenWordsSilence ) {
 					if (currentState != STATE_IN_SILENCE ) {
 						previousState = currentState;
-						ast_verbose(VERBOSE_PREFIX_3 "AMD: Changed state to STATE_IN_SILENCE\n");
+						if (option_verbose > 2)
+							ast_verbose(VERBOSE_PREFIX_3 "AMD: Changed state to STATE_IN_SILENCE\n");
 					}
 					currentState  = STATE_IN_SILENCE;
 					consecutiveVoiceDuration = 0;
 				}
 				if (inInitialSilence == 1  && silenceDuration >= initialSilence ) {
-					ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: silenceDuration:%d initialSilence:%d\n",
+					if (option_verbose > 2)
+						ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: silenceDuration:%d initialSilence:%d\n",
 							silenceDuration, initialSilence );
 					ast_frfree(f);
 					strcpy(amdStatus , "MACHINE" );
@@ -248,7 +252,8 @@
 				}
 
 				if (silenceDuration >= afterGreetingSilence  &&  inGreeting == 1 ) {
-					ast_verbose(VERBOSE_PREFIX_3 "AMD: HUMAN: silenceDuration:%d afterGreetingSilence:%d\n",
+					if (option_verbose > 2)
+						ast_verbose(VERBOSE_PREFIX_3 "AMD: HUMAN: silenceDuration:%d afterGreetingSilence:%d\n",
 							silenceDuration, afterGreetingSilence );
 					ast_frfree(f);
 					strcpy(amdStatus , "HUMAN" );
@@ -258,21 +263,22 @@
 			} else {
 				consecutiveVoiceDuration += framelength;
 				voiceDuration += framelength;
-				/* ast_verbose(VERBOSE_PREFIX_3 "AMD: %d VOICE: ConsecutiveVoice:%d voiceDuration:%d inGreeting:%d\n", currentState, consecutiveVoiceDuration, voiceDuration, inGreeting ); */
 
 				/* If I have enough consecutive voice to say that I am in a Word, I can only increment the
 					number of words if my previous state was Silence, which means that I moved into a word. */
 				if (consecutiveVoiceDuration >= minimumWordLength ) {
 					if (currentState == STATE_IN_SILENCE ) {
 						iWordsCount++;
-						ast_verbose(VERBOSE_PREFIX_3 "AMD: Word detected. iWordsCount:%d\n", iWordsCount );
+						if (option_verbose > 2)
+							ast_verbose(VERBOSE_PREFIX_3 "AMD: Word detected. iWordsCount:%d\n", iWordsCount );
 						previousState = currentState;
 						currentState = STATE_IN_WORD;
 					}
 				}
 
 				if (iWordsCount >= maximumNumberOfWords ) {
-					ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: iWordsCount:%d\n", iWordsCount );
+					if (option_verbose > 2)
+						ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: iWordsCount:%d\n", iWordsCount );
 					ast_frfree(f);
 					strcpy(amdStatus , "MACHINE" );
 					sprintf(amdCause , "MAXWORDS-%d-%d", iWordsCount, maximumNumberOfWords );
@@ -280,9 +286,9 @@
 				}
 
 				if (inGreeting == 1  &&  voiceDuration >= greeting ) {
-					ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: voiceDuration:%d greeting:%d\n",
-							voiceDuration, greeting );
-					ast_frfree(f);
+					if (option_verbose > 2)
+					ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: voiceDuration:%d greeting:%d\n", voiceDuration, greeting);
+					 ast_frfree(f);
 					strcpy(amdStatus , "MACHINE" );
 					sprintf(amdCause , "LONGGREETING-%d-%d", voiceDuration, greeting );
 					break;
@@ -296,12 +302,19 @@
 		}
 		ast_frfree(f);
 	}
+	if (!ret) {
+		/* It took too long to get a frame back. Giving up. */
+		if (option_verbose > 2)
+			ast_verbose(VERBOSE_PREFIX_3 "AMD: Channel [%s]. Too long...\n", chan->name );
+		strcpy(amdStatus , "NOTSURE" );
+		sprintf(amdCause , "TOOLONG-%d", iTotalTime );
+	}
 
 	pbx_builtin_setvar_helper(chan , "AMDSTATUS" , amdStatus );
 	pbx_builtin_setvar_helper(chan , "AMDCAUSE" , amdCause );
 
 	/* If We Started With A Valid Read Format, Return To It... */
-	if (readFormat) {
+	if (readFormat && chan->_state == AST_STATE_UP) {
 		res = ast_set_read_format(chan, readFormat );
 		if (res)
 			ast_log(LOG_WARNING, "AMD: Unable to restore read format on '%s'\n", chan->name);
@@ -371,7 +384,8 @@
 	}
 	ast_config_destroy(cfg);
 
-	ast_verbose(VERBOSE_PREFIX_3 "AMD defaults: initialSilence [%d] greeting [%d] afterGreetingSilence [%d] "
+	if (option_verbose > 2)
+		ast_verbose(VERBOSE_PREFIX_3 "AMD defaults: initialSilence [%d] greeting [%d] afterGreetingSilence [%d] "
 		"totalAnalysisTime [%d] minimumWordLength [%d] betweenWordsSilence [%d] maximumNumberOfWords [%d] silenceThreshold [%d] \n",
 				dfltInitialSilence, dfltGreeting, dfltAfterGreetingSilence, dfltTotalAnalysisTime,
 				dfltMinimumWordLength, dfltBetweenWordsSilence, dfltMaximumNumberOfWords, dfltSilenceThreshold );

Modified: team/oej/res_auth/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/oej/res_auth/apps/app_meetme.c?rev=18127&r1=18126&r2=18127&view=diff
==============================================================================
--- team/oej/res_auth/apps/app_meetme.c (original)
+++ team/oej/res_auth/apps/app_meetme.c Fri Apr  7 01:43:41 2006
@@ -2,7 +2,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  *
@@ -75,8 +75,9 @@
 "conference.  If the conference number is omitted, the user will be prompted\n"
 "to enter one.  User can exit the conference by hangup, or if the 'p' option\n"
 "is specified, by pressing '#'.\n"
-"Please note: A ZAPTEL INTERFACE MUST BE INSTALLED FOR CONFERENCING TO WORK!\n\n"
-
+"Please note: The Zaptel kernel modules and at least one hardware driver (or ztdummy)\n"
+"             must be present for conferencing to operate properly. In addition, the chan_zap\n"
+"             channel driver must be loaded for the 'i' and 'r' options to operate at all.\n\n"
 "The option string may contain zero or more of the following characters:\n"
 "      'a' -- set admin mode\n"
 "      'A' -- set marked mode\n"
@@ -1733,12 +1734,9 @@
 	return ret;
 }
 
-/*
-  This function looks for a conference via the RealTime module
-*/
-static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char *confno, int make, int dynamic, char *dynamic_pin, int refcount)
-{
-
+static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char *confno, int make, int dynamic,
+						 char *dynamic_pin, int refcount, struct ast_flags *confflags)
+{
 	struct ast_variable *var;
 	struct ast_conference *cnf;
 
@@ -1778,11 +1776,27 @@
 		cnf = build_conf(confno, pin ? pin : "", pinadmin ? pinadmin : "", make, dynamic, refcount);
 	}
 
+	if (cnf) {
+		if (confflags && !cnf->chan &&
+		    !ast_test_flag(confflags, CONFFLAG_QUIET) &&
+		    ast_test_flag(confflags, CONFFLAG_INTROUSER)) {
+			ast_log(LOG_WARNING, "No Zap channel available for conference, user introduction disabled (is chan_zap loaded?)\n");
+			ast_clear_flag(confflags, CONFFLAG_INTROUSER);
+		}
+		
+		if (confflags && !cnf->chan &&
+		    ast_test_flag(confflags, CONFFLAG_RECORDCONF)) {
+			ast_log(LOG_WARNING, "No Zap channel available for conference, conference recording disabled (is chan_zap loaded?)\n");
+			ast_clear_flag(confflags, CONFFLAG_RECORDCONF);
+		}
+	}
+
 	return cnf;
 }
 
 
-static struct ast_conference *find_conf(struct ast_channel *chan, char *confno, int make, int dynamic, char *dynamic_pin, int refcount)
+static struct ast_conference *find_conf(struct ast_channel *chan, char *confno, int make, int dynamic,
+					char *dynamic_pin, int refcount, struct ast_flags *confflags)
 {
 	struct ast_config *cfg;
 	struct ast_variable *var;
@@ -1856,6 +1870,21 @@
 			dynamic_pin[0] = '\0';
 	}
 
+	if (cnf) {
+		if (confflags && !cnf->chan &&
+		    !ast_test_flag(confflags, CONFFLAG_QUIET) &&
+		    ast_test_flag(confflags, CONFFLAG_INTROUSER)) {
+			ast_log(LOG_WARNING, "No Zap channel available for conference, user introduction disabled (is chan_zap loaded?)\n");
+			ast_clear_flag(confflags, CONFFLAG_INTROUSER);
+		}
+		
+		if (confflags && !cnf->chan &&
+		    ast_test_flag(confflags, CONFFLAG_RECORDCONF)) {
+			ast_log(LOG_WARNING, "No Zap channel available for conference, conference recording disabled (is chan_zap loaded?)\n");
+			ast_clear_flag(confflags, CONFFLAG_RECORDCONF);
+		}
+	}
+
 	return cnf;
 }
 
@@ -1887,7 +1916,8 @@
 
 	AST_STANDARD_APP_ARGS(args, localdata);
 	
-	conf = find_conf(chan, args.confno, 0, 0, NULL, 0);
+	conf = find_conf(chan, args.confno, 0, 0, NULL, 0, NULL);
+
 	if (conf)
 		count = conf->users;
 	else
@@ -2073,10 +2103,10 @@
 		}
 		if (!ast_strlen_zero(confno)) {
 			/* Check the validity of the conference */
-			cnf = find_conf(chan, confno, 1, dynamic, the_pin, 1);
-			if (!cnf) {
-				cnf = find_conf_realtime(chan, confno, 1, dynamic, the_pin, 1);
-			}
+			cnf = find_conf(chan, confno, 1, dynamic, the_pin, 1, &confflags);
+			if (!cnf)
+				cnf = find_conf_realtime(chan, confno, 1, dynamic, the_pin, 1, &confflags);
+
 			if (!cnf) {
 				res = ast_streamfile(chan, "conf-invalid", chan->language);
 				if (!res)

Modified: team/oej/res_auth/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/res_auth/channels/chan_sip.c?rev=18127&r1=18126&r2=18127&view=diff
==============================================================================
--- team/oej/res_auth/channels/chan_sip.c (original)
+++ team/oej/res_auth/channels/chan_sip.c Fri Apr  7 01:43:41 2006
@@ -950,6 +950,7 @@
 static struct sip_peer *temp_peer(const char *name);
 static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req, char *header, char *respheader, int sipmethod, int init);
 static void free_old_route(struct sip_route *route);
+static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header, int sipmethod, char *digest, int digest_len);
 static int build_reply_digest(struct sip_pvt *p, int method, char *digest, int digest_len);
 static int update_call_counter(struct sip_pvt *fup, int event);
 static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int realtime);
@@ -1048,7 +1049,7 @@
 	if (ast_strlen_zero(msg))
 		return 0;
 
-	for (i = 1; (i < (sizeof(sip_methods) / sizeof(sip_methods[0]))) && !res; i++) {
+	for (i = 1; i < (sizeof(sip_methods) / sizeof(sip_methods[0])) && !res; i++) {
 		if (!strcasecmp(sip_methods[i].text, msg)) 
 			res = sip_methods[i].id;
 	}
@@ -1058,52 +1059,43 @@
 /*! \brief Parse supported header in incoming packet */
 static unsigned int parse_sip_options(struct sip_pvt *pvt, char *supported)
 {
-	char *next = NULL;
-	char *sep = NULL;
+	char *next, *sep;
 	char *temp = ast_strdupa(supported);
-	int i;
 	unsigned int profile = 0;
-
-	if (ast_strlen_zero(supported) )
+	int i, found;
+
+	if (!pvt || ast_strlen_zero(supported) )
 		return 0;
 
 	if (option_debug > 2 && sipdebug)
 		ast_log(LOG_DEBUG, "Begin: parsing SIP \"Supported: %s\"\n", supported);
 
-	next = temp;
-	while (next) {
-		char res=0;
-		if ( (sep = strchr(next, ',')) != NULL) {
-			*sep = '\0';
-			sep++;
-		}
-		while (*next == ' ')	/* Skip spaces */
-			next++;
+	for (next = temp; next; next = sep) {
+		found = FALSE;
+		if ( (sep = strchr(next, ',')) != NULL)
+			*sep++ = '\0';
+		next = ast_skip_blanks(next);
 		if (option_debug > 2 && sipdebug)
 			ast_log(LOG_DEBUG, "Found SIP option: -%s-\n", next);
-		for (i=0; (i < (sizeof(sip_options) / sizeof(sip_options[0]))) && !res; i++) {
+		for (i=0; i < (sizeof(sip_options) / sizeof(sip_options[0])); i++) {
 			if (!strcasecmp(next, sip_options[i].text)) {
 				profile |= sip_options[i].id;
-				res = 1;
+				found = TRUE;
 				if (option_debug > 2 && sipdebug)
 					ast_log(LOG_DEBUG, "Matched SIP option: %s\n", next);
+				break;
 			}
 		}
-		if (!res) 
-			if (option_debug > 2 && sipdebug)
-				ast_log(LOG_DEBUG, "Found no match for SIP option: %s (Please file bug report!)\n", next);
-		next = sep;
-	}
-	if (pvt) {
-		pvt->sipoptions = profile;
-		if (option_debug)
-			ast_log(LOG_DEBUG, "* SIP extension value: %d for call %s\n", profile, pvt->callid);
-	}
+		if (!found && option_debug > 2 && sipdebug)
+			ast_log(LOG_DEBUG, "Found no match for SIP option: %s (Please file bug report!)\n", next);
+	}
+
+	pvt->sipoptions = profile;
 	return profile;
 }
 
 /*! \brief See if we pass debug IP filter */
-static inline int sip_debug_test_addr(struct sockaddr_in *addr) 
+static inline int sip_debug_test_addr(const struct sockaddr_in *addr) 
 {
 	if (!sipdebug)
 		return 0;
@@ -1180,7 +1172,7 @@
 			} else
 				ast_log(LOG_NOTICE, "Warning: Re-lookup of '%s' failed!\n", externhost);
 		}
-		memcpy(us, &externip.sin_addr, sizeof(struct in_addr));
+		*us = externip.sin_addr;
 		if (option_debug) {
 			char iabuf[INET_ADDRSTRLEN];
 			ast_inet_ntoa(iabuf, sizeof(iabuf), *(struct in_addr *)&them->s_addr);
@@ -1188,7 +1180,7 @@
 			ast_log(LOG_DEBUG, "Target address %s is not local, substituting externip\n", iabuf);
 		}
 	} else if (bindaddr.sin_addr.s_addr)
-		memcpy(us, &bindaddr.sin_addr, sizeof(struct in_addr));
+		*us = bindaddr.sin_addr;
 	else
 		return ast_ouraddrfor(them, us);
 	return 0;
@@ -1312,13 +1304,9 @@
 		}
 	}
 	/* In any case, go ahead and remove the packet */
-	prev = NULL;
-	cur = pkt->owner->packets;
-	while(cur) {
+	for (prev = NULL, cur = pkt->owner->packets; cur; prev = cur, cur = cur->next) {
 		if (cur == pkt)
 			break;
-		prev = cur;
-		cur = cur->next;
 	}
 	if (cur) {
 		if (prev)
@@ -1431,7 +1419,7 @@
 }
 
 /*! \brief Acknowledges receipt of a packet and stops retransmission */
-static int __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
+static int __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod, int reset)
 {
 	struct sip_pkt *cur, *prev = NULL;
 	int res = -1;
@@ -1442,8 +1430,7 @@
 	msg = sip_methods[sipmethod].text;
 
 	ast_mutex_lock(&p->lock);
-	cur = p->packets;
-	while(cur) {
+	for (cur = p->packets; cur; prev = cur, cur = cur->next) {
 		if ((cur->seqno == seqno) && ((ast_test_flag(cur, FLAG_RESPONSE)) == resp) &&
 			((ast_test_flag(cur, FLAG_RESPONSE)) || 
 			 (!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) {
@@ -1461,12 +1448,11 @@
 					ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
 				ast_sched_del(sched, cur->retransid);
 			}
-			free(cur);
+			if (!reset)
+				free(cur);
 			res = 0;
 			break;
 		}
-		prev = cur;
-		cur = cur->next;
 	}
 	ast_mutex_unlock(&p->lock);
 	if (option_debug)
@@ -1486,7 +1472,7 @@
 		}
 		cur = p->packets;
 		if (cur->method)
-			__sip_ack(p, p->packets->seqno, (ast_test_flag(p->packets, FLAG_RESPONSE)), cur->method);
+			__sip_ack(p, p->packets->seqno, (ast_test_flag(p->packets, FLAG_RESPONSE)), cur->method, FALSE);
 		else {	/* Unknown packet type */
 			char *c;
 			char method[128];
@@ -1494,7 +1480,7 @@
 			ast_copy_string(method, p->packets->data, sizeof(method));
 			c = ast_skip_blanks(method); /* XXX what ? */
 			*c = '\0';
-			__sip_ack(p, p->packets->seqno, (ast_test_flag(p->packets, FLAG_RESPONSE)), find_sip_method(method));
+			__sip_ack(p, p->packets->seqno, (ast_test_flag(p->packets, FLAG_RESPONSE)), find_sip_method(method), FALSE);
 		}
 	}
 	return 0;
@@ -1507,8 +1493,7 @@
 	int res = -1;
 	char *msg = sip_methods[sipmethod].text;
 
-	cur = p->packets;
-	while(cur) {
+	for (cur = p->packets; cur ; cur = cur->next) {
 		if ((cur->seqno == seqno) && ((ast_test_flag(cur, FLAG_RESPONSE)) == resp) &&
 			((ast_test_flag(cur, FLAG_RESPONSE)) || 
 			 (!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) {
@@ -1522,7 +1507,6 @@
 			res = 0;
 			break;
 		}
-		cur = cur->next;
 	}
 	if (option_debug)
 		ast_log(LOG_DEBUG, "(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %d: %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found");
@@ -1599,7 +1583,7 @@
 	char last_char;
 
 	parse = tmp;
-	while (1) {
+	for (;;) {
 		first_quote = strchr(parse, '"');
 		first_bracket = strchr(parse, '<');
 		if (first_quote && first_bracket && (first_quote < first_bracket)) {
@@ -1913,16 +1897,8 @@
 {
 	if ((peer->addr.sin_addr.s_addr || peer->defaddr.sin_addr.s_addr) &&
 	    (!peer->maxms || ((peer->lastms >= 0)  && (peer->lastms <= peer->maxms)))) {
-		if (peer->addr.sin_addr.s_addr) {
-			r->sa.sin_family = peer->addr.sin_family;
-			r->sa.sin_addr = peer->addr.sin_addr;
-			r->sa.sin_port = peer->addr.sin_port;
-		} else {
-			r->sa.sin_family = peer->defaddr.sin_family;
-			r->sa.sin_addr = peer->defaddr.sin_addr;
-			r->sa.sin_port = peer->defaddr.sin_port;
-		}
-		memcpy(&r->recv, &r->sa, sizeof(r->recv));
+		r->sa = (peer->addr.sin_addr.s_addr) ? peer->addr : peer->defaddr;
+		r->recv = r->sa;
 	} else {
 		return -1;
 	}
@@ -2052,7 +2028,7 @@
 			ast_string_field_set(dialog, tohost, peer);
 			memcpy(&dialog->sa.sin_addr, hp->h_addr, sizeof(dialog->sa.sin_addr));
 			dialog->sa.sin_port = htons(portno);
-			memcpy(&dialog->recv, &dialog->sa, sizeof(dialog->recv));
+			dialog->recv = dialog->sa;
 			return 0;
 		} else {
 			ast_log(LOG_WARNING, "No such host: %s\n", peer);
@@ -2207,12 +2183,10 @@
 	if (p->autokillid > -1)
 		ast_sched_del(sched, p->autokillid);
 
-	if (p->rtp) {
+	if (p->rtp)
 		ast_rtp_destroy(p->rtp);
-	}
-	if (p->vrtp) {
+	if (p->vrtp)
 		ast_rtp_destroy(p->vrtp);
-	}
 	if (p->route) {
 		free_old_route(p->route);
 		p->route = NULL;
@@ -2235,17 +2209,14 @@
 	}
 	/* Clear history */
 	if (p->history) {
-		while(!AST_LIST_EMPTY(p->history)) {
-			struct sip_history *hist = AST_LIST_FIRST(p->history);
-			AST_LIST_REMOVE_HEAD(p->history, list);
+		struct sip_history *hist;
+		while( (hist = AST_LIST_REMOVE_HEAD(p->history, list)) )
 			free(hist);
-		}
 		free(p->history);
 		p->history = NULL;
 	}
 
-	cur = iflist;
-	while(cur) {
+	for (prev = NULL, cur = iflist; cur; prev = cur, cur = cur->next) {
 		if (cur == p) {
 			if (prev)
 				prev->next = cur->next;
@@ -2253,8 +2224,6 @@
 				iflist = cur->next;
 			break;
 		}
-		prev = cur;
-		cur = cur->next;
 	}
 	if (!cur) {
 		ast_log(LOG_WARNING, "Trying to destroy \"%s\", not found in dialog list?!?! \n", p->callid);
@@ -3009,6 +2978,8 @@
 	/* Set channel variables for this call from configuration */
 	for (v = i->chanvars ; v ; v = v->next)
 		pbx_builtin_setvar_helper(tmp,v->name,v->value);
+
+	append_history(i, "NewChan", "Channel %s - from %s", tmp->name, i->callid);
 				
 	return tmp;
 }
@@ -3247,11 +3218,11 @@
 	p->osptimelimit = 0;
 #endif	
 	if (sin) {
-		memcpy(&p->sa, sin, sizeof(p->sa));
+		p->sa = *sin;
 		if (ast_sip_ouraddrfor(&p->sa.sin_addr,&p->ourip))
-			memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
+			p->ourip = __ourip;
 	} else {
-		memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
+		p->ourip = __ourip;
 	}
 	
 	ast_copy_flags(&p->flags[0], &global_flags[0], SIP_FLAGS_TO_COPY);
@@ -3289,7 +3260,7 @@
 	if (useglobal_nat && sin) {
 		/* Setup NAT structure according to global settings if we have an address */
 		ast_copy_flags(&p->flags[0], &global_flags[0], SIP_NAT);
-		memcpy(&p->recv, sin, sizeof(p->recv));
+		p->recv = *sin;
 		if (p->rtp)
 			ast_rtp_setnat(p->rtp, ast_test_flag(&p->flags[0], SIP_NAT_ROUTE));
 		if (p->vrtp)
@@ -3355,8 +3326,8 @@
 	}
 
 	ast_mutex_lock(&iflock);
-	p = iflist;
-	while(p) {	/* In pedantic, we do not want packets with bad syntax to be connected to a PVT */
+	for (p = iflist; p; p = p->next) {
+		/* In pedantic, we do not want packets with bad syntax to be connected to a PVT */
 		int found = FALSE;
 		if (req->method == SIP_REGISTER)
 			found = (!strcmp(p->callid, callid));
@@ -3388,7 +3359,6 @@
 			ast_mutex_unlock(&iflock);
 			return p;
 		}
-		p = p->next;
 	}
 	ast_mutex_unlock(&iflock);
 	p = sip_alloc(callid, sin, 1, intended_method);
@@ -3658,8 +3628,7 @@
 			portno = x;
 			/* Scan through the RTP payload types specified in a "m=" line: */
 			ast_rtp_pt_clear(p->rtp);
-			codecs = m + len;
-			while(!ast_strlen_zero(codecs)) {
+			for (codecs = m + len; !ast_strlen_zero(codecs); codecs = ast_skip_blanks(codecs + len)) {
 				if (sscanf(codecs, "%d%n", &codec, &len) != 1) {
 					ast_log(LOG_WARNING, "Error in codec string '%s'\n", codecs);
 					return -1;
@@ -3667,7 +3636,6 @@
 				if (debug)
 					ast_verbose("Found RTP audio format %d\n", codec);
 				ast_rtp_set_m_type(p->rtp, codec);
-				codecs = ast_skip_blanks(codecs + len);
 			}
 		}
 		if (p->vrtp)
@@ -3678,8 +3646,7 @@
 			ast_clear_flag(&p->flags[0], SIP_NOVIDEO);	
 			vportno = x;
 			/* Scan through the RTP payload types specified in a "m=" line: */
-			codecs = m + len;
-			while(!ast_strlen_zero(codecs)) {
+			for (codecs = m + len; !ast_strlen_zero(codecs); codecs = ast_skip_blanks(codecs + len)) {
 				if (sscanf(codecs, "%d%n", &codec, &len) != 1) {
 					ast_log(LOG_WARNING, "Error in codec string '%s'\n", codecs);
 					return -1;
@@ -3687,7 +3654,6 @@
 				if (debug)
 					ast_verbose("Found RTP video format %d\n", codec);
 				ast_rtp_set_m_type(p->vrtp, codec);
-				codecs = ast_skip_blanks(codecs + len);
 			}
 		}
 		if (!found )
@@ -4063,12 +4029,14 @@
 	char r[256], *p;
 	int n, rem = sizeof(r);
 
-	if (!route) return;
+	if (!route)
+		return;
 
 	p = r;
-	while (route) {
+	for (;route ; route = route->next) {
 		n = strlen(route->hop);
-		if ((n+3)>rem) break;
+		if ( n + 3 > rem)
+			break;
 		if (p != r) {
 			*p++ = ',';
 			--rem;
@@ -4077,7 +4045,6 @@
 		ast_copy_string(p, route->hop, rem);  p += n;
 		*p++ = '>';
 		rem -= (n+2);
-		route = route->next;
 	}
 	*p = '\0';
 	add_header(req, "Route", r);
@@ -4795,7 +4762,8 @@
 			return -1;
 		}
 		/* XXX maybe trim_blanks() ? */
-		while( isspace( *(--e) ) ) {}
+		while( isspace( *(--e) ) )
+			;
 		if ( *e == '>' ) {
 			*e = '\0';
 		} else {
@@ -5143,11 +5111,8 @@
 						if (*headdup == '"')
 					 		headdup++;
 						if ((content = strchr(headdup, ':'))) {
-							*content = '\0';
-							content++;	/* Move pointer ahead */
-							/* Skip white space */
-							while (*content == ' ')
-						  		content++;
+							*content++ = '\0';
+							content = ast_skip_blanks(content); /* Skip white space */
 							/* Strip the ending " (if it's there) */
 					 		end = content + strlen(content) -1;	
 							if (*end == '"')
@@ -5406,22 +5371,21 @@
 	return send_request(p, req, 0, p->ocseq);
 }
 
-/*! \brief Notify a transferring party of the status of trasnfer
-\note   Apparently the draft SIP REFER structure was too simple, so it was decided that the
-	status of transfers also needed to be sent via NOTIFY instead of just the 202 Accepted
-	that had worked heretofore.
+/*! \brief Notify a transferring party of the status of transfer
  */
-static int transmit_notify_with_sipfrag(struct sip_pvt *p, int cseq)
+static int transmit_notify_with_sipfrag(struct sip_pvt *p, int cseq, char *message)
 {
 	struct sip_request req;
-	char tmp[20];
+	char tmp[50];
 	reqprep(&req, p, SIP_NOTIFY, 0, 1);
 	snprintf(tmp, sizeof(tmp), "refer;id=%d", cseq);
 	add_header(&req, "Event", tmp);
 	add_header(&req, "Subscription-state", "terminated;reason=noresource");
 	add_header(&req, "Content-Type", "message/sipfrag;version=2.0");
-
-	strcpy(tmp, "SIP/2.0 200 OK");
+	add_header(&req, "Allow", ALLOWED_METHODS);
+	add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
+
+	snprintf(tmp, sizeof(tmp), "SIP/2.0 %s\r\n", message);
 	add_header_contentLength(&req, strlen(tmp));
 	add_line(&req, tmp);
 
@@ -5627,7 +5591,7 @@
 		  internal network so we can register through nat
 		 */
 		if (ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip))
-			memcpy(&p->ourip, &bindaddr.sin_addr, sizeof(p->ourip));
+			p->ourip = bindaddr.sin_addr;
 		build_contact(p);
 	}
 
@@ -5742,7 +5706,8 @@
 	char *of, *c;
 	char referto[256];
 
-	if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) 
+	/* Are we transfering an inbound or outbound call? */
+	if (ast_test_flag(&p->flags[0], SIP_OUTGOING))
 		of = get_header(&p->initreq, "To");
 	else
 		of = get_header(&p->initreq, "From");
@@ -5766,16 +5731,26 @@
 		snprintf(referto, sizeof(referto), "<sip:%s>", dest);
 	}
 
+	add_header(&req, "Max-Forwards", DEFAULT_MAX_FORWARDS);
+
 	/* save in case we get 407 challenge */
 	ast_string_field_set(p, refer_to, referto);
 	ast_string_field_set(p, referred_by, p->our_contact);
 
 	reqprep(&req, p, SIP_REFER, 0, 1);
 	add_header(&req, "Refer-To", referto);
+	add_header(&req, "Allow", ALLOWED_METHODS);
+	add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
 	if (!ast_strlen_zero(p->our_contact))
 		add_header(&req, "Referred-By", p->our_contact);
 	add_blank_header(&req);
 	return send_request(p, &req, 1, p->ocseq);
+
+	/*! \todo In theory, we should hang around and wait for a reply, before
+	returning to the dial plan here. Don't know really how that would
+	affect the transfer() app or the pbx, but, well, to make this
+	useful we should have a STATUS code on transfer().
+	*/
 }
 
 /*! \brief Send SIP INFO dtmf message, see Cisco documentation on cisco.com */
@@ -5992,7 +5967,7 @@
 	} else
 		port = DEFAULT_SIP_PORT;
 
-	memcpy(&oldsin, &pvt->sa, sizeof(oldsin));
+	oldsin = pvt->sa;
 
 	if (!ast_test_flag(&pvt->flags[0], SIP_NAT_ROUTE)) {
 		/* XXX This could block for a long time XXX */
@@ -6008,7 +5983,7 @@
 	} else {
 		/* Don't trust the contact field.  Just use what they came to us
 		   with. */
-		memcpy(&pvt->sa, &pvt->recv, sizeof(pvt->sa));
+		pvt->sa = pvt->recv;
 	}
 	return 0;
 }
@@ -6116,7 +6091,7 @@
 		port = atoi(pt);
 	} else
 		port = DEFAULT_SIP_PORT;
-	memcpy(&oldsin, &p->addr, sizeof(oldsin));
+	oldsin = p->addr;
 	if (!ast_test_flag(&p->flags[0], SIP_NAT_ROUTE)) {
 		/* XXX This could block for a long time XXX */
 		hp = ast_gethostbyname(n, &ahp);
@@ -6130,7 +6105,7 @@
 	} else {
 		/* Don't trust the contact field.  Just use what they came to us
 		   with */
-		memcpy(&p->addr, &pvt->recv, sizeof(p->addr));
+		p->addr = pvt->recv;
 	}
 
 	if (c)	/* Overwrite the default username from config at registration */
@@ -6193,10 +6168,8 @@
 		ast_verbose("list_route: no route\n");
 		return;
 	}
-	while (route) {
+	for (;route; route = route->next)
 		ast_verbose("list_route: hop: <%s>\n", route->hop);
-		route = route->next;
-	}
 }
 
 /*! \brief Build route list from Record-Route header */
@@ -6905,8 +6878,7 @@
 	
 	/* Search interfaces and find the match */
 	ast_mutex_lock(&iflock);
-	sip_pvt_ptr = iflist;
-	while(sip_pvt_ptr) {
+	for (sip_pvt_ptr = iflist; sip_pvt_ptr ; sip_pvt_ptr = sip_pvt_ptr->next) {
 		if (!strcmp(sip_pvt_ptr->callid, callid)) {
 			/* Go ahead and lock it (and its owner) before returning */
 			ast_mutex_lock(&sip_pvt_ptr->lock);
@@ -6921,7 +6893,6 @@
 			}
 			break;
 		}
-		sip_pvt_ptr = sip_pvt_ptr->next;
 	}
 	ast_mutex_unlock(&iflock);
 	return sip_pvt_ptr;
@@ -8271,11 +8242,9 @@
 		}
 		ast_cli(fd, "  Secret       : %s\n", ast_strlen_zero(peer->secret)?"<Not set>":"<Set>");
 		ast_cli(fd, "  MD5Secret    : %s\n", ast_strlen_zero(peer->md5secret)?"<Not set>":"<Set>");
-		auth = peer->auth;
-		while(auth) {
+		for (auth = peer->auth; auth; auth = auth->next) {
 			ast_cli(fd, "  Realm-auth   : Realm %-15.15s User %-10.20s ", auth->realm, auth->username);
 			ast_cli(fd, "%s\n", !ast_strlen_zero(auth->secret)?"<Secret set>":(!ast_strlen_zero(auth->md5secret)?"<MD5secret set>" : "<Not set>"));
-			auth = auth->next;
 		}
 		ast_cli(fd, "  Context      : %s\n", peer->context);
 		ast_cli(fd, "  Subscr.Cont. : %s\n", S_OR(peer->subscribecontext, "<Not set>") );
@@ -8666,7 +8635,7 @@
 		ast_cli(fd, FORMAT2, "Peer", "User/ANR", "Call ID", "Seq (Tx/Rx)", "Format", "Hold", "Last Message");
 	else 
 		ast_cli(fd, FORMAT3, "Peer", "User", "Call ID", "Extension", "Last state", "Type", "Mailbox");
-	while (cur) {
+	for (; cur; cur = cur->next) {
 		if (cur->subscribed == NONE && !subscriptions) {
 			ast_cli(fd, FORMAT, ast_inet_ntoa(iabuf, sizeof(iabuf), cur->sa.sin_addr), 
 				S_OR(cur->username, S_OR(cur->cid_num, "(None)")),
@@ -8690,7 +8659,6 @@
 );
 			numchans++;
 		}
-		cur = cur->next;
 	}
 	ast_mutex_unlock(&iflock);
 	if (!subscriptions)
@@ -8713,11 +8681,9 @@
 
 	ast_mutex_lock(&iflock);
 	for (cur = iflist; cur; cur = cur->next) {
-		if (!strncasecmp(word, cur->callid, wordlen)) {
-			if (++which > state) {
-				c = ast_strdup(cur->callid);
-				break;
-			}
+		if (!strncasecmp(word, cur->callid, wordlen) && ++which > state) {
+			c = ast_strdup(cur->callid);
+			break;
 		}
 	}
 	ast_mutex_unlock(&iflock);
@@ -8807,11 +8773,9 @@
 			return NULL;
 		
 		while ( (cat = ast_category_browse(notify_types, cat)) ) {
-			if (!strncasecmp(word, cat, wordlen)) {
-				if (++which > state) {
-					c = ast_strdup(cat);
-					break;
-				}
+			if (!strncasecmp(word, cat, wordlen) && ++which > state) {
+				c = ast_strdup(cat);
+				break;
 			}
 		}
 		return c;
@@ -9102,7 +9066,7 @@
 	if (peer) {
 		if (peer->addr.sin_addr.s_addr) {
 			debugaddr.sin_family = AF_INET;
-			memcpy(&debugaddr.sin_addr, &peer->addr.sin_addr, sizeof(debugaddr.sin_addr));
+			debugaddr.sin_addr = peer->addr.sin_addr;
 			debugaddr.sin_port = peer->addr.sin_port;
 			ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr), ntohs(debugaddr.sin_port));
 			ast_set_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONSOLE);
@@ -9183,7 +9147,7 @@
 		add_blank_header(&req);
 		/* Recalculate our side, and recalculate Call ID */
 		if (ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip))
-			memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
+			p->ourip = __ourip;
 		build_via(p);
 		build_callid_pvt(p);
 		ast_cli(fd, "Sending NOTIFY of type '%s' to '%s'\n", argv[2], argv[i]);
@@ -9215,7 +9179,7 @@
 	return RESULT_SUCCESS;
 }
 
-/*! \brief  sip_no_debug: Disable SIP Debugging in CLI */
+/*! \brief Disable SIP Debugging in CLI */
 static int sip_no_debug(int fd, int argc, char *argv[])
 
 {
@@ -9226,9 +9190,8 @@
 	return RESULT_SUCCESS;
 }
 
-static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header, int sipmethod, char *digest, int digest_len);
-
-/*! \brief  do_register_auth: Authenticate for outbound registration */
+
+/*! \brief Authenticate for outbound registration */
 static int do_register_auth(struct sip_pvt *p, struct sip_request *req, char *header, char *respheader) 
 {
 	char digest[1024];
@@ -9249,7 +9212,7 @@

[... 732 lines stripped ...]


More information about the asterisk-commits mailing list