mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 16:15:04 +00:00
timer based nat_map refresh
This commit is contained in:
parent
3d54eec814
commit
b36f2a23bf
8
src/include/switch_nat.h
Normal file → Executable file
8
src/include/switch_nat.h
Normal file → Executable file
@ -57,6 +57,14 @@ typedef enum {
|
|||||||
\note Generally called by the core_init
|
\note Generally called by the core_init
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool);
|
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
|
\brief Shuts down the NAT Traversal System
|
||||||
*/
|
*/
|
||||||
|
2
src/switch_core.c
Normal file → Executable file
2
src/switch_core.c
Normal file → Executable file
@ -1325,6 +1325,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
|
|||||||
|
|
||||||
switch_scheduler_task_thread_start();
|
switch_scheduler_task_thread_start();
|
||||||
|
|
||||||
|
switch_nat_late_init();
|
||||||
|
|
||||||
switch_rtp_init(runtime.memory_pool);
|
switch_rtp_init(runtime.memory_pool);
|
||||||
|
|
||||||
runtime.running = 1;
|
runtime.running = 1;
|
||||||
|
17
src/switch_nat.c
Normal file → Executable file
17
src/switch_nat.c
Normal file → Executable file
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#define MULTICAST_BUFFSIZE 65536
|
#define MULTICAST_BUFFSIZE 65536
|
||||||
#define IP_LEN 16
|
#define IP_LEN 16
|
||||||
|
#define NAT_REFRESH_INTERVAL 900
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
switch_nat_type_t nat_type;
|
switch_nat_type_t nat_type;
|
||||||
@ -677,6 +678,22 @@ SWITCH_DECLARE(void) switch_nat_republish(void)
|
|||||||
switch_xml_free(natxml);
|
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_DECLARE(char *) switch_nat_status(void)
|
||||||
{
|
{
|
||||||
switch_stream_handle_t stream = { 0 };
|
switch_stream_handle_t stream = { 0 };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user