diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 2b31e27b13..79fa4b6e51 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -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" diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 1585badbd1..8673884d47 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -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; }