[Asterisk-code-review] res pjsip t38.c: Be smarter about how we respond when T.38 i... (asterisk[master])

Joshua Colp asteriskteam at digium.com
Tue Jul 10 07:21:46 CDT 2018


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9335 )

Change subject: res_pjsip_t38.c: Be smarter about how we respond when T.38 is disabled.
......................................................................

res_pjsip_t38.c: Be smarter about how we respond when T.38 is disabled.

We were blindly responding with AST_T38_REFUSED when ANY T.38 control
frame came accross the bridge.  This causes T.38 Gateway to get confused
and the T.38 session to get in a strange state.

* Made the T.38 framehook only respond to request frames and ignore
response frames.

ASTERISK-27657
ASTERISK-27080

Change-Id: I5fb5967c7d1efb30a7ff375f82887ca82a55b05b
---
M res/res_pjsip_t38.c
1 file changed, 31 insertions(+), 10 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  George Joseph: Looks good to me, approved



diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c
index 3f4110f..6efe0d7 100644
--- a/res/res_pjsip_t38.c
+++ b/res/res_pjsip_t38.c
@@ -507,21 +507,42 @@
 		return f;
 	}
 
-	if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_T38_PARAMETERS) {
+	if (f->frametype == AST_FRAME_CONTROL
+		&& f->subclass.integer == AST_CONTROL_T38_PARAMETERS) {
 		if (channel->session->endpoint->media.t38.enabled) {
-			struct t38_parameters_task_data *data = t38_parameters_task_data_alloc(channel->session, f);
+			struct t38_parameters_task_data *data;
 
-			if (!data) {
-				return f;
-			}
-
-			if (ast_sip_push_task(channel->session->serializer, t38_interpret_parameters, data)) {
+			data = t38_parameters_task_data_alloc(channel->session, f);
+			if (data
+				&& ast_sip_push_task(channel->session->serializer,
+					t38_interpret_parameters, data)) {
 				ao2_ref(data, -1);
 			}
 		} else {
-			struct ast_control_t38_parameters parameters = { .request_response = AST_T38_REFUSED, };
-			ast_debug(2, "T.38 support not enabled, rejecting T.38 control packet\n");
-			ast_queue_control_data(chan, AST_CONTROL_T38_PARAMETERS, &parameters, sizeof(parameters));
+			static const struct ast_control_t38_parameters rsp_refused = {
+				.request_response = AST_T38_REFUSED,
+			};
+			static const struct ast_control_t38_parameters rsp_terminated = {
+				.request_response = AST_T38_TERMINATED,
+			};
+			const struct ast_control_t38_parameters *parameters = f->data.ptr;
+
+			switch (parameters->request_response) {
+			case AST_T38_REQUEST_NEGOTIATE:
+				ast_debug(2, "T.38 support not enabled on %s, refusing T.38 negotiation\n",
+					ast_channel_name(chan));
+				ast_queue_control_data(chan, AST_CONTROL_T38_PARAMETERS,
+					&rsp_refused, sizeof(rsp_refused));
+				break;
+			case AST_T38_REQUEST_TERMINATE:
+				ast_debug(2, "T.38 support not enabled on %s, 'terminating' T.38 session\n",
+					ast_channel_name(chan));
+				ast_queue_control_data(chan, AST_CONTROL_T38_PARAMETERS,
+					&rsp_terminated, sizeof(rsp_terminated));
+				break;
+			default:
+				break;
+			}
 		}
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/9335
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5fb5967c7d1efb30a7ff375f82887ca82a55b05b
Gerrit-Change-Number: 9335
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180710/7c7f0116/attachment-0001.html>


More information about the asterisk-code-review mailing list