don't segfault when -nonat is used and nat_map reinit is called
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16253 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
a4604e1af5
commit
fe74b20563
|
@ -88,6 +88,10 @@ SWITCH_DECLARE(void) switch_nat_reinit(void);
|
||||||
\param sticky make the mapping permanent
|
\param sticky make the mapping permanent
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t *external_port, switch_bool_t sticky);
|
SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t *external_port, switch_bool_t sticky);
|
||||||
|
/*!
|
||||||
|
\brief Has the NAT subsystem been initialized
|
||||||
|
*/
|
||||||
|
SWITCH_DECLARE(switch_bool_t) switch_nat_is_initialized(void);
|
||||||
/*!
|
/*!
|
||||||
\brief Deletes a NAT mapping
|
\brief Deletes a NAT mapping
|
||||||
\param proto Protocol
|
\param proto Protocol
|
||||||
|
|
|
@ -112,6 +112,11 @@ SWITCH_STANDARD_API(nat_map_function)
|
||||||
if (!cmd) {
|
if (!cmd) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!switch_nat_is_initialized()) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "nat_map API called while NAT not initialized\n");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
mydata = strdup(cmd);
|
mydata = strdup(cmd);
|
||||||
switch_assert(mydata);
|
switch_assert(mydata);
|
||||||
|
|
|
@ -2399,6 +2399,66 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_directories_storage_dir_get(void * j
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_recordings_dir_set(void * jarg1, char * jarg2) {
|
||||||
|
switch_directories *arg1 = (switch_directories *) 0 ;
|
||||||
|
char *arg2 = (char *) 0 ;
|
||||||
|
|
||||||
|
arg1 = (switch_directories *)jarg1;
|
||||||
|
arg2 = (char *)jarg2;
|
||||||
|
{
|
||||||
|
if (arg1->recordings_dir) delete [] arg1->recordings_dir;
|
||||||
|
if (arg2) {
|
||||||
|
arg1->recordings_dir = (char *) (new char[strlen((const char *)arg2)+1]);
|
||||||
|
strcpy((char *)arg1->recordings_dir, (const char *)arg2);
|
||||||
|
} else {
|
||||||
|
arg1->recordings_dir = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_directories_recordings_dir_get(void * jarg1) {
|
||||||
|
char * jresult ;
|
||||||
|
switch_directories *arg1 = (switch_directories *) 0 ;
|
||||||
|
char *result = 0 ;
|
||||||
|
|
||||||
|
arg1 = (switch_directories *)jarg1;
|
||||||
|
result = (char *) ((arg1)->recordings_dir);
|
||||||
|
jresult = SWIG_csharp_string_callback((const char *)result);
|
||||||
|
return jresult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWIGEXPORT void SWIGSTDCALL CSharp_switch_directories_sounds_dir_set(void * jarg1, char * jarg2) {
|
||||||
|
switch_directories *arg1 = (switch_directories *) 0 ;
|
||||||
|
char *arg2 = (char *) 0 ;
|
||||||
|
|
||||||
|
arg1 = (switch_directories *)jarg1;
|
||||||
|
arg2 = (char *)jarg2;
|
||||||
|
{
|
||||||
|
if (arg1->sounds_dir) delete [] arg1->sounds_dir;
|
||||||
|
if (arg2) {
|
||||||
|
arg1->sounds_dir = (char *) (new char[strlen((const char *)arg2)+1]);
|
||||||
|
strcpy((char *)arg1->sounds_dir, (const char *)arg2);
|
||||||
|
} else {
|
||||||
|
arg1->sounds_dir = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWIGEXPORT char * SWIGSTDCALL CSharp_switch_directories_sounds_dir_get(void * jarg1) {
|
||||||
|
char * jresult ;
|
||||||
|
switch_directories *arg1 = (switch_directories *) 0 ;
|
||||||
|
char *result = 0 ;
|
||||||
|
|
||||||
|
arg1 = (switch_directories *)jarg1;
|
||||||
|
result = (char *) ((arg1)->sounds_dir);
|
||||||
|
jresult = SWIG_csharp_string_callback((const char *)result);
|
||||||
|
return jresult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_directories() {
|
SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_directories() {
|
||||||
void * jresult ;
|
void * jresult ;
|
||||||
switch_directories *result = 0 ;
|
switch_directories *result = 0 ;
|
||||||
|
|
|
@ -5490,6 +5490,18 @@ class freeswitchPINVOKE {
|
||||||
[DllImport("mod_managed", EntryPoint="CSharp_switch_directories_storage_dir_get")]
|
[DllImport("mod_managed", EntryPoint="CSharp_switch_directories_storage_dir_get")]
|
||||||
public static extern string switch_directories_storage_dir_get(HandleRef jarg1);
|
public static extern string switch_directories_storage_dir_get(HandleRef jarg1);
|
||||||
|
|
||||||
|
[DllImport("mod_managed", EntryPoint="CSharp_switch_directories_recordings_dir_set")]
|
||||||
|
public static extern void switch_directories_recordings_dir_set(HandleRef jarg1, string jarg2);
|
||||||
|
|
||||||
|
[DllImport("mod_managed", EntryPoint="CSharp_switch_directories_recordings_dir_get")]
|
||||||
|
public static extern string switch_directories_recordings_dir_get(HandleRef jarg1);
|
||||||
|
|
||||||
|
[DllImport("mod_managed", EntryPoint="CSharp_switch_directories_sounds_dir_set")]
|
||||||
|
public static extern void switch_directories_sounds_dir_set(HandleRef jarg1, string jarg2);
|
||||||
|
|
||||||
|
[DllImport("mod_managed", EntryPoint="CSharp_switch_directories_sounds_dir_get")]
|
||||||
|
public static extern string switch_directories_sounds_dir_get(HandleRef jarg1);
|
||||||
|
|
||||||
[DllImport("mod_managed", EntryPoint="CSharp_new_switch_directories")]
|
[DllImport("mod_managed", EntryPoint="CSharp_new_switch_directories")]
|
||||||
public static extern IntPtr new_switch_directories();
|
public static extern IntPtr new_switch_directories();
|
||||||
|
|
||||||
|
@ -21594,6 +21606,26 @@ public class switch_directories : IDisposable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string recordings_dir {
|
||||||
|
set {
|
||||||
|
freeswitchPINVOKE.switch_directories_recordings_dir_set(swigCPtr, value);
|
||||||
|
}
|
||||||
|
get {
|
||||||
|
string ret = freeswitchPINVOKE.switch_directories_recordings_dir_get(swigCPtr);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string sounds_dir {
|
||||||
|
set {
|
||||||
|
freeswitchPINVOKE.switch_directories_sounds_dir_set(swigCPtr, value);
|
||||||
|
}
|
||||||
|
get {
|
||||||
|
string ret = freeswitchPINVOKE.switch_directories_sounds_dir_get(swigCPtr);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public switch_directories() : this(freeswitchPINVOKE.new_switch_directories(), true) {
|
public switch_directories() : this(freeswitchPINVOKE.new_switch_directories(), true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22473,6 +22505,7 @@ public enum switch_event_types_t {
|
||||||
SWITCH_EVENT_RECORD_STOP,
|
SWITCH_EVENT_RECORD_STOP,
|
||||||
SWITCH_EVENT_CALL_UPDATE,
|
SWITCH_EVENT_CALL_UPDATE,
|
||||||
SWITCH_EVENT_FAILURE,
|
SWITCH_EVENT_FAILURE,
|
||||||
|
SWITCH_EVENT_SOCKET_DATA,
|
||||||
SWITCH_EVENT_ALL
|
SWITCH_EVENT_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26256,7 +26289,8 @@ public enum switch_session_ctl_t {
|
||||||
SCSC_CANCEL_SHUTDOWN,
|
SCSC_CANCEL_SHUTDOWN,
|
||||||
SCSC_SEND_SIGHUP,
|
SCSC_SEND_SIGHUP,
|
||||||
SCSC_DEBUG_LEVEL,
|
SCSC_DEBUG_LEVEL,
|
||||||
SCSC_FLUSH_DB_HANDLES
|
SCSC_FLUSH_DB_HANDLES,
|
||||||
|
SCSC_SHUTDOWN_NOW
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ typedef struct {
|
||||||
static nat_globals_perm_t nat_globals_perm;
|
static nat_globals_perm_t nat_globals_perm;
|
||||||
|
|
||||||
static switch_bool_t first_init = SWITCH_TRUE;
|
static switch_bool_t first_init = SWITCH_TRUE;
|
||||||
|
static switch_bool_t initialized = SWITCH_FALSE;
|
||||||
|
|
||||||
static switch_status_t get_upnp_pubaddr(char *pub_addr)
|
static switch_status_t get_upnp_pubaddr(char *pub_addr)
|
||||||
{
|
{
|
||||||
|
@ -414,6 +415,7 @@ SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool)
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No PMP or UPnP NAT devices detected!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No PMP or UPnP NAT devices detected!\n");
|
||||||
}
|
}
|
||||||
first_init = SWITCH_FALSE;
|
first_init = SWITCH_FALSE;
|
||||||
|
initialized = SWITCH_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static switch_status_t switch_nat_add_mapping_pmp(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t *external_port)
|
static switch_status_t switch_nat_add_mapping_pmp(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t *external_port)
|
||||||
|
@ -630,7 +632,6 @@ SWITCH_DECLARE(void) switch_nat_republish(void)
|
||||||
if (!(natxml = switch_xml_parse_str_dup(stream.data))) {
|
if (!(natxml = switch_xml_parse_str_dup(stream.data))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to parse XML: %s\n", (char *) stream.data);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to parse XML: %s\n", (char *) stream.data);
|
||||||
switch_safe_free(stream.data);
|
switch_safe_free(stream.data);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* iterate the xml and publish the mappings */
|
/* iterate the xml and publish the mappings */
|
||||||
|
@ -677,6 +678,10 @@ SWITCH_DECLARE(char *) switch_nat_status(void)
|
||||||
return stream.data; /* caller frees */
|
return stream.data; /* caller frees */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_bool_t) switch_nat_is_initialized(void)
|
||||||
|
{
|
||||||
|
return initialized;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_nat_shutdown(void)
|
SWITCH_DECLARE(void) switch_nat_shutdown(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue