[asterisk-commits] rizzo: trunk r44844 - /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Oct 11 01:56:15 MST 2006


Author: rizzo
Date: Wed Oct 11 03:56:09 2006
New Revision: 44844

URL: http://svn.digium.com/view/asterisk?rev=44844&view=rev
Log:
small formatting cleanup

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=44844&r1=44843&r2=44844&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Oct 11 03:56:09 2006
@@ -4500,6 +4500,8 @@
 
 /*! \brief Process SIP SDP offer, select formats and activate RTP channels
 	If offer is rejected, we will not change any properties of the call
+ 	Return 0 on success, a negative value on errors.
+	Must be called after find_sdp().
 */
 static int process_sdp(struct sip_pvt *p, struct sip_request *req)
 {
@@ -8712,6 +8714,16 @@
 	if (ast_strlen_zero(of))
 		return AUTH_SUCCESSFUL;
 
+	if (1) {
+		const char *hdr = (sipmethod == SIP_REGISTER || sipmethod == SIP_SUBSCRIBE) ?
+			"Authorization" : "Proxy-Authorization";
+		if ( (hdr = get_header(req, hdr)) && (hdr = strstr(hdr, "username=\"")) ) {
+			ast_copy_string(from, hdr + strlen("username=\""), sizeof(from));
+			of = from;
+			of = strsep(&of, "\"");
+		}
+	}
+
 	if (!authpeer)	/* If we are looking for a peer, don't check the user objects (or realtime) */
 		user = find_user(of, 1);
 
@@ -11285,10 +11297,7 @@
 	/* RFC3261 says we must treat every 1xx response (but not 100)
 	   that we don't recognize as if it was 183.
 	*/
-	if ((resp > 100) &&
-	    (resp < 200) &&
-	    (resp != 180) &&
-	    (resp != 183))
+	if (resp > 100 && resp < 200 && resp != 180 && resp != 183)
 		resp = 183;
 
 	switch (resp) {
@@ -11297,6 +11306,7 @@
 			sip_cancel_destroy(p);
 		check_pendings(p);
 		break;
+
 	case 180:	/* 180 Ringing */
 		if (!ast_test_flag(req, SIP_PKT_IGNORE))
 			sip_cancel_destroy(p);
@@ -11316,6 +11326,7 @@
 		ast_set_flag(&p->flags[0], SIP_CAN_BYE);
 		check_pendings(p);
 		break;
+
 	case 183:	/* Session progress */
 		if (!ast_test_flag(req, SIP_PKT_IGNORE))
 			sip_cancel_destroy(p);
@@ -11330,6 +11341,7 @@
 		ast_set_flag(&p->flags[0], SIP_CAN_BYE);
 		check_pendings(p);
 		break;
+
 	case 200:	/* 200 OK on invite - someone's answering our call */
 		if (!ast_test_flag(req, SIP_PKT_IGNORE))
 			sip_cancel_destroy(p);
@@ -11428,6 +11440,7 @@
 		ast_set_flag(&p->flags[0], SIP_CAN_BYE);
 		check_pendings(p);
 		break;
+
 	case 407: /* Proxy authentication */
 	case 401: /* Www auth */
 		/* First we ACK */
@@ -11449,6 +11462,7 @@
 			}
 		}
 		break;
+
 	case 403: /* Forbidden */
 		/* First we ACK */
 		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
@@ -11458,22 +11472,26 @@
 		ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
 		ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
 		break;
+
 	case 404: /* Not found */
 		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
 		if (p->owner && !ast_test_flag(req, SIP_PKT_IGNORE))
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
 		ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
 		break;
+
 	case 481: /* Call leg does not exist */
 		/* Could be REFER or INVITE */
 		ast_log(LOG_WARNING, "Re-invite to non-existing call leg on other UA. SIP dialog '%s'. Giving up.\n", p->callid);
 		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
 		break;
+
 	case 491: /* Pending */
 		/* we have to wait a while, then retransmit */
 		/* Transmission is rescheduled, so everything should be taken care of.
 			We should support the retry-after at some point */
 		break;
+
 	case 501: /* Not implemented */
 		if (p->owner)
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);



More information about the asterisk-commits mailing list