[asterisk-commits] branch oej/outgoingfix r36170 - /team/oej/outgoingfix/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jun 26 14:03:52 MST 2006


Author: oej
Date: Mon Jun 26 16:03:51 2006
New Revision: 36170

URL: http://svn.digium.com/view/asterisk?rev=36170&view=rev
Log:
- Set the SIP_OUTGOING flag *only* for a dialog - was it outbound or inbound when it was created
- Add a flag for the last TRANSACTION to see if it's outbound or inbound
  We can send re-invites on OUTBOUND and INBOUND calls, but re-invites should
  not change the direction of the call
  We can receive re-invites in the same way
- Now, we need the new flag to pick correct from/to headers and tags, which is a current bug
  that affects both normal calls and t.38 re-invites.

This is not the complete fix, but a start of this branch in order to fix these issues with
svn trunk

Modified:
    team/oej/outgoingfix/channels/chan_sip.c

Modified: team/oej/outgoingfix/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/outgoingfix/channels/chan_sip.c?rev=36170&r1=36169&r2=36170&view=diff
==============================================================================
--- team/oej/outgoingfix/channels/chan_sip.c (original)
+++ team/oej/outgoingfix/channels/chan_sip.c Mon Jun 26 16:03:51 2006
@@ -705,6 +705,7 @@
 #define SIP_CALL_LIMIT		(1 << 28)	/*!< Call limit enforced for this call */
 #define SIP_SENDRPID		(1 << 29)	/*!< Remote Party-ID Support */
 #define SIP_INC_COUNT		(1 << 30)	/*!< Did this connection increment the counter of in-use calls? */
+#define SIP_TRANS_OUTGOING	(1 << 31)	/*!< Is the current transaction (secno) outgoing ? */
 
 #define SIP_FLAGS_TO_COPY \
 	(SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \
@@ -2673,7 +2674,8 @@
 	}
 	
 	res = 0;
-	ast_set_flag(&p->flags[0], SIP_OUTGOING);
+	ast_set_flag(&p->flags[0], SIP_OUTGOING);	/* Outbound dialog */
+	ast_set_flag(&p->flags[0], SIP_TRANS_OUTGOING);	/* Outbound transaction */
 
 	if (p->options->transfer) {
 		char buf[BUFSIZ/2];
@@ -5261,6 +5263,7 @@
 	if (!strcasestr(ot, "tag=") && strncmp(msg, "100", 3)) {
 		/* Add the proper tag if we don't have it already.  If they have specified
 		   their tag, use it.  Otherwise, use our own tag */
+		/* SKREP */
 		if (!ast_strlen_zero(p->theirtag) && ast_test_flag(&p->flags[0], SIP_OUTGOING))
 			snprintf(newto, sizeof(newto), "%s;tag=%s", ot, p->theirtag);
 		else if (p->tag && !ast_test_flag(&p->flags[0], SIP_OUTGOING))
@@ -5356,7 +5359,7 @@
 		add_route(req, is_strict ? p->route->next : p->route);
 	}
 
-	ot = get_header(orig, "To");
+	ot = get_header(orig, "To");		/* Get the original headers */
 	of = get_header(orig, "From");
 
 	/* Add tag *unless* this is a CANCEL, in which case we need to send it exactly
@@ -5364,6 +5367,8 @@
 	if (!strcasestr(ot, "tag=") && sipmethod != SIP_CANCEL) {
 		/* Add the proper tag if we don't have it already.  If they have specified
 		   their tag, use it.  Otherwise, use our own tag */
+
+		/* XXX Should we really base this on the direction of the call ? */
 		if (ast_test_flag(&p->flags[0], SIP_OUTGOING) && !ast_strlen_zero(p->theirtag))
 			snprintf(newto, sizeof(newto), "%s;tag=%s", ot, p->theirtag);
 		else if (!ast_test_flag(&p->flags[0], SIP_OUTGOING))
@@ -5373,6 +5378,7 @@
 		ot = newto;
 	}
 
+	SKREP
 	if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
 		add_header(req, "From", of);
 		add_header(req, "To", ot);
@@ -6090,6 +6096,7 @@
 
 	reqprep(&req, p, ast_test_flag(&p->flags[0], SIP_REINVITE_UPDATE) ?  SIP_UPDATE : SIP_INVITE, 0, 1);
 	
+	ast_set_flag(&p->flags[0], SIP_TRANS_OUTGOING);	/* Outbound transaction */
 	add_header(&req, "Allow", ALLOWED_METHODS);
 	add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
 	if (sipdebug)
@@ -6100,7 +6107,6 @@
 	/* Use this as the basis */
 	initialize_initreq(p, &req);
 	p->lastinvite = p->ocseq;
-	ast_set_flag(&p->flags[0], SIP_OUTGOING);
 	return send_request(p, &req, 1, p->ocseq);
 }
 
@@ -6125,7 +6131,6 @@
 	/* Use this as the basis */
 	initialize_initreq(p, &req);
 	p->lastinvite = p->ocseq;
-	ast_set_flag(&p->flags[0], SIP_OUTGOING);
 	return send_request(p, &req, 1, p->ocseq);
 }
 
@@ -13640,8 +13645,6 @@
 		if (ast_test_flag(req, SIP_PKT_DEBUG))
 			ast_verbose("Creating new subscription\n");
 
-		/* This call is no longer outgoing if it ever was */
-		ast_clear_flag(&p->flags[0], SIP_OUTGOING);
 		copy_request(&p->initreq, req);
 		check_via(p, req);
 	} else if (ast_test_flag(req, SIP_PKT_DEBUG) && ast_test_flag(req, SIP_PKT_IGNORE))



More information about the asterisk-commits mailing list