]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8910: Properly negotiate SDES when receiving SDP with a=crypto:0
authorCarlos Perez Alcaraz <perez.alcaraz@gmail.com>
Tue, 8 Mar 2016 11:10:43 +0000 (12:10 +0100)
committerCarlos Perez Alcaraz <perez.alcaraz@gmail.com>
Tue, 8 Mar 2016 11:10:43 +0000 (12:10 +0100)
When receiving an SDP with a=crypto:0 with the wanted crypto suite, we should
maintain that crypto tag in the local SDP in order for SDES setup to succeed.

src/include/switch_core_media.h
src/switch_core_media.c

index 65c400ea33d65e2f5cb1f6d3e1df5a0049620861..721e90b3ac20f14f4de2c8f46e205fa82a7ba09b 100644 (file)
@@ -39,6 +39,7 @@
 SWITCH_BEGIN_EXTERN_C
 
 #define SWITCH_MAX_CAND_ACL 25
+#define SWITCH_NO_CRYPTO_TAG -1
 
 typedef enum {
        DTMF_2833,
index a3dba3cfd1bf829c81dae8b9d40f7e28f8cec1ba..2e9eefece63dc00dfae7e9fa14cd72c21f0b5777 100644 (file)
@@ -1065,7 +1065,7 @@ static switch_status_t switch_core_media_build_crypto(switch_media_handle_t *smh
                *p-- = '\0';
        }
 
-       if (!index) index = ctype + 1;
+       if (index == SWITCH_NO_CRYPTO_TAG) index = ctype + 1;
 
        engine->ssec[ctype].local_crypto_key = switch_core_session_sprintf(smh->session, "%d %s inline:%s", index, SUITES[ctype].name, b64_key);
        switch_channel_set_variable_name_printf(smh->session->channel, engine->ssec[ctype].local_crypto_key, "rtp_last_%s_local_crypto_key", type2str(type));
@@ -1461,10 +1461,10 @@ SWITCH_DECLARE(void) switch_core_session_check_outgoing_crypto(switch_core_sessi
 
        for (i = 0; smh->crypto_suite_order[i] != CRYPTO_INVALID; i++) {
                switch_core_media_build_crypto(session->media_handle,
-                                                                          SWITCH_MEDIA_TYPE_AUDIO, 0, smh->crypto_suite_order[i], SWITCH_RTP_CRYPTO_SEND, 0);
+                                                                          SWITCH_MEDIA_TYPE_AUDIO, SWITCH_NO_CRYPTO_TAG, smh->crypto_suite_order[i], SWITCH_RTP_CRYPTO_SEND, 0);
 
                switch_core_media_build_crypto(session->media_handle,
-                                                                          SWITCH_MEDIA_TYPE_VIDEO, 0, smh->crypto_suite_order[i], SWITCH_RTP_CRYPTO_SEND, 0);
+                                                                          SWITCH_MEDIA_TYPE_VIDEO, SWITCH_NO_CRYPTO_TAG, smh->crypto_suite_order[i], SWITCH_RTP_CRYPTO_SEND, 0);
        }
 
 }