]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
dialplan_functions: wrong srtp use status report of a dialplan function
authorSalah Ahmed <txrubel@gmail.com>
Thu, 2 Aug 2018 19:37:16 +0000 (14:37 -0500)
committerSalah Ahmed <txrubel@gmail.com>
Thu, 2 Aug 2018 21:58:47 +0000 (16:58 -0500)
If asterisk offer an endpoint with SRTP and that endpoint respond
with non srtp, in that case channel(rtp,secure,audio) reply wrong
status.

Why delete flag AST_SRTP_CRYPTO_OFFER_OK while check identical remote_key:
Currently this flag has being set redundantly. In either case identical
or different remote_key this flag has being set. So if we
don't set it while we receive identical remote_key or non SRTP SDP
response then we can take decision of srtp use by using that flag.

ASTERISK-27999

Change-Id: I29dc2843cf4e5ae2604301cb4ff258f1822dc2d7

channels/pjsip/dialplan_functions.c
main/sdp_srtp.c

index 8dd30a5894872e786e24147ddbaec8fb4a583810..b7a74607cc903a0ae592ab9abbdc34ed14215078 100644 (file)
@@ -530,7 +530,13 @@ static int channel_read_rtp(struct ast_channel *chan, const char *type, const ch
        } else if (!strcmp(type, "direct")) {
                ast_copy_string(buf, ast_sockaddr_stringify(&media->direct_media_addr), buflen);
        } else if (!strcmp(type, "secure")) {
-               snprintf(buf, buflen, "%d", media->srtp ? 1 : 0);
+               if (media->srtp) {
+                       struct ast_sdp_srtp *srtp = media->srtp;
+                       int flag = ast_test_flag(srtp, AST_SRTP_CRYPTO_OFFER_OK);
+                       snprintf(buf, buflen, "%d", flag ? 1 : 0);
+               } else {
+                       snprintf(buf, buflen, "%d", 0);
+               }
        } else if (!strcmp(type, "hold")) {
                snprintf(buf, buflen, "%d", media->held ? 1 : 0);
        } else {
index 2b83eee3cf2cc573eea7d52a945382cdb47999f2..12985708ea0465cbc189844a6bb819a0cb750e35 100644 (file)
@@ -350,7 +350,6 @@ int ast_sdp_crypto_process(struct ast_rtp_instance *rtp, struct ast_sdp_srtp *sr
 
        if (!memcmp(crypto->remote_key, remote_key, sizeof(crypto->remote_key))) {
                ast_debug(1, "SRTP remote key unchanged; maintaining current policy\n");
-               ast_set_flag(srtp, AST_SRTP_CRYPTO_OFFER_OK);
                return 0;
        }
        memcpy(crypto->remote_key, remote_key, sizeof(crypto->remote_key));