SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel, const char *file, const char *func, int line);
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_channel_t *channel, const char *file, const char *func, int line);
+SWITCH_DECLARE(void) switch_channel_check_zrtp(switch_channel_t *channel);
/*!
\brief Answer a channel (initiate/acknowledge a successful connection)
CF_VIDEO_REFRESH_REQ,
CF_SERVICE_AUDIO,
CF_SERVICE_VIDEO,
+ CF_ZRTP_HASH,
+ CF_ZRTP_PASS,
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
/* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
CF_FLAG_MAX
}
}
+ switch_channel_check_zrtp(tech_pvt->channel);
+
if ((status = sofia_glue_tech_choose_port(tech_pvt, 0)) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
goto end_lock;
sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
if (match) {
+ switch_channel_check_zrtp(channel);
+
if (sofia_glue_tech_choose_port(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) {
if (sofia_glue_activate_rtp(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) {
switch_channel_mark_answered(channel);
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 (sr) {
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=%s\n", 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 (sr) {
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=%s\n", sr);
}
switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
+
+ if (switch_channel_test_flag(tech_pvt->channel, CF_ZRTP_PASS)) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_INFO, "Activating ZRTP PROXY MODE\n");
+ sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
+ switch_rtp_udptl_mode(tech_pvt->rtp_session);
+ }
+
+
video:
sofia_glue_check_video_codecs(tech_pvt);
if (!strcasecmp(attr->a_name, "rtcp") && attr->a_value) {
switch_channel_set_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port", attr->a_value);
- }
-
- if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) {
+ } else if (!strcasecmp(attr->a_name, "ptime") && attr->a_value) {
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;
return SWITCH_STATUS_FALSE;
}
+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)) {
+ 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)) {
+
+ switch_channel_set_flag(channel, CF_ZRTP_PASS);
+ switch_channel_set_flag(other_channel, CF_ZRTP_PASS);
+
+ 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_secure_media", "false");
+ switch_channel_set_variable(other_channel, "zrtp_secure_media", "false");
+ doit = 0;
+ }
+
+ switch_core_session_rwunlock(other_session);
+ }
+
+ if (doit) {
+ 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, Activating ZRTP man-in-the-middle mode.\n", switch_channel_get_name(channel));
+
+ switch_channel_clear_flag(channel, CF_ZRTP_PASS);
+ 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_secure_media", "true");
+ switch_channel_clear_flag(other_channel, CF_ZRTP_PASS);
+ switch_channel_clear_flag(other_channel, CF_ZRTP_HASH);
+
+ switch_core_session_rwunlock(other_session);
+ }
+
+ }
+ }
+}
+
+
+
+
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_channel_t *channel, const char *file, const char *func, int line)
{
switch_event_t *event;
const char *uuid;
switch_core_session_t *other_session;
+ switch_channel_check_zrtp(channel);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name);
switch_channel_set_flag(channel, CF_EARLY_MEDIA);
switch_channel_set_callstate(channel, CCS_EARLY);
switch_mutex_unlock(channel->profile_mutex);
}
+ switch_channel_check_zrtp(channel);
switch_channel_set_flag(channel, CF_ANSWERED);
switch_channel_set_callstate(channel, CCS_ACTIVE);
return SWITCH_STATUS_SUCCESS;
}
+
msg.message_id = SWITCH_MESSAGE_INDICATE_ANSWER;
msg.from = channel->name;
status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);