diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 66055012c8..7d61fc9eab 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -847,7 +847,9 @@ SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool) zrtp_config.is_mitm = 1; zrtp_config.lic_mode = ZRTP_LICENSE_MODE_ACTIVE; switch_snprintf(zrtp_cache_path, sizeof(zrtp_cache_path), "%s%szrtp.dat", SWITCH_GLOBAL_dirs.db_dir, SWITCH_PATH_SEPARATOR); - zrtp_zstrcpyc(ZSTR_GV(zrtp_config.def_cache_path), zrtp_cache_path); + zrtp_zstrcpyc((zrtp_stringn_t*)zrtp_config.def_cache_path.buffer, zrtp_cache_path); + zrtp_config.def_cache_path.length = strlen(zrtp_cache_path); + zrtp_config.def_cache_path.max_length = 255; zrtp_config.cb.event_cb.on_zrtp_protocol_event = zrtp_event_callback; zrtp_config.cb.misc_cb.on_send_packet = zrtp_send_rtp_callback; zrtp_config.cb.event_cb.on_zrtp_security_event = zrtp_event_callback; @@ -1674,7 +1676,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session } #ifdef ENABLE_ZRTP - if (zrtp_on) { + if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) { switch_rtp_t *master_rtp_session = NULL; int initiator = 0; @@ -2169,7 +2171,7 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session) #ifdef ENABLE_ZRTP /* ZRTP */ - if (zrtp_on) { + if (zrtp_on && !switch_test_flag((*rtp_session), SWITCH_RTP_FLAG_PROXY_MEDIA)) { if ((*rtp_session)->zrtp_stream != NULL) { zrtp_stream_stop((*rtp_session)->zrtp_stream); @@ -2605,25 +2607,27 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) { #ifdef ENABLE_ZRTP /* ZRTP Recv */ - - unsigned int sbytes = (int) *bytes; - zrtp_status_t stat = 0; - - stat = zrtp_process_srtp(rtp_session->zrtp_stream, (void *) &rtp_session->recv_msg, &sbytes); - - switch (stat) { - case zrtp_status_ok: - *bytes = sbytes; - break; - case zrtp_status_drop: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: zRTP protection drop with code %d\n", stat); - *bytes = 0; - return SWITCH_STATUS_SUCCESS; - case zrtp_status_fail: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: zRTP protection fail with code %d\n", stat); - return SWITCH_STATUS_FALSE; - default: - break; + if(zrtp_on) { + + unsigned int sbytes = (int) *bytes; + zrtp_status_t stat = 0; + + stat = zrtp_process_srtp(rtp_session->zrtp_stream, (void *) &rtp_session->recv_msg, &sbytes); + + switch (stat) { + case zrtp_status_ok: + *bytes = sbytes; + break; + case zrtp_status_drop: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: zRTP protection drop with code %d\n", stat); + *bytes = 0; + return SWITCH_STATUS_SUCCESS; + case zrtp_status_fail: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: zRTP protection fail with code %d\n", stat); + return SWITCH_STATUS_FALSE; + default: + break; + } } #endif @@ -2771,27 +2775,29 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t #ifdef ENABLE_ZRTP - /* ZRTP Recv */ - if (bytes) { - unsigned int sbytes = (int) *bytes; - zrtp_status_t stat = 0; - - stat = zrtp_process_srtcp(rtp_session->zrtp_stream, (void *) &rtp_session->rtcp_recv_msg, &sbytes); - - switch (stat) { - case zrtp_status_ok: - *bytes = sbytes; - break; - case zrtp_status_drop: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: zRTP protection drop with code %d\n", stat); - *bytes = 0; - break; - case zrtp_status_fail: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: zRTP protection fail with code %d\n", stat); - *bytes = 0; - break; - default: - break; + if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) { + /* ZRTP Recv */ + if (bytes) { + unsigned int sbytes = (int) *bytes; + zrtp_status_t stat = 0; + + stat = zrtp_process_srtcp(rtp_session->zrtp_stream, (void *) &rtp_session->rtcp_recv_msg, &sbytes); + + switch (stat) { + case zrtp_status_ok: + *bytes = sbytes; + break; + case zrtp_status_drop: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: zRTP protection drop with code %d\n", stat); + *bytes = 0; + break; + case zrtp_status_fail: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error: zRTP protection fail with code %d\n", stat); + *bytes = 0; + break; + default: + break; + } } } #endif @@ -3022,12 +3028,12 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ #ifdef ENABLE_ZRTP /* ZRTP Send */ - if (1) { + if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) { unsigned int sbytes = (int) bytes; zrtp_status_t stat = zrtp_status_fail; - + stat = zrtp_process_rtcp(other_rtp_session->zrtp_stream, (void *) &other_rtp_session->rtcp_send_msg, &sbytes); - + switch (stat) { case zrtp_status_ok: break; @@ -3042,7 +3048,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ default: break; } - + bytes = sbytes; } #endif @@ -3906,7 +3912,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, #endif #ifdef ENABLE_ZRTP /* ZRTP Send */ - if (1) { + if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) { unsigned int sbytes = (int) bytes; zrtp_status_t stat = zrtp_status_fail; @@ -4027,7 +4033,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, #ifdef ENABLE_ZRTP /* ZRTP Send */ - if (1) { + if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) { unsigned int sbytes = (int) bytes; zrtp_status_t stat = zrtp_status_fail; @@ -4356,7 +4362,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session, #endif #ifdef ENABLE_ZRTP /* ZRTP Send */ - if (1) { + if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) { unsigned int sbytes = (int) bytes; zrtp_status_t stat = zrtp_status_fail;