<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][16204] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=16204">16204</a></dd>
<dt>Author</dt> <dd>brian</dd>
<dt>Date</dt> <dd>2010-01-07 17:29:06 -0600 (Thu, 07 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre> fix mitm for audio for passing sas with zrtp</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcswitch_rtpc">freeswitch/trunk/src/switch_rtp.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcswitch_rtpc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_rtp.c (16203 => 16204)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_rtp.c        2010-01-07 23:00:34 UTC (rev 16203)
+++ freeswitch/trunk/src/switch_rtp.c        2010-01-07 23:29:06 UTC (rev 16204)
</span><span class="lines">@@ -219,7 +219,8 @@
</span><span class="cx"> #ifdef ENABLE_ZRTP
</span><span class="cx">         zrtp_session_t *zrtp_session;
</span><span class="cx">         zrtp_profile_t *zrtp_profile;
</span><del>-        zrtp_stream_t *zrtp_ctx;
</del><ins>+        zrtp_stream_t *zrtp_audio_ctx;
+        zrtp_stream_t *zrtp_video_ctx;
</ins><span class="cx">         int zrtp_mitm_tries;
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -474,8 +475,8 @@
</span><span class="cx"> #if 0
</span><span class="cx">         case ZRTP_EVENT_NO_ZRTP_QUICK:
</span><span class="cx">                 {
</span><del>-                        if (rtp_session->zrtp_ctx != NULL) {
-                                zrtp_stream_stop(rtp_session->zrtp_ctx);
</del><ins>+                        if (rtp_session->zrtp_audio_ctx != NULL) {
+                                zrtp_stream_stop(rtp_session->zrtp_audio_ctx);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="lines">@@ -561,7 +562,7 @@
</span><span class="cx">         zrtp_status_t status = zrtp_status_fail;
</span><span class="cx">         unsigned int len = datalen;
</span><span class="cx">
</span><del>-        status = zrtp_process_srtp(rtp_session->zrtp_ctx, (char*)data, &len);
</del><ins>+        status = zrtp_process_srtp(rtp_session->zrtp_audio_ctx, (char*)data, &len);
</ins><span class="cx">         switch(status) {
</span><span class="cx">         case zrtp_status_ok:
</span><span class="cx">                 break;
</span><span class="lines">@@ -1190,6 +1191,8 @@
</span><span class="cx">                         zrtp_enabled = NULL;
</span><span class="cx">                 }
</span><span class="cx">
</span><ins>+                switch_channel_set_private(channel, "__zrtp_rtp_session", rtp_session);
+                
</ins><span class="cx">                 if (switch_true(zrtp_enabled)) {
</span><span class="cx">                         if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
</span><span class="cx">                                 initiator = 1;
</span><span class="lines">@@ -1210,15 +1213,15 @@
</span><span class="cx">                         
</span><span class="cx">                         zrtp_session_set_userdata(rtp_session->zrtp_session, rtp_session);
</span><span class="cx">                         
</span><del>-                        if (zrtp_status_ok != zrtp_stream_attach(rtp_session->zrtp_session, &rtp_session->zrtp_ctx)) {
</del><ins>+                        if (zrtp_status_ok != zrtp_stream_attach(rtp_session->zrtp_session, &rtp_session->zrtp_audio_ctx)) {
</ins><span class="cx">                                 abort();
</span><span class="cx">                         }
</span><del>-                        zrtp_stream_set_userdata(rtp_session->zrtp_ctx, rtp_session);
</del><ins>+                        zrtp_stream_set_userdata(rtp_session->zrtp_audio_ctx, rtp_session);
</ins><span class="cx">                         
</span><span class="cx">                         if (switch_true(switch_channel_get_variable(channel, "zrtp_enrollment"))) {
</span><del>-                                zrtp_stream_registration_start(rtp_session->zrtp_ctx, rtp_session->ssrc);
</del><ins>+                                zrtp_stream_registration_start(rtp_session->zrtp_audio_ctx, rtp_session->ssrc);
</ins><span class="cx">                         } else {
</span><del>-                                zrtp_stream_start(rtp_session->zrtp_ctx, rtp_session->ssrc);
</del><ins>+                                zrtp_stream_start(rtp_session->zrtp_audio_ctx, rtp_session->ssrc);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -1481,8 +1484,8 @@
</span><span class="cx">         /* ZRTP */
</span><span class="cx">         if (zrtp_on) {
</span><span class="cx">
</span><del>-                if ((*rtp_session)->zrtp_ctx != NULL) {
-                        zrtp_stream_stop((*rtp_session)->zrtp_ctx);
</del><ins>+                if ((*rtp_session)->zrtp_audio_ctx != NULL) {
+                        zrtp_stream_stop((*rtp_session)->zrtp_audio_ctx);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (switch_test_flag((*rtp_session), SWITCH_ZRTP_FLAG_SECURE_SEND)) {
</span><span class="lines">@@ -2129,7 +2132,7 @@
</span><span class="cx">                         unsigned int sbytes = (int) bytes;
</span><span class="cx">                         zrtp_status_t stat = 0;
</span><span class="cx">                         
</span><del>-                        stat = zrtp_process_srtp(rtp_session->zrtp_ctx, (void *)&rtp_session->recv_msg, &sbytes);
</del><ins>+                        stat = zrtp_process_srtp(rtp_session->zrtp_audio_ctx, (void *)&rtp_session->recv_msg, &sbytes);
</ins><span class="cx">                         
</span><span class="cx">                         switch (stat) {
</span><span class="cx">                         case zrtp_status_ok:
</span><span class="lines">@@ -2497,14 +2500,39 @@
</span><span class="cx">
</span><span class="cx">                 if (zrtp_status_ok == zrtp_session_get(rtp_session->zrtp_session, &zrtp_session_info)) {
</span><span class="cx">                         if (zrtp_session_info.sas_is_ready) {
</span><del>-                                frame->extra_data = rtp_session->zrtp_ctx;
-                                switch_set_flag(frame, SFF_ZRTP);
-                                if (rtp_session->zrtp_mitm_tries > ZRTP_MITM_TRIES) {
-                                        zrtp_verified_set(zrtp_global, &rtp_session->zrtp_session->zid,
-                                                                         &rtp_session->zrtp_session->peer_zid, zrtp_session_info.sas_is_verified^1);
-                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
</del><ins>+                                switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
+                                switch_channel_t *channel = switch_core_session_get_channel(session);
+
+                                const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
+                                if (uuid) {
+                                        switch_core_session_t *other_session;
+
+                                        if ((other_session = switch_core_session_locate(uuid))) {
+                                                switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+                                                switch_rtp_t *other_rtp_session = switch_channel_get_private(other_channel, "__zrtp_rtp_session");
+
+                                                if (other_rtp_session) {
+                                                        if (zrtp_status_ok == zrtp_session_get(other_rtp_session->zrtp_session, &zrtp_session_info)) {
+                                                                if (rtp_session->zrtp_mitm_tries > ZRTP_MITM_TRIES) {
+                                                                        switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
+                                                                        switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
+                                                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
+                                                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
+                                                                } else if (zrtp_status_ok == zrtp_resolve_mitm_call(other_rtp_session->zrtp_audio_ctx, rtp_session->zrtp_audio_ctx)) {
+                                                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
+                                                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
+                                                                        switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
+                                                                        switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
+                                                                        zrtp_verified_set(zrtp_global, &rtp_session->zrtp_session->zid,
+                                                                                                         &rtp_session->zrtp_session->peer_zid, zrtp_session_info.sas_is_verified^1);
+                                                                        rtp_session->zrtp_mitm_tries++;
+                                                                }
+                                                        }
+                                                }
+                                                
+                                                switch_core_session_rwunlock(other_session);
+                                        }
</ins><span class="cx">                                 }
</span><del>-                                rtp_session->zrtp_mitm_tries++;
</del><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -2767,7 +2795,7 @@
</span><span class="cx">                         unsigned int sbytes = (int) bytes;
</span><span class="cx">                         zrtp_status_t stat = zrtp_status_fail;
</span><span class="cx">                         
</span><del>-                        stat = zrtp_process_rtp(rtp_session->zrtp_ctx, (void*)send_msg, &sbytes);
</del><ins>+                        stat = zrtp_process_rtp(rtp_session->zrtp_audio_ctx, (void*)send_msg, &sbytes);
</ins><span class="cx">
</span><span class="cx">                         switch (stat) {
</span><span class="cx">                         case zrtp_status_ok:
</span><span class="lines">@@ -2974,18 +3002,43 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> #ifdef ENABLE_ZRTP
</span><del>-        if (zrtp_on && switch_test_flag(frame, SFF_ZRTP) && switch_test_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND)) {
</del><ins>+        if (zrtp_on && switch_test_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND)) {
</ins><span class="cx">                 zrtp_session_info_t zrtp_session_info;
</span><span class="cx">
</span><span class="cx">                 if (zrtp_status_ok == zrtp_session_get(rtp_session->zrtp_session, &zrtp_session_info)) {
</span><span class="cx">                         if (zrtp_session_info.sas_is_ready) {
</span><del>-                                if (rtp_session->zrtp_mitm_tries > ZRTP_MITM_TRIES) {
-                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
-                                } else if (zrtp_status_ok == zrtp_resolve_mitm_call(frame->extra_data, rtp_session->zrtp_ctx)) {
-                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
-                                        zrtp_verified_set(zrtp_global, &rtp_session->zrtp_session->zid,
-                                                                         &rtp_session->zrtp_session->peer_zid, zrtp_session_info.sas_is_verified^1);
-                                        rtp_session->zrtp_mitm_tries++;
</del><ins>+                                switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
+                                switch_channel_t *channel = switch_core_session_get_channel(session);
+
+                                const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
+                                if (uuid) {
+                                        switch_core_session_t *other_session;
+
+                                        if ((other_session = switch_core_session_locate(uuid))) {
+                                                switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+                                                switch_rtp_t *other_rtp_session = switch_channel_get_private(other_channel, "__zrtp_rtp_session");
+                                                if (other_rtp_session) {
+                                                        if (zrtp_status_ok == zrtp_session_get(other_rtp_session->zrtp_session, &zrtp_session_info)) {
+                                                                if (rtp_session->zrtp_mitm_tries > ZRTP_MITM_TRIES) {
+                                                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
+                                                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
+                                                                        switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
+                                                                        switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
+                                                                } else if (zrtp_status_ok == zrtp_resolve_mitm_call(other_rtp_session->zrtp_audio_ctx, rtp_session->zrtp_audio_ctx)) {
+                                                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
+                                                                        switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
+                                                                        switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
+                                                                        switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
+                                                                        zrtp_verified_set(zrtp_global, &rtp_session->zrtp_session->zid,
+                                                                                                         &rtp_session->zrtp_session->peer_zid, zrtp_session_info.sas_is_verified^1);
+                                                                        rtp_session->zrtp_mitm_tries++;
+                                                                }
+                                                                rtp_session->zrtp_mitm_tries++;
+                                                        }
+                                                }
+
+                                                switch_core_session_rwunlock(other_session);
+                                        }
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -3096,7 +3149,7 @@
</span><span class="cx">                 unsigned int sbytes = (int) bytes;
</span><span class="cx">                 zrtp_status_t stat = zrtp_status_fail;
</span><span class="cx">                 
</span><del>-                stat = zrtp_process_rtp(rtp_session->zrtp_ctx, (void*)&rtp_session->write_msg, &sbytes);
</del><ins>+                stat = zrtp_process_rtp(rtp_session->zrtp_audio_ctx, (void*)&rtp_session->write_msg, &sbytes);
</ins><span class="cx">                 
</span><span class="cx">                 switch (stat) {
</span><span class="cx">                 case zrtp_status_ok:
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>