[asterisk-commits] irroot: trunk r319087 - in /trunk: ./ channels/ channels/sip/include/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 16 09:57:16 CDT 2011


Author: irroot
Date: Mon May 16 09:56:53 2011
New Revision: 319087

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=319087
Log:
 When a error in T.38 negotiation happens or its rejected on a channel the
 state of the channel reverts to unknown this should be rejected.
 
 this is important for negotiating T.38 gateway see #13405

 This patch adds a option T38_REJECTED that behaves as T38_DISABLED except it reports state rejected.

 Trivial Change to res_fax to honnor UNAVAILABLE and REJECTED states.

 (closes issue #18889)
 Reported by: irroot
 Tested by: irroot, darkbasic, 	mnicholson

 Review: https://reviewboard.asterisk.org/r/1115


Modified:
    trunk/CHANGES
    trunk/channels/chan_sip.c
    trunk/channels/sip/include/sip.h
    trunk/res/res_fax.c

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=319087&r1=319086&r2=319087
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Mon May 16 09:56:53 2011
@@ -199,6 +199,7 @@
    res_stun_monitor module support in chan_sip.
  * Addition of the 'auth_options_requests' option for turning on and off
    authentication for OPTIONS requests in chan_sip.
+ * Add T38 support for REJECTED state where T.38 Negotiation is explicitly rejected.
 
 
 IAX2 Changes

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=319087&r1=319086&r2=319087
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon May 16 09:56:53 2011
@@ -4301,6 +4301,9 @@
 			case T38_ENABLED:
 				state = T38_STATE_NEGOTIATED;
 				break;
+			case T38_REJECTED:
+				state = T38_STATE_REJECTED;
+				break;
 			default:
 				state = T38_STATE_UNKNOWN;
 			}
@@ -4961,6 +4964,7 @@
 		parameters.request_response = AST_T38_NEGOTIATED;
 		ast_udptl_set_tag(p->udptl, "SIP/%s", p->username);
 		break;
+	case T38_REJECTED:
 	case T38_DISABLED:
 		if (old == T38_ENABLED) {
 			parameters.request_response = AST_T38_TERMINATED;
@@ -6528,11 +6532,11 @@
 	case AST_T38_REQUEST_NEGOTIATE:         /* Request T38 */
 		/* Negotiation can not take place without a valid max_ifp value. */
 		if (!parameters->max_ifp) {
-			change_t38_state(p, T38_DISABLED);
 			if (p->t38.state == T38_PEER_REINVITE) {
 				AST_SCHED_DEL_UNREF(sched, p->t38id, dialog_unref(p, "when you delete the t38id sched, you should dec the refcount for the stored dialog ptr"));
 				transmit_response_reliable(p, "488 Not acceptable here", &p->initreq);
 			}
+			change_t38_state(p, T38_REJECTED);
 			break;
 		} else if (p->t38.state == T38_PEER_REINVITE) {
 			AST_SCHED_DEL_UNREF(sched, p->t38id, dialog_unref(p, "when you delete the t38id sched, you should dec the refcount for the stored dialog ptr"));
@@ -6570,7 +6574,7 @@
 	case AST_T38_REQUEST_TERMINATE:         /* Shutdown T38 */
 		if (p->t38.state == T38_PEER_REINVITE) {
 			AST_SCHED_DEL_UNREF(sched, p->t38id, dialog_unref(p, "when you delete the t38id sched, you should dec the refcount for the stored dialog ptr"));
-			change_t38_state(p, T38_DISABLED);
+			change_t38_state(p, T38_REJECTED);
 			transmit_response_reliable(p, "488 Not acceptable here", &p->initreq);
 		} else if (p->t38.state == T38_ENABLED)
 			transmit_reinvite_with_sdp(p, FALSE, FALSE);
@@ -9141,7 +9145,7 @@
 		}
 	}
 
-	if ((portno == -1) && (p->t38.state != T38_DISABLED)) {
+	if ((portno == -1) && (p->t38.state != T38_DISABLED) && (p->t38.state != T38_REJECTED)) {
 		ast_debug(3, "Have T.38 but no audio, accepting offer anyway\n");
 		res = 0;
 		goto process_sdp_cleanup;
@@ -19081,7 +19085,7 @@
 	} else  if (!strcasecmp(data, "peername")) {
 		ast_copy_string(buf, p->peername, len);
 	} else if (!strcasecmp(data, "t38passthrough")) {
-		if (p->t38.state == T38_DISABLED) {
+		if ((p->t38.state == T38_DISABLED) || (p->t38.state == T38_REJECTED)) {
 			ast_copy_string(buf, "0", len);
 		} else { /* T38 is offered or enabled in this call */
 			ast_copy_string(buf, "1", len);
@@ -19852,7 +19856,7 @@
 	case 606: /* Not Acceptable */
 		xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
 		if (p->udptl && p->t38.state == T38_LOCAL_REINVITE) {
-			change_t38_state(p, T38_DISABLED);
+			change_t38_state(p, T38_REJECTED);
 			/* Try to reset RTP timers */
 			//ast_rtp_set_rtptimers_onhold(p->rtp);
 
@@ -21573,7 +21577,7 @@
 	 * want to abort the negotiation process
 	 */
 	if (p->t38id != -1) {
-		change_t38_state(p, T38_DISABLED);
+		change_t38_state(p, T38_REJECTED);
 		transmit_response_reliable(p, "488 Not acceptable here", &p->initreq);
 		p->t38id = -1;
 		dialog_unref(p, "unref the dialog ptr from sip_t38_abort, because it held a dialog ptr");
@@ -22449,7 +22453,7 @@
 			} else if (p->t38.state == T38_ENABLED) {
 				ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
 				transmit_response_with_t38_sdp(p, "200 OK", req, (reinvite ? XMIT_RELIABLE : (req->ignore ?  XMIT_UNRELIABLE : XMIT_CRITICAL)));
-			} else if (p->t38.state == T38_DISABLED) {
+			} else if ((p->t38.state == T38_DISABLED) || (p->t38.state == T38_REJECTED)) {
 				/* If this is not a re-invite or something to ignore - it's critical */
 				if (p->srtp && !ast_test_flag(p->srtp, SRTP_CRYPTO_OFFER_OK)) {
 					ast_log(LOG_WARNING, "Target does not support required crypto\n");

Modified: trunk/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/include/sip.h?view=diff&rev=319087&r1=319086&r2=319087
==============================================================================
--- trunk/channels/sip/include/sip.h (original)
+++ trunk/channels/sip/include/sip.h Mon May 16 09:56:53 2011
@@ -594,7 +594,8 @@
 	T38_DISABLED = 0,     /*!< Not enabled */
 	T38_LOCAL_REINVITE,   /*!< Offered from local - REINVITE */
 	T38_PEER_REINVITE,    /*!< Offered from peer - REINVITE */
-	T38_ENABLED           /*!< Negotiated (enabled) */
+	T38_ENABLED,          /*!< Negotiated (enabled) */
+	T38_REJECTED          /*!< Refused */
 };
 
 /*! \brief Parameters to know status of transfer */

Modified: trunk/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_fax.c?view=diff&rev=319087&r1=319086&r2=319087
==============================================================================
--- trunk/res/res_fax.c (original)
+++ trunk/res/res_fax.c Mon May 16 09:56:53 2011
@@ -991,6 +991,7 @@
 	case T38_STATE_UNKNOWN:
 		details->caps |= AST_FAX_TECH_T38;
 		break;
+	case T38_STATE_REJECTED:
 	case T38_STATE_UNAVAILABLE:
 		details->caps |= AST_FAX_TECH_AUDIO;
 		break;
@@ -1510,6 +1511,7 @@
 	);
 	struct ast_flags opts = { 0, };
 	struct manager_event_info info;
+	enum ast_t38_state t38state;
 
 	/* initialize output channel variables */
 	pbx_builtin_setvar_helper(chan, "FAXSTATUS", "FAILED");
@@ -1631,7 +1633,8 @@
 		details->option.statusevents = AST_FAX_OPTFLAG_TRUE;
 	}
 
-	if ((ast_channel_get_t38_state(chan) == T38_STATE_UNAVAILABLE) ||
+	t38state = ast_channel_get_t38_state(chan);
+	if ((t38state == T38_STATE_UNAVAILABLE) || (t38state == T38_STATE_REJECTED) ||
 	    ast_test_flag(&opts, OPT_ALLOWAUDIO) ||
 	    ast_test_flag(&opts, OPT_FORCE_AUDIO)) {
 		details->option.allow_audio = AST_FAX_OPTFLAG_TRUE;
@@ -1972,6 +1975,7 @@
 	);
 	struct ast_flags opts = { 0, };
 	struct manager_event_info info;
+	enum ast_t38_state t38state;
 
 	/* initialize output channel variables */
 	pbx_builtin_setvar_helper(chan, "FAXSTATUS", "FAILED");
@@ -2112,7 +2116,8 @@
 		details->option.statusevents = AST_FAX_OPTFLAG_TRUE;
 	}
 
-	if ((ast_channel_get_t38_state(chan) == T38_STATE_UNAVAILABLE) ||
+	t38state = ast_channel_get_t38_state(chan);
+	if ((t38state == T38_STATE_UNAVAILABLE) || (t38state == T38_STATE_REJECTED) ||
 	    ast_test_flag(&opts, OPT_ALLOWAUDIO) ||
 	    ast_test_flag(&opts, OPT_FORCE_AUDIO)) {
 		details->option.allow_audio = AST_FAX_OPTFLAG_TRUE;




More information about the asterisk-commits mailing list