[svn-commits] branch oej/02-labarea r21238 - /team/oej/02-labarea/channels/chan_sip.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Apr 18 16:47:59 MST 2006


Author: oej
Date: Tue Apr 18 18:47:56 2006
New Revision: 21238

URL: http://svn.digium.com/view/asterisk?rev=21238&view=rev
Log:
Update

Modified:
    team/oej/02-labarea/channels/chan_sip.c

Modified: team/oej/02-labarea/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/02-labarea/channels/chan_sip.c?rev=21238&r1=21237&r2=21238&view=diff
==============================================================================
--- team/oej/02-labarea/channels/chan_sip.c (original)
+++ team/oej/02-labarea/channels/chan_sip.c Tue Apr 18 18:47:56 2006
@@ -228,10 +228,11 @@
 
 enum xmittype {
 	XMIT_CRITICAL = 2,		/*!< Transmit critical SIP message reliably, with re-transmits.
-							If it fails, it's critical and will cause a teardown of the session */
+					If it fails, it's critical and will cause a teardown of the session */
 	XMIT_RELIABLE = 1,		/*!< Transmit SIP message reliably, with re-transmits */
 	XMIT_UNRELIABLE = 0,		/*!< Transmit SIP message without bothering with re-transmits */
 };
+
 
 enum subscriptiontype { 
 	NONE = 0,
@@ -317,6 +318,11 @@
 	{ SIP_INFO,	 NO_RTP, "INFO" },
 	{ SIP_CANCEL,	 NO_RTP, "CANCEL" },
 	{ SIP_PUBLISH,	 NO_RTP, "PUBLISH" }
+};
+
+enum sip_header {
+	SIP_HEADER_FROM,
+	SIP_HEADER_TO,
 };
 
 /*!  Define SIP option tags, used in Require: and Supported: headers 
@@ -1095,7 +1101,7 @@
 static void sip_dump_history(struct sip_pvt *dialog);	/* Dump history to LOG_DEBUG at end of dialog, before destroying data */
 static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype);
 static int transmit_state_notify(struct sip_pvt *p, int state, int full);
-static const char *gettag(const struct sip_request *req, char *header, char *tagbuf, int tagbufsize);
+static const char *gettag(const struct sip_request *req, enum sip_header header, char *tagbuf, int tagbufsize);
 static int find_sip_method(const char *msg);
 static unsigned int parse_sip_options(struct sip_pvt *pvt, const char *supported);
 static void sip_destroy(struct sip_pvt *p);
@@ -2758,7 +2764,7 @@
 				__sip_pretend_ack(p);
 
 				/* Send a new request: CANCEL */
-				transmit_request_with_auth(p, SIP_CANCEL, p->ocseq, XMIT_RELIABLE, TRUE);
+				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);
@@ -3491,11 +3497,6 @@
 	char totag[128];
 	char fromtag[128];
 
-	req->callid = get_header(req, "Call-ID");
-	req->from = get_header(req, "From");
-	req->to = get_header(req, "To");
-	req->cseq = get_header(req, "Cseq");
-	req->via = get_header(req, "Via");
 
 	//SKREP
 	ast_log(LOG_DEBUG, "---Find_call::: Call-ID: %s\n", req->callid);
@@ -3512,9 +3513,9 @@
 		   For Asterisk to behave correctly, you need to turn on pedanticsipchecking
 		   in sip.conf
 		   */
-		if (gettag(req, "To", totag, sizeof(totag)))
+		if (gettag(req, SIP_HEADER_TO, totag, sizeof(totag)))
 			ast_set_flag(req, SIP_PKT_WITH_TOTAG);	/* Used in handle_request/response */
-		gettag(req, "From", fromtag, sizeof(fromtag));
+		gettag(req, SIP_HEADER_FROM, fromtag, sizeof(fromtag));
 
 		tag = (req->method == SIP_RESPONSE) ? totag : fromtag;
 
@@ -3760,6 +3761,11 @@
 		ast_log(LOG_WARNING, "Odd content, extra stuff left over ('%s')\n", c);
 	/* Split up the first line parts */
 	determine_firstline_parts(req);
+	req->callid = get_header(req, "Call-ID");
+	req->from = get_header(req, "From");
+	req->to = get_header(req, "To");
+	req->cseq = get_header(req, "Cseq");
+	req->via = get_header(req, "Via");
 }
 
 /*! \brief Process SIP SDP and activate RTP channels*/
@@ -3847,6 +3853,10 @@
 			vportno = x;
 			/* Scan through the RTP payload types specified in a "m=" line: */
 			for (codecs = m + len; !ast_strlen_zero(codecs); codecs = ast_skip_blanks(codecs + len)) {
+				/* XXX Crashes on 
+					m=video 7160/2 RTP/AVP 34
+				 	(RADvision)
+				*/
 				if (sscanf(codecs, "%d%n", &codec, &len) != 1) {
 					ast_log(LOG_WARNING, "Error in codec string '%s'\n", codecs);
 					return -1;
@@ -4420,7 +4430,7 @@
 	snprintf(p->lastmsg, sizeof(p->lastmsg), "Tx: %s", sip_methods[sipmethod].text);
 	
 	if (!seqno) {
-		p->ocseq++;
+		p->ocseq++;	/* Increment our Cseq */
 		seqno = p->ocseq;
 	}
 	
@@ -10291,7 +10301,7 @@
 	if (ast_strlen_zero(p->theirtag) || (resp >= 200)) {
 		char tag[128];
 
-		gettag(req, "To", tag, sizeof(tag));
+		gettag(req, SIP_HEADER_TO, tag, sizeof(tag));
 		ast_string_field_set(p, theirtag, tag);
 	}
 	if (p->relatedpeer && p->method == SIP_OPTIONS) {
@@ -10498,12 +10508,12 @@
 		if (ast_test_flag(req, SIP_PKT_DEBUG))
 			ast_verbose("SIP Response message for INCOMING dialog %s arrived\n", msg);
 
-		if (resp == 200) {
+		if (resp == 200)  {
 			/* Tags in early session is replaced by the tag in 200 OK, which is 
 		  	the final reply to our INVITE */
-			char tag[128];
-
-			gettag(req, "To", tag, sizeof(tag));
+			char tag[BUFSIZ];
+
+			gettag(req, SIP_HEADER_TO, tag, sizeof(tag));
 			ast_string_field_set(p, theirtag, tag);
 		}
 
@@ -10750,24 +10760,25 @@
 	return 0;
 }
 
-/*! \brief Get tag from packet */
-static const char *gettag(const struct sip_request *req, char *header, char *tagbuf, int tagbufsize) 
-{
-	const char *thetag;
+/*! \brief Get tag from incoming SIP packet */
+static const char *gettag(const struct sip_request *req, enum sip_header header, char *tagbuf, int tagbufsize) 
+{
+	char *thetag;
 
 	if (!tagbuf)
 		return NULL;
 	tagbuf[0] = '\0'; 	/* reset the buffer */
-	thetag = get_header(req, header);
-	thetag = strcasestr(thetag, ";tag=");
-	if (thetag) {
+	if (header == SIP_HEADER_FROM)
+		thetag = ast_strdupa(req->from);
+	else
+		thetag = ast_strdupa(req->to);
+	if ((thetag = strcasestr(thetag, ";tag="))) {
 		char *sep;
 		thetag += 5;
-		ast_copy_string(tagbuf, thetag, tagbufsize);
-		sep = strchr(tagbuf, ';');
-		if (sep)
+		if ((sep = strchr(thetag, ';')))
 			*sep = '\0';
 	}
+	ast_copy_string(tagbuf, thetag, tagbufsize);
 	return thetag;	/* XXX maybe this should be tagbuf instead ? */
 }
 
@@ -11733,29 +11744,6 @@
 	if (option_debug > 3)
 		ast_log(LOG_DEBUG, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, cmd); 
 
-	/* Check for loop in INVITE */
-	if (p->icseq && p->icseq == seqno && req->method == SIP_INVITE) {
-		char *branch = ast_strdupa(req->via);
-		char *tag;
-		char *s;
-		int ok = FALSE;
-		if (ast_strlen_zero(branch)) {
-			ast_log(LOG_DEBUG, "**** NO VIA HEADER in req->via\n");
-			branch = ast_strdupa(get_header(req, "Via"));
-		}
-		tag = strcasestr(branch, ";branch=");
-		if (tag) {
-			if ((s = strchr(tag, ';')))
-				*s = '\0';
-			tag += 8;
-			ast_log(LOG_DEBUG, "### Comparing our branch %s with request branch %s\n", p->viabranchtag, tag);
-				
-		}
-		ok = TRUE;
-		//SKREP
-		ast_log(LOG_DEBUG, "**** Our initial VIA %s - This req VIA %s\n", p->initreq.via, req->via);
-		//if (strcasecmp(p->viabranchtag, ???? )
-	}
 
 	if (p->icseq && (p->icseq > seqno)) {
 		if (option_debug)
@@ -11783,11 +11771,37 @@
 		   increasing */
 		p->icseq = seqno;
 
+	/* Check for loop in INVITE */
+	if (p->icseq && p->icseq == seqno && req->method == SIP_INVITE) {
+		char *branch = ast_strdupa(req->via);
+		char *tag;
+		char *s;
+		int ok = FALSE;
+		if (ast_strlen_zero(branch)) {
+			ast_log(LOG_DEBUG, "**** NO VIA HEADER in req->via\n");
+			branch = ast_strdupa(get_header(req, "Via"));
+		}
+		tag = strcasestr(branch, ";branch=");
+		if (tag) {
+			if ((s = strchr(tag, ';')))
+				*s = '\0';
+			tag += 8;
+			ast_log(LOG_DEBUG, "### Comparing our branch %s with request branch %s\n", p->viabranchtag, tag);
+				
+		}
+		ok = TRUE;
+		//SKREP
+		ast_log(LOG_DEBUG, "**** Our initial VIA %s - This req VIA %s\n", p->initreq.via, req->via);
+		//if (strcasecmp(p->viabranchtag, ???? )
+	} else {
+		ast_log(LOG_DEBUG, "**** Different: p->icseq %d secno %d \n", p->icseq, seqno);
+	}
+
 	/* Find their tag if we haven't got it */
 	if (ast_strlen_zero(p->theirtag)) {
-		char tag[128];
-
-		gettag(req, "From", tag, sizeof(tag));
+		char tag[BUFSIZ];
+
+		gettag(req, SIP_HEADER_FROM, tag, sizeof(tag));
 		ast_string_field_set(p, theirtag, tag);
 	}
 	snprintf(p->lastmsg, sizeof(p->lastmsg), "Rx: %s", cmd);



More information about the svn-commits mailing list