]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
timer based nat_map refresh
authorRupa Schomaker <rupa@rupa.com>
Mon, 21 Jun 2010 00:21:42 +0000 (19:21 -0500)
committerRupa Schomaker <rupa@rupa.com>
Mon, 21 Jun 2010 14:51:57 +0000 (09:51 -0500)
src/include/switch_nat.h [changed mode: 0644->0755]
src/switch_core.c [changed mode: 0644->0755]
src/switch_nat.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index ced175b..09118c1
@@ -57,6 +57,14 @@ typedef enum {
   \note Generally called by the core_init
 */
 SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool);
+
+/*! 
+  \brief Initilize the rest of the NAT Traversal System
+  \note nat_init is called prior to some other modules being loaded.  
+        This method allows us to init the rest of the NAT system.
+*/
+SWITCH_DECLARE(void) switch_nat_late_init(void);
+
 /*!
  \brief Shuts down the NAT Traversal System
 */
old mode 100644 (file)
new mode 100755 (executable)
index d24ea83..37dabbc
@@ -1325,6 +1325,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
 
        switch_scheduler_task_thread_start();
 
+       switch_nat_late_init();
+
        switch_rtp_init(runtime.memory_pool);
 
        runtime.running = 1;
old mode 100644 (file)
new mode 100755 (executable)
index 0f618ef..843e139
@@ -41,6 +41,7 @@
 
 #define MULTICAST_BUFFSIZE 65536
 #define IP_LEN 16
+#define NAT_REFRESH_INTERVAL 900
 
 typedef struct {
        switch_nat_type_t nat_type;
@@ -677,6 +678,22 @@ SWITCH_DECLARE(void) switch_nat_republish(void)
        switch_xml_free(natxml);
 }
 
+SWITCH_STANDARD_SCHED_FUNC(switch_nat_republish_sched)
+{
+       switch_nat_republish();
+       if (nat_globals_perm.running == 1) {
+               task->runtime = switch_epoch_time_now(NULL) + NAT_REFRESH_INTERVAL;
+       }
+}
+
+SWITCH_DECLARE(void) switch_nat_late_init(void)
+{
+       if (nat_globals_perm.running == 1) {
+               switch_scheduler_add_task(switch_epoch_time_now(NULL) + NAT_REFRESH_INTERVAL, switch_nat_republish_sched, "nat_republish", "core", 0, NULL,
+                                                                 SSHF_NONE);
+       }
+}
+
 SWITCH_DECLARE(char *) switch_nat_status(void)
 {
        switch_stream_handle_t stream = { 0 };