]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res/res_pjsip_t38 ensure t38 requests get rejected quickly
authorTorrey Searle <torrey@voxbone.com>
Thu, 22 Jun 2017 12:47:54 +0000 (14:47 +0200)
committerTorrey Searle <tsearle@gmail.com>
Thu, 13 Jul 2017 06:54:41 +0000 (01:54 -0500)
arm the t38 webhook always, so we can correctly reject a
T38 negotiation request when t38 is disabled on a channel

Change-Id: Ib1ffe35aee145d4e0fe61dd012580be11aae079d

res/res_pjsip_t38.c

index 3028d35f600f1e9b5e3ecb695dfb806f88bddd5e..241d8b3c53fe5c4fb7889da0ee19d93018c5ada9 100644 (file)
@@ -403,16 +403,21 @@ static int t38_interpret_parameters(void *obj)
 static struct ast_frame *t38_framehook_write(struct ast_channel *chan,
        struct ast_sip_session *session, struct ast_frame *f)
 {
-       if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_T38_PARAMETERS &&
-               session->endpoint->media.t38.enabled) {
-               struct t38_parameters_task_data *data = t38_parameters_task_data_alloc(session, f);
+       if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_T38_PARAMETERS) {
+               if (session->endpoint->media.t38.enabled) {
+                       struct t38_parameters_task_data *data = t38_parameters_task_data_alloc(session, f);
 
-               if (!data) {
-                       return f;
-               }
+                       if (!data) {
+                               return f;
+                       }
 
-               if (ast_sip_push_task(session->serializer, t38_interpret_parameters, data)) {
-                       ao2_ref(data, -1);
+                       if (ast_sip_push_task(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(session->channel, AST_CONTROL_T38_PARAMETERS, &parameters, sizeof(parameters));
                }
        } else if (f->frametype == AST_FRAME_MODEM) {
                struct ast_sip_session_media *session_media;
@@ -503,10 +508,7 @@ static void t38_attach_framehook(struct ast_sip_session *session)
                return;
        }
 
-       /* Only attach the framehook if t38 is enabled for the endpoint */
-       if (!session->endpoint->media.t38.enabled) {
-               return;
-       }
+       /* Always attach the framehook so we can quickly reject */
 
        ast_channel_lock(session->channel);