[asterisk-commits] branch oej/sdpcleanup r26921 - in /team/oej/sdpcleanup: ./ build_tools/ chann...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu May 11 07:57:24 MST 2006


Author: oej
Date: Thu May 11 09:57:24 2006
New Revision: 26921

URL: http://svn.digium.com/view/asterisk?rev=26921&view=rev
Log:
Update from AstriDevCon in Pisa

Added:
    team/oej/sdpcleanup/build_tools/make_buildopts_h
      - copied unchanged from r26884, trunk/build_tools/make_buildopts_h
Modified:
    team/oej/sdpcleanup/   (props changed)
    team/oej/sdpcleanup/.cleancount
    team/oej/sdpcleanup/Makefile
    team/oej/sdpcleanup/asterisk.c
    team/oej/sdpcleanup/build_tools/Makefile
    team/oej/sdpcleanup/build_tools/cflags.xml
    team/oej/sdpcleanup/channel.c
    team/oej/sdpcleanup/channels/chan_sip.c
    team/oej/sdpcleanup/configs/manager.conf.sample
    team/oej/sdpcleanup/configs/sip.conf.sample
    team/oej/sdpcleanup/configure.ac
    team/oej/sdpcleanup/doc/cliprompt.txt
    team/oej/sdpcleanup/enum.c
    team/oej/sdpcleanup/include/asterisk/   (props changed)
    team/oej/sdpcleanup/include/asterisk/rtp.h
    team/oej/sdpcleanup/include/autoconfig.h.in
    team/oej/sdpcleanup/manager.c
    team/oej/sdpcleanup/rtp.c

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

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

Propchange: team/oej/sdpcleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu May 11 09:57:24 2006
@@ -1,1 +1,1 @@
-/trunk:1-26742
+/trunk:1-26886

Modified: team/oej/sdpcleanup/.cleancount
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/.cleancount?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/.cleancount (original)
+++ team/oej/sdpcleanup/.cleancount Thu May 11 09:57:24 2006
@@ -1,1 +1,1 @@
-15
+16

Modified: team/oej/sdpcleanup/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/Makefile?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/Makefile (original)
+++ team/oej/sdpcleanup/Makefile Thu May 11 09:57:24 2006
@@ -69,7 +69,7 @@
 OVERWRITE=y
 
 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
-DEBUG=-g3 #-pg
+DEBUG=-g3
 
 # Set NOCRYPTO to yes if you do not want to have crypto support or dependencies
 #NOCRYPTO=yes
@@ -85,17 +85,7 @@
 #endif
 
 # Asterisk SMDI integration
-WITH_SMDI = 1
-
-# Optional debugging parameters
-DEBUG_THREADS = #-DDUMP_SCHEDULER #-DDEBUG_SCHEDULER #-DDEBUG_THREADS #-DDO_CRASH #-DDETECT_DEADLOCKS
-
-# If you want to debug channel locking, try this (depends on code using
-# ast_channel_lock and companions to work)
-DEBUG_THREADS += #-DDEBUG_CHANNEL_LOCKS
-
-# Uncomment next one to enable ast_frame tracing (for debugging)
-TRACE_FRAMES = #-DTRACE_FRAMES
+WITH_SMDI=1
 
 # Where to install asterisk after compiling
 # Default -> leave empty
@@ -110,16 +100,16 @@
 #DESTDIR?=/tmp/asterisk
 
 # Original busydetect routine
-BUSYDETECT = #-DBUSYDETECT
+#BUSYDETECT = -DBUSYDETECT
 
 # Improved busydetect routine, comment the previous one if you use this one
-BUSYDETECT+= #-DBUSYDETECT_MARTIN 
+#BUSYDETECT+= -DBUSYDETECT_MARTIN 
 # Detect the busy signal looking only at tone lengths
 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
-BUSYDETECT+= #-DBUSYDETECT_TONEONLY
+#BUSYDETECT+= -DBUSYDETECT_TONEONLY
 # Enforce the detection of busy signal (get rid of false hangups)
 # Don't use together with -DBUSYDETECT_TONEONLY
-BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
+#BUSYDETECT+= -DBUSYDETECT_COMPARE_TONE_AND_SILENCE
 
 # Define standard directories for various platforms
 # These apply if they are not redefined in asterisk.conf 
@@ -195,7 +185,6 @@
   include makeopts
 endif
 
-ASTCFLAGS+=$(MENUSELECT_CFLAGS)
 TOPDIR_CFLAGS=-include include/autoconfig.h -Iinclude
 MOD_SUBDIR_CFLAGS=-include ../include/autoconfig.h -I../include -I..
 OTHER_SUBDIR_CFLAGS=-include ../include/autoconfig.h -I../include -I..
@@ -252,7 +241,7 @@
   ID=/usr/xpg4/bin/id
 endif
 
-ASTCFLAGS+=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) #-DMAKE_VALGRIND_HAPPY
+ASTCFLAGS+=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE)
 ASTCFLAGS+=$(OPTIMIZE)
 
 ifeq ($(AST_DEVMODE),yes)
@@ -260,7 +249,7 @@
 endif
 
 ifeq ($(shell gcc -v 2>&1 | grep 'gcc version' | cut -f3 -d' ' | cut -f1 -d.),4)
-ASTCFLAGS+= -Wno-pointer-sign
+ASTCFLAGS+=-Wno-pointer-sign
 endif
 ASTOBJ=-o asterisk
 
@@ -323,13 +312,9 @@
   endif
 endif
 
-ASTCFLAGS+= $(DEBUG_THREADS)
-ASTCFLAGS+= $(TRACE_FRAMES)
-ASTCFLAGS+= $(MALLOC_DEBUG)
-ASTCFLAGS+= $(BUSYDETECT)
-ASTCFLAGS+= $(OPTIONS)
+ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
 ifeq ($(findstring dont-optimize,$(MAKECMDGOALS)),)
-ASTCFLAGS+= -fomit-frame-pointer 
+ASTCFLAGS+=-fomit-frame-pointer 
 endif
 
 MOD_SUBDIRS=res channels pbx apps codecs formats cdr funcs
@@ -348,11 +333,11 @@
 # we need to link in the objects statically, not as a library, because
 # otherwise modules will not have them available if none of the static
 # objects use it.
-OBJS+= stdtime/localtime.o
+OBJS+=stdtime/localtime.o
 
 # At the moment say.o is an optional component which can be overridden
 # by a module.
-OBJS+= say.o
+OBJS+=say.o
 
 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
   OBJS+= poll.o
@@ -432,7 +417,7 @@
 	@echo " +               make install                +"  
 	@echo " +-------------------------------------------+"  
 
-all: config.status menuselect.makeopts cleantest depend asterisk subdirs
+all: cleantest config.status menuselect.makeopts depend asterisk subdirs
 
 config.status: configure
 	@CFLAGS="" ./configure
@@ -525,10 +510,17 @@
 	fi
 	@rm -f $@.tmp
 
+include/asterisk/buildopts.h: menuselect.makeopts
+	@build_tools/make_buildopts_h > $@.tmp
+	@if cmp -s $@.tmp $@ ; then echo; else \
+		mv $@.tmp $@ ; \
+	fi
+	@rm -f $@.tmp
+
 stdtime/libtime.a:
 	CFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" $(MAKE) -C stdtime libtime.a
 
-asterisk: editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
+asterisk: include/asterisk/buildopts.h editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
 	build_tools/make_build_h > include/asterisk/build.h.tmp
 	if cmp -s include/asterisk/build.h.tmp include/asterisk/build.h ; then echo ; else \
 		mv include/asterisk/build.h.tmp include/asterisk/build.h ; \
@@ -567,6 +559,7 @@
 	rm -f menuselect.makeopts makeopts makeopts.xml
 	rm -f config.log config.status
 	rm -f include/autoconfig.h
+	rm -f include/asterisk/buildopts.h
 	$(MAKE) -C mxml clean
 	$(MAKE) -C build_tools dist-clean
 
@@ -675,7 +668,7 @@
 	if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi
 	ln -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
 	$(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
-	$(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/	
+	$(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
 	if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
 		cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
 		chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
@@ -862,7 +855,7 @@
 
 rpm: __rpm
 
-__rpm: include/asterisk/version.h spec
+__rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
 	rm -rf /tmp/asterisk ; \
 	mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
 	$(MAKE) DESTDIR=/tmp/asterisk install ; \
@@ -911,10 +904,10 @@
 
 valgrind: dont-optimize
 
-depend: include/asterisk/version.h .depend defaults.h 
+depend: include/asterisk/version.h include/asterisk/buildopts.h .depend defaults.h 
 	@for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
 
-.depend: include/asterisk/version.h defaults.h
+.depend: include/asterisk/version.h include/asterisk/buildopts.h defaults.h
 	build_tools/mkdep $(CFLAGS) $(wildcard *.c)
 
 .tags-depend:

Modified: team/oej/sdpcleanup/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/asterisk.c?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/asterisk.c (original)
+++ team/oej/sdpcleanup/asterisk.c Thu May 11 09:57:24 2006
@@ -1644,6 +1644,9 @@
 					}
 					break;
 #endif
+				case 's': /* Asterisk system name (from asterisk.conf) */
+					strncat(p, ast_config_AST_SYSTEM_NAME, sizeof(prompt) - strlen(prompt) - 1);
+					break;
 				case 't': /* time */
 					memset(&tm, 0, sizeof(tm));
 					time(&ts);

Modified: team/oej/sdpcleanup/build_tools/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/build_tools/Makefile?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/build_tools/Makefile (original)
+++ team/oej/sdpcleanup/build_tools/Makefile Thu May 11 09:57:24 2006
@@ -1,5 +1,5 @@
 MENUSELECT_OBJS=menuselect.o menuselect_curses.o
-MENUSELECT_CFLAGS=-g -c -D_GNU_SOURCE -I../ -I../include/
+MENUSELECT_CFLAGS=-g -c -D_GNU_SOURCE -DMENUSELECT -I../ -I../include/
 MENUSELECT_LIBS=../mxml/libmxml.a
 
 ifeq ($(OSARCH),SunOS)

Modified: team/oej/sdpcleanup/build_tools/cflags.xml
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/build_tools/cflags.xml?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/build_tools/cflags.xml (original)
+++ team/oej/sdpcleanup/build_tools/cflags.xml Thu May 11 09:57:24 2006
@@ -1,20 +1,20 @@
 	<category name="MENUSELECT_CFLAGS" displayname="Compiler Flags" positive_output="yes" force_clean_on_change="yes">
-		<member name="-DDEBUG_SCHEDULER">
+		<member name="DEBUG_SCHEDULER" displayname="Enable Scheduler Debugging Output">
 		</member>
-		<member name="-DDEBUG_THREADS">
+		<member name="DEBUG_THREADS" displayname="Enable Thread Debugging">
 		</member>
-		<member name="-DDETECT_DEADLOCKS">
+		<member name="DETECT_DEADLOCKS" displayname="Detect Deadlocks">
 		</member>
-		<member name="-DDUMP_SCHEDULER">
+		<member name="DUMP_SCHEDULER" displayname="Dump Scheduler Contents for Debugging">
 		</member>
-		<member name="-DLOW_MEMORY">
+		<member name="LOW_MEMORY" displayname="Optimize for Low Memory Usage">
 		</member>
-		<member name="-DMALLOC_DEBUG">
+		<member name="MALLOC_DEBUG" displayname="Keep Track of Memory Allocations">
 		</member>
-		<member name="-DRADIO_RELAX">
+		<member name="RADIO_RELAX" displayname="Relax DTMF for Radio Applications">
 		</member>
-		<member name="-DTRACE_FRAMES">
+		<member name="TRACE_FRAMES" displayname="Trace Frame Allocations">
 		</member>
-		<member name="-DMTX_PROFILE">
+		<member name="MTX_PROFILE" displayname="Enable Code Profiling Using TSC Counters">
 		</member>
 	</category>

Modified: team/oej/sdpcleanup/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/channel.c?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/channel.c (original)
+++ team/oej/sdpcleanup/channel.c Thu May 11 09:57:24 2006
@@ -3328,7 +3328,6 @@
 		if (!f) {
 			*fo = NULL;
 			*rc = who;
-			res = AST_BRIDGE_COMPLETE;
 			ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name);
 			break;
 		}
@@ -3336,6 +3335,8 @@
 		other = (who == c0) ? c1 : c0; /* the 'other' channel */
 
 		if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
+			int bridge_exit = 0;
+
 			switch (f->subclass) {
 			case AST_CONTROL_HOLD:
 			case AST_CONTROL_UNHOLD:
@@ -3345,11 +3346,11 @@
 			default:
 				*fo = f;
 				*rc = who;
-				res =  AST_BRIDGE_COMPLETE;
+				bridge_exit = 1;
 				ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
 				break;
 			}
-			if (res == AST_BRIDGE_COMPLETE)
+			if (bridge_exit)
 				break;
 		}
 		if ((f->frametype == AST_FRAME_VOICE) ||
@@ -3365,7 +3366,6 @@
 			if (f->frametype == AST_FRAME_DTMF && monitored_source) {
 				*fo = f;
 				*rc = who;
-				res = AST_BRIDGE_COMPLETE;
 				ast_log(LOG_DEBUG, "Got DTMF on channel (%s)\n", who->name);
 				break;
 			}

Modified: team/oej/sdpcleanup/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/channels/chan_sip.c?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/channels/chan_sip.c (original)
+++ team/oej/sdpcleanup/channels/chan_sip.c Thu May 11 09:57:24 2006
@@ -1024,7 +1024,7 @@
 static int ourport;
 static struct sockaddr_in debugaddr;
 
-struct ast_config *notify_types;		/*!< The list of manual NOTIFY types we know how to send */
+static struct ast_config *notify_types;		/*!< The list of manual NOTIFY types we know how to send */
 
 /*---------------------------- Forward declarations of functions in chan_sip.c */
 /*! \note Sorted up from start to build_rpid.... Will continue categorization in order to
@@ -1173,7 +1173,6 @@
 static unsigned int parse_sip_options(struct sip_pvt *pvt, const char *supported);
 static void parse_request(struct sip_request *req);
 static const char *get_header(const struct sip_request *req, const char *name);
-static void copy_request(struct sip_request *dst,struct sip_request *src);
 static char *referstatus2str(enum referstatus rstatus);
 static int method_match(enum sipmethod id, const char *name);
 static void parse_copy(struct sip_request *dst, struct sip_request *src);
@@ -1188,7 +1187,7 @@
 static void initialize_initreq(struct sip_pvt *p, struct sip_request *req);
 static int init_req(struct sip_request *req, int sipmethod, const char *recip);
 static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, int seqno, int newbranch);
-static int init_resp(struct sip_request *req, const char *resp, struct sip_request *orig);
+static int init_resp(struct sip_request *resp, const char *msg);
 static int respprep(struct sip_request *resp, struct sip_pvt *p, const char *msg, struct sip_request *req);
 static const struct sockaddr_in *sip_real_dst(const struct sip_pvt *p);
 static void build_via(struct sip_pvt *p);
@@ -1263,6 +1262,15 @@
 	.send_text = sip_sendtext,
 };
 
+/**--- some list management macros. **/
+ 
+#define UNLINK(element, head, prev) do {	\
+	if (prev)				\
+		(prev)->next = (element)->next;	\
+	else					\
+		(head) = (element)->next;	\
+	} while (0)
+
 /*! \brief Interface structure with callbacks used to connect to RTP module */
 static struct ast_rtp_protocol sip_rtp = {
 	type: "SIP",
@@ -1305,7 +1313,7 @@
  * matches the sip method 'id'.
  * Strictly speaking, SIP methods are case SENSITIVE, but we do
  * a case-insensitive comparison to be more tolerant.
- * following Jon Postel's rule: Be gentle in what you accept, strict with what you send 
+ * following Jon Postel's rule: Be gentle in what you accept, strict with what you send
  */
 static int method_match(enum sipmethod id, const char *name)
 {
@@ -1720,10 +1728,7 @@
 				p->pendinginvite = 0;
 			}
 			/* this is our baby */
-			if (prev)
-				prev->next = cur->next;
-			else
-				p->packets = cur->next;
+			UNLINK(cur, p->packets, prev);
 			if (cur->retransid > -1) {
 				if (sipdebug && option_debug > 3)
 					ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
@@ -1742,27 +1747,20 @@
 }
 
 /*! \brief Pretend to ack all packets */
+/* maybe the lock on p is not strictly necessary but there might be a race */
 static int __sip_pretend_ack(struct sip_pvt *p)
 {
 	struct sip_pkt *cur = NULL;
 
 	while (p->packets) {
+		int method;
 		if (cur == p->packets) {
 			ast_log(LOG_WARNING, "Have a packet that doesn't want to give up! %s\n", sip_methods[cur->method].text);
 			return -1;
 		}
 		cur = p->packets;
-		if (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];
-
-			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), FALSE);
-		}
+		method = (cur->method) ? cur->method : find_sip_method(cur->data);
+		__sip_ack(p, cur->seqno, ast_test_flag(cur, FLAG_RESPONSE), method, FALSE);
 	}
 	return 0;
 }
@@ -2498,10 +2496,7 @@
 
 	for (prev = NULL, cur = iflist; cur; prev = cur, cur = cur->next) {
 		if (cur == p) {
-			if (prev)
-				prev->next = cur->next;
-			else
-				iflist = cur->next;
+			UNLINK(cur, iflist, prev);
 			break;
 		}
 	}
@@ -2845,7 +2840,7 @@
 				__sip_pretend_ack(p);
 
 				/* Send a new request: CANCEL */
-				transmit_request_with_auth(p, SIP_CANCEL, p->ocseq, XMIT_RELIABLE, 0);
+				transmit_request_with_auth(p, SIP_CANCEL, p->ocseq, XMIT_RELIABLE, FALSE);
 				/* Actually don't destroy us yet, wait for the 487 on our original 
 				   INVITE, but do set an autodestruct just in case we never get it. */
 				ast_clear_flag(&locflags, SIP_NEEDDESTROY);
@@ -4225,6 +4220,8 @@
 /*! \brief Add header to SIP message */
 static int add_header(struct sip_request *req, const char *var, const char *value)
 {
+	int maxlen = sizeof(req->data) - 4 - req->len; /* 4 bytes are for two \r\n ? */
+
 	if (req->headers == SIP_MAX_HEADERS) {
 		ast_log(LOG_WARNING, "Out of SIP header space\n");
 		return -1;
@@ -4235,7 +4232,7 @@
 		return -1;
 	}
 
-	if (req->len >= sizeof(req->data) - 4) {
+	if (maxlen <= 0) {
 		ast_log(LOG_WARNING, "Out of space, can't add anymore (%s:%s)\n", var, value);
 		return -1;
 	}
@@ -4245,7 +4242,7 @@
 	if (compactheaders)
 		var = find_alias(var, var);
 
-	snprintf(req->header[req->headers], sizeof(req->data) - req->len - 4, "%s: %s\r\n", var, value);
+	snprintf(req->header[req->headers], maxlen, "%s: %s\r\n", var, value);
 	req->len += strlen(req->header[req->headers]);
 	req->headers++;
 
@@ -4495,37 +4492,31 @@
 }
 
 /*! \brief Initialize SIP response, based on SIP request */
-static int init_resp(struct sip_request *req, const char *resp, struct sip_request *orig)
+static int init_resp(struct sip_request *resp, const char *msg)
 {
 	/* Initialize a response */
-	if (req->headers || req->len) {
-		ast_log(LOG_WARNING, "Request already initialized?!?\n");
-		return -1;
-	}
-	req->method = SIP_RESPONSE;
-	req->header[req->headers] = req->data + req->len;
-	snprintf(req->header[req->headers], sizeof(req->data) - req->len, "SIP/2.0 %s\r\n", resp);
-	req->len += strlen(req->header[req->headers]);
+	memset(resp, 0, sizeof(*resp));
+	resp->method = SIP_RESPONSE;
+	resp->header[0] = resp->data;
+	snprintf(resp->header[0], sizeof(resp->data), "SIP/2.0 %s\r\n", msg);
+	resp->len = strlen(resp->header[0]);
+	resp->headers++;
+	return 0;
+}
+
+/*! \brief Initialize SIP request */
+static int init_req(struct sip_request *req, int sipmethod, const char *recip)
+{
+	/* Initialize a request */
+	memset(req, 0, sizeof(*req));
+        req->method = sipmethod;
+	req->header[0] = req->data;
+	snprintf(req->header[0], sizeof(req->data), "%s %s SIP/2.0\r\n", sip_methods[sipmethod].text, recip);
+	req->len = strlen(req->header[0]);
 	req->headers++;
 	return 0;
 }
 
-/*! \brief Initialize SIP request */
-static int init_req(struct sip_request *req, int sipmethod, const char *recip)
-{
-	/* Initialize a response */
-	if (req->headers || req->len) {
-		ast_log(LOG_WARNING, "Request already initialized?!?\n");
-		return -1;
-	}
-	req->header[req->headers] = req->data + req->len;
-	snprintf(req->header[req->headers], sizeof(req->data) - req->len, "%s %s SIP/2.0\r\n", sip_methods[sipmethod].text, recip);
-	req->len += strlen(req->header[req->headers]);
-	req->headers++;
-	req->method = sipmethod;
-	return 0;
-}
-
 
 /*! \brief Prepare SIP response packet */
 static int respprep(struct sip_request *resp, struct sip_pvt *p, const char *msg, struct sip_request *req)
@@ -4533,8 +4524,7 @@
 	char newto[256];
 	const char *ot;
 
-	memset(resp, 0, sizeof(*resp));
-	init_resp(resp, msg, req);
+	init_resp(resp, msg);
 	copy_via_headers(p, resp, req, "Via");
 	if (msg[0] == '2')
 		copy_all_header(resp, req, "Record-Route");
@@ -5421,7 +5411,6 @@
 		snprintf(to, sizeof(to), "<%s>", p->uri);
 	}
 	
-	memset(req, 0, sizeof(struct sip_request));
 	init_req(req, sipmethod, p->uri);
 	snprintf(tmp, sizeof(tmp), "%d %s", ++p->ocseq, sip_methods[sipmethod].text);
 
@@ -6009,7 +5998,6 @@
 
 	p->branch ^= ast_random();
 
-	memset(&req, 0, sizeof(req));
 	init_req(&req, sipmethod, addr);
 
 	/* Add to CSEQ */
@@ -6941,6 +6929,9 @@
 				switch (parse_register_contact(p, peer, req)) {
 				case PARSE_REGISTER_FAILED:
 					ast_log(LOG_WARNING, "Failed to parse contact info\n");
+					transmit_response_with_date(p, "400 Bad Request", req);
+					peer->lastmsgssent = -1;
+					res = 0;
 					break;
 				case PARSE_REGISTER_QUERY:
 					transmit_response_with_date(p, "200 OK", req);
@@ -6964,11 +6955,13 @@
 		peer = temp_peer(name);
 		if (peer) {
 			ASTOBJ_CONTAINER_LINK(&peerl, peer);
-			peer->lastmsgssent = -1;
 			sip_cancel_destroy(p);
 			switch (parse_register_contact(p, peer, req)) {
 			case PARSE_REGISTER_FAILED:
 				ast_log(LOG_WARNING, "Failed to parse contact info\n");
+				transmit_response_with_date(p, "400 Bad Request", req);
+				peer->lastmsgssent = -1;
+				res = 0;
 				break;
 			case PARSE_REGISTER_QUERY:
 				transmit_response_with_date(p, "200 OK", req);
@@ -10063,7 +10056,7 @@
 {
 	/* Go ahead and send bye at this point */
 	if (ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
-		transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
+		transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, TRUE);
 		ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
 		ast_clear_flag(&p->flags[0], SIP_NEEDREINVITE);	
 	} else if (ast_test_flag(&p->flags[0], SIP_NEEDREINVITE)) {
@@ -10179,13 +10172,13 @@
 				ast_set_flag(&p->flags[0], SIP_PENDINGBYE);	
 		}
 		/* If I understand this right, the branch is different for a non-200 ACK only */
-		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, 1);
+		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, TRUE);
 		check_pendings(p);
 		break;
 	case 407: /* Proxy authentication */
 	case 401: /* Www auth */
 		/* First we ACK */
-		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, 0);
+		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
 		if (p->options)
 			p->options->auth_type = (resp == 401 ? WWW_AUTH : PROXY_AUTH);
 
@@ -10205,7 +10198,7 @@
 		break;
 	case 403: /* Forbidden */
 		/* First we ACK */
-		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, 0);
+		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
 		ast_log(LOG_WARNING, "Received response: \"Forbidden\" from '%s'\n", get_header(&p->initreq, "From"));
 		if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner)
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
@@ -10213,7 +10206,7 @@
 		ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
 		break;
 	case 404: /* Not found */
-		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, 0);
+		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
 		if (p->owner && !ast_test_flag(req, SIP_PKT_IGNORE))
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
 		ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
@@ -10221,7 +10214,7 @@
 	case 481: /* Call leg does not exist */
 		/* Could be REFER or INVITE */
 		ast_log(LOG_WARNING, "Re-invite to non-existing call leg on other UA. SIP dialog '%s'. Giving up.\n", p->callid);
-		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, 0);
+		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
 		break;
 	case 491: /* Pending */
 		/* we have to wait a while, then retransmit */
@@ -10589,7 +10582,7 @@
 		case 481: /* Call leg does not exist */
 			if (sipmethod == SIP_INVITE) {
 				/* First we ACK */
-				transmit_request(p, SIP_ACK, seqno, 0, 0);
+				transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
 					ast_log(LOG_WARNING, "INVITE with REPLACEs failed to '%s'\n", get_header(&p->initreq, "From"));
 				if (owner)
 					ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
@@ -10702,7 +10695,7 @@
 				}
 				/* ACK on invite */
 				if (sipmethod == SIP_INVITE) 
-					transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, 0);
+					transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
 				ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
 				if (!p->owner)
 					ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
@@ -11558,7 +11551,7 @@
 			transmit_notify_with_sipfrag(p, seqno, "200 OK", 1);
 			/* Always increment on a BYE */
 			if (!nobye) {
-				transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
+				transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, TRUE);
 				ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
 			}
 		}
@@ -11571,6 +11564,14 @@
 		
 	check_via(p, req);
 	ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
+	
+	if (p->owner && p->owner->_state == AST_STATE_UP) {
+		/* This call is up, cancel is ignored, we need a bye */
+		transmit_response(p, "200 OK", req);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Got CANCEL on an answered call. Ignoring... \n");
+		return 0;
+	}
 	if (p->rtp) {
 		/* Immediately stop RTP */
 		ast_rtp_stop(p->rtp);
@@ -13397,7 +13398,10 @@
 	global_allowsubscribe = FALSE;
 	ast_copy_string(global_useragent, DEFAULT_USERAGENT, sizeof(global_useragent));
 	ast_copy_string(default_notifymime, DEFAULT_NOTIFYMIME, sizeof(default_notifymime));
-	ast_copy_string(global_realm, DEFAULT_REALM, sizeof(global_realm));
+	if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME))
+		ast_copy_string(global_realm, DEFAULT_REALM, sizeof(global_realm));
+	else
+		ast_copy_string(global_realm, ast_config_AST_SYSTEM_NAME, sizeof(global_realm));
 	ast_copy_string(default_callerid, DEFAULT_CALLERID, sizeof(default_callerid));
 	compactheaders = DEFAULT_COMPACTHEADERS;
 	global_reg_timeout = DEFAULT_REGISTRATION_TIMEOUT;

Modified: team/oej/sdpcleanup/configs/manager.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/configs/manager.conf.sample?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/configs/manager.conf.sample (original)
+++ team/oej/sdpcleanup/configs/manager.conf.sample Thu May 11 09:57:24 2006
@@ -21,6 +21,7 @@
 ; default is 60 seconds.
 ;
 [general]
+displaysystemname = yes
 enabled = no
 ;webenabled = yes
 port = 5038

Modified: team/oej/sdpcleanup/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/configs/sip.conf.sample?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/configs/sip.conf.sample (original)
+++ team/oej/sdpcleanup/configs/sip.conf.sample Thu May 11 09:57:24 2006
@@ -32,7 +32,8 @@
 ;allowtransfer=no		; Disable all transfers (unless enabled in peers or users)
 				; Default is enabled
 ;realm=mydomain.tld		; Realm for digest authentication
-				; defaults to "asterisk"
+				; defaults to "asterisk". If you set a system name in
+				; asterisk.conf, it defaults to that system name
 				; Realms MUST be globally unique according to RFC 3261
 				; Set this to your host name or domain name
 bindport=5060			; UDP Port to bind to (SIP standard port is 5060)

Modified: team/oej/sdpcleanup/configure.ac
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/configure.ac?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/configure.ac (original)
+++ team/oej/sdpcleanup/configure.ac Thu May 11 09:57:24 2006
@@ -111,6 +111,10 @@
 AC_GNU_SOURCE
 
 AH_TOP(
+#ifndef MENUSELECT
+#include "asterisk/buildopts.h"
+#endif
+
 #ifndef _REENTRANT
 #define _REENTRANT
 #endif

Modified: team/oej/sdpcleanup/doc/cliprompt.txt
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/doc/cliprompt.txt?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/doc/cliprompt.txt (original)
+++ team/oej/sdpcleanup/doc/cliprompt.txt Thu May 11 09:57:24 2006
@@ -8,6 +8,7 @@
 the current value by Asterisk:
 
 %d	Date (year-month-date)
+%s	Asterisk system name (from asterisk.conf)
 %h	Full hostname
 %H	Short hostname
 %t	Time

Modified: team/oej/sdpcleanup/enum.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/enum.c?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/enum.c (original)
+++ team/oej/sdpcleanup/enum.c Thu May 11 09:57:24 2006
@@ -95,7 +95,7 @@
 } __attribute__ ((__packed__));
 
 /*! \brief Parse NAPTR record information elements */
-static int parse_ie(char *data, int maxdatalen, char *src, int srclen)
+static int parse_ie(unsigned char *data, int maxdatalen, unsigned char *src, int srclen)
 {
 	int len, olen;
 
@@ -113,7 +113,7 @@
 }
 
 /*! \brief Parse DNS NAPTR record used in ENUM ---*/
-static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, char *answer, int len, char *naptrinput)
+static int parse_naptr(unsigned char *dst, int dstsize, char *tech, int techsize, unsigned char *answer, int len, unsigned char *naptrinput)
 {
 
 	char tech_return[80];

Propchange: team/oej/sdpcleanup/include/asterisk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu May 11 09:57:24 2006
@@ -1,2 +1,3 @@
 build.h
 version.h
+buildopts.h

Modified: team/oej/sdpcleanup/include/asterisk/rtp.h
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/include/asterisk/rtp.h?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/include/asterisk/rtp.h (original)
+++ team/oej/sdpcleanup/include/asterisk/rtp.h Thu May 11 09:57:24 2006
@@ -79,11 +79,12 @@
  *
  */
 struct ast_rtp {
-	int s;				/*!< File descriptor */
-	char resp;			/*!< Frame subclass */
-	struct ast_frame f;		/*!< The media frame */
-	unsigned char rawdata[8192 + AST_FRIENDLY_OFFSET];	/*!< The RTP raw data */
+	int s;
+	char resp;
+	struct ast_frame f;
+	unsigned char rawdata[8192 + AST_FRIENDLY_OFFSET];
 	unsigned int ssrc;		/*!< Synchronization source, RFC 3550, page 10. */
+	unsigned int rxssrc;
 	unsigned int lastts;
 	unsigned int lastdigitts;
 	unsigned int lastrxts;

Modified: team/oej/sdpcleanup/include/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/include/autoconfig.h.in?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/include/autoconfig.h.in (original)
+++ team/oej/sdpcleanup/include/autoconfig.h.in Thu May 11 09:57:24 2006
@@ -1,4 +1,8 @@
 /* include/autoconfig.h.in.  Generated from configure.ac by autoheader.  */
+
+#ifndef MENUSELECT
+#include "asterisk/buildopts.h"
+#endif
 
 #ifndef _REENTRANT
 #define _REENTRANT

Modified: team/oej/sdpcleanup/manager.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/manager.c?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/manager.c (original)
+++ team/oej/sdpcleanup/manager.c Thu May 11 09:57:24 2006
@@ -158,6 +158,7 @@
 	char inbuf[AST_MAX_MANHEADER_LEN];
 	int inlen;
 	int send_events;
+	int displaysystemname;		/*!< Add system name to manager responses and events */
 	/* Queued events that we've not had the ability to send yet */
 	struct eventqent *eventq;
 	/* Timeout for ast_carefulwrite() */
@@ -772,6 +773,14 @@
 				while (v) {
 					if (!strcasecmp(v->name, "secret")) {
 						password = v->value;
+					} else if (!strcasecmp(v->name, "displaysystemname")) {
+						if (ast_true(v->value)) {
+							if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) {
+								s->displaysystemname = 1;
+							} else {
+								ast_log(LOG_ERROR, "Can't enable displaysystemname in manager.conf - no system name configured in asterisk.conf\n");
+							}
+						}
 					} else if (!strcasecmp(v->name, "permit") ||
 						   !strcasecmp(v->name, "deny")) {
 						ha = ast_append_ha(v->name, v->value, ha);

Modified: team/oej/sdpcleanup/rtp.c
URL: http://svn.digium.com/view/asterisk/team/oej/sdpcleanup/rtp.c?rev=26921&r1=26920&r2=26921&view=diff
==============================================================================
--- team/oej/sdpcleanup/rtp.c (original)
+++ team/oej/sdpcleanup/rtp.c Thu May 11 09:57:24 2006
@@ -382,6 +382,7 @@
 	int ext;
 	int x;
 	char iabuf[INET_ADDRSTRLEN];
+	unsigned int ssrc;
 	unsigned int timestamp;
 	unsigned int *rtpheader;
 	struct rtpPayloadType rtpPT;
@@ -437,6 +438,14 @@
 	ext = seqno & (1 << 28);
 	seqno &= 0xffff;
 	timestamp = ntohl(rtpheader[1]);
+	ssrc = ntohl(rtpheader[2]);
+	
+	if (!mark && rtp->rxssrc && rtp->rxssrc != ssrc) {
+		ast_log(LOG_WARNING, "Forcing Marker bit, because SSRC has changed\n");
+		mark = 1;
+	}
+
+	rtp->rxssrc = ssrc;
 	
 	if (padding) {
 		/* Remove padding bytes */



More information about the asterisk-commits mailing list