[svn-commits] rizzo: branch rizzo/astobj2 r57984 - /team/rizzo/astobj2/channels/chan_sip.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Mar 6 01:48:07 MST 2007


Author: rizzo
Date: Tue Mar  6 02:48:06 2007
New Revision: 57984

URL: http://svn.digium.com/view/asterisk?view=rev&rev=57984
Log:
merge from trunk to svn 57478 (current as of today)


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=57984&r1=57983&r2=57984
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Tue Mar  6 02:48:06 2007
@@ -825,11 +825,12 @@
 #define SIP_PAGE2_CALL_ONHOLD		(3 << 23)	/*!< Call states */
 #define SIP_PAGE2_CALL_ONHOLD_ONEDIR	(1 << 23)	/*!< 23: One directional hold */
 #define SIP_PAGE2_CALL_ONHOLD_INACTIVE	(1 << 24)	/*!< 24: Inactive  */
-#define SIP_PAGE2_RFC2833_COMPENSATE    (1 << 25)	/*!< 25: ???? */
+#define SIP_PAGE2_RFC2833_COMPENSATE    (1 << 25)       /*!< 25: Compensate for buggy RFC2833 implementations */
 #define SIP_PAGE2_BUGGY_MWI		(1 << 26)	/*!< 26: Buggy CISCO MWI fix */
-#define SIP_PAGE2_NOTEXT                (1 << 27)       /*!< 26: Text not supported  */
-#define SIP_PAGE2_TEXTSUPPORT           (1 << 28)       /*!< 27: Global text enable */
-#define SIP_PAGE2_DEBUG_TEXT            (1 << 29)       /*!< 28: Global text debug */
+#define SIP_PAGE2_NOTEXT                (1 << 27)       /*!< 27: Text not supported  */
+#define SIP_PAGE2_TEXTSUPPORT           (1 << 28)       /*!< 28: Global text enable */
+#define SIP_PAGE2_DEBUG_TEXT            (1 << 29)       /*!< 29: Global text debug */
+#define SIP_PAGE2_OUTGOING_CALL         (1 << 30)       /*!< 30: Is this an outgoing call? */
 
 #define SIP_PAGE2_FLAGS_TO_COPY \
 	(SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_VIDEOSUPPORT | \
@@ -3597,7 +3598,7 @@
 {
 	char name[256];
 	int *inuse = NULL, *call_limit = NULL, *inringing = NULL;
-	int outgoing = ast_test_flag(&fup->flags[0], SIP_OUTGOING);
+	int outgoing = ast_test_flag(&fup->flags[1], SIP_PAGE2_OUTGOING_CALL);
 	struct sip_user *u = NULL;
 	struct sip_peer *p = NULL;
 
@@ -3871,6 +3872,11 @@
 	}
 
 	if (ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
+		if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
+			if (option_debug && sipdebug)
+				ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+			update_call_counter(p, DEC_CALL_LIMIT);
+		}
 		if (option_debug >3)
 			ast_log(LOG_DEBUG, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);	/* also cancels previous one if there */
@@ -3894,9 +3900,11 @@
 		ast_log(LOG_DEBUG, "Hanging up zombie call. Be scared.\n");
 
 	sip_pvt_lock(p);
-	if (option_debug && sipdebug)
-		ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
-	update_call_counter(p, DEC_CALL_LIMIT);
+	if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
+		if (option_debug && sipdebug)
+			ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+		update_call_counter(p, DEC_CALL_LIMIT);
+	}
 
 	/* Determine how to disconnect */
 	if (p->owner != ast) {
@@ -4702,27 +4710,33 @@
 	    (ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_RFC2833))
 		return &ast_null_frame;
 
-	if (p->owner) {
-		/* We already hold the channel lock */
-		if (f->frametype == AST_FRAME_VOICE) {
-			if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
+	/* We already hold the channel lock */
+	if (!p->owner || f->frametype != AST_FRAME_VOICE)
+		return f;
+
+	if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
+		if (!(f->subclass & p->jointcapability)) {
+			if (option_debug) {
+				ast_log(LOG_DEBUG, "Bogus frame of format '%s' received from '%s'!\n",
+				ast_getformatname(f->subclass), p->owner->name);
+			}
+			return &ast_null_frame;
+		}
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+		p->owner->nativeformats = (p->owner->nativeformats & (AST_FORMAT_VIDEO_MASK | AST_FORMAT_TEXT_MASK) ) | f->subclass;
+		ast_set_read_format(p->owner, p->owner->readformat);
+		ast_set_write_format(p->owner, p->owner->writeformat);
+	}
+	if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
+		f = ast_dsp_process(p->owner, p->vad, f);
+		if (f && f->frametype == AST_FRAME_DTMF) {
+			if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
 				if (option_debug)
-					ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
-				p->owner->nativeformats = (p->owner->nativeformats & (AST_FORMAT_VIDEO_MASK | AST_FORMAT_TEXT_MASK) ) | f->subclass;
-				ast_set_read_format(p->owner, p->owner->readformat);
-				ast_set_write_format(p->owner, p->owner->writeformat);
-			}
-			if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
-				f = ast_dsp_process(p->owner, p->vad, f);
-				if (f && f->frametype == AST_FRAME_DTMF) {
-					if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
-						if (option_debug)
-							ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
-						*faxdetect = 1;
-					} else if (option_debug) {
-						ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
-					}
-				}
+					ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
+				*faxdetect = 1;
+			} else if (option_debug) {
+				ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
 			}
 		}
 	}
@@ -8502,7 +8516,7 @@
 	if (contact)
 		ast_copy_string(peer->fullcontact, contact, sizeof(peer->fullcontact));
 
-	if (option_verbose > 2)
+	if (option_verbose > 1)
 		ast_verbose(VERBOSE_PREFIX_3 "SIP Seeding peer from astdb: '%s' at %s@%s:%d for %d\n",
 			    peer->name, peer->username, ast_inet_ntoa(in), port, expiry);
 
@@ -13598,7 +13612,11 @@
 			} else if (sipmethod == SIP_NOTIFY) {
 				/* They got the notify, this is the end */
 				if (p->owner) {
-					ast_log(LOG_WARNING, "Notify answer on an owned channel?\n");
+					if (p->refer) {
+						if (option_debug)
+							ast_log(LOG_DEBUG, "Got 200 OK on NOTIFY for transfer\n");
+					} else
+						ast_log(LOG_WARNING, "Notify answer on an owned channel?\n");
 					/* ast_queue_hangup(p->owner); Disabled */
 				} else {
 					if (!p->subscribed && !p->refer)
@@ -13889,7 +13907,7 @@
 			ast_log(LOG_DEBUG, "-- No target second channel ---\n");
 		ast_log(LOG_DEBUG, "-- END Sip transfer:--------------------\n");
 	}
-	if (transferer->chan2) {			/* We have a bridge on the transferer's channel */
+	if (transferer->chan2) { /* We have a bridge on the transferer's channel */
 		peera = transferer->chan1;	/* Transferer - PBX -> transferee channel * the one we hangup */
 		peerb = target->chan1;		/* Transferer - PBX -> target channel - This will get lost in masq */
 		peerc = transferer->chan2;	/* Asterisk to Transferee */
@@ -15840,6 +15858,12 @@
 			}
 			return res;
 		}
+	}
+
+	if (!e && (p->method == SIP_INVITE || p->method == SIP_SUBSCRIBE || p->method == SIP_REGISTER || p->method == SIP_NOTIFY)) {
+		transmit_response(p, "503 Server error", req);
+		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+		return -1;
 	}
 
 	/* Handle various incoming SIP methods in requests */
@@ -16557,6 +16581,8 @@
 		*cause = AST_CAUSE_SWITCH_CONGESTION;
 		return NULL;
 	}
+
+	ast_set_flag(&p->flags[1], SIP_PAGE2_OUTGOING_CALL);
 
 	if (!(p->options = ast_calloc(1, sizeof(*p->options)))) {
 		sip_destroy(p);



More information about the svn-commits mailing list