]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3054 re-open if this does not fix it.
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 22 Feb 2011 02:17:58 +0000 (20:17 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 22 Feb 2011 02:17:58 +0000 (20:17 -0600)
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/switch_nat.c

index 9fb1f39e115ab9d9ad4a2d852d16bdf224b7cf82..f9f0788c9380c1446c4baaad1ba597c3b846fe95 100644 (file)
@@ -596,9 +596,9 @@ static void ipchanged_event_handler(switch_event_t *event)
 
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "EVENT_TRAP: IP change detected\n");
 
-       if (cond && !strcmp(cond, "network-address-change")) {
-               const char *old_ip4 = switch_event_get_header_nil(event, "network-address-previous-v4");
-               const char *new_ip4 = switch_event_get_header_nil(event, "network-address-change-v4");
+       if (cond && !strcmp(cond, "network-external-address-change")) {
+               const char *old_ip4 = switch_event_get_header_nil(event, "network-external-address-previous-v4");
+               const char *new_ip4 = switch_event_get_header_nil(event, "network-external-address-change-v4");
                switch_hash_index_t *hi;
                void *val;
                char *tmp;
index 7125bceb7c3b26ff2de8dfb23c4455020b7c7670..dff33ee6f5edde29fd3863cf48c34e01aa8cdf3d 100644 (file)
@@ -4587,17 +4587,42 @@ static void general_event_handler(switch_event_t *event)
        case SWITCH_EVENT_TRAP:
                {
                        const char *cond = switch_event_get_header(event, "condition");
+                       switch_hash_index_t *hi;
+                       const void *var;
+                       void *val;
+                       sofia_profile_t *profile;
+
+                       if (zstr(cond)) {
+                               cond = "";
+                       }
+
+                       if (!strcmp(cond, "network-external-address-change") && mod_sofia_globals.auto_restart) {
+                               const char *old_ip4 = switch_event_get_header_nil(event, "network-external-address-previous-v4");
+                               const char *new_ip4 = switch_event_get_header_nil(event, "network-external-address-change-v4");
+                               
+                               switch_mutex_lock(mod_sofia_globals.hash_mutex);
+                               if (mod_sofia_globals.profile_hash) {
+                                       for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+                                               switch_hash_this(hi, &var, NULL, &val);
 
+                                               if ((profile = (sofia_profile_t *) val)) {
+                                                       if (!strcmp(profile->extsipip, old_ip4)) {
+                                                               profile->extsipip = switch_core_strdup(profile->pool, new_ip4);
+                                                       }
 
-                       if (cond && !strcmp(cond, "network-address-change") && mod_sofia_globals.auto_restart) {
+                                                       if (!strcmp(profile->extrtpip, old_ip4)) {
+                                                               profile->extrtpip = switch_core_strdup(profile->pool, new_ip4);
+                                                       }
+                                               }
+                                       }
+                               }
+                               switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+                               sofia_glue_restart_all_profiles();                              
+                       } else if (!strcmp(cond, "network-address-change") && mod_sofia_globals.auto_restart) {
                                const char *old_ip4 = switch_event_get_header_nil(event, "network-address-previous-v4");
                                const char *new_ip4 = switch_event_get_header_nil(event, "network-address-change-v4");
                                const char *old_ip6 = switch_event_get_header_nil(event, "network-address-previous-v6");
                                const char *new_ip6 = switch_event_get_header_nil(event, "network-address-change-v6");
-                               switch_hash_index_t *hi;
-                               const void *var;
-                               void *val;
-                               sofia_profile_t *profile;
 
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "EVENT_TRAP: IP change detected\n");
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "IP change detected [%s]->[%s] [%s]->[%s]\n", old_ip4, new_ip4, old_ip6, new_ip6);
index 85b0247d6d0c39791c4988a876dfbeb8b1eda8b9..d9110efe18799e5297500102e174038341b7957a 100644 (file)
@@ -325,9 +325,9 @@ static void *SWITCH_THREAD_FUNC switch_nat_multicast_runtime(switch_thread_t * t
                        do_repub = SWITCH_TRUE;
 
                        switch_event_create(&event, SWITCH_EVENT_TRAP);
-                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "network-address-change");
-                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-address-previous-v4", nat_globals.pub_addr);
-                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-address-change-v4", newip);
+                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "network-external-address-change");
+                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-external-address-previous-v4", nat_globals.pub_addr);
+                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-external-address-change-v4", newip);
                        switch_event_fire(&event);
 
                        switch_set_string(nat_globals.pub_addr, newip);