[Freeswitch-trunk] [commit] r13967 - in freeswitch/trunk: conf/jingle_profiles src/mod/endpoints/mod_dingaling
FreeSWITCH SVN
brian at freeswitch.org
Thu Jun 25 14:38:45 PDT 2009
Author: brian
Date: Thu Jun 25 16:38:44 2009
New Revision: 13967
Log:
adding auto-nat options to dingaling
Modified:
freeswitch/trunk/conf/jingle_profiles/client.xml
freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
Modified: freeswitch/trunk/conf/jingle_profiles/client.xml
==============================================================================
--- freeswitch/trunk/conf/jingle_profiles/client.xml (original)
+++ freeswitch/trunk/conf/jingle_profiles/client.xml Thu Jun 25 16:38:44 2009
@@ -9,7 +9,7 @@
<param name="context" value="public"/>
<param name="message" value="Jingle all the way"/>
<param name="rtp-ip" value="$${bind_server_ip}"/>
- <!-- <param name="ext-rtp-ip" value="$${external_rtp_ip}"/> -->
+ <!-- <param name="ext-rtp-ip" value="auto-nat"/> -->
<param name="auto-login" value="true"/>
<!-- SASL "plain" or "md5" -->
<param name="sasl" value="plain"/>
@@ -27,5 +27,6 @@
<param name="vad" value="both"/>
<!--<param name="avatar" value="/path/to/tiny.jpg"/>-->
<!--<param name="candidate-acl" value="wan.auto"/>-->
+ <param name="local-network-acl" value="localnet.auto"/>
</x-profile>
</include>
Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Thu Jun 25 16:38:44 2009
@@ -104,7 +104,7 @@
switch_event_node_t *probe_node;
switch_event_node_t *out_node;
switch_event_node_t *roster_node;
-
+ int auto_nat;
} globals;
struct mdl_profile {
@@ -135,6 +135,7 @@
uint32_t user_flags;
char *acl[MAX_ACL];
uint32_t acl_count;
+ char *local_network;
};
typedef struct mdl_profile mdl_profile_t;
@@ -841,6 +842,12 @@
switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
+ if(globals.auto_nat && tech_pvt->profile->local_network &&
+ !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
+ switch_port_t external_port = 0;
+ switch_nat_add_mapping((switch_port_t)tech_pvt->local_port, SWITCH_NAT_UDP, &external_port);
+ tech_pvt->local_port = external_port;
+ }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip,
tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
@@ -1194,6 +1201,11 @@
tech_pvt->rtp_session = NULL;
}
+ if(globals.auto_nat && tech_pvt->profile->local_network &&
+ !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
+ switch_nat_del_mapping((switch_port_t)tech_pvt->local_port, SWITCH_NAT_UDP);
+ }
+
if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
@@ -1943,10 +1955,22 @@
profile->name = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "message") && !switch_strlen_zero(val)) {
profile->message = switch_core_strdup(module_pool, val);
+ } else if (!strcasecmp(var, "local-network-acl")) {
+ profile->local_network = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "rtp-ip")) {
profile->ip = switch_core_strdup(module_pool, strcasecmp(switch_str_nil(val), "auto") ? switch_str_nil(val) : globals.guess_ip);
} else if (!strcasecmp(var, "ext-rtp-ip")) {
- profile->extip = switch_core_strdup(module_pool, strcasecmp(switch_str_nil(val), "auto") ? switch_str_nil(val) : globals.guess_ip);
+ char *ip = globals.guess_ip;
+ if (!strcasecmp(val, "auto-nat")) {
+ ip = globals.auto_nat ? switch_core_get_variable("nat_public_addr") : globals.guess_ip;
+ } else if (strcasecmp(val, "auto")) {
+ globals.auto_nat = 0;
+ ip = globals.guess_ip;
+ } else {
+ globals.auto_nat = 0;
+ ip = switch_strlen_zero(val) ? globals.guess_ip : val;
+ }
+ profile->extip = switch_core_strdup(module_pool, ip);
} else if (!strcasecmp(var, "server") && !switch_strlen_zero(val)) {
profile->server = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "rtp-timer-name") && !switch_strlen_zero(val)) {
@@ -2184,6 +2208,7 @@
memset(&globals, 0, sizeof(globals));
globals.running = 1;
+ globals.auto_nat = (switch_core_get_variable("nat_type") ? 1 : 0);
switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), NULL, AF_INET);
More information about the Freeswitch-trunk
mailing list