[Asterisk-cvs] asterisk/channels chan_sip.c,1.453,1.454

markster at lists.digium.com markster at lists.digium.com
Fri Jul 16 11:59:35 CDT 2004


Update of /usr/cvsroot/asterisk/channels
In directory localhost.localdomain:/tmp/cvs-serv11660/channels

Modified Files:
	chan_sip.c 
Log Message:
Only apply acking when method matches, too, when not acking a response


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.453
retrieving revision 1.454
diff -u -d -r1.453 -r1.454
--- chan_sip.c	16 Jul 2004 04:40:54 -0000	1.453
+++ chan_sip.c	16 Jul 2004 15:45:37 -0000	1.454
@@ -783,14 +783,18 @@
 }
 
 /*--- __sip_ack: Acknowledges receipt of a packet and stops retransmission ---*/
-static int __sip_ack(struct sip_pvt *p, int seqno, int resp)
+static int __sip_ack(struct sip_pvt *p, int seqno, int resp, const char *msg)
 {
 	struct sip_pkt *cur, *prev = NULL;
 	int res = -1;
 	int resetinvite = 0;
+	/* Just in case... */
+	if (!msg) msg = "___NEVER___";
 	cur = p->packets;
 	while(cur) {
-		if ((cur->seqno == seqno) && ((cur->flags & FLAG_RESPONSE) == resp)) {
+		if ((cur->seqno == seqno) && ((cur->flags & FLAG_RESPONSE) == resp) &&
+			((cur->flags & FLAG_RESPONSE) || 
+			 (!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) {
 			if (!resp && (seqno == p->pendinginvite)) {
 				ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite);
 				p->pendinginvite = 0;
@@ -815,13 +819,15 @@
 }
 
 /*--- __sip_semi_ack: Acks receipt of packet, keep it around (used for provisional responses) ---*/
-static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp)
+static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp, const char *msg)
 {
 	struct sip_pkt *cur;
 	int res = -1;
 	cur = p->packets;
 	while(cur) {
-		if ((cur->seqno == seqno) && ((cur->flags & FLAG_RESPONSE) == resp)) {
+		if ((cur->seqno == seqno) && ((cur->flags & FLAG_RESPONSE) == resp) &&
+			((cur->flags & FLAG_RESPONSE) || 
+			 (!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) {
 			/* this is our baby */
 			if (cur->retransid > -1)
 				ast_sched_del(sched, cur->retransid);
@@ -6356,9 +6362,9 @@
 		owner->hangupcause = hangup_sip2cause(resp);
 	/* Acknowledge whatever it is destined for */
 	if ((resp >= 100) && (resp <= 199))
-		__sip_semi_ack(p, seqno, 0);
+		__sip_semi_ack(p, seqno, 0, msg);
 	else
-		__sip_ack(p, seqno, 0);
+		__sip_ack(p, seqno, 0, msg);
 	/* Get their tag if we haven't already */
 	to = get_header(req, "To");
 	to = strstr(to, "tag=");
@@ -7318,7 +7324,7 @@
 		/* Make sure we don't ignore this */
 		if (seqno == p->pendinginvite) {
 			p->pendinginvite = 0;
-			__sip_ack(p, seqno, FLAG_RESPONSE);
+			__sip_ack(p, seqno, FLAG_RESPONSE, NULL);
 			if (!ast_strlen_zero(get_header(req, "Content-Type"))) {
 				if (process_sdp(p, req))
 					return -1;




More information about the svn-commits mailing list