Freeswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- 12151 discussions
[commit] r5043 - in freeswitch/trunk: conf src src/mod/endpoints/mod_sofia
by Freeswitch SVN 30 Apr '07
by Freeswitch SVN 30 Apr '07
30 Apr '07
Author: anthm
Date: Mon Apr 30 16:35:35 2007
New Revision: 5043
Modified:
freeswitch/trunk/conf/directory.xml
freeswitch/trunk/conf/sofia.conf.xml
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
freeswitch/trunk/src/switch_xml.c
Log:
more changes to sofia to make better use of the directories
Modified: freeswitch/trunk/conf/directory.xml
==============================================================================
--- freeswitch/trunk/conf/directory.xml (original)
+++ freeswitch/trunk/conf/directory.xml Mon Apr 30 16:35:35 2007
@@ -2,61 +2,35 @@
<domain name="$${domain}">
<!--the user id (the left hand side of the @ in the addr-->
<user id="stpeter">
+ <!-- Outbound Registrations Related to this user -->
+ <gateways>
+ <!--<gateway name="asterlink.com">-->
+ <!--/// account username *required* ///-->
+ <!--<param name="username" value="cluecon"/>-->
+ <!--/// auth realm: *optional* same as gateway name, if blank ///-->
+ <!--<param name="realm" value="asterlink.com"/>-->
+ <!--/// account password *required* ///-->
+ <!--<param name="password" value="2007"/>-->
+ <!--/// replace the INVITE from user with the channel's caller-id ///-->
+ <!--<param name="caller-id-in-from" value="false"/>-->
+ <!--/// extension for inbound calls: *optional* same as username, if blank ///-->
+ <!--<param name="extension" value="cluecon"/>-->
+ <!--/// proxy host: *optional* same as realm, if blank ///-->
+ <!--<param name="proxy" value="asterlink.com"/>-->
+ <!--/// expire in seconds: *optional* 3600, if blank ///-->
+ <!--<param name="expire-seconds" value="60"/>-->
+ <!--/// do not register ///-->
+ <!--<param name="register" value="false"/>-->
+ <!--</gateway>-->
+ </gateways>
<params>
<!-- omit password for authless registration -->
<param name="password" value="mypass"/>
<!-- optionally use this instead if you want to store the hash of user:domain:pass-->
<!--<param name="a1-hash" value="c6440e5de50b403206989679159de89a"/>-->
</params>
-
- <!-- This is only for mod_dingaling so it can deliver vcards in component mode-->
- <vcard xmlns='vcard-temp'>
- <FN>Peter Saint-Andre</FN>
- <N>
- <FAMILY>Saint-Andre</FAMILY>
- <GIVEN>Peter</GIVEN>
- <MIDDLE/>
- </N>
- <NICKNAME>stpeter</NICKNAME>
- <URL>http://www.jabber.org/people/stpeter.php</URL>
- <BDAY>1966-08-06</BDAY>
- <ORG>
- <ORGNAME>Jabber Software Foundation</ORGNAME>
- <ORGUNIT>Jabber Software Foundation</ORGUNIT>
- </ORG>
- <TITLE>Executive Director</TITLE>
- <ROLE>Patron Saint</ROLE>
- <TEL><WORK/><VOICE/><NUMBER>303-308-3282</NUMBER></TEL>
- <TEL><WORK/><FAX/><NUMBER/></TEL>
- <TEL><WORK/><MSG/><NUMBER/></TEL>
- <ADR>
- <WORK/>
- <EXTADD>Suite 600</EXTADD>
- <STREET>1899 Wynkoop Street</STREET>
- <LOCALITY>Denver</LOCALITY>
- <REGION>CO</REGION>
- <PCODE>80202</PCODE>
- <CTRY>USA</CTRY>
- </ADR>
- <TEL><HOME/><VOICE/><NUMBER>303-555-1212</NUMBER></TEL>
- <TEL><HOME/><FAX/><NUMBER/></TEL>
- <TEL><HOME/><MSG/><NUMBER/></TEL>
- <ADR>
- <HOME/>
- <EXTADD/>
- <STREET/>
- <LOCALITY>Denver</LOCALITY>
- <REGION>CO</REGION>
- <PCODE>80209</PCODE>
- <CTRY>USA</CTRY>
- </ADR>
- <EMAIL><INTERNET/><PREF/><USERID>stpeter(a)jabber.org</USERID></EMAIL>
- <JABBERID>stpeter(a)jabber.org</JABBERID>
- <DESC>
- More information about me is located on my
- personal website: http://www.saint-andre.com/
- </DESC>
+ <vcard>
+ <!-- insert optional compliant vcard xml here-->
</vcard>
-
</user>
</domain>
Modified: freeswitch/trunk/conf/sofia.conf.xml
==============================================================================
--- freeswitch/trunk/conf/sofia.conf.xml (original)
+++ freeswitch/trunk/conf/sofia.conf.xml Mon Apr 30 16:35:35 2007
@@ -1,6 +1,10 @@
<configuration name="sofia.conf" description="sofia Endpoint">
<profiles>
<profile name="$${sip_profile}">
+ <!--aliases are other names that will work as a valid profile name for this profile-->
+ <aliases>
+ <alias name="default"/>
+ </aliases>
<!-- Outbound Registrations -->
<gateways>
<!--<gateway name="asterlink.com">-->
@@ -22,6 +26,12 @@
<!--<param name="register" value="false"/>-->
<!--</gateway>-->
</gateways>
+
+ <domains>
+ <!-- indicator to parse the directory for domains with parse="true" to get gateways-->
+ <!--<domain name="$${domain}" parse="true"/>-->
+ </domains>
+
<settings>
<param name="debug" value="1"/>
<param name="rfc2833-pt" value="101"/>
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Mon Apr 30 16:35:35 2007
@@ -893,19 +893,35 @@
sofia_profile_t *profile = NULL;
switch_hash_index_t *hi;
void *val;
+ const void *vvar;
int c = 0;
+ int ac = 0;
+ const char *line = "================================================================================";
+
+
+ stream->write_function(stream, "%25s\t%s\t %32s\n", "Name", " Type", "Data");
+ stream->write_function(stream, "%s\n", line);
switch_mutex_lock(mod_sofia_globals.hash_mutex);
for (hi = switch_hash_first(switch_hash_pool_get(mod_sofia_globals.profile_hash), mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
- switch_hash_this(hi, NULL, NULL, &val);
+ switch_hash_this(hi, &vvar, NULL, &val);
profile = (sofia_profile_t *) val;
if (sofia_test_pflag(profile, PFLAG_RUNNING)) {
- stream->write_function(stream, "Profile %s\n", profile->name);
- c++;
+
+ if (strcmp(vvar, profile->name)) {
+ ac++;
+ stream->write_function(stream, "%25s\t%s\t %32s\n", vvar, " alias", profile->name);
+ } else {
+ stream->write_function(stream, "%25s\t%s\t %32s\n", profile->name, "profile", profile->url);
+ c++;
+ }
+
+
}
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
- stream->write_function(stream, "%d profiles\n", c);
+ stream->write_function(stream, "%s\n", line);
+ stream->write_function(stream, "%d profiles %d aliases\n", c, ac);
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Mon Apr 30 16:35:35 2007
@@ -437,14 +437,14 @@
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
sofia_profile_t *sofia_glue_find_profile(char *key);
-void sofia_glue_add_profile(char *key, sofia_profile_t *profile);
+switch_status_t sofia_glue_add_profile(char *key, sofia_profile_t *profile);
void sofia_glue_execute_sql(sofia_profile_t *profile, switch_bool_t master, char *sql, switch_mutex_t *mutex);
void sofia_reg_check_expire(sofia_profile_t *profile, time_t now);
void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now);
void sofia_reg_unregister(sofia_profile_t *profile);
switch_status_t sofia_glue_ext_address_lookup(char **ip, switch_port_t *port, char *sourceip, switch_memory_pool_t *pool);
sofia_gateway_t *sofia_reg_find_gateway(char *key);
-void sofia_reg_add_gateway(char *key, sofia_gateway_t *gateway);
+switch_status_t sofia_reg_add_gateway(char *key, sofia_gateway_t *gateway);
void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp);
int sofia_glue_get_user_host(char *in, char **user, char **host);
switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
@@ -467,3 +467,4 @@
char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, char *resbuf, size_t len);
void sofia_glue_check_video_codecs(private_object_t *tech_pvt);
void sofia_reg_release_gateway(sofia_gateway_t *gateway);
+void sofia_glue_del_profile(sofia_profile_t *profile);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Apr 30 16:35:35 2007
@@ -380,9 +380,8 @@
su_root_destroy(profile->s_root);
pool = profile->pool;
- switch_mutex_lock(mod_sofia_globals.hash_mutex);
- switch_core_hash_delete(mod_sofia_globals.profile_hash, profile->name);
- switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+
+ sofia_glue_del_profile(profile);
switch_thread_rwlock_unlock(profile->rwlock);
@@ -436,14 +435,148 @@
}
+static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
+{
+ switch_xml_t gateway_tag, param;
+ sofia_gateway_t *gp;
+
+ for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag; gateway_tag = gateway_tag->next) {
+ char *name = (char *) switch_xml_attr_soft(gateway_tag, "name");
+ sofia_gateway_t *gateway;
+
+ if (switch_strlen_zero(name)) {
+ name = "anonymous";
+ }
+
+ if ((gateway = switch_core_alloc(profile->pool, sizeof(*gateway)))) {
+ char *register_str = "true", *scheme = "Digest",
+ *realm = NULL,
+ *username = NULL,
+ *password = NULL,
+ *caller_id_in_from = "false",
+ *extension = NULL,
+ *proxy = NULL,
+ *context = "default",
+ *expire_seconds = "3600";
+
+ gateway->pool = profile->pool;
+ gateway->profile = profile;
+ gateway->name = switch_core_strdup(gateway->pool, name);
+ gateway->freq = 0;
+
+
+ for (param = switch_xml_child(gateway_tag, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+
+ if (!strcmp(var, "register")) {
+ register_str = val;
+ } else if (!strcmp(var, "scheme")) {
+ scheme = val;
+ } else if (!strcmp(var, "realm")) {
+ realm = val;
+ } else if (!strcmp(var, "username")) {
+ username = val;
+ } else if (!strcmp(var, "password")) {
+ password = val;
+ } else if (!strcmp(var, "caller-id-in-from")) {
+ caller_id_in_from = val;
+ } else if (!strcmp(var, "extension")) {
+ extension = val;
+ } else if (!strcmp(var, "proxy")) {
+ proxy = val;
+ } else if (!strcmp(var, "context")) {
+ context = val;
+ } else if (!strcmp(var, "expire-seconds")) {
+ expire_seconds = val;
+ }
+ }
+
+ if (switch_strlen_zero(realm)) {
+ realm = name;
+ }
+
+ if (switch_strlen_zero(username)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: username param is REQUIRED!\n");
+ goto skip;
+ }
+
+ if (switch_strlen_zero(password)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: password param is REQUIRED!\n");
+ goto skip;
+ }
+
+ if (switch_strlen_zero(extension)) {
+ extension = username;
+ }
+
+ if (switch_strlen_zero(proxy)) {
+ proxy = realm;
+ }
+
+ if (!switch_true(register_str)) {
+ gateway->state = REG_STATE_NOREG;
+ }
+ gateway->register_scheme = switch_core_strdup(gateway->pool, scheme);
+ gateway->register_context = switch_core_strdup(gateway->pool, context);
+ gateway->register_realm = switch_core_strdup(gateway->pool, realm);
+ gateway->register_username = switch_core_strdup(gateway->pool, username);
+ gateway->register_password = switch_core_strdup(gateway->pool, password);
+ if (switch_true(caller_id_in_from)) {
+ switch_set_flag(gateway, REG_FLAG_CALLERID);
+ }
+ gateway->register_from = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, realm);
+ gateway->register_contact = switch_core_sprintf(gateway->pool, "sip:%s@%s:%d", extension, profile->sipip, profile->sip_port);
+
+ if (!strncasecmp(proxy, "sip:", 4)) {
+ gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
+ gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
+ } else {
+ gateway->register_proxy = switch_core_sprintf(gateway->pool, "sip:%s", proxy);
+ gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy);
+ }
+
+ gateway->expires_str = switch_core_strdup(gateway->pool, expire_seconds);
+
+ if ((gateway->freq = atoi(gateway->expires_str)) < 5) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ "Invalid Freq: %d. Setting Register-Frequency to 3600\n", gateway->freq);
+ gateway->freq = 3600;
+ }
+ gateway->freq -= 2;
+
+ gateway->next = profile->gateways;
+ profile->gateways = gateway;
+
+ if ((gp = sofia_reg_find_gateway(gateway->name))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", gateway->name);
+ sofia_reg_release_gateway(gp);
+ } else if ((gp=sofia_reg_find_gateway(gateway->register_from))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate uri '%s'\n", gateway->register_from);
+ sofia_reg_release_gateway(gp);
+ } else if ((gp=sofia_reg_find_gateway(gateway->register_contact))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate contact '%s'\n", gateway->register_from);
+ sofia_reg_release_gateway(gp);
+ } else {
+ sofia_reg_add_gateway(gateway->name, gateway);
+ sofia_reg_add_gateway(gateway->register_from, gateway);
+ sofia_reg_add_gateway(gateway->register_contact, gateway);
+ }
+ }
+
+ skip:
+ assert(gateway_tag);
+ }
+
+}
+
switch_status_t config_sofia(int reload, char *profile_name)
{
char *cf = "sofia.conf";
- switch_xml_t cfg, xml = NULL, xprofile, param, settings, profiles, gateway_tag, gateways_tag;
+ switch_xml_t cfg, xml = NULL, xprofile, param, settings, profiles, gateways_tag, domain_tag, domains_tag;
switch_status_t status = SWITCH_STATUS_SUCCESS;
sofia_profile_t *profile = NULL;
char url[512] = "";
- sofia_gateway_t *gp;
int profile_found = 0;
if (!reload) {
@@ -713,143 +846,52 @@
}
}
if (profile) {
+ switch_xml_t aliases_tag, alias_tag;
+
if ((gateways_tag = switch_xml_child(xprofile, "registrations"))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
"The <registrations> syntax has been discontinued, please see the new syntax in the default configuration examples\n");
+ } else if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) {
+ parse_gateways(profile, gateways_tag);
}
- if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) {
- for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag; gateway_tag = gateway_tag->next) {
- char *name = (char *) switch_xml_attr_soft(gateway_tag, "name");
- sofia_gateway_t *gateway;
-
- if (switch_strlen_zero(name)) {
- name = "anonymous";
- }
-
- if ((gateway = switch_core_alloc(profile->pool, sizeof(*gateway)))) {
- char *register_str = "true", *scheme = "Digest",
- *realm = NULL,
- *username = NULL,
- *password = NULL,
- *caller_id_in_from = "false",
- *extension = NULL,
- *proxy = NULL,
- *context = "default",
- *expire_seconds = "3600";
-
- gateway->pool = profile->pool;
- gateway->profile = profile;
- gateway->name = switch_core_strdup(gateway->pool, name);
- gateway->freq = 0;
-
-
- for (param = switch_xml_child(gateway_tag, "param"); param; param = param->next) {
- char *var = (char *) switch_xml_attr_soft(param, "name");
- char *val = (char *) switch_xml_attr_soft(param, "value");
-
- if (!strcmp(var, "register")) {
- register_str = val;
- } else if (!strcmp(var, "scheme")) {
- scheme = val;
- } else if (!strcmp(var, "realm")) {
- realm = val;
- } else if (!strcmp(var, "username")) {
- username = val;
- } else if (!strcmp(var, "password")) {
- password = val;
- } else if (!strcmp(var, "caller-id-in-from")) {
- caller_id_in_from = val;
- } else if (!strcmp(var, "extension")) {
- extension = val;
- } else if (!strcmp(var, "proxy")) {
- proxy = val;
- } else if (!strcmp(var, "context")) {
- context = val;
- } else if (!strcmp(var, "expire-seconds")) {
- expire_seconds = val;
+ if ((domains_tag = switch_xml_child(xprofile, "domains"))) {
+ for (domain_tag = switch_xml_child(domains_tag, "domain"); domain_tag; domain_tag = domain_tag->next) {
+ switch_xml_t droot, actual_domain_tag, ut;
+ char *dname = (char *) switch_xml_attr_soft(domain_tag, "name");
+ char *parse = (char *) switch_xml_attr_soft(domain_tag, "parse");
+
+ if (!switch_strlen_zero(dname)) {
+ if (switch_true(parse)) {
+ if (switch_xml_locate_domain(dname, NULL, &droot, &actual_domain_tag) == SWITCH_STATUS_SUCCESS) {
+ for (ut = switch_xml_child(actual_domain_tag, "user"); ut; ut = ut->next) {
+ if (((gateways_tag = switch_xml_child(ut, "gateways")))) {
+ parse_gateways(profile, gateways_tag);
+ }
+ }
}
}
+ sofia_glue_add_profile(switch_core_strdup(profile->pool, dname), profile);
+ }
+ }
+ }
+
+ if ((aliases_tag = switch_xml_child(xprofile, "aliases"))) {
+ for (alias_tag = switch_xml_child(aliases_tag, "alias"); alias_tag; alias_tag = alias_tag->next) {
+ char *aname = (char *) switch_xml_attr_soft(alias_tag, "name");
+ if (!switch_strlen_zero(aname)) {
- if (switch_strlen_zero(realm)) {
- realm = name;
- }
-
- if (switch_strlen_zero(username)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: username param is REQUIRED!\n");
- switch_xml_free(xml);
- goto skip;
- }
-
- if (switch_strlen_zero(password)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: password param is REQUIRED!\n");
- switch_xml_free(xml);
- goto skip;
- }
-
- if (switch_strlen_zero(extension)) {
- extension = username;
- }
-
- if (switch_strlen_zero(proxy)) {
- proxy = realm;
- }
-
- if (!switch_true(register_str)) {
- gateway->state = REG_STATE_NOREG;
- }
- gateway->register_scheme = switch_core_strdup(gateway->pool, scheme);
- gateway->register_context = switch_core_strdup(gateway->pool, context);
- gateway->register_realm = switch_core_strdup(gateway->pool, realm);
- gateway->register_username = switch_core_strdup(gateway->pool, username);
- gateway->register_password = switch_core_strdup(gateway->pool, password);
- if (switch_true(caller_id_in_from)) {
- switch_set_flag(gateway, REG_FLAG_CALLERID);
- }
- gateway->register_from = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, realm);
- gateway->register_contact = switch_core_sprintf(gateway->pool, "sip:%s@%s:%d", extension, profile->sipip, profile->sip_port);
-
- if (!strncasecmp(proxy, "sip:", 4)) {
- gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
- gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
- } else {
- gateway->register_proxy = switch_core_sprintf(gateway->pool, "sip:%s", proxy);
- gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy);
- }
-
- gateway->expires_str = switch_core_strdup(gateway->pool, expire_seconds);
-
- if ((gateway->freq = atoi(gateway->expires_str)) < 5) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
- "Invalid Freq: %d. Setting Register-Frequency to 3600\n", gateway->freq);
- gateway->freq = 3600;
- }
- gateway->freq -= 2;
-
- gateway->next = profile->gateways;
- profile->gateways = gateway;
-
- if ((gp = sofia_reg_find_gateway(gateway->name))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", gateway->name);
- sofia_reg_release_gateway(gp);
- } else if ((gp=sofia_reg_find_gateway(gateway->register_from))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate uri '%s'\n", gateway->register_from);
- sofia_reg_release_gateway(gp);
- } else if ((gp=sofia_reg_find_gateway(gateway->register_contact))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate contact '%s'\n", gateway->register_from);
- sofia_reg_release_gateway(gp);
+ if (sofia_glue_add_profile(switch_core_strdup(profile->pool, aname), profile) == SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Alias [%s] for profile [%s]\n", aname, profile->name);
} else {
- sofia_reg_add_gateway(gateway->name, gateway);
- sofia_reg_add_gateway(gateway->register_from, gateway);
- sofia_reg_add_gateway(gateway->register_contact, gateway);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Adding Alias [%s] for profile [%s] (name in use)\n",
+ aname, profile->name);
}
}
-
- skip:
- assert(gateway_tag);
}
}
+
if (profile->sipip) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Started Profile %s [%s]\n", profile->name, url);
launch_sofia_profile_thread(profile);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Mon Apr 30 16:35:35 2007
@@ -1437,11 +1437,48 @@
return profile;
}
-void sofia_glue_add_profile(char *key, sofia_profile_t *profile)
+switch_status_t sofia_glue_add_profile(char *key, sofia_profile_t *profile)
{
+ switch_status_t status = SWITCH_STATUS_FALSE;
+
+ switch_mutex_lock(mod_sofia_globals.hash_mutex);
+ if (!switch_core_hash_find(mod_sofia_globals.profile_hash, key)) {
+ status = switch_core_hash_insert(mod_sofia_globals.profile_hash, key, profile);
+ }
+ switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+
+ return status;
+}
+
+void sofia_glue_del_profile(sofia_profile_t *profile)
+{
+ switch_hash_index_t *hi;
+ void *vval;
+ const void *vvar;
+ sofia_profile_t *this_profile;
+ sofia_gateway_t *gp, *this_gateway;
+
+
switch_mutex_lock(mod_sofia_globals.hash_mutex);
- switch_core_hash_insert(mod_sofia_globals.profile_hash, key, profile);
+ for (hi = switch_hash_first(switch_hash_pool_get(mod_sofia_globals.profile_hash), mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+ switch_hash_this(hi, &vvar, NULL, &vval);
+ this_profile = (sofia_profile_t *) vval;
+ if (this_profile == profile) {
+ switch_core_hash_delete(mod_sofia_globals.profile_hash, vvar);
+ }
+ }
+ for (hi = switch_hash_first(switch_hash_pool_get(mod_sofia_globals.gateway_hash), mod_sofia_globals.gateway_hash); hi; hi = switch_hash_next(hi)) {
+ switch_hash_this(hi, &vvar, NULL, &vval);
+ this_gateway = (sofia_gateway_t *) vval;
+
+ for (gp = profile->gateways; gp; gp = gp->next) {
+ if (gp == this_gateway) {
+ switch_core_hash_delete(mod_sofia_globals.gateway_hash, vvar);
+ }
+ }
+ }
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+
}
int sofia_glue_init_sql(sofia_profile_t *profile)
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Mon Apr 30 16:35:35 2007
@@ -838,13 +838,18 @@
switch_thread_rwlock_unlock(gateway->profile->rwlock);
}
-void sofia_reg_add_gateway(char *key, sofia_gateway_t * gateway)
+switch_status_t sofia_reg_add_gateway(char *key, sofia_gateway_t *gateway)
{
+ switch_status_t status = SWITCH_STATUS_FALSE;
+
switch_mutex_lock(mod_sofia_globals.hash_mutex);
- switch_core_hash_insert(mod_sofia_globals.gateway_hash, key, gateway);
+ if (!switch_core_hash_find(mod_sofia_globals.gateway_hash, key)) {
+ status = switch_core_hash_insert(mod_sofia_globals.gateway_hash, key, gateway);
+ }
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
-}
+ return status;
+}
Modified: freeswitch/trunk/src/switch_xml.c
==============================================================================
--- freeswitch/trunk/src/switch_xml.c (original)
+++ freeswitch/trunk/src/switch_xml.c Mon Apr 30 16:35:35 2007
@@ -1176,6 +1176,13 @@
SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(char *domain_name, char *params, switch_xml_t *root, switch_xml_t *domain)
{
*domain = NULL;
+ char my_params[512];
+
+ if (!params) {
+ snprintf(my_params, sizeof(my_params), "domain=%s", domain_name);
+ params = my_params;
+ }
+
return switch_xml_locate("directory", "domain", "name", domain_name, root, domain, params);
}
1
0
30 Apr '07
Author: anthm
Date: Mon Apr 30 12:26:44 2007
New Revision: 5042
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
Log:
<variables> section in user for local chan vars during authed calls
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Mon Apr 30 12:26:44 2007
@@ -414,7 +414,8 @@
void sofia_presence_mwi_event_handler(switch_event_t *event);
void sofia_presence_cancel(void);
switch_status_t config_sofia(int reload, char *profile_name);
-auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, const char *regstr, char *np, size_t nplen, char *ip);
+auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization,
+ const char *regstr, char *np, size_t nplen, char *ip, switch_event_t **v_event);
void sofia_reg_handle_sip_r_challenge(int status,
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
@@ -448,7 +449,8 @@
int sofia_glue_get_user_host(char *in, char **user, char **host);
switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
void sofia_glue_do_xfer_invite(switch_core_session_t *session);
-uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, sofia_regtype_t regtype, char *key, uint32_t keylen);
+uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip,
+ sofia_regtype_t regtype, char *key, uint32_t keylen, switch_event_t **v_event);
const switch_endpoint_interface_t sofia_endpoint_interface;
void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip);
switch_status_t sofia_on_hangup(switch_core_session_t *session);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Apr 30 12:26:44 2007
@@ -52,7 +52,7 @@
if (sofia_private) {
if (!switch_strlen_zero(sofia_private->uuid)) {
-
+
if ((session = switch_core_session_locate(sofia_private->uuid))) {
tech_pvt = switch_core_session_get_private(session);
channel = switch_core_session_get_channel(tech_pvt->session);
@@ -69,7 +69,6 @@
}
}
}
-
if (status != 100 && status != 200) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "event [%s] status [%d][%s] session: %s\n",
@@ -89,7 +88,7 @@
char network_ip[80];
get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_addr);
auth_res = sofia_reg_parse_auth(profile, authorization,
- (char *) sip->sip_request->rq_method_name, tech_pvt->key, strlen(tech_pvt->key), network_ip);
+ (char *) sip->sip_request->rq_method_name, tech_pvt->key, strlen(tech_pvt->key), network_ip, NULL);
}
if (auth_res != AUTH_OK) {
@@ -322,20 +321,11 @@
gateway_loops = GATEWAY_SECONDS;
if (switch_event_create(&s_event, SWITCH_EVENT_PUBLISH) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp");
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", profile->sip_port);
- switch_event_fire(&s_event);
- }
-
- if (switch_event_create(&s_event, SWITCH_EVENT_PUBLISH) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._tcp");
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", profile->sip_port);
- switch_event_fire(&s_event);
- }
-
- if (switch_event_create(&s_event, SWITCH_EVENT_PUBLISH) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._sctp");
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp,_sip._tcp,_sip._sctp");
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", profile->sip_port);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "module_name", "%s", "mod_sofia");
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_name", "%s", profile->name);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_uri", "%s", profile->url);
switch_event_fire(&s_event);
}
@@ -377,8 +367,11 @@
}
if (switch_event_create(&s_event, SWITCH_EVENT_UNPUBLISH) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp");
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp,_sip._tcp,_sip._sctp");
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", profile->sip_port);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "module_name", "%s", "mod_sofia");
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_name", "%s", profile->name);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_uri", "%s", profile->url);
switch_event_fire(&s_event);
}
@@ -1639,6 +1632,7 @@
const char *from_user = NULL, *from_host = NULL;
const char *context = NULL;
char network_ip[80];
+ switch_event_t *v_event = NULL;
if (!sip || !sip->sip_request || !sip->sip_request->rq_method_name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received an invalid packet!\n");
@@ -1654,11 +1648,14 @@
}
if ((profile->pflags & PFLAG_AUTH_CALLS)) {
- if (sofia_reg_handle_register(nua, profile, nh, sip, REG_INVITE, key, sizeof(key))) {
+ if (sofia_reg_handle_register(nua, profile, nh, sip, REG_INVITE, key, sizeof(key), &v_event)) {
+ if (v_event) {
+ switch_event_destroy(&v_event);
+ }
return;
}
}
-
+
if (!(session = switch_core_session_request(&sofia_endpoint_interface, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Session Alloc Failed!\n");
nua_respond(nh, SIP_503_SERVICE_UNAVAILABLE, TAG_END());
@@ -1681,6 +1678,16 @@
channel = switch_core_session_get_channel(session);
+ if (v_event) {
+ switch_event_header_t *hp;
+
+ for(hp = v_event->headers; hp; hp = hp->next) {
+ switch_channel_set_variable(channel, hp->name, hp->value);
+ }
+
+ switch_event_destroy(&v_event);
+ }
+
if (sip->sip_from && sip->sip_from->a_url) {
from_user = sip->sip_from->a_url->url_user;
from_host = sip->sip_from->a_url->url_host;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Mon Apr 30 12:26:44 2007
@@ -244,7 +244,7 @@
}
uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_handle_t * nh, sip_t const *sip, sofia_regtype_t regtype, char *key,
- uint32_t keylen)
+ uint32_t keylen, switch_event_t **v_event)
{
sip_from_t const *from = NULL;
sip_expires_t const *expires = NULL;
@@ -327,10 +327,10 @@
}
if (authorization) {
- if ((auth_res = sofia_reg_parse_auth(profile, authorization, sip->sip_request->rq_method_name, key, keylen, network_ip)) == AUTH_STALE) {
+ if ((auth_res = sofia_reg_parse_auth(profile, authorization, sip->sip_request->rq_method_name, key, keylen, network_ip, v_event)) == AUTH_STALE) {
stale = 1;
}
-
+
if (auth_res != AUTH_OK && !stale) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "send %s for [%s@%s]\n", forbidden ? "forbidden" : "challange", from_user, from_host);
if (auth_res == AUTH_FORBIDDEN) {
@@ -472,7 +472,7 @@
return;
}
- sofia_reg_handle_register(nua, profile, nh, sip, REG_REGISTER, key, sizeof(key));
+ sofia_reg_handle_register(nua, profile, nh, sip, REG_REGISTER, key, sizeof(key), NULL);
}
@@ -630,7 +630,8 @@
}
-auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, const char *regstr, char *np, size_t nplen, char *ip)
+auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization,
+ const char *regstr, char *np, size_t nplen, char *ip, switch_event_t **v_event)
{
int indexnum;
const char *cur;
@@ -641,8 +642,9 @@
auth_res_t ret = AUTH_FORBIDDEN;
char *npassword = NULL;
int cnt = 0;
- username = realm = nonce = uri = qop = cnonce = nc = response = NULL;
+ username = realm = nonce = uri = qop = cnonce = nc = response = NULL;
+
if (authorization->au_params) {
for (indexnum = 0; (cur = authorization->au_params[indexnum]); indexnum++) {
char *var, *val, *p, *work;
@@ -734,7 +736,21 @@
a1_hash = val;
}
}
-
+
+ if (v_event && (xparams = switch_xml_child(user, "variables"))) {
+ if (switch_event_create(v_event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ for (param = switch_xml_child(xparams, "variable"); param; param = param->next) {
+ const char *var = switch_xml_attr_soft(param, "name");
+ const char *val = switch_xml_attr_soft(param, "value");
+
+ if (!switch_strlen_zero(var) && !switch_strlen_zero(val)) {
+ switch_event_add_header(*v_event, SWITCH_STACK_BOTTOM, var, "%s", val);
+ }
+ }
+ }
+ }
+
+
if (switch_strlen_zero(passwd) && switch_strlen_zero(a1_hash)) {
ret = AUTH_OK;
goto end;
1
0
29 Apr '07
Author: mikej
Date: Sun Apr 29 12:34:00 2007
New Revision: 5041
Modified:
freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
Log:
fix form MODLANG-13 from Matt brown, thanks Matt.
Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp Sun Apr 29 12:34:00 2007
@@ -76,17 +76,19 @@
int SessionContainer::play_file(char *file, char *timer_name)
{
switch_status_t status;
+ switch_input_args_t args = { 0 };
if (switch_strlen_zero(timer_name)) {
timer_name = NULL;
}
if (!dtmfCallbackFunction) {
- status = switch_ivr_play_file(session, NULL, file, timer_name, NULL, NULL, 0);
+ status = switch_ivr_play_file(session, NULL, file, &args);
}
else {
globalDTMFCallbackFunction = dtmfCallbackFunction;
- status = switch_ivr_play_file(session, NULL, file, timer_name, PythonDTMFCallback, NULL, 0);
+ args.input_callback = PythonDTMFCallback;
+ status = switch_ivr_play_file(session, NULL, file, &args);
}
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
@@ -106,13 +108,19 @@
int SessionContainer::speak_text(char *text)
{
switch_status_t status;
+ switch_codec_t *codec;
+ switch_input_args_t args = { 0 };
+ codec = switch_core_session_get_read_codec(session);
if (!dtmfCallbackFunction) {
- status = switch_ivr_speak_text(session, tts_name, voice_name, NULL, 0, NULL, text, NULL, 0);
+ status = switch_ivr_speak_text(session, tts_name, voice_name,
+ codec->implementation->samples_per_second, text, &args);
}
else {
globalDTMFCallbackFunction = dtmfCallbackFunction;
- status = switch_ivr_speak_text(session, tts_name, voice_name, NULL, 0, PythonDTMFCallback, text, NULL, 0);
+ args.input_callback = PythonDTMFCallback;
+ status = switch_ivr_speak_text(session, tts_name, voice_name,
+ codec->implementation->samples_per_second, text, &args);
}
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
@@ -151,3 +159,4 @@
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
+
1
0
29 Apr '07
Author: anthm
Date: Sat Apr 28 23:42:38 2007
New Revision: 5040
Modified:
freeswitch/trunk/src/include/private/switch_core.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/switch_core_session.c
Log:
recursion protection
Modified: freeswitch/trunk/src/include/private/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core.h (original)
+++ freeswitch/trunk/src/include/private/switch_core.h Sat Apr 28 23:42:38 2007
@@ -127,6 +127,7 @@
switch_thread_rwlock_t *bug_rwlock;
switch_media_bug_t *bugs;
switch_app_log_t *app_log;
+ uint32_t stack_count;
};
struct switch_media_bug {
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Sat Apr 28 23:42:38 2007
@@ -229,6 +229,7 @@
typedef struct switch_directories switch_directories;
SWITCH_DECLARE_DATA extern switch_directories SWITCH_GLOBAL_dirs;
+#define SWITCH_MAX_STACKS 32
#define SWITCH_THREAD_STACKSIZE 240 * 1024
#define SWITCH_RECOMMENDED_BUFFER_SIZE 3968
#define SWITCH_MAX_CODECS 30
Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c (original)
+++ freeswitch/trunk/src/switch_core_session.c Sat Apr 28 23:42:38 2007
@@ -921,13 +921,21 @@
switch_caller_extension_t *extension = NULL;
const switch_application_interface_t *application_interface;
switch_event_t *event;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
channel = switch_core_session_get_channel(session);
-
+
if (!(profile = switch_channel_get_caller_profile(channel))) {
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (session->stack_count > SWITCH_MAX_STACKS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error %s too many stacked extensions\n", switch_channel_get_name(session->channel));
+ return SWITCH_STATUS_FALSE;
}
+ session->stack_count++;
+
new_profile = switch_caller_profile_clone(session, profile);
new_profile->destination_number = switch_core_session_strdup(session, exten);
@@ -965,7 +973,8 @@
}
if (!extension) {
- return SWITCH_STATUS_FALSE;
+ status = SWITCH_STATUS_FALSE;
+ goto done;
}
new_profile->caller_extension = extension;
@@ -983,18 +992,21 @@
extension->current_application->application_name, switch_str_nil(extension->current_application->application_data));
if ((application_interface = switch_loadable_module_get_application_interface(extension->current_application->application_name)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Application %s\n", extension->current_application->application_name);
- return SWITCH_STATUS_FALSE;
+ status = SWITCH_STATUS_FALSE;
+ goto done;
}
if (switch_channel_test_flag(session->channel, CF_NOMEDIA) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Application %s Cannot be used with NO_MEDIA mode!\n",
extension->current_application->application_name);
- return SWITCH_STATUS_FALSE;
+ status = SWITCH_STATUS_FALSE;
+ goto done;
}
if (!application_interface->application_function) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Function for %s\n", extension->current_application->application_name);
- return SWITCH_STATUS_FALSE;
+ status = SWITCH_STATUS_FALSE;
+ goto done;
}
if ((expanded =
@@ -1030,7 +1042,11 @@
extension->current_application = extension->current_application->next;
}
- return SWITCH_STATUS_SUCCESS;
+ done:
+
+ session->stack_count--;
+
+ return status;
}
1
0
[commit] r5039 - in freeswitch/trunk/src: . mod/applications/mod_commands
by Freeswitch SVN 29 Apr '07
by Freeswitch SVN 29 Apr '07
29 Apr '07
Author: anthm
Date: Sat Apr 28 23:21:56 2007
New Revision: 5039
Modified:
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/switch_loadable_module.c
Log:
update msg txt
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Sat Apr 28 23:21:56 2007
@@ -133,7 +133,7 @@
arg = 0;
switch_core_session_ctl(SCSC_SHUTDOWN, &arg);
} else {
- stream->write_function(stream, "INVALID COMMAND [%s]\nUSAGE: fsctl [hupall|pause|resume|shutdown]\n", argv[0]);
+ stream->write_function(stream, "INVALID COMMAND\nUSAGE: fsctl [hupall|pause|resume|shutdown]\n");
goto end;
}
Modified: freeswitch/trunk/src/switch_loadable_module.c
==============================================================================
--- freeswitch/trunk/src/switch_loadable_module.c (original)
+++ freeswitch/trunk/src/switch_loadable_module.c Sat Apr 28 23:21:56 2007
@@ -959,8 +959,7 @@
status = api->function(arg, session, stream);
} else {
status = SWITCH_STATUS_FALSE;
- stream->write_function(stream, "INVALID COMMAND [%s]", cmd);
- /* snprintf(retbuf, len, "INVALID COMMAND [%s]", cmd); */
+ stream->write_function(stream, "INVALID COMMAND!\n");
}
if (stream->event) {
1
0
29 Apr '07
Author: mikej
Date: Sat Apr 28 22:02:05 2007
New Revision: 5038
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
hint... hint...
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Sat Apr 28 22:02:05 2007
@@ -467,7 +467,9 @@
return status;
}
- if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
+ snprintf(url, sizeof(url), "profile=%s", switch_str_nil(profile_name));
+
+ if (!(xml = switch_xml_open_cfg(cf, &cfg, url))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
status = SWITCH_STATUS_FALSE;
goto done;
1
0
29 Apr '07
Author: mikej
Date: Sat Apr 28 21:51:32 2007
New Revision: 5037
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/switch_channel.c
Log:
fix build on msvc.
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Sat Apr 28 21:51:32 2007
@@ -372,8 +372,8 @@
su_root_run(profile->s_root);
nua_destroy(profile->nua);
- while(0 && profile->inuse) {
- switch_yield(1000000);
+ while(profile->inuse) {
+ switch_yield(100000);
}
if (switch_event_create(&s_event, SWITCH_EVENT_UNPUBLISH) == SWITCH_STATUS_SUCCESS) {
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Sat Apr 28 21:51:32 2007
@@ -354,8 +354,8 @@
SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, char *key)
{
- assert(channel != NULL);
void *val;
+ assert(channel != NULL);
switch_mutex_lock(channel->profile_mutex);
val = switch_core_hash_find(channel->private_hash, key);
switch_mutex_unlock(channel->profile_mutex);
1
0
29 Apr '07
Author: anthm
Date: Sat Apr 28 21:16:49 2007
New Revision: 5036
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
freeswitch/trunk/src/switch_odbc.c
Log:
either break everything or make it cooler ... ?
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Sat Apr 28 21:16:49 2007
@@ -244,6 +244,10 @@
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+ switch_mutex_lock(tech_pvt->profile->flag_mutex);
+ tech_pvt->profile->inuse--;
+ switch_mutex_unlock(tech_pvt->profile->flag_mutex);
+
if (tech_pvt->sofia_private) {
*tech_pvt->sofia_private->uuid = '\0';
}
@@ -275,7 +279,6 @@
assert(channel != NULL);
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
switch_set_flag_locked(tech_pvt, TFLAG_ANS);
@@ -314,9 +317,11 @@
}
}
}
+
nua_respond(tech_pvt->nh, SIP_200_OK,
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
+
}
return SWITCH_STATUS_SUCCESS;
@@ -336,7 +341,7 @@
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
assert(tech_pvt != NULL);
- if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+ if (switch_test_flag(tech_pvt, TFLAG_HUP) || !sofia_test_pflag(tech_pvt->profile, PFLAG_RUNNING)) {
return SWITCH_STATUS_FALSE;
}
@@ -408,7 +413,7 @@
}
}
- if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+ if (switch_test_flag(tech_pvt, TFLAG_HUP) || !sofia_test_pflag(tech_pvt->profile, PFLAG_RUNNING)) {
return SWITCH_STATUS_FALSE;
}
@@ -440,7 +445,7 @@
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
assert(tech_pvt != NULL);
- if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+ if (switch_test_flag(tech_pvt, TFLAG_HUP) || !sofia_test_pflag(tech_pvt->profile, PFLAG_RUNNING)) {
return SWITCH_STATUS_FALSE;
}
@@ -535,7 +540,7 @@
}
}
- if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+ if (switch_test_flag(tech_pvt, TFLAG_HUP) || !sofia_test_pflag(tech_pvt->profile, PFLAG_RUNNING)) {
return SWITCH_STATUS_FALSE;
}
@@ -880,6 +885,126 @@
return SWITCH_STATUS_SUCCESS;
}
+typedef switch_status_t (*sofia_command_t) (char **argv, int argc, switch_stream_handle_t *stream);
+
+
+static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t *stream)
+{
+ sofia_profile_t *profile = NULL;
+ switch_hash_index_t *hi;
+ void *val;
+ int c = 0;
+
+ switch_mutex_lock(mod_sofia_globals.hash_mutex);
+ for (hi = switch_hash_first(switch_hash_pool_get(mod_sofia_globals.profile_hash), mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+ switch_hash_this(hi, NULL, NULL, &val);
+ profile = (sofia_profile_t *) val;
+ if (sofia_test_pflag(profile, PFLAG_RUNNING)) {
+ stream->write_function(stream, "Profile %s\n", profile->name);
+ c++;
+ }
+ }
+ switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+ stream->write_function(stream, "%d profiles\n", c);
+ return SWITCH_STATUS_SUCCESS;
+
+}
+
+static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t *stream)
+{
+ sofia_profile_t *profile = NULL;
+ char *profile_name = argv[0];
+
+ if (argc < 2) {
+ stream->write_function(stream, "Invalid Args!\n");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (!strcasecmp(argv[1], "start")) {
+ if (config_sofia(1, argv[0]) == SWITCH_STATUS_SUCCESS) {
+ stream->write_function(stream, "%s started successfully\n", argv[0]);
+ } else {
+ stream->write_function(stream, "Failure starting %s\n", argv[0]);
+ }
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (switch_strlen_zero(profile_name) || !(profile = sofia_glue_find_profile(profile_name))) {
+ stream->write_function(stream, "Invalid Profile [%s]", switch_str_nil(profile_name));
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (!strcasecmp(argv[1], "stop")) {
+ sofia_clear_pflag_locked(profile, PFLAG_RUNNING);
+ stream->write_function(stream, "stopping: %s", profile->name);
+ }
+
+ if (profile) {
+ switch_thread_rwlock_unlock(profile->rwlock);
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t sofia_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+ char *argv[1024] = { 0 };
+ int argc = 0;
+ char *mycmd = NULL;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ sofia_command_t func = NULL;
+ int lead = 1;
+ const char *usage_string = "USAGE:\n"
+ "--------------------------------------------------------------------------------\n"
+ "sofia help\n"
+ "sofia profile <options>\n"
+ "sofia status\n"
+ "--------------------------------------------------------------------------------\n";
+
+ if (isession) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (switch_strlen_zero(cmd)) {
+ stream->write_function(stream, "%s", usage_string);
+ goto done;
+ }
+
+ if (!(mycmd = strdup(cmd))) {
+ status = SWITCH_STATUS_MEMERR;
+ goto done;
+ }
+
+ if (!(argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+ stream->write_function(stream, "%s", usage_string);
+ goto done;
+ }
+
+ if (!strcasecmp(argv[0], "profile")) {
+ func = cmd_profile;
+ } else if (!strcasecmp(argv[0], "status")) {
+ func = cmd_status;
+ } else if (!strcasecmp(argv[0], "help")) {
+ stream->write_function(stream, "%s", usage_string);
+ goto done;
+ }
+
+ if (func) {
+ status = func(&argv[lead], argc - lead, stream);
+ } else {
+ stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
+ }
+
+
+ done:
+
+ switch_safe_free(mycmd);
+
+ return status;
+
+
+}
+
static const switch_io_routines_t sofia_io_routines = {
/*.outgoing_channel */ sofia_outgoing_channel,
/*.read_frame */ sofia_read_frame,
@@ -928,6 +1053,14 @@
/*.management_function */ sofia_manage
};
+static switch_api_interface_t sofia_api_interface = {
+ /*.interface_name */ "sofia",
+ /*.desc */ "Sofia Controls",
+ /*.function */ sofia_function,
+ /*.syntax */ "<cmd> <args>",
+ /*.next */ NULL
+};
+
static const switch_loadable_module_interface_t sofia_module_interface = {
/*.module_name */ modname,
/*.endpoint_interface */ &sofia_endpoint_interface,
@@ -935,7 +1068,7 @@
/*.dialplan_interface */ NULL,
/*.codec_interface */ NULL,
/*.application_interface */ NULL,
- /*.api_interface */ NULL,
+ /*.api_interface */ &sofia_api_interface,
/*.file_interface */ NULL,
/*.speech_interface */ NULL,
/*.directory_interface */ NULL,
@@ -954,7 +1087,7 @@
switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
switch_core_session_t *nsession;
char *data, *profile_name, *dest;
- sofia_profile_t *profile;
+ sofia_profile_t *profile = NULL;
switch_caller_profile_t *caller_profile = NULL;
private_object_t *tech_pvt = NULL;
switch_channel_t *nchannel;
@@ -979,7 +1112,7 @@
if (!strncasecmp(profile_name, "gateway", 7)) {
char *gw;
- outbound_reg_t *gateway_ptr;
+ sofia_gateway_t *gateway_ptr = NULL;
if (!(gw = strchr(profile_name, '/'))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
@@ -1016,6 +1149,7 @@
tech_pvt->dest = switch_core_session_sprintf(nsession, "sip:%s", dest);
}
tech_pvt->invite_contact = switch_core_session_strdup(nsession, gateway_ptr->register_contact);
+ sofia_reg_release_gateway(gateway_ptr);
} else {
if (!(dest = strchr(profile_name, '/'))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");
@@ -1102,6 +1236,10 @@
}
done:
+ if (profile) {
+ switch_thread_rwlock_unlock(profile->rwlock);
+ }
+
return cause;
}
@@ -1133,7 +1271,7 @@
switch_core_hash_init(&mod_sofia_globals.gateway_hash, module_pool);
switch_mutex_init(&mod_sofia_globals.hash_mutex, SWITCH_MUTEX_NESTED, module_pool);
- if (config_sofia(0) != SWITCH_STATUS_SUCCESS) {
+ if (config_sofia(0, NULL) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_GENERR;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Sat Apr 28 21:16:49 2007
@@ -47,8 +47,8 @@
static const char modname[] = "mod_sofia";
static const switch_state_handler_table_t noop_state_handler = { 0 };
-struct outbound_reg;
-typedef struct outbound_reg outbound_reg_t;
+struct sofia_gateway;
+typedef struct sofia_gateway sofia_gateway_t;
struct sofia_profile;
typedef struct sofia_profile sofia_profile_t;
@@ -82,7 +82,7 @@
struct sofia_private {
char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
- outbound_reg_t *gateway;
+ sofia_gateway_t *gateway;
su_home_t *home;
};
@@ -109,7 +109,8 @@
PFLAG_PRESENCE = (1 << 4),
PFLAG_PASS_RFC2833 = (1 << 5),
PFLAG_DISABLE_TRANSCODING = (1 << 6),
- PFLAG_REWRITE_TIMESTAMPS = (1 << 7)
+ PFLAG_REWRITE_TIMESTAMPS = (1 << 7),
+ PFLAG_RUNNING = (1 << 8)
} PFLAGS;
typedef enum {
@@ -170,7 +171,7 @@
REG_STATE_NOREG
} reg_state_t;
-struct outbound_reg {
+struct sofia_gateway {
sofia_private_t *sofia_private;
nua_handle_t *nh;
sofia_profile_t *profile;
@@ -191,7 +192,7 @@
uint32_t flags;
reg_state_t state;
switch_memory_pool_t *pool;
- struct outbound_reg *next;
+ struct sofia_gateway *next;
};
@@ -229,11 +230,14 @@
uint32_t codec_flags;
switch_mutex_t *ireg_mutex;
switch_mutex_t *gateway_mutex;
- outbound_reg_t *gateways;
+ sofia_gateway_t *gateways;
su_home_t *home;
switch_hash_t *profile_hash;
switch_hash_t *chat_hash;
switch_core_db_t *master_db;
+ switch_thread_rwlock_t *rwlock;
+ switch_mutex_t *flag_mutex;
+ uint32_t inuse;
#ifdef SWITCH_HAVE_ODBC
char *odbc_dsn;
char *odbc_user;
@@ -350,6 +354,17 @@
AUTH_STALE,
} auth_res_t;
+
+#define sofia_test_pflag(obj, flag) ((obj)->pflags & flag)
+#define sofia_set_pflag(obj, flag) (obj)->pflags |= (flag)
+#define sofia_set_pflag_locked(obj, flag) assert(obj->flag_mutex != NULL);\
+switch_mutex_lock(obj->flag_mutex);\
+(obj)->pflags |= (flag);\
+switch_mutex_unlock(obj->flag_mutex);
+#define sofia_clear_pflag_locked(obj, flag) switch_mutex_lock(obj->flag_mutex); (obj)->pflags &= ~(flag); switch_mutex_unlock(obj->flag_mutex);
+#define sofia_clear_pflag(obj, flag) (obj)->pflags &= ~(flag)
+#define sofia_copy_pflags(dest, src, flags) (dest)->pflags &= ~(flags); (dest)->pflags |= ((src)->pflags & (flags))
+
/* Function Prototypes */
/*************************************************************************************************************************************************************/
@@ -398,7 +413,7 @@
void sofia_presence_event_handler(switch_event_t *event);
void sofia_presence_mwi_event_handler(switch_event_t *event);
void sofia_presence_cancel(void);
-switch_status_t config_sofia(int reload);
+switch_status_t config_sofia(int reload, char *profile_name);
auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, const char *regstr, char *np, size_t nplen, char *ip);
void sofia_reg_handle_sip_r_challenge(int status,
char const *phrase,
@@ -427,8 +442,8 @@
void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now);
void sofia_reg_unregister(sofia_profile_t *profile);
switch_status_t sofia_glue_ext_address_lookup(char **ip, switch_port_t *port, char *sourceip, switch_memory_pool_t *pool);
-outbound_reg_t *sofia_reg_find_gateway(char *key);
-void sofia_reg_add_gateway(char *key, outbound_reg_t *gateway);
+sofia_gateway_t *sofia_reg_find_gateway(char *key);
+void sofia_reg_add_gateway(char *key, sofia_gateway_t *gateway);
void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp);
int sofia_glue_get_user_host(char *in, char **user, char **host);
switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
@@ -449,3 +464,4 @@
void *pdata);
char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, char *resbuf, size_t len);
void sofia_glue_check_video_codecs(private_object_t *tech_pvt);
+void sofia_reg_release_gateway(sofia_gateway_t *gateway);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Sat Apr 28 21:16:49 2007
@@ -70,7 +70,7 @@
}
}
-
+
if (status != 100 && status != 200) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "event [%s] status [%d][%s] session: %s\n",
nua_event_name(event), status, phrase, session ? switch_channel_get_name(channel) : "n/a");
@@ -110,6 +110,10 @@
switch (event) {
case nua_r_shutdown:
+ if (status >= 200) {
+ su_root_break(profile->s_root);
+ }
+ break;
case nua_r_get_params:
case nua_r_invite:
case nua_r_unregister:
@@ -201,7 +205,7 @@
char *rpid = switch_event_get_header(event, "orig-rpid");
long expires = (long) time(NULL) + atol(exp_str);
char *profile_name = switch_event_get_header(event, "orig-profile-name");
- sofia_profile_t *profile;
+ sofia_profile_t *profile = NULL;
char buf[512];
if (!rpid) {
@@ -233,6 +237,9 @@
}
+ if (profile) {
+ switch_thread_rwlock_unlock(profile->rwlock);
+ }
}
}
@@ -340,7 +347,9 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting thread for %s\n", profile->name);
- while (mod_sofia_globals.running == 1) {
+
+ sofia_set_pflag_locked(profile, PFLAG_RUNNING);
+ while (mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) {
if (++ireg_loops >= IREG_SECONDS) {
sofia_reg_check_expire(profile, time(NULL));
ireg_loops = 0;
@@ -353,23 +362,40 @@
su_root_step(profile->s_root, 1000);
}
-
- sofia_glue_sql_close(profile);
+ //sofia_reg_check_expire(profile, 0);
+ //sofia_reg_check_gateway(profile, 0);
+ switch_thread_rwlock_wrlock(profile->rwlock);
sofia_reg_unregister(profile);
- su_home_unref(profile->home);
+ nua_shutdown(profile->nua);
+ su_root_run(profile->s_root);
+ nua_destroy(profile->nua);
+ while(0 && profile->inuse) {
+ switch_yield(1000000);
+ }
+
if (switch_event_create(&s_event, SWITCH_EVENT_UNPUBLISH) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp");
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", profile->sip_port);
switch_event_fire(&s_event);
}
+ sofia_glue_sql_close(profile);
+ su_home_unref(profile->home);
su_root_destroy(profile->s_root);
pool = profile->pool;
+
+ switch_mutex_lock(mod_sofia_globals.hash_mutex);
+ switch_core_hash_delete(mod_sofia_globals.profile_hash, profile->name);
+ switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+
+ switch_thread_rwlock_unlock(profile->rwlock);
+
switch_core_destroy_memory_pool(&pool);
+
end:
switch_mutex_lock(mod_sofia_globals.mutex);
@@ -417,14 +443,15 @@
}
-switch_status_t config_sofia(int reload)
+switch_status_t config_sofia(int reload, char *profile_name)
{
char *cf = "sofia.conf";
switch_xml_t cfg, xml = NULL, xprofile, param, settings, profiles, gateway_tag, gateways_tag;
switch_status_t status = SWITCH_STATUS_SUCCESS;
sofia_profile_t *profile = NULL;
char url[512] = "";
-
+ sofia_gateway_t *gp;
+ int profile_found = 0;
if (!reload) {
su_init();
@@ -432,6 +459,14 @@
su_log_redirect(tport_log, logger, NULL);
}
+
+ if (!switch_strlen_zero(profile_name) && (profile = sofia_glue_find_profile(profile_name))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile [%s] Already exists.\n", switch_str_nil(profile_name));
+ status = SWITCH_STATUS_FALSE;
+ switch_thread_rwlock_unlock(profile->rwlock);
+ return status;
+ }
+
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
status = SWITCH_STATUS_FALSE;
@@ -458,7 +493,18 @@
char *xprofilename = (char *) switch_xml_attr_soft(xprofile, "name");
switch_memory_pool_t *pool = NULL;
-
+ if (!xprofilename) {
+ xprofilename = "unnamed";
+ }
+
+ if (profile_name) {
+ if (strcasecmp(profile_name, xprofilename)) {
+ continue;
+ } else {
+ profile_found = 1;
+ }
+ }
+
/* Setup the pool */
if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
@@ -470,9 +516,7 @@
goto done;
}
- if (!xprofilename) {
- xprofilename = "unnamed";
- }
+
profile->pool = pool;
@@ -481,7 +525,8 @@
profile->dbname = switch_core_strdup(profile->pool, url);
switch_core_hash_init(&profile->chat_hash, profile->pool);
-
+ switch_thread_rwlock_create(&profile->rwlock, profile->pool);
+ switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool);
profile->dtmf_duration = 100;
profile->codec_ms = 20;
@@ -503,7 +548,6 @@
if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) {
*profile->odbc_pass++ = '\0';
}
-
#else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
@@ -682,7 +726,7 @@
if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) {
for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag; gateway_tag = gateway_tag->next) {
char *name = (char *) switch_xml_attr_soft(gateway_tag, "name");
- outbound_reg_t *gateway;
+ sofia_gateway_t *gateway;
if (switch_strlen_zero(name)) {
name = "anonymous";
@@ -790,12 +834,15 @@
gateway->next = profile->gateways;
profile->gateways = gateway;
- if (sofia_reg_find_gateway(gateway->name)) {
+ if ((gp = sofia_reg_find_gateway(gateway->name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", gateway->name);
- } else if (sofia_reg_find_gateway(gateway->register_from)) {
+ sofia_reg_release_gateway(gp);
+ } else if ((gp=sofia_reg_find_gateway(gateway->register_from))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate uri '%s'\n", gateway->register_from);
- } else if (sofia_reg_find_gateway(gateway->register_contact)) {
+ sofia_reg_release_gateway(gp);
+ } else if ((gp=sofia_reg_find_gateway(gateway->register_contact))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate contact '%s'\n", gateway->register_from);
+ sofia_reg_release_gateway(gp);
} else {
sofia_reg_add_gateway(gateway->name, gateway);
sofia_reg_add_gateway(gateway->register_from, gateway);
@@ -816,6 +863,9 @@
}
profile = NULL;
}
+ if (profile_found) {
+ break;
+ }
}
}
done:
@@ -823,6 +873,11 @@
switch_xml_free(xml);
}
+ if (profile_name && !profile_found) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No Such Profile '%s'\n", profile_name);
+ status = SWITCH_STATUS_FALSE;
+ }
+
return status;
}
@@ -1169,6 +1224,10 @@
tech_pvt->nh = NULL;
+ switch_mutex_lock(profile->flag_mutex);
+ profile->inuse--;
+ switch_mutex_unlock(profile->flag_mutex);
+
} else if (sofia_private) {
if (sofia_private->home) {
su_home_unref(sofia_private->home);
@@ -1706,7 +1765,7 @@
if (sip->sip_request->rq_url) {
- outbound_reg_t *gateway;
+ sofia_gateway_t *gateway;
char *from_key = switch_core_session_sprintf(session, "sip:%s@%s",
(char *) sip->sip_request->rq_url->url_user,
(char *) sip->sip_request->rq_url->url_host);
@@ -1714,6 +1773,7 @@
if ((gateway = sofia_reg_find_gateway(from_key))) {
context = gateway->register_context;
switch_channel_set_variable(channel, "sip_gateway", gateway->name);
+ sofia_reg_release_gateway(gateway);
}
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Sat Apr 28 21:16:49 2007
@@ -315,9 +315,13 @@
switch_mutex_lock(tech_pvt->flag_mutex);
+ switch_mutex_lock(profile->flag_mutex);
tech_pvt->flags = profile->flags;
- switch_mutex_unlock(tech_pvt->flag_mutex);
tech_pvt->profile = profile;
+ profile->inuse++;
+ switch_mutex_unlock(profile->flag_mutex);
+ switch_mutex_unlock(tech_pvt->flag_mutex);
+
if (tech_pvt->bte) {
tech_pvt->te = tech_pvt->bte;
} else if (!tech_pvt->te) {
@@ -1420,7 +1424,14 @@
sofia_profile_t *profile;
switch_mutex_lock(mod_sofia_globals.hash_mutex);
- profile = (sofia_profile_t *) switch_core_hash_find(mod_sofia_globals.profile_hash, key);
+ if ((profile = (sofia_profile_t *) switch_core_hash_find(mod_sofia_globals.profile_hash, key))) {
+ if (!sofia_test_pflag(profile, PFLAG_RUNNING)) {
+ profile = NULL;
+ } else if (switch_thread_rwlock_tryrdlock(profile->rwlock) != SWITCH_STATUS_SUCCESS) {
+ profile = NULL;
+ }
+ }
+
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
return profile;
@@ -1508,6 +1519,7 @@
} else {
#endif
switch_core_db_close(profile->master_db);
+ profile->master_db = NULL;
#ifdef SWITCH_HAVE_ODBC
}
#endif
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Sat Apr 28 21:16:49 2007
@@ -43,7 +43,7 @@
{
char buf[256];
char *user, *host;
- sofia_profile_t *profile;
+ sofia_profile_t *profile = NULL;
char *ffrom = NULL;
nua_handle_t *msg_nh;
char *contact;
@@ -98,6 +98,10 @@
switch_safe_free(ffrom);
free(user);
+
+ if (profile) {
+ switch_thread_rwlock_unlock(profile->rwlock);
+ }
}
return SWITCH_STATUS_SUCCESS;
@@ -178,7 +182,7 @@
{
char *account, *dup_account, *yn, *host, *user;
char *sql;
- sofia_profile_t *profile;
+ sofia_profile_t *profile = NULL;
switch_stream_handle_t stream = { 0 };
switch_event_header_t *hp;
@@ -230,11 +234,16 @@
switch_safe_free(sql);
switch_safe_free(dup_account);
+
+ if (profile) {
+ switch_thread_rwlock_unlock(profile->rwlock);
+ }
+
}
void sofia_presence_event_handler(switch_event_t *event)
{
- sofia_profile_t *profile;
+ sofia_profile_t *profile = NULL;
switch_hash_index_t *hi;
void *val;
char *from = switch_event_get_header(event, "from");
@@ -364,6 +373,9 @@
sofia_presence_resub_callback,
profile);
+
+ switch_thread_rwlock_unlock(profile->rwlock);
+
switch_safe_free(sql);
}
switch_safe_free(user);
@@ -569,7 +581,7 @@
char *expires = argv[10];
char *body = argv[11];
char *exp;
- sofia_profile_t *profile;
+ sofia_profile_t *profile = NULL;
char *tmp, *id = NULL;
nua_handle_t *nh;
int expire_sec = atoi(expires);
@@ -606,6 +618,11 @@
switch_safe_free(id);
switch_safe_free(exp);
+
+ if (profile) {
+ switch_thread_rwlock_unlock(profile->rwlock);
+ }
+
return 0;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Sat Apr 28 21:16:49 2007
@@ -39,7 +39,7 @@
void sofia_reg_unregister(sofia_profile_t *profile)
{
- outbound_reg_t *gateway_ptr;
+ sofia_gateway_t *gateway_ptr;
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
if (gateway_ptr->sofia_private) {
free(gateway_ptr->sofia_private);
@@ -52,11 +52,16 @@
void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
{
- outbound_reg_t *gateway_ptr;
+ sofia_gateway_t *gateway_ptr;
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
int ss_state = nua_callstate_authenticating;
reg_state_t ostate = gateway_ptr->state;
+ if (!now) {
+ gateway_ptr->state = ostate = REG_STATE_UNREGED;
+ gateway_ptr->expires_str = "0";
+ }
+
switch (ostate) {
case REG_STATE_NOREG:
break;
@@ -80,14 +85,26 @@
gateway_ptr->sofia_private->gateway = gateway_ptr;
nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private);
- nua_register(gateway_ptr->nh,
- SIPTAG_FROM_STR(gateway_ptr->register_from),
- SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
- SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
- NUTAG_REGISTRAR(gateway_ptr->register_proxy),
- NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
- gateway_ptr->retry = now + 10;
+ if (now) {
+ nua_register(gateway_ptr->nh,
+ SIPTAG_FROM_STR(gateway_ptr->register_from),
+ SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
+ SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
+ NUTAG_REGISTRAR(gateway_ptr->register_proxy),
+ NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
+ gateway_ptr->retry = now + 10;
+ } else {
+ nua_unregister(gateway_ptr->nh,
+ SIPTAG_FROM_STR(gateway_ptr->register_from),
+ SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
+ SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
+ NUTAG_REGISTRAR(gateway_ptr->register_proxy),
+ NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
+ }
+
+ gateway_ptr->retry = now + time(NULL);
gateway_ptr->state = REG_STATE_TRYING;
+
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error registering %s\n", gateway_ptr->name);
gateway_ptr->state = REG_STATE_FAILED;
@@ -107,7 +124,6 @@
break;
}
}
-
}
@@ -157,7 +173,11 @@
}
#endif
- snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0 and expires <= %ld", profile->name, (long) now);
+ if (now) {
+ snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0 and expires <= %ld", profile->name, (long) now);
+ } else {
+ snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0", profile->name);
+ }
switch_mutex_lock(profile->ireg_mutex);
sofia_glue_execute_sql_callback(profile,
@@ -166,12 +186,23 @@
sql,
sofia_reg_del_callback,
NULL);
-
- snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires <= %ld", (long) now);
+ if (now) {
+ snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires <= %ld", (long) now);
+ } else {
+ snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0");
+ }
sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL);
- snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires <= %ld", (long) now);
+ if (now) {
+ snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires <= %ld", (long) now);
+ } else {
+ snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0");
+ }
sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL);
- snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires > 0 and expires <= %ld", (long) now);
+ if (now) {
+ snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires > 0 and expires <= %ld", (long) now);
+ } else {
+ snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires > 0");
+ }
sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL);
switch_mutex_unlock(profile->ireg_mutex);
@@ -479,7 +510,7 @@
char const *phrase,
nua_t * nua, sofia_profile_t *profile, nua_handle_t * nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
{
- outbound_reg_t *gateway = NULL;
+ sofia_gateway_t *gateway = NULL;
sip_www_authenticate_t const *authenticate = NULL;
char const *realm = NULL;
char *p = NULL, *duprealm = NULL, *qrealm = NULL;
@@ -522,7 +553,7 @@
}
if (profile) {
- outbound_reg_t *gateway_ptr;
+ sofia_gateway_t *gateway_ptr;
if ((duprealm = strdup(realm))) {
qrealm = duprealm;
@@ -548,13 +579,21 @@
}
if (!gateway) {
+ switch_mutex_lock(mod_sofia_globals.hash_mutex);
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
if (scheme && qrealm && !strcasecmp(gateway_ptr->register_scheme, scheme)
&& !strcasecmp(gateway_ptr->register_realm, qrealm)) {
gateway = gateway_ptr;
+
+ if (!switch_test_flag(gateway->profile, PFLAG_RUNNING)) {
+ gateway = NULL;
+ } else if (switch_thread_rwlock_tryrdlock(gateway->profile->rwlock) != SWITCH_STATUS_SUCCESS) {
+ gateway = NULL;
+ }
break;
}
}
+ switch_mutex_unlock(mod_sofia_globals.hash_mutex);
}
if (!gateway) {
@@ -578,7 +617,7 @@
tl_gets(tags, NUTAG_CALLSTATE_REF(ss_state), SIPTAG_WWW_AUTHENTICATE_REF(authenticate), TAG_END());
nua_authenticate(nh, SIPTAG_EXPIRES_STR(gateway->expires_str), NUTAG_AUTH(authentication), TAG_END());
-
+ sofia_reg_release_gateway(gateway);
return;
cancel:
@@ -761,18 +800,29 @@
}
-outbound_reg_t *sofia_reg_find_gateway(char *key)
+sofia_gateway_t *sofia_reg_find_gateway(char *key)
{
- outbound_reg_t *gateway;
+ sofia_gateway_t *gateway = NULL;
switch_mutex_lock(mod_sofia_globals.hash_mutex);
- gateway = (outbound_reg_t *) switch_core_hash_find(mod_sofia_globals.gateway_hash, key);
- switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+ if ((gateway = (sofia_gateway_t *) switch_core_hash_find(mod_sofia_globals.gateway_hash, key))) {
+ if (!sofia_test_pflag(gateway->profile, PFLAG_RUNNING)) {
+ gateway = NULL;
+ } else if (switch_thread_rwlock_tryrdlock(gateway->profile->rwlock) != SWITCH_STATUS_SUCCESS) {
+ gateway = NULL;
+ }
+ }
+ switch_mutex_unlock(mod_sofia_globals.hash_mutex);
return gateway;
}
-void sofia_reg_add_gateway(char *key, outbound_reg_t * gateway)
+void sofia_reg_release_gateway(sofia_gateway_t *gateway)
+{
+ switch_thread_rwlock_unlock(gateway->profile->rwlock);
+}
+
+void sofia_reg_add_gateway(char *key, sofia_gateway_t * gateway)
{
switch_mutex_lock(mod_sofia_globals.hash_mutex);
switch_core_hash_insert(mod_sofia_globals.gateway_hash, key, gateway);
Modified: freeswitch/trunk/src/switch_odbc.c
==============================================================================
--- freeswitch/trunk/src/switch_odbc.c (original)
+++ freeswitch/trunk/src/switch_odbc.c Sat Apr 28 21:16:49 2007
@@ -372,6 +372,7 @@
switch_safe_free(handle->password);
free(handle);
}
+ *handlep = NULL;
}
SWITCH_DECLARE(switch_odbc_state_t) switch_odbc_handle_get_state(switch_odbc_handle_t *handle)
1
0
[commit] r5035 - in freeswitch/trunk/src: . include mod/applications/mod_conference mod/applications/mod_enum mod/dialplans/mod_dialplan_xml mod/endpoints/mod_sofia
by Freeswitch SVN 28 Apr '07
by Freeswitch SVN 28 Apr '07
28 Apr '07
Author: anthm
Date: Sat Apr 28 17:48:03 2007
New Revision: 5035
Modified:
freeswitch/trunk/src/include/switch_channel.h
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c
freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_ivr_originate.c
Log:
add locking to vars
Modified: freeswitch/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/trunk/src/include/switch_channel.h (original)
+++ freeswitch/trunk/src/include/switch_channel.h Sat Apr 28 17:48:03 2007
@@ -228,6 +228,7 @@
* @remark Use switch_hash_next and switch_hash_this with this function to iterate all the channel variables
*/
SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel, switch_memory_pool_t *pool);
+SWITCH_DECLARE(void) switch_channel_variable_last(switch_channel_t *channel);
/*!
\brief Assign a caller extension to a given channel
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Sat Apr 28 17:48:03 2007
@@ -1025,10 +1025,6 @@
if (member->energy_level > 3000) {
member->energy_level = 3000;
}
- switch_mutex_unlock(member->flag_mutex);
-
- snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
- conference_member_say(member, msg, 0);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
@@ -1040,6 +1036,12 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
switch_event_fire(&event);
}
+ switch_mutex_unlock(member->flag_mutex);
+
+ snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
+ conference_member_say(member, msg, 0);
+
+
}
}
@@ -1051,10 +1053,6 @@
switch_mutex_lock(member->flag_mutex);
member->energy_level = member->conference->energy_level;
- switch_mutex_unlock(member->flag_mutex);
-
- snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
- conference_member_say(member, msg, 0);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
@@ -1066,6 +1064,11 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
switch_event_fire(&event);
}
+ switch_mutex_unlock(member->flag_mutex);
+
+ snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
+ conference_member_say(member, msg, 0);
+
}
}
@@ -1080,10 +1083,6 @@
if (member->energy_level < 0) {
member->energy_level = 0;
}
- switch_mutex_unlock(member->flag_mutex);
-
- snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
- conference_member_say(member, msg, 0);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
@@ -1095,6 +1094,13 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
switch_event_fire(&event);
}
+ switch_mutex_unlock(member->flag_mutex);
+
+ snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
+ conference_member_say(member, msg, 0);
+
+
+
}
}
@@ -1107,10 +1113,7 @@
switch_mutex_lock(member->flag_mutex);
member->volume_out_level++;
switch_normalize_volume(member->volume_out_level);
- switch_mutex_unlock(member->flag_mutex);
- snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
- conference_member_say(member, msg, 0);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
@@ -1122,6 +1125,12 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
switch_event_fire(&event);
}
+ switch_mutex_unlock(member->flag_mutex);
+
+
+ snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
+ conference_member_say(member, msg, 0);
+
}
}
@@ -1133,10 +1142,7 @@
switch_mutex_lock(member->flag_mutex);
member->volume_out_level = 0;
- switch_mutex_unlock(member->flag_mutex);
- snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
- conference_member_say(member, msg, 0);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
@@ -1148,6 +1154,13 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
switch_event_fire(&event);
}
+ switch_mutex_unlock(member->flag_mutex);
+
+
+ snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
+ conference_member_say(member, msg, 0);
+
+
}
}
@@ -1160,10 +1173,6 @@
switch_mutex_lock(member->flag_mutex);
member->volume_out_level--;
switch_normalize_volume(member->volume_out_level);
- switch_mutex_unlock(member->flag_mutex);
-
- snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
- conference_member_say(member, msg, 0);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
@@ -1175,6 +1184,12 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
switch_event_fire(&event);
}
+ switch_mutex_unlock(member->flag_mutex);
+
+ snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
+ conference_member_say(member, msg, 0);
+
+
}
}
@@ -1187,10 +1202,7 @@
switch_mutex_lock(member->flag_mutex);
member->volume_in_level++;
switch_normalize_volume(member->volume_in_level);
- switch_mutex_unlock(member->flag_mutex);
- snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
- conference_member_say(member, msg, 0);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
@@ -1202,6 +1214,14 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
switch_event_fire(&event);
}
+ switch_mutex_unlock(member->flag_mutex);
+
+
+ snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
+ conference_member_say(member, msg, 0);
+
+
+
}
}
@@ -1213,10 +1233,6 @@
switch_mutex_lock(member->flag_mutex);
member->volume_in_level = 0;
- switch_mutex_unlock(member->flag_mutex);
-
- snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
- conference_member_say(member, msg, 0);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
@@ -1228,6 +1244,13 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
switch_event_fire(&event);
}
+ switch_mutex_unlock(member->flag_mutex);
+
+ snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
+ conference_member_say(member, msg, 0);
+
+
+
}
}
@@ -1240,10 +1263,7 @@
switch_mutex_lock(member->flag_mutex);
member->volume_in_level--;
switch_normalize_volume(member->volume_in_level);
- switch_mutex_unlock(member->flag_mutex);
- snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
- conference_member_say(member, msg, 0);
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *channel = switch_core_session_get_channel(member->session);
@@ -1255,6 +1275,13 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
switch_event_fire(&event);
}
+ switch_mutex_unlock(member->flag_mutex);
+
+
+ snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
+ conference_member_say(member, msg, 0);
+
+
}
}
Modified: freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c Sat Apr 28 17:48:03 2007
@@ -591,11 +591,14 @@
void *vval;
const void *vvar;
- for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
- switch_hash_this(hi, &vvar, NULL, &vval);
- if (vvar && !strncmp(vvar, "enum_", 5)) {
- switch_channel_set_variable(channel, (char *) vvar, NULL);
+ if ((hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)))) {
+ for (; hi; hi = switch_hash_next(hi)) {
+ switch_hash_this(hi, &vvar, NULL, &vval);
+ if (vvar && !strncmp(vvar, "enum_", 5)) {
+ switch_channel_set_variable(channel, (char *) vvar, NULL);
+ }
}
+ switch_channel_variable_last(channel);
}
for (rtp = globals.route_order; rtp; rtp = rtp->next) {
Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c (original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c Sat Apr 28 17:48:03 2007
@@ -251,28 +251,30 @@
stream.write_function(&stream, "%s=%s&", prof_names[x], encode_buf);
}
+ if ((hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)))) {
+ for (; hi; hi = switch_hash_next(hi)) {
+ void *val;
+ const void *var;
+ switch_hash_this(hi, &var, NULL, &val);
+
+ new_len = (strlen((char *) var) * 3) + 1;
+ if (encode_len < new_len) {
+ char *tmp;
+
+ encode_len = new_len;
+
+ if (!(tmp = realloc(encode_buf, encode_len))) {
+ goto done;
+ }
- for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
- void *val;
- const void *var;
- switch_hash_this(hi, &var, NULL, &val);
-
- new_len = (strlen((char *) var) * 3) + 1;
- if (encode_len < new_len) {
- char *tmp;
-
- encode_len = new_len;
-
- if (!(tmp = realloc(encode_buf, encode_len))) {
- goto done;
+ encode_buf = tmp;
}
- encode_buf = tmp;
- }
-
- switch_url_encode((char *) val, encode_buf, encode_len - 1);
- stream.write_function(&stream, "%s=%s&", (char *) var, encode_buf);
+ switch_url_encode((char *) val, encode_buf, encode_len - 1);
+ stream.write_function(&stream, "%s=%s&", (char *) var, encode_buf);
+ }
+ switch_channel_variable_last(channel);
}
e = (char *) stream.data + (strlen((char *) stream.data) - 1);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Sat Apr 28 17:48:03 2007
@@ -570,17 +570,20 @@
SWITCH_STANDARD_STREAM(stream);
- for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(tech_pvt->session)); hi; hi = switch_hash_next(hi)) {
- switch_hash_this(hi, &vvar, NULL, &vval);
- if (vvar && vval) {
- const char *name = vvar;
- char *value = (char *) vval;
-
- if (!strncasecmp(name, SOFIA_SIP_HEADER_PREFIX, strlen(SOFIA_SIP_HEADER_PREFIX))) {
- const char *hname = name + strlen(SOFIA_SIP_HEADER_PREFIX);
- stream.write_function(&stream, "%s: %s\r\n", hname, value);
+ if ((hi = switch_channel_variable_first(channel, switch_core_session_get_pool(tech_pvt->session)))) {
+ for (; hi; hi = switch_hash_next(hi)) {
+ switch_hash_this(hi, &vvar, NULL, &vval);
+ if (vvar && vval) {
+ const char *name = vvar;
+ char *value = (char *) vval;
+
+ if (!strncasecmp(name, SOFIA_SIP_HEADER_PREFIX, strlen(SOFIA_SIP_HEADER_PREFIX))) {
+ const char *hname = name + strlen(SOFIA_SIP_HEADER_PREFIX);
+ stream.write_function(&stream, "%s: %s\r\n", hname, value);
+ }
}
}
+ switch_channel_variable_last(channel);
}
if (stream.data) {
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Sat Apr 28 17:48:03 2007
@@ -115,6 +115,7 @@
switch_hash_t *variables;
switch_hash_t *private_hash;
switch_call_cause_t hangup_cause;
+ int vi;
};
@@ -306,6 +307,7 @@
char *v = NULL;
assert(channel != NULL);
+ switch_mutex_lock(channel->profile_mutex);
if (!(v = switch_core_hash_find(channel->variables, varname))) {
if (!channel->caller_profile || !(v = switch_caller_get_field_by_name(channel->caller_profile, varname))) {
if (!strcmp(varname, "base_dir")) {
@@ -314,27 +316,50 @@
v = switch_core_get_variable(varname);
}
}
+ switch_mutex_unlock(channel->profile_mutex);
return v;
}
+SWITCH_DECLARE(void) switch_channel_variable_last(switch_channel_t *channel)
+{
+ assert(channel != NULL);
+ if (channel->vi) {
+ switch_mutex_unlock(channel->profile_mutex);
+ }
+}
+
SWITCH_DECLARE(switch_hash_index_t *) switch_channel_variable_first(switch_channel_t *channel, switch_memory_pool_t *pool)
{
+ switch_hash_index_t *hi;
+
assert(channel != NULL);
- return switch_hash_first(pool, channel->variables);
+
+ if ((hi = switch_hash_first(pool, channel->variables))) {
+ switch_mutex_lock(channel->profile_mutex);
+ channel->vi = 1;
+ }
+
+ return hi;
}
SWITCH_DECLARE(switch_status_t) switch_channel_set_private(switch_channel_t *channel, char *key, void *private_info)
{
assert(channel != NULL);
+ switch_mutex_lock(channel->profile_mutex);
switch_core_hash_insert_dup(channel->private_hash, switch_core_session_strdup(channel->session, key), private_info);
+ switch_mutex_unlock(channel->profile_mutex);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(void *) switch_channel_get_private(switch_channel_t *channel, char *key)
{
assert(channel != NULL);
- return switch_core_hash_find(channel->private_hash, key);
+ void *val;
+ switch_mutex_lock(channel->profile_mutex);
+ val = switch_core_hash_find(channel->private_hash, key);
+ switch_mutex_unlock(channel->profile_mutex);
+ return val;
}
SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channel, char *name)
@@ -361,12 +386,14 @@
assert(channel != NULL);
if (varname) {
+ switch_mutex_lock(channel->profile_mutex);
switch_core_hash_delete(channel->variables, varname);
if (!switch_strlen_zero(value)) {
switch_core_hash_insert_dup(channel->variables, varname, switch_core_session_strdup(channel->session, value));
} else {
switch_core_hash_delete(channel->variables, varname);
}
+ switch_mutex_unlock(channel->profile_mutex);
return SWITCH_STATUS_SUCCESS;
}
@@ -378,12 +405,14 @@
assert(channel != NULL);
if (varname) {
+ switch_mutex_lock(channel->profile_mutex);
switch_core_hash_delete(channel->variables, varname);
if (!switch_strlen_zero(value)) {
switch_core_hash_insert_dup(channel->variables, varname, value);
} else {
switch_core_hash_delete(channel->variables, varname);
}
+ switch_mutex_unlock(channel->profile_mutex);
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Sat Apr 28 17:48:03 2007
@@ -900,11 +900,14 @@
void *vval;
const void *vvar;
- for (hi = switch_channel_variable_first(chana, switch_core_session_get_pool(sessa)); hi; hi = switch_hash_next(hi)) {
- switch_hash_this(hi, &vvar, NULL, &vval);
- if (vvar && vval && (!prefix || (var && !strncmp((char *) vvar, var, strlen(var))))) {
- switch_channel_set_variable(chanb, (char *) vvar, (char *) vval);
+ if ((hi = switch_channel_variable_first(chana, switch_core_session_get_pool(sessa)))) {
+ for (; hi; hi = switch_hash_next(hi)) {
+ switch_hash_this(hi, &vvar, NULL, &vval);
+ if (vvar && vval && (!prefix || (var && !strncmp((char *) vvar, var, strlen(var))))) {
+ switch_channel_set_variable(chanb, (char *) vvar, (char *) vval);
+ }
}
+ switch_channel_variable_last(chana);
}
}
@@ -1260,20 +1263,23 @@
}
}
- for (hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
- switch_hash_this(hi, &vvar, NULL, &vval);
- if (vvar && vval) {
- if ((variable = switch_xml_add_child_d(variables, (char *) vvar, v_off++))) {
- char *data;
- char *value = (char *) vval;
- switch_size_t dlen = strlen(value) * 3;
-
- if ((data = switch_core_session_alloc(session, dlen))) {
- switch_url_encode(value, data, dlen);
- switch_xml_set_txt_d(variable, data);
+ if (((hi = switch_channel_variable_first(channel, switch_core_session_get_pool(session))))) {
+ for (; hi; hi = switch_hash_next(hi)) {
+ switch_hash_this(hi, &vvar, NULL, &vval);
+ if (vvar && vval) {
+ if ((variable = switch_xml_add_child_d(variables, (char *) vvar, v_off++))) {
+ char *data;
+ char *value = (char *) vval;
+ switch_size_t dlen = strlen(value) * 3;
+
+ if ((data = switch_core_session_alloc(session, dlen))) {
+ switch_url_encode(value, data, dlen);
+ switch_xml_set_txt_d(variable, data);
+ }
}
}
}
+ switch_channel_variable_last(channel);
}
caller_profile = switch_channel_get_caller_profile(channel);
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Sat Apr 28 17:48:03 2007
@@ -323,11 +323,14 @@
assert(caller_channel != NULL);
/* Copy all the channel variables into the event */
- for (hi = switch_channel_variable_first(caller_channel, switch_core_session_get_pool(session)); hi; hi = switch_hash_next(hi)) {
- switch_hash_this(hi, &vvar, NULL, &vval);
- if (vvar && vval) {
- switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, (void *) vvar, "%s", (char *) vval);
+ if ((hi = switch_channel_variable_first(caller_channel, switch_core_session_get_pool(session)))) {
+ for (; hi; hi = switch_hash_next(hi)) {
+ switch_hash_this(hi, &vvar, NULL, &vval);
+ if (vvar && vval) {
+ switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, (void *) vvar, "%s", (char *) vval);
+ }
}
+ switch_channel_variable_last(caller_channel);
}
}
1
0
Author: mikej
Date: Sat Apr 28 15:27:17 2007
New Revision: 5034
Added:
freeswitch/trunk/scripts/combineconf.pl
Modified:
freeswitch/trunk/conf/conference.conf.xml
freeswitch/trunk/conf/default_context.xml
freeswitch/trunk/conf/dingaling.conf.xml
freeswitch/trunk/conf/enum.conf.xml
freeswitch/trunk/conf/freeswitch.xml
freeswitch/trunk/conf/sofia.conf.xml
Log:
updates, cleanups, and clarifications to the sample conf files. Uses more of the preprocessor variables for simplicity. FSBUILD-2 from Mark D. Anderson. Thanks Mark.
Modified: freeswitch/trunk/conf/conference.conf.xml
==============================================================================
--- freeswitch/trunk/conf/conference.conf.xml (original)
+++ freeswitch/trunk/conf/conference.conf.xml Sat Apr 28 15:27:17 2007
@@ -1,8 +1,8 @@
<!-- None of these paths are real if you want any of these options you need to really set them up -->
<configuration name="conference.conf" description="Audio Conference">
- <!-- Advertise certian presence on startup . -->
+ <!-- Advertise certain presence on startup . -->
<advertise>
- <room name="888(a)sub.mydomain.com" status="FreeSWITCH"/>
+ <room name="888@$${server_name}" status="FreeSWITCH"/>
</advertise>
<!-- These are the default keys that map when you do not specify a caller control group -->
@@ -29,7 +29,7 @@
<!--If no profile is specified it will default to "default"-->
<profile name="default">
<!-- Domain (for presence) -->
- <param name="domain" value="sub.mydomain.com"/>
+ <param name="domain" value="$${server_name}"/>
<!-- Sample Rate-->
<param name="rate" value="8000"/>
<!-- Number of milliseconds per frame -->
@@ -81,9 +81,9 @@
<!-- Conference pin -->
<!--<param name="pin" value="12345"/>-->
<!-- Default Caller ID Name for outbound calls -->
- <param name="caller-id-name" value="FreeSWITCH"/>
+ <param name="caller-id-name" value="$${outbound_caller_name}"/>
<!-- Default Caller ID Number for outbound calls -->
- <param name="caller-id-number" value="8777423583"/>
+ <param name="caller-id-number" value="$${outbound_caller_id}"/>
</profile>
</profiles>
</configuration>
Modified: freeswitch/trunk/conf/default_context.xml
==============================================================================
--- freeswitch/trunk/conf/default_context.xml (original)
+++ freeswitch/trunk/conf/default_context.xml Sat Apr 28 15:27:17 2007
@@ -29,7 +29,7 @@
<!-- Call the FreeSWITCH conference via SIP -->
<!--<extension name="FreeSWITCH Conference SIP">-->
<!--<condition field="destination_number" expression="^888$">-->
- <!--<action application="bridge" data="sofia/$${domain}/888(a)conference.freeswitch.org"/>-->
+ <!--<action application="bridge" data="sofia/$${sip_profile}/888(a)conference.freeswitch.org"/>-->
<!--</condition>-->
<!--</extension> -->
@@ -53,7 +53,7 @@
<!-- Request a certain tone/file to be played while you wait for the call to be answered-->
<action application="set" data="ringback=${us-ring}"/>
<!--<action application="set" data="ringback=/home/ring.wav"/>-->
- <action application="bridge" data="sofia/$${domain}/1234(a)conference.freeswitch.org"/>
+ <action application="bridge" data="sofia/$${sip_profile}/1234(a)conference.freeswitch.org"/>
</condition>
</extension>
@@ -67,7 +67,7 @@
<!-- Start a dynamic conference and call someone at the same time -->
<extension name="2000">
<condition field="destination_number" expression="^2000$">
- <action application="conference" data="bridge:mydynaconf:sofia/$${domain}/1234@conference.freeswitch.org"/>
+ <action application="conference" data="bridge:mydynaconf:sofia/$${sip_profile}/1234@conference.freeswitch.org"/>
</condition>
</extension>
Modified: freeswitch/trunk/conf/dingaling.conf.xml
==============================================================================
--- freeswitch/trunk/conf/dingaling.conf.xml (original)
+++ freeswitch/trunk/conf/dingaling.conf.xml Sat Apr 28 15:27:17 2007
@@ -8,12 +8,13 @@
<!-- Client Profile (Original mode) -->
<x-profile type="client">
- <param name="name" value="$${domain}"/>
+ <param name="name" value="$${xmpp_client_profile}"/>
<param name="login" value="myjid(a)myserver.com/talk"/>
<param name="password" value="mypass"/>
<param name="dialplan" value="XML"/>
<param name="message" value="Jingle all the way"/>
- <param name="rtp-ip" value="auto"/>
+ <param name="rtp-ip" value="$${bind_server_ip}"/>
+ <!-- <param name="ext-rtp-ip" value="$${external_rtp_ip"/> -->
<param name="auto-login" value="true"/>
<!-- SASL "plain" or "md5" -->
<param name="sasl" value="plain"/>
@@ -23,9 +24,6 @@
<param name="tls" value="true"/>
<!-- disable to trade async for more calls -->
<param name="use-rtp-timer" value="true"/>
- <!-- or -->
- <!-- <param name="rtp-ip" value="auto"/> -->
- <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/> -->
<!-- default extension (if one cannot be determined) -->
<param name="exten" value="888"/>
<!-- VAD choose one -->
@@ -37,11 +35,10 @@
<!-- Component (Server to Server Login) -->
<x-profile type="component">
- <!-- All traffic for *(a)sub.mydomain.com will come to you -->
- <param name="name" value="$${subdomain}"/>
+ <param name="name" value="$${xmpp_server_profile}"/>
<param name="password" value="secret"/>
<param name="dialplan" value="XML"/>
- <param name="rtp-ip" value="auto"/>
+ <param name="rtp-ip" value="$${bind_server_ip}"/>
<param name="server" value="jabber.server.org:5347"/>
<!-- disable to trade async for more calls -->
<param name="use-rtp-timer" value="true"/>
Modified: freeswitch/trunk/conf/enum.conf.xml
==============================================================================
--- freeswitch/trunk/conf/enum.conf.xml (original)
+++ freeswitch/trunk/conf/enum.conf.xml Sat Apr 28 15:27:17 2007
@@ -4,8 +4,8 @@
</settings>
<routes>
- <route service="E2U+SIP" regex="sip:(.*)" replace="sofia/$${domain}/$1"/>
+ <route service="E2U+SIP" regex="sip:(.*)" replace="sofia/$${sip_profile}/$1"/>
<route service="E2U+IAX2" regex="iax2:(.*)" replace="iax/$1"/>
- <route service="E2U+XMPP" regex="XMPP:(.*)" replace="dingaling/$${domain}/$1"/>
+ <route service="E2U+XMPP" regex="XMPP:(.*)" replace="dingaling/$${xmpp_server_profile}/$1"/>
</routes>
</configuration>
Modified: freeswitch/trunk/conf/freeswitch.xml
==============================================================================
--- freeswitch/trunk/conf/freeswitch.xml (original)
+++ freeswitch/trunk/conf/freeswitch.xml Sat Apr 28 15:27:17 2007
@@ -13,34 +13,115 @@
Don't modify it while freeswitch is running cos it is mem mapped in most cases =D
-->
- <!--#set "domain=mydomain.com"-->
- <!--#set "subdomain=sub.mydomain.com"-->
- <!--#set "default_codecs=PCMU@20i"-->
- <!--my domain is $${domain}-->
+ <!-- Preprocessor Variables
+ These are introduced when configuration strings must be consistent across modules.
+ -->
+ <!-- sip_profile
+ Must be a domain name if you are being a registry server; otherwise
+ can be any string.
+ used by: sofia.conf.xml enum.conf.xml default_context.xml directory.xml
+ -->
+ <!--#set "sip_profile=mydomain.com"-->
+ <!-- xmpp_client_profile and xmpp_server_profile
+ xmpp_client_profile can be any string.
+ xmpp_server_profile is appended to "dingaling_" to form the database name
+ containing the "subscriptions" table.
+ used by: dingaling.conf.xml enum.conf.xml
+ -->
+ <!--#set "xmpp_client_profile=xmppc"-->
+ <!--#set "xmpp_server_profile=xmpps"-->
+ <!-- bind_server_ip
+ Can be an ip address, a dns name, or "auto".
+ This determines an ip address available on this host to bind.
+ If you are separating RTP and SIP traffic, you will want to have
+ use different addresses where this variable appears.
+ Used by: sofia.conf.xml dingaling.conf.xml
+ -->
+ <!--#set "bind_server_ip=auto"-->
+ <!-- external_rtp_ip
+ Used as the public IP address for SDP.
+ Can be an ip address or a string like "stun:stun.server.com"
+ If unspecified, the bind_server_ip value is used.
+ Used by: sofia.conf.xml dingaling.conf.xml
+ -->
+ <!--#set "external_rtp_ip=stun:stun.server.com"-->
+ <!-- server_name
+ A public ip address or DNS name that is used when advertising conference
+ presence or registering sip.
+ Used by: conference.conf.xml
+ -->
+ <!-- outbound_caller_id and outbound_caller_name
+ The caller ID telephone number we should use when calling out.
+ Used by: conference.conf.xml
+ -->
+ <!--#set "outbound_caller_name=FreeSWITCH"-->
+ <!--#set "outbound_caller_id=8777423583"-->
+
<section name="configuration" description="Various Configuration">
<!--#include "switch.conf.xml"-->
<!--#include "modules.conf.xml"-->
- <!--#include "spidermonkey.conf.xml"-->
+
+ <!-- Order doesn't matter, but for clarity these are in same order as modules.conf.xml.
+ If they aren't loaded by modules.conf.xml, then they are ignored.
+ -->
+ <!-- Loggers -->
+ <!--#include "console.conf.xml"-->
+ <!--#include "syslog.conf.xml"-->
+
+ <!-- Multi-Faceted -->
+ <!--#include "enum.conf.xml"-->
+
+ <!-- XML Interfaces -->
+ <!--#include "xml_rpc.conf.xml"-->
+ <!--#include "xml_curl.conf.xml"-->
+ <!-- none for mod_xml_cdr -->
+
+ <!-- Event Handlers -->
+ <!--#include "cdr.conf.xml"-->
<!--#include "event_multicast.conf.xml"-->
<!--#include "event_socket.conf.xml"-->
+ <!--#include "xmpp_event.conf.xml"-->
+ <!--#include "zeroconf.conf.xml"-->
+
+ <!-- Directory Interfaces -->
+ <!-- none for mod_ldap; dialplan_directory.conf.xml has ldap connection info -->
+
+ <!-- Endpoints -->
+ <!--#include "dingaling.conf.xml"-->
<!--#include "iax.conf.xml"-->
- <!--#include "console.conf.xml"-->
- <!--#include "sofia.conf.xml"-->
- <!--#include "syslog.conf.xml"-->
- <!--#include "woomera.conf.xml"-->
- <!--#include "wanpipe.conf.xml"-->
<!--#include "portaudio.conf.xml"-->
<!--#include "alsa.conf.xml"-->
- <!--#include "zeroconf.conf.xml"-->
- <!--#include "xmpp_event.conf.xml"-->
- <!--#include "dialplan_directory.conf.xml"-->
- <!--#include "dingaling.conf.xml"-->
- <!--#include "xml_curl.conf.xml"-->
- <!--#include "xml_rpc.conf.xml"-->
- <!--#include "rss.conf.xml"-->
+ <!--#include "sofia.conf.xml"-->
+ <!--#include "wanpipe.conf.xml"-->
+ <!--#include "woomera.conf.xml"-->
+
+ <!-- Applications -->
+ <!-- none for mod_bridgecall, mod_commands, mod_echo, mod_park, mod_playback -->
<!--#include "conference.conf.xml"-->
- <!--#include "enum.conf.xml"-->
+ <!-- ivr.conf is used by mod_dptools -->
<!--#include "ivr.conf.xml"-->
+
+ <!-- Dialplan Interfaces -->
+ <!--#include "dialplan_directory.conf.xml"-->
+ <!-- mod_dialplan_xml is configured in the separate "dialplan" section. -->
+
+ <!-- Codec Interfaces -->
+ <!-- no configuration needed -->
+ <!-- File Format Interfaces -->
+ <!-- no configuration needed -->
+ <!-- Timers -->
+ <!-- no configuration needed -->
+
+ <!-- Languages -->
+ <!--#include "spidermonkey.conf.xml"-->
+ <!-- none for mod_perl -->
+
+ <!-- ASR /TTS -->
+ <!-- none for mod_cepstral -->
+ <!--#include "rss.conf.xml"-->
+
+ <!-- Say -->
+ <!-- none for mod_say_en -->
<!--#include "mod_cdr.conf.xml"-->
</section>
@@ -48,6 +129,8 @@
<!--#include "default_context.xml"-->
</section>
+ <!-- mod_dingaling is reliant on the vcard data in the "directory" section. -->
+ <!-- mod_sofia is reliant on the user data for authorization -->
<section name="directory" description="User Directory">
<!--#include "directory.xml"-->
</section>
@@ -66,3 +149,4 @@
</document>
+
Modified: freeswitch/trunk/conf/sofia.conf.xml
==============================================================================
--- freeswitch/trunk/conf/sofia.conf.xml (original)
+++ freeswitch/trunk/conf/sofia.conf.xml Sat Apr 28 15:27:17 2007
@@ -1,6 +1,6 @@
<configuration name="sofia.conf" description="sofia Endpoint">
<profiles>
- <profile name="$${domain}">
+ <profile name="$${sip_profile}">
<!-- Outbound Registrations -->
<gateways>
<!--<gateway name="asterlink.com">-->
@@ -28,12 +28,12 @@
<param name="sip-port" value="5060"/>
<param name="dialplan" value="enum,XML"/>
<param name="dtmf-duration" value="100"/>
- <param name="codec-prefs" value="$${default_codecs}"/>
+ <param name="codec-prefs" value="PCMU@20i"/>
<param name="codec-ms" value="20"/>
<param name="use-rtp-timer" value="true"/>
<param name="rtp-timer-name" value="soft"/>
- <param name="rtp-ip" value="auto"/>
- <param name="sip-ip" value="auto"/>
+ <param name="rtp-ip" value="$${bind_server_ip}"/>
+ <param name="sip-ip" value="$${bind_server_ip}"/>
<!--If you don't want to pass through timestampes from 1 RTP call to another (on a per call basis with rtp_rewrite_timestamps chanvar)-->
<!--<param name="rtp-rewrite-timestampes" value="true"/>-->
@@ -60,9 +60,8 @@
<!-- on authed calls, authenticate *all* the packets not just invite -->
<!--<param name="auth-all-packets" value="true"/>-->
- <!-- optional ; -->
- <!-- <param name="ext-rtp-ip" value="stun:stun.server.com"/>-->
- <!-- <param name="ext-rtp-ip" value="100.101.102.103"/> -->
+ <!-- <param name="ext-rtp-ip" value="$${external_rtp_ip}"/>-->
+
<!-- <param name="ext-sip-ip" value="100.101.102.103"/> -->
<!-- VAD choose one (out is a good choice); -->
<!-- <param name="vad" value="in"/> -->
Added: freeswitch/trunk/scripts/combineconf.pl
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/combineconf.pl Sat Apr 28 15:27:17 2007
@@ -0,0 +1,49 @@
+#!/usr/bin/perl -w
+use strict;
+
+=head1 NAME
+
+combineconf.pl - expand #include PIs in a freeswitch conf file
+
+=head1 SYNOPSIS
+
+ # cd conf
+ # ../scripts/combineconf.pl freeswitch.xml > freeswitch_combined.xml
+
+=head1 DESCRIPTION
+
+This is recursive, and will take multiple input files on the command line.
+
+You need to run it from the working directory that the relative include paths
+except to be resolved from.
+
+=head1 AUTHOR
+
+Mark D. Anderson (mda(a)discerning.com)
+Released under same terms as Perl, or alternatively the MPL.
+
+=cut
+
+use IO::File;
+
+sub filter_file {
+ my ($f) = @_;
+ my $fh = $f eq '-' ? \*STDIN : IO::File->new($f, 'r');
+ die "ERROR: Can't open $f: $!\n" unless $fh;
+ while(<$fh>) {
+ if (m/<!--#include\s+"(.*?)"/) {
+ filter_file($1);
+ }
+ else {print;}
+ }
+ undef $fh;
+}
+
+sub main {
+ die "Usage: $0 file1 ...\nCombined output goes to stdout. Use '-' as the filename to use stdin." unless @ARGV;
+ for(@ARGV) {
+ filter_file($_);
+ }
+}
+
+main();
1
0