]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
google changed something in DTLS
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 16 Oct 2013 17:57:15 +0000 (22:57 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 16 Oct 2013 22:58:09 +0000 (03:58 +0500)
src/include/switch_event.h
src/switch_core_cert.c
src/switch_core_media.c
src/switch_event.c

index be60c17cd908766d04dd0e2f63c001df7965fbaf..d812602a5bc309e32f9920103cbdcd9559f1ff4a 100644 (file)
@@ -451,7 +451,8 @@ SWITCH_DECLARE(void) switch_live_array_unlock(switch_live_array_t *la);
 SWITCH_DECLARE(void) switch_live_array_set_user_data(switch_live_array_t *la, void *user_data);
 SWITCH_DECLARE(void) switch_live_array_set_command_handler(switch_live_array_t *la, switch_live_array_command_handler_t command_handler);
 SWITCH_DECLARE(void) switch_live_array_parse_json(cJSON *json, switch_event_channel_id_t channel_id);
-
+SWITCH_DECLARE(switch_bool_t) switch_live_array_add_alias(switch_live_array_t *la, const char *event_channel, const char *name);
+SWITCH_DECLARE(switch_bool_t) switch_live_array_clear_alias(switch_live_array_t *la, const char *event_channel, const char *name);
 
 ///\}
 
index 41446c600dd552d4177f7e55ee9d3d7f556c0a52..ffba06ade566e59cdc8bda612abac34a5e12bb5a 100644 (file)
@@ -97,6 +97,7 @@ static const EVP_MD *get_evp_by_name(const char *name)
 {
        if (!strcasecmp(name, "md5")) return EVP_md5();
        if (!strcasecmp(name, "sha1")) return EVP_sha1();
+       if (!strcasecmp(name, "sha-1")) return EVP_sha1();
        if (!strcasecmp(name, "sha-256")) return EVP_sha256();
        if (!strcasecmp(name, "sha-512")) return EVP_sha512();
 
index b412a518f5e3395a0df6b2c8934430ddcc287f71..38f61fd826b3917482b807f40ee56aaca8ae3d93 100644 (file)
@@ -2038,7 +2038,11 @@ static void generate_local_fingerprint(switch_media_handle_t *smh, switch_media_
        switch_rtp_engine_t *engine = &smh->engines[type];
 
        if (!engine->local_dtls_fingerprint.len) {
-               engine->local_dtls_fingerprint.type = "sha-256";
+               if (engine->remote_dtls_fingerprint.type) {
+                       engine->local_dtls_fingerprint.type = engine->remote_dtls_fingerprint.type;
+               } else {
+                       engine->local_dtls_fingerprint.type = "sha-256";
+               }
                switch_core_cert_gen_fingerprint(DTLS_SRTP_FNAME, &engine->local_dtls_fingerprint);
        }
 }
@@ -2118,16 +2122,16 @@ static void check_ice(switch_media_handle_t *smh, switch_media_type_t type, sdp_
                                switch_set_string(engine->local_dtls_fingerprint.str, p);
                        }
                        
-                       if (strcasecmp(engine->remote_dtls_fingerprint.type, "sha-256")) {
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_WARNING, "Unsupported fingerprint type.\n");
-                               engine->local_dtls_fingerprint.type = NULL;
-                               engine->remote_dtls_fingerprint.type = NULL;
-                       }
+                       //if (strcasecmp(engine->remote_dtls_fingerprint.type, "sha-256")) {
+                       //      switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_WARNING, "Unsupported fingerprint type.\n");
+                               //engine->local_dtls_fingerprint.type = NULL;
+                               //engine->remote_dtls_fingerprint.type = NULL;
+                       //}
 
 
                        generate_local_fingerprint(smh, type);
                        switch_channel_set_flag(smh->session->channel, CF_DTLS);
-
+                       
                } else if (!engine->remote_ssrc && !strcasecmp(attr->a_name, "ssrc") && attr->a_value) {
                        engine->remote_ssrc = (uint32_t) atol(attr->a_value);
 
index 926b3d85f60163a1ee3b24ba4a143598eddbb2ba..873e3d98dd2a2bc78927cc831bd36a0448a80154 100644 (file)
@@ -2963,6 +2963,12 @@ SWITCH_DECLARE(switch_status_t) switch_event_channel_bind(const char *event_chan
        return status;
 }
 
+typedef struct alias_node_s {
+       char *event_channel;
+       char *name;
+       struct alias_node_s *next;
+} alias_node_t;
+
 typedef struct la_node_s {
        char *name;
        cJSON *obj;
@@ -2986,8 +2992,31 @@ struct switch_live_array_s {
        switch_event_channel_id_t channel_id;
        switch_live_array_command_handler_t command_handler;
        void *user_data;
+       alias_node_t *aliases;
 };
 
+static switch_status_t la_broadcast(switch_live_array_t *la, cJSON **json)
+{
+       alias_node_t *np;
+
+       if (la->aliases) {
+               switch_mutex_lock(la->mutex);
+               for (np = la->aliases; np; np = np->next) {
+                       cJSON *dup = cJSON_Duplicate(*json, 1);
+                       cJSON *data = cJSON_GetObjectItem(dup, "data");
+
+                       cJSON_ReplaceItemInObject(dup, "eventChannel", cJSON_CreateString(np->event_channel));
+                       cJSON_ReplaceItemInObject(data, "name", cJSON_CreateString(np->name));
+                       
+                       switch_event_channel_broadcast(np->event_channel, &dup, __FILE__, la->channel_id);
+               }
+               switch_mutex_unlock(la->mutex);
+       }
+
+       return switch_event_channel_broadcast(la->event_channel, json, __FILE__, la->channel_id);
+
+}
+
 
 SWITCH_DECLARE(switch_status_t) switch_live_array_visible(switch_live_array_t *la, switch_bool_t visible, switch_bool_t force)
 {
@@ -3004,7 +3033,7 @@ SWITCH_DECLARE(switch_status_t) switch_live_array_visible(switch_live_array_t *l
                cJSON_AddItemToObject(data, "action", cJSON_CreateString(visible ? "hide" : "show"));
                cJSON_AddItemToObject(data, "wireSerno", cJSON_CreateNumber(la->serno++));
                
-               switch_event_channel_broadcast(la->event_channel, &msg, __FILE__, la->channel_id);
+               la_broadcast(la, &msg);
 
                la->visible = visible;
        }
@@ -3030,7 +3059,7 @@ SWITCH_DECLARE(switch_status_t) switch_live_array_clear(switch_live_array_t *la)
        cJSON_AddItemToObject(data, "wireSerno", cJSON_CreateNumber(-1));
        cJSON_AddItemToObject(data, "data", cJSON_CreateObject());
        
-       switch_event_channel_broadcast(la->event_channel, &msg, __FILE__, la->channel_id);
+       la_broadcast(la, &msg);
 
        while(np) {
                cur = np;
@@ -3146,6 +3175,60 @@ SWITCH_DECLARE(switch_bool_t) switch_live_array_isnew(switch_live_array_t *la)
        return la->new;
 }
 
+SWITCH_DECLARE(switch_bool_t) switch_live_array_clear_alias(switch_live_array_t *la, const char *event_channel, const char *name)
+{
+       alias_node_t *np, *last = NULL;
+       switch_bool_t r = SWITCH_FALSE;
+
+       switch_mutex_lock(la->mutex);
+       for (np = la->aliases; np; np = np->next) {
+               if (!strcmp(np->event_channel, event_channel) && !strcmp(np->name, name)) {
+                       r = SWITCH_TRUE;
+
+                       if (last) {
+                               last->next = np->next;
+                       } else {
+                               la->aliases = np->next;
+                       }
+               } else {
+                       last = np;
+               }
+       }
+       switch_mutex_unlock(la->mutex);
+
+       return r;
+}
+
+SWITCH_DECLARE(switch_bool_t) switch_live_array_add_alias(switch_live_array_t *la, const char *event_channel, const char *name)
+{
+       alias_node_t *node, *np;
+       switch_bool_t exist = SWITCH_FALSE;
+
+       switch_mutex_lock(la->mutex);
+       for (np = la->aliases; np && np->next; np = np->next) {
+               if (!strcmp(np->event_channel, event_channel) && !strcmp(np->name, name)) {
+                       exist = SWITCH_TRUE;
+                       break;
+               }
+       }
+       
+       if (!exist) {
+               node = switch_core_alloc(la->pool, sizeof(*node));
+               node->event_channel = switch_core_strdup(la->pool, event_channel);
+               node->name = switch_core_strdup(la->pool, name);
+               if (np) {
+                       np->next = node;
+               } else {
+                       la->aliases = node;
+               }
+       }
+
+       switch_mutex_unlock(la->mutex);
+
+       return !exist;
+}
+
+
 SWITCH_DECLARE(switch_status_t) switch_live_array_create(const char *event_channel, const char *name, 
                                                                                                                 switch_event_channel_id_t channel_id, switch_live_array_t **live_arrayP)
 {
@@ -3259,7 +3342,7 @@ SWITCH_DECLARE(switch_status_t) switch_live_array_del(switch_live_array_t *la, c
                                cJSON_AddItemToObject(data, "data", cur->obj);
                                cur->obj = NULL;
 
-                               switch_event_channel_broadcast(la->event_channel, &msg, __FILE__, la->channel_id);
+                               la_broadcast(la, &msg);
                                free(cur->name);
                                free(cur);
                        } else {
@@ -3360,7 +3443,7 @@ SWITCH_DECLARE(switch_status_t) switch_live_array_add(switch_live_array_t *la, c
        cJSON_AddItemToObject(data, "wireSerno", cJSON_CreateNumber(la->serno++));
        cJSON_AddItemToObject(data, "data", cJSON_Duplicate(node->obj, 1));
 
-       switch_event_channel_broadcast(la->event_channel, &msg, __FILE__, la->channel_id);
+       la_broadcast(la, &msg);
        
        switch_mutex_unlock(la->mutex);