git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4702 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-03-20 23:09:35 +00:00
parent 1317571e6d
commit a4cdac1d78
1 changed files with 31 additions and 7 deletions

View File

@ -215,6 +215,7 @@ struct outbound_reg {
char *register_contact; char *register_contact;
char *register_to; char *register_to;
char *register_proxy; char *register_proxy;
char *register_context;
char *expires_str; char *expires_str;
uint32_t freq; uint32_t freq;
time_t expires; time_t expires;
@ -4546,7 +4547,7 @@ static void sip_i_invite(nua_t *nua,
const char *displayname = NULL; const char *displayname = NULL;
const char *destination_number = NULL; const char *destination_number = NULL;
const char *from_user = NULL, *from_host = NULL; const char *from_user = NULL, *from_host = NULL;
const char *context; const char *context = NULL;
char network_ip[80]; char network_ip[80];
if (!sip || !sip->sip_request || !sip->sip_request->rq_method_name) { if (!sip || !sip->sip_request || !sip->sip_request->rq_method_name) {
@ -4673,10 +4674,26 @@ static void sip_i_invite(nua_t *nua,
switch_channel_set_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards); switch_channel_set_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards);
} }
if (profile->context && !strcasecmp(profile->context, "_domain_")) {
context = from_host; if (sip->sip_request->rq_url) {
} else { outbound_reg_t *gateway;
context = profile->context; 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);
if ((gateway = find_gateway(from_key))) {
context = gateway->register_context;
switch_channel_set_variable(channel, "sip_gateway", gateway->name);
}
}
if (!context) {
if (profile->context && !strcasecmp(profile->context, "_domain_")) {
context = from_host;
} else {
context = profile->context;
}
} }
tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
@ -5137,9 +5154,8 @@ static void check_gateway(sofia_profile_t *profile, time_t now)
} }
break; break;
default: default:
if (gateway_ptr->expires && now >= gateway_ptr->expires) { if (now >= gateway_ptr->expires) {
gateway_ptr->state = REG_STATE_UNREGED; gateway_ptr->state = REG_STATE_UNREGED;
gateway_ptr->expires = 0;
} }
break; break;
} }
@ -5556,8 +5572,10 @@ static switch_status_t config_sofia(int reload)
*password = NULL, *password = NULL,
*extension = NULL, *extension = NULL,
*proxy = NULL, *proxy = NULL,
*context = "default",
*expire_seconds = "3600"; *expire_seconds = "3600";
for (param = switch_xml_child(gateway_tag, "param"); param; param = param->next) { for (param = switch_xml_child(gateway_tag, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name"); char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value"); char *val = (char *) switch_xml_attr_soft(param, "value");
@ -5574,6 +5592,8 @@ static switch_status_t config_sofia(int reload)
extension = val; extension = val;
} else if (!strcmp(var, "proxy")) { } else if (!strcmp(var, "proxy")) {
proxy = val; proxy = val;
} else if (!strcmp(var, "context")) {
context = val;
} else if (!strcmp(var, "expire-seconds")) { } else if (!strcmp(var, "expire-seconds")) {
expire_seconds = val; expire_seconds = val;
} }
@ -5604,6 +5624,7 @@ static switch_status_t config_sofia(int reload)
} }
gateway->register_scheme = switch_core_strdup(gateway->pool, scheme); 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_realm = switch_core_strdup(gateway->pool, realm);
gateway->register_username = switch_core_strdup(gateway->pool, username); gateway->register_username = switch_core_strdup(gateway->pool, username);
gateway->register_password = switch_core_strdup(gateway->pool, password); gateway->register_password = switch_core_strdup(gateway->pool, password);
@ -5635,9 +5656,12 @@ static switch_status_t config_sofia(int reload)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", gateway->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", gateway->name);
} else if (find_gateway(gateway->register_from)) { } else if (find_gateway(gateway->register_from)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate uri '%s'\n", gateway->register_from); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate uri '%s'\n", gateway->register_from);
} else if (find_gateway(gateway->register_contact)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate contact '%s'\n", gateway->register_from);
} else { } else {
add_gateway(gateway->name, gateway); add_gateway(gateway->name, gateway);
add_gateway(gateway->register_from, gateway); add_gateway(gateway->register_from, gateway);
add_gateway(gateway->register_contact, gateway);
} }
} }