stream->write_function(stream, "NOMEDIA \t%s\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
stream->write_function(stream, "LATE-NEG \t%s\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
stream->write_function(stream, "PROXY-MEDIA \t%s\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
+ stream->write_function(stream, "ZRTP-PASSTHRU \t%s\n", sofia_test_flag(profile, TFLAG_ZRTP_PASSTHRU) ? "true" : "false");
stream->write_function(stream, "AGGRESSIVENAT \t%s\n",
sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
stream->write_function(stream, "STUN-ENABLED \t%s\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
stream->write_function(stream, " <nomedia>%s</nomedia>\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
stream->write_function(stream, " <late-neg>%s</late-neg>\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
stream->write_function(stream, " <proxy-media>%s</proxy-media>\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
+ stream->write_function(stream, " <zrtp-passthru>%s</zrtp-passthru>\n", sofia_test_flag(profile, TFLAG_ZRTP_PASSTHRU) ? "true" : "false");
stream->write_function(stream, " <aggressive-nat>%s</aggressive-nat>\n",
sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
stream->write_function(stream, " <stun-enabled>%s</stun-enabled>\n",
sofia_clear_flag(ctech_pvt, TFLAG_ENABLE_SOA);
}
+ if (switch_channel_test_flag(o_channel, CF_ZRTP_PASSTHRU_REQ)) {
+ const char *x = NULL;
+ sofia_glue_pass_zrtp_hash2(session, nsession);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[zrtp_passthru] Setting a-leg inherit_codec=true\n");
+ switch_channel_set_variable(o_channel, "inherit_codec", "true");
+ if ((x = switch_channel_get_variable(o_channel, "ep_codec_string"))) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[zrtp_passthru] Setting b-leg absolute_codec_string='%s'\n", x);
+ switch_channel_set_variable(nchannel, "absolute_codec_string", x);
+ }
+ }
+
/* SNARK: lets copy this across so we can see if we're the other leg of 3PCC + bypass_media... */
if (sofia_test_flag(ctech_pvt, TFLAG_3PCC) && (switch_channel_test_flag(o_channel, CF_PROXY_MODE) || switch_channel_test_flag(o_channel, CF_PROXY_MEDIA))) {
sofia_set_flag(tech_pvt, TFLAG_3PCC_INVITE);
int rate;
int already_did[128] = { 0 };
int ptime = 0, noptime = 0;
- const char *zrtp;
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "m=audio %d RTP/%sAVP",
port, secure ? "S" : "");
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=ptime:%d\n", cur_ptime);
}
- if ((zrtp = switch_channel_get_variable(tech_pvt->channel, "sdp_zrtp_hash_string"))) {
- switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=zrtp-hash:%s\n", zrtp);
+ if (tech_pvt->local_sdp_audio_zrtp_hash) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Adding audio a=zrtp-hash:%s\n",
+ tech_pvt->local_sdp_audio_zrtp_hash);
+ switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=zrtp-hash:%s\n",
+ tech_pvt->local_sdp_audio_zrtp_hash);
}
if (sr) {
switch_event_t *map = NULL, *ptmap = NULL;
const char *b_sdp = NULL;
int verbose_sdp = 0;
- const char *zrtp;
sofia_glue_check_dtmf_type(tech_pvt);
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);
}
- if ((zrtp = switch_channel_get_variable(tech_pvt->channel, "sdp_zrtp_hash_string"))) {
- switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=zrtp-hash:%s\n", zrtp);
+
+ if (tech_pvt->local_sdp_audio_zrtp_hash) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Adding audio a=zrtp-hash:%s\n",
+ tech_pvt->local_sdp_audio_zrtp_hash);
+ switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=zrtp-hash:%s\n",
+ tech_pvt->local_sdp_audio_zrtp_hash);
}
if (sr) {
}
}
+
+ if (tech_pvt->local_sdp_video_zrtp_hash) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Adding video a=zrtp-hash:%s\n",
+ tech_pvt->local_sdp_video_zrtp_hash);
+ switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=zrtp-hash:%s\n",
+ tech_pvt->local_sdp_video_zrtp_hash);
+ }
}
}
switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
- if (switch_channel_test_flag(tech_pvt->channel, CF_ZRTP_PASS)) {
+ if (switch_channel_test_flag(tech_pvt->channel, CF_ZRTP_PASSTHRU)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_INFO, "Activating ZRTP PROXY MODE\n");
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Disable NOTIMER_DURING_BRIDGE\n");
sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Activating audio UDPTL mode\n");
switch_rtp_udptl_mode(tech_pvt->rtp_session);
}
}
}
}
-
+ if (switch_channel_test_flag(tech_pvt->channel, CF_ZRTP_PASSTHRU)) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Activating video UDPTL mode\n");
+ switch_rtp_udptl_mode(tech_pvt->video_rtp_session);
+ }
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", switch_str_nil(err));
}
+void sofia_glue_pass_zrtp_hash2(switch_core_session_t *aleg_session, switch_core_session_t *bleg_session)
+{
+ switch_channel_t *aleg_channel = switch_core_session_get_channel(aleg_session);
+ private_object_t *aleg_tech_pvt = switch_core_session_get_private(aleg_session);
+ switch_channel_t *bleg_channel = switch_core_session_get_channel(bleg_session);
+ private_object_t *bleg_tech_pvt = switch_core_session_get_private(bleg_session);
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Deciding whether to pass zrtp-hash between a-leg and b-leg\n");
+ if (!(switch_channel_test_flag(aleg_tech_pvt->channel, CF_ZRTP_PASSTHRU_REQ))) {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "CF_ZRTP_PASSTHRU_REQ not set on a-leg, so not propagating zrtp-hash\n");
+ return;
+ }
+ if (aleg_tech_pvt->remote_sdp_audio_zrtp_hash) {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Passing a-leg remote zrtp-hash (audio) to b-leg\n");
+ bleg_tech_pvt->local_sdp_audio_zrtp_hash = switch_core_session_strdup(bleg_tech_pvt->session, aleg_tech_pvt->remote_sdp_audio_zrtp_hash);
+ switch_channel_set_variable(bleg_channel, "l_sdp_audio_zrtp_hash", bleg_tech_pvt->local_sdp_audio_zrtp_hash);
+ }
+ if (aleg_tech_pvt->remote_sdp_video_zrtp_hash) {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Passing a-leg remote zrtp-hash (video) to b-leg\n");
+ bleg_tech_pvt->local_sdp_video_zrtp_hash = switch_core_session_strdup(bleg_tech_pvt->session, aleg_tech_pvt->remote_sdp_video_zrtp_hash);
+ switch_channel_set_variable(bleg_channel, "l_sdp_video_zrtp_hash", bleg_tech_pvt->local_sdp_video_zrtp_hash);
+ }
+ if (bleg_tech_pvt->remote_sdp_audio_zrtp_hash) {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Passing b-leg remote zrtp-hash (audio) to a-leg\n");
+ aleg_tech_pvt->local_sdp_audio_zrtp_hash = switch_core_session_strdup(aleg_tech_pvt->session, bleg_tech_pvt->remote_sdp_audio_zrtp_hash);
+ switch_channel_set_variable(aleg_channel, "l_sdp_audio_zrtp_hash", aleg_tech_pvt->local_sdp_audio_zrtp_hash);
+ }
+ if (bleg_tech_pvt->remote_sdp_video_zrtp_hash) {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Passing b-leg remote zrtp-hash (video) to a-leg\n");
+ aleg_tech_pvt->local_sdp_video_zrtp_hash = switch_core_session_strdup(aleg_tech_pvt->session, bleg_tech_pvt->remote_sdp_video_zrtp_hash);
+ switch_channel_set_variable(aleg_channel, "l_sdp_video_zrtp_hash", aleg_tech_pvt->local_sdp_video_zrtp_hash);
+ }
+}
+
+void sofia_glue_pass_zrtp_hash(switch_core_session_t *session)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
+ switch_core_session_t *other_session;
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Deciding whether to pass zrtp-hash between legs\n");
+ if (!(switch_channel_test_flag(tech_pvt->channel, CF_ZRTP_PASSTHRU_REQ))) {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "CF_ZRTP_PASSTHRU_REQ not set, so not propagating zrtp-hash\n");
+ return;
+ } else if (!(switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS)) {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "No partner channel found, so not propagating zrtp-hash\n");
+ return;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Found peer channel; propagating zrtp-hash if set\n");
+ sofia_glue_pass_zrtp_hash2(session, other_session);
+ switch_core_session_rwunlock(other_session);
+ }
+}
+
+static void find_zrtp_hash(switch_core_session_t *session, sdp_session_t *sdp)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ private_object_t *tech_pvt = switch_core_session_get_private(session);
+ sdp_media_t *m;
+ sdp_attribute_t *attr;
+ int got_audio = 0, got_video = 0;
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Looking for zrtp-hash\n");
+ for (m = sdp->sdp_media; m; m = m->m_next) {
+ if (got_audio && got_video) break;
+ if (m->m_port && ((m->m_type == sdp_media_audio && !got_audio)
+ || (m->m_type == sdp_media_video && !got_video))) {
+ for (attr = m->m_attributes; attr; attr = attr->a_next) {
+ if (zstr(attr->a_name)) continue;
+ if (strcasecmp(attr->a_name, "zrtp-hash") || !(attr->a_value)) continue;
+ if (m->m_type == sdp_media_audio) {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG,
+ "Found audio zrtp-hash; setting r_sdp_audio_zrtp_hash=%s\n", attr->a_value);
+ switch_channel_set_variable(channel, "r_sdp_audio_zrtp_hash", attr->a_value);
+ tech_pvt->remote_sdp_audio_zrtp_hash = switch_core_session_strdup(tech_pvt->session, attr->a_value);
+ got_audio++;
+ } else if (m->m_type == sdp_media_video) {
+ switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG,
+ "Found video zrtp-hash; setting r_sdp_video_zrtp_hash=%s\n", attr->a_value);
+ switch_channel_set_variable(channel, "r_sdp_video_zrtp_hash", attr->a_value);
+ tech_pvt->remote_sdp_video_zrtp_hash = switch_core_session_strdup(tech_pvt->session, attr->a_value);
+ got_video++;
+ }
+ switch_channel_set_flag(channel, CF_ZRTP_HASH);
+ break;
+ }
+ }
+ }
+}
void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp)
{
}
}
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Looking for zrtp-hash to set sdp_zrtp_hash_string\n");
- for (m = sdp->sdp_media; m; m = m->m_next) {
- for (attr = m->m_attributes; attr; attr = attr->a_next) {
- if (zstr(attr->a_name)) continue;
- if (!strcasecmp(attr->a_name, "zrtp-hash") && attr->a_value) {
- switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Found zrtp-hash, setting sdp_zrtp_hash_string=%s\n", attr->a_value);
- switch_channel_set_variable(channel, "sdp_zrtp_hash_string", attr->a_value);
- switch_channel_set_flag(channel, CF_ZRTP_HASH);
- break;
- }
- }
- }
+ find_zrtp_hash(session, sdp);
+ sofia_glue_pass_zrtp_hash(session);
for (m = sdp->sdp_media; m; m = m->m_next) {
ptime = dptime;
switch_channel_set_variable(tech_pvt->channel, "t38_broken_boolean", "true");
}
+ find_zrtp_hash(session, sdp);
+ sofia_glue_pass_zrtp_hash(session);
+
for (m = sdp->sdp_media; m; m = m->m_next) {
sdp_connection_t *connection;
switch_core_session_t *other_session;
ptime = atoi(attr->a_value);
} else if (!strcasecmp(attr->a_name, "maxptime") && attr->a_value) {
maxptime = atoi(attr->a_value);
- } else if (!strcasecmp(attr->a_name, "zrtp-hash") && attr->a_value) {
- switch_channel_set_variable(tech_pvt->channel, "sdp_zrtp_hash_string", attr->a_value);
- switch_channel_set_flag(tech_pvt->channel, CF_ZRTP_HASH);
} else if (!got_crypto && !strcasecmp(attr->a_name, "crypto") && !zstr(attr->a_value)) {
int crypto_tag;
SWITCH_DECLARE(void) switch_channel_check_zrtp(switch_channel_t *channel)
{
- if (switch_channel_test_flag(channel, CF_ZRTP_HASH) && !switch_channel_test_flag(channel, CF_ZRTP_PASS)) {
+ if (!switch_channel_test_flag(channel, CF_ZRTP_PASSTHRU)
+ && switch_channel_test_flag(channel, CF_ZRTP_PASSTHRU_REQ)
+ && switch_channel_test_flag(channel, CF_ZRTP_HASH)) {
switch_core_session_t *other_session;
switch_channel_t *other_channel;
int doit = 1;
if (switch_core_session_get_partner(channel->session, &other_session) == SWITCH_STATUS_SUCCESS) {
other_channel = switch_core_session_get_channel(other_session);
- if (switch_channel_test_flag(other_channel, CF_ZRTP_HASH) && !switch_channel_test_flag(other_channel, CF_ZRTP_PASS)) {
+ if (switch_channel_test_flag(other_channel, CF_ZRTP_HASH) && !switch_channel_test_flag(other_channel, CF_ZRTP_PASSTHRU)) {
- switch_channel_set_flag(channel, CF_ZRTP_PASS);
- switch_channel_set_flag(other_channel, CF_ZRTP_PASS);
+ switch_channel_set_flag(channel, CF_ZRTP_PASSTHRU);
+ switch_channel_set_flag(other_channel, CF_ZRTP_PASSTHRU);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO,
"%s Activating ZRTP passthru mode.\n", switch_channel_get_name(channel));
+ switch_channel_set_variable(channel, "zrtp_passthru_active", "true");
+ switch_channel_set_variable(other_channel, "zrtp_passthru_active", "true");
switch_channel_set_variable(channel, "zrtp_secure_media", "false");
switch_channel_set_variable(other_channel, "zrtp_secure_media", "false");
doit = 0;
}
if (doit) {
+ switch_channel_set_variable(channel, "zrtp_passthru_active", "false");
switch_channel_set_variable(channel, "zrtp_secure_media", "true");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO,
"%s ZRTP not negotiated on both sides; disabling ZRTP passthru mode.\n", switch_channel_get_name(channel));
- switch_channel_clear_flag(channel, CF_ZRTP_PASS);
+ switch_channel_clear_flag(channel, CF_ZRTP_PASSTHRU);
switch_channel_clear_flag(channel, CF_ZRTP_HASH);
if (switch_core_session_get_partner(channel->session, &other_session) == SWITCH_STATUS_SUCCESS) {
other_channel = switch_core_session_get_channel(other_session);
+ switch_channel_set_variable(other_channel, "zrtp_passthru_active", "false");
switch_channel_set_variable(other_channel, "zrtp_secure_media", "true");
- switch_channel_clear_flag(other_channel, CF_ZRTP_PASS);
+ switch_channel_clear_flag(other_channel, CF_ZRTP_PASSTHRU);
switch_channel_clear_flag(other_channel, CF_ZRTP_HASH);
switch_core_session_rwunlock(other_session);