[Asterisk-cvs] asterisk/channels chan_sip.c,1.835,1.836

kpfleming kpfleming
Fri Sep 2 15:23:39 CDT 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv13796/channels

Modified Files:
	chan_sip.c 
Log Message:
ensure that notify message sent out have the correct state (issue #5088 with minor mods)


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.835
retrieving revision 1.836
diff -u -d -r1.835 -r1.836
--- chan_sip.c	1 Sep 2005 23:01:54 -0000	1.835
+++ chan_sip.c	2 Sep 2005 19:24:32 -0000	1.836
@@ -1042,7 +1042,7 @@
 
 /*--- append_history: Append to SIP dialog history */
 /*	Always returns 0 */
-static int append_history(struct sip_pvt *p, char *event, char *data)
+static int append_history(struct sip_pvt *p, const char *event, const char *data)
 {
 	struct sip_history *hist, *prev;
 	char *c;
@@ -9947,7 +9947,7 @@
 {
 	int gotdest;
 	int res = 0;
-	int firststate = 0;
+	int firststate = AST_EXTENSION_REMOVED;
 
 	if (p->initreq.headers) {	
 		/* We already have a dialog */
@@ -10066,13 +10066,6 @@
 			}
 			if (p->subscribed != NONE)
 				p->stateid = ast_extension_state_add(p->context, p->exten, cb_extensionstate, p);
-			firststate = ast_extension_state(NULL, p->context, p->exten);
-			if (firststate < 0) {
-				ast_log(LOG_ERROR, "Got SUBSCRIBE for extensions without hint. Please add hint to %s in context %s\n", p->exten, p->context);
-				transmit_response(p, "404 Not found", req);
-				ast_set_flag(p, SIP_NEEDDESTROY);	
-				return 0;
-			}
 		}
 	}
 
@@ -10084,8 +10077,7 @@
 			ast_set_flag(p, SIP_NEEDDESTROY);	
 			return 0;
 		}
-		/* TODO: Do we need this any longer? And what exactly to remove? */
-		/* The next line can be removed if the SNOM200 Expires bug is fixed */
+		/* The next 4 lines can be removed if the SNOM Expires bug is fixed */
 		if (p->subscribed == DIALOG_INFO_XML) {  
 			if (p->expiry > max_expiry)
 				p->expiry = max_expiry;
@@ -10096,8 +10088,16 @@
 		if (p->autokillid > -1)
 			sip_cancel_destroy(p);	/* Remove subscription expiry for renewals */
 		sip_scheddestroy(p, (p->expiry + 10) * 1000);	/* Set timer for destruction of call at expiration */
-		transmit_state_notify(p, firststate, 1, 1);	/* Send first notification */
-		append_history(p, "Subscribestatus", "active");
+
+		if ((firststate = ast_extension_state(NULL, p->context, p->exten)) < 0) {
+			ast_log(LOG_ERROR, "Got SUBSCRIBE for extensions without hint. Please add hint to %s in context %s\n", p->exten, p->context);
+			transmit_response(p, "404 Not found", req);
+			ast_set_flag(p, SIP_NEEDDESTROY);	
+			return 0;
+		} else {
+			transmit_state_notify(p, firststate, 1, 1);	/* Send first notification */
+			append_history(p, "Subscribestatus", ast_extension_state2str(firststate));
+		}
 	}
 	return 1;
 }




More information about the svn-commits mailing list