]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10853: Fix failed build for mod_dingaling
authorPiotr Gregor <piotr@dataandsignal.com>
Wed, 20 Dec 2017 18:31:50 +0000 (18:31 +0000)
committerMuteesa Fred <muteesafred@hotmail.com>
Tue, 24 Jul 2018 07:21:34 +0000 (07:21 +0000)
Fixes build but must be tested at runtime.

src/include/switch_core_media.h
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/switch_core_media.c

index cf9b321655dd3fa6f2d4388d2d32374a88eb27e7..1c73c2367ace23e3c6dce4af289633ead37e6859 100644 (file)
@@ -210,6 +210,7 @@ SWITCH_DECLARE(void) switch_core_media_set_rtp_session(switch_core_session_t *se
 
 SWITCH_DECLARE(const char *)switch_core_media_get_codec_string(switch_core_session_t *session);
 SWITCH_DECLARE(void) switch_core_media_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str);
+SWITCH_DECLARE(switch_status_t) switch_core_media_add_crypto(switch_core_session_t *session, switch_secure_settings_t *ssec, switch_rtp_crypto_direction_t direction);
 SWITCH_DECLARE(switch_t38_options_t *) switch_core_media_extract_t38_options(switch_core_session_t *session, const char *r_sdp);
 SWITCH_DECLARE(void) switch_core_media_pass_zrtp_hash(switch_core_session_t *session);
 SWITCH_DECLARE(const char *) switch_core_media_get_zrtp_hash(switch_core_session_t *session, switch_media_type_t type, switch_bool_t local);
@@ -309,7 +310,8 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se
 SWITCH_DECLARE(switch_status_t) switch_core_media_check_autoadj(switch_core_session_t *session);
 SWITCH_DECLARE(switch_rtp_crypto_key_type_t) switch_core_media_crypto_str2type(const char *str);
 SWITCH_DECLARE(const char *) switch_core_media_crypto_type2str(switch_rtp_crypto_key_type_t type);
-SWITCH_DECLARE(int) switch_core_media_crypto_keylen(switch_rtp_crypto_key_type_t type);
+SWITCH_DECLARE(int) switch_core_media_crypto_keysalt_len(switch_rtp_crypto_key_type_t type);
+SWITCH_DECLARE(int) switch_core_media_crypto_salt_len(switch_rtp_crypto_key_type_t type);
 SWITCH_DECLARE(char *) switch_core_media_filter_sdp(const char *sdp, const char *cmd, const char *arg);
 SWITCH_DECLARE(char *) switch_core_media_process_sdp_filter(const char *sdp, const char *cmd_buf, switch_core_session_t *session);
 
index 898b21345fdfcdd8ad309a93bdfac2cc46373cca..271719035522e559c81b92726bdecd52047abfdf 100644 (file)
@@ -255,7 +255,6 @@ struct rfc2833_digit {
        int duration;
 };
 
-
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan);
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string);
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string);
@@ -1102,35 +1101,35 @@ static switch_status_t mdl_add_crypto(struct private_object *tech_pvt,
 
 static void try_secure(struct private_object *tech_pvt, ldl_transport_type_t ttype)
 {
+       switch_secure_settings_t        ssec;   /* Used just to wrap over params in a call to switch_rtp_add_crypto_key. */
 
        if (!switch_test_flag(tech_pvt, TFLAG_SECURE)) {
                return;
        }
 
+       memset(&ssec, 0, sizeof(ssec));
 
        if (tech_pvt->transports[ttype].crypto_recv_type) {
                tech_pvt->transports[ttype].crypto_type = tech_pvt->transports[ttype].crypto_recv_type;
        }
 
-
        if (tech_pvt->transports[ttype].crypto_type) {
-               switch_rtp_add_crypto_key(tech_pvt->transports[ttype].rtp_session,
-                                                                 SWITCH_RTP_CRYPTO_SEND, 1, tech_pvt->transports[ttype].crypto_type,
-                                                                 tech_pvt->transports[ttype].local_raw_key, SWITCH_RTP_KEY_LEN);
 
+               memcpy(ssec.local_raw_key, tech_pvt->transports[ttype].local_raw_key, switch_core_media_crypto_keysalt_len(tech_pvt->transports[ttype].crypto_type));
+               ssec.local_crypto_key = switch_core_session_strdup(tech_pvt->session, tech_pvt->transports[ttype].local_crypto_key);
+               switch_core_media_add_crypto(tech_pvt->session, &ssec, SWITCH_RTP_CRYPTO_SEND);
+               switch_rtp_add_crypto_key(tech_pvt->transports[ttype].rtp_session, SWITCH_RTP_CRYPTO_SEND_RTCP, tech_pvt->transports[ttype].crypto_type, &ssec);
 
-               switch_rtp_add_crypto_key(tech_pvt->transports[ttype].rtp_session,
-                                                                 SWITCH_RTP_CRYPTO_RECV, tech_pvt->transports[ttype].crypto_tag,
-                                                                 tech_pvt->transports[ttype].crypto_type,
-                                                                 tech_pvt->transports[ttype].remote_raw_key, SWITCH_RTP_KEY_LEN);
+               memcpy(ssec.remote_raw_key, tech_pvt->transports[ttype].remote_raw_key, switch_core_media_crypto_keysalt_len(tech_pvt->transports[ttype].crypto_type));
+               ssec.remote_crypto_key = switch_core_session_strdup(tech_pvt->session, tech_pvt->transports[ttype].local_crypto_key);
+               switch_core_media_add_crypto(tech_pvt->session, &ssec, SWITCH_RTP_CRYPTO_RECV);
+               switch_rtp_add_crypto_key(tech_pvt->transports[ttype].rtp_session, SWITCH_RTP_CRYPTO_RECV, tech_pvt->transports[ttype].crypto_type, &ssec);
 
                switch_channel_set_variable(tech_pvt->channel, "jingle_secure_audio_confirmed", "true");
 
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_NOTICE,
-                                                 "%s %s crypto confirmed\n", ldl_transport_type_str(ttype), switch_core_session_get_name(tech_pvt->session));
-
-               }
-
+                               "%s %s crypto confirmed\n", ldl_transport_type_str(ttype), switch_core_session_get_name(tech_pvt->session));
+       }
 }
 
 
index 12e8ae812e1666c9ee7a2d950c235f831c33f781..0c546221a3b81044d4300ee69f802498099896da 100644 (file)
@@ -311,6 +311,12 @@ SWITCH_DECLARE(int) switch_core_media_crypto_keysalt_len(switch_rtp_crypto_key_t
        return SUITES[type].keysalt_len;
 }
 
+SWITCH_DECLARE(int) switch_core_media_crypto_salt_len(switch_rtp_crypto_key_type_t type)
+{
+       switch_assert(type < CRYPTO_INVALID);
+       return SUITES[type].salt_len;
+}
+
 static const char* CRYPTO_KEY_PARAM_METHOD[CRYPTO_KEY_PARAM_METHOD_INVALID] = {
        [CRYPTO_KEY_PARAM_METHOD_INLINE] = "inline",
 };
@@ -1343,7 +1349,7 @@ static const char* switch_core_media_crypto_find_key_material_candidate_end(cons
        return end;
 }
 
-switch_status_t switch_core_media_add_crypto(switch_core_session_t *session, switch_secure_settings_t *ssec, switch_rtp_crypto_direction_t direction)
+SWITCH_DECLARE(switch_status_t) switch_core_media_add_crypto(switch_core_session_t *session, switch_secure_settings_t *ssec, switch_rtp_crypto_direction_t direction)
 {
        unsigned char key[SWITCH_RTP_MAX_CRYPTO_LEN];
        switch_rtp_crypto_key_type_t type;