From: Salah Ahmed Date: Thu, 2 Aug 2018 19:37:16 +0000 (-0500) Subject: dialplan_functions: wrong srtp use status report of a dialplan function X-Git-Tag: 13.23.0-rc1~32^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aa91c6f11d30850ef14941336c090da4545d8dc;p=thirdparty%2Fasterisk.git dialplan_functions: wrong srtp use status report of a dialplan function 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 --- diff --git a/channels/pjsip/dialplan_functions.c b/channels/pjsip/dialplan_functions.c index 8dd30a5894..b7a74607cc 100644 --- a/channels/pjsip/dialplan_functions.c +++ b/channels/pjsip/dialplan_functions.c @@ -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 { diff --git a/main/sdp_srtp.c b/main/sdp_srtp.c index 2b83eee3cf..12985708ea 100644 --- a/main/sdp_srtp.c +++ b/main/sdp_srtp.c @@ -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));