Improve the on off switch in ZRTP thanks jim

This commit is contained in:
Brian West 2012-01-24 23:38:53 -06:00
parent 94bcd55e4b
commit d72a54ffe8
1 changed files with 56 additions and 50 deletions

View File

@ -847,7 +847,9 @@ SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool)
zrtp_config.is_mitm = 1; zrtp_config.is_mitm = 1;
zrtp_config.lic_mode = ZRTP_LICENSE_MODE_ACTIVE; 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); 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.event_cb.on_zrtp_protocol_event = zrtp_event_callback;
zrtp_config.cb.misc_cb.on_send_packet = zrtp_send_rtp_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; 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 #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; switch_rtp_t *master_rtp_session = NULL;
int initiator = 0; int initiator = 0;
@ -2169,7 +2171,7 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
#ifdef ENABLE_ZRTP #ifdef ENABLE_ZRTP
/* ZRTP */ /* ZRTP */
if (zrtp_on) { if (zrtp_on && !switch_test_flag((*rtp_session), SWITCH_RTP_FLAG_PROXY_MEDIA)) {
if ((*rtp_session)->zrtp_stream != NULL) { if ((*rtp_session)->zrtp_stream != NULL) {
zrtp_stream_stop((*rtp_session)->zrtp_stream); zrtp_stream_stop((*rtp_session)->zrtp_stream);
@ -2605,6 +2607,7 @@ 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)) { if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) {
#ifdef ENABLE_ZRTP #ifdef ENABLE_ZRTP
/* ZRTP Recv */ /* ZRTP Recv */
if(zrtp_on) {
unsigned int sbytes = (int) *bytes; unsigned int sbytes = (int) *bytes;
zrtp_status_t stat = 0; zrtp_status_t stat = 0;
@ -2625,6 +2628,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
default: default:
break; break;
} }
}
#endif #endif
#ifdef ENABLE_SRTP #ifdef ENABLE_SRTP
@ -2771,6 +2775,7 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
#ifdef ENABLE_ZRTP #ifdef ENABLE_ZRTP
if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
/* ZRTP Recv */ /* ZRTP Recv */
if (bytes) { if (bytes) {
unsigned int sbytes = (int) *bytes; unsigned int sbytes = (int) *bytes;
@ -2794,6 +2799,7 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
break; break;
} }
} }
}
#endif #endif
@ -3022,7 +3028,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
#ifdef ENABLE_ZRTP #ifdef ENABLE_ZRTP
/* ZRTP Send */ /* ZRTP Send */
if (1) { if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
unsigned int sbytes = (int) bytes; unsigned int sbytes = (int) bytes;
zrtp_status_t stat = zrtp_status_fail; zrtp_status_t stat = zrtp_status_fail;
@ -3906,7 +3912,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
#endif #endif
#ifdef ENABLE_ZRTP #ifdef ENABLE_ZRTP
/* ZRTP Send */ /* ZRTP Send */
if (1) { if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
unsigned int sbytes = (int) bytes; unsigned int sbytes = (int) bytes;
zrtp_status_t stat = zrtp_status_fail; zrtp_status_t stat = zrtp_status_fail;
@ -4027,7 +4033,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
#ifdef ENABLE_ZRTP #ifdef ENABLE_ZRTP
/* ZRTP Send */ /* ZRTP Send */
if (1) { if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
unsigned int sbytes = (int) bytes; unsigned int sbytes = (int) bytes;
zrtp_status_t stat = zrtp_status_fail; zrtp_status_t stat = zrtp_status_fail;
@ -4356,7 +4362,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
#endif #endif
#ifdef ENABLE_ZRTP #ifdef ENABLE_ZRTP
/* ZRTP Send */ /* ZRTP Send */
if (1) { if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
unsigned int sbytes = (int) bytes; unsigned int sbytes = (int) bytes;
zrtp_status_t stat = zrtp_status_fail; zrtp_status_t stat = zrtp_status_fail;