]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FSRTP-2 with mods
authorBrian West <brian@freeswitch.org>
Fri, 29 May 2009 02:08:24 +0000 (02:08 +0000)
committerBrian West <brian@freeswitch.org>
Fri, 29 May 2009 02:08:24 +0000 (02:08 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13502 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_core_sqldb.c
src/switch_rtp.c

index 2b31e27b134876da0b6340d89ad1a53b76b86aeb..79fa4b6e51efd4837f684df04368be191db89a73 100644 (file)
@@ -387,6 +387,18 @@ static void core_event_handler(switch_event_t *event)
                        }
                        break;
                }
+       case SWITCH_EVENT_CALL_SECURE:
+               {
+                       const char *type = switch_event_get_header_nil(event, "secure_type");
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Secure Type: %s\n", type);
+                       if (switch_strlen_zero(type)) {
+                               break;
+                       }
+                       sql = switch_mprintf("update channels set secure='%s' where uuid='%s'",
+                                                                type,
+                                                                switch_event_get_header_nil(event, "caller-unique-id"));
+                       break;
+               }
        default:
                break;
        }
@@ -454,7 +466,8 @@ void switch_core_sqldb_start(switch_memory_pool_t *pool)
                        "   read_codec  VARCHAR(255),\n" 
                        "   read_rate  VARCHAR(255),\n" 
                        "   write_codec  VARCHAR(255),\n" 
-                       "   write_rate  VARCHAR(255)\n" 
+                       "   write_rate  VARCHAR(255),\n" 
+                       "   secure VARCHAR(255)\n"
                        ");\ncreate index uuindex on channels (uuid);\n";
                char create_calls_sql[] =
                        "CREATE TABLE calls (\n"
index 1585badbd1e245da9af006fd9bc803836c04cc53..8673884d472b18296c328ef295c228926770e5ec 100644 (file)
@@ -437,6 +437,7 @@ static void zrtp_event_callback(zrtp_stream_t *stream, unsigned event)
        switch_rtp_t *rtp_session = zrtp_stream_get_userdata(stream);
        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);
+       switch_event_t *fsevent = NULL;
        
        zrtp_session_info_t zrtp_session_info;
 
@@ -460,6 +461,12 @@ static void zrtp_event_callback(zrtp_stream_t *stream, unsigned event)
                                }
                        }
                }
+               if (switch_event_create(&fsevent, SWITCH_EVENT_CALL_SECURE) == SWITCH_STATUS_SUCCESS) {
+                       switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "zrtp:%s:%s",
+                                                                       rtp_session->zrtp_session->sas1.buffer, rtp_session->zrtp_session->sas2.buffer);
+                       switch_event_add_header_string(fsevent, SWITCH_STACK_BOTTOM, "caller-unique-id", switch_channel_get_uuid(channel));
+                       switch_event_fire(&fsevent);
+               }
                break;
 
        case ZRTP_EVENT_IS_CLIENT_ENROLLMENT:
@@ -909,6 +916,9 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
        srtp_policy_t *policy;
        err_status_t stat;
        switch_status_t status = SWITCH_STATUS_SUCCESS;
+       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);
+       switch_event_t *fsevent = NULL;
 
        if (direction >= SWITCH_RTP_CRYPTO_MAX || keylen > SWITCH_RTP_MAX_CRYPTO_LEN) {
                return SWITCH_STATUS_FALSE;
@@ -996,6 +1006,13 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
                break;
        }
 
+       if (switch_event_create(&fsevent, SWITCH_EVENT_CALL_SECURE) == SWITCH_STATUS_SUCCESS) {
+               switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "srtp:%s", switch_channel_get_variable(channel, "sip_has_crypto"));
+               switch_event_add_header_string(fsevent, SWITCH_STACK_BOTTOM, "caller-unique-id", switch_channel_get_uuid(channel));
+               switch_event_fire(&fsevent);
+       }
+
+
        return SWITCH_STATUS_SUCCESS;
 }