more changes to sofia to make better use of the directories
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5043 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
d038cdbfdb
commit
01f9b3f1c8
|
@ -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@jabber.org</USERID></EMAIL>
|
||||
<JABBERID>stpeter@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>
|
||||
|
|
|
@ -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"/>
|
||||
|
|
|
@ -893,19 +893,35 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
|||
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;
|
||||
|
||||
}
|
||||
|
|
|
@ -437,14 +437,14 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
|||
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 @@ switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile,
|
|||
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);
|
||||
|
|
|
@ -380,9 +380,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
|||
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 logger(void *logarg, char const *fmt, va_list ap)
|
|||
}
|
||||
|
||||
|
||||
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,142 +846,51 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
|||
}
|
||||
}
|
||||
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 ((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(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(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
} else {
|
||||
sofia_reg_add_gateway(gateway->name, gateway);
|
||||
sofia_reg_add_gateway(gateway->register_from, gateway);
|
||||
sofia_reg_add_gateway(gateway->register_contact, gateway);
|
||||
}
|
||||
sofia_glue_add_profile(switch_core_strdup(profile->pool, dname), profile);
|
||||
}
|
||||
|
||||
skip:
|
||||
assert(gateway_tag);
|
||||
}
|
||||
}
|
||||
|
||||
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 (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 {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Adding Alias [%s] for profile [%s] (name in use)\n",
|
||||
aname, profile->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (profile->sipip) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Started Profile %s [%s]\n", profile->name, url);
|
||||
|
|
|
@ -1437,11 +1437,48 @@ sofia_profile_t *sofia_glue_find_profile(char *key)
|
|||
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);
|
||||
switch_core_hash_insert(mod_sofia_globals.profile_hash, key, profile);
|
||||
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);
|
||||
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)
|
||||
|
|
|
@ -838,13 +838,18 @@ 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_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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1176,6 +1176,13 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section,
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue