whoever thought making SIP all text based was simply a genius, umm no, that was sarcasm
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6026 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
31a81a8b75
commit
76ae69ada4
|
@ -548,7 +548,8 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
|
|||
*from_domain = "",
|
||||
*register_proxy = NULL,
|
||||
*contact_params = NULL,
|
||||
*params = NULL;
|
||||
*params = NULL,
|
||||
*register_transport = "udp";
|
||||
|
||||
gateway->pool = profile->pool;
|
||||
gateway->profile = profile;
|
||||
|
@ -588,6 +589,13 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
|
|||
register_proxy = val;
|
||||
} else if (!strcmp(var, "contact-params")) {
|
||||
contact_params = val;
|
||||
} else if (!strcmp(var, "register-transport")) {
|
||||
if (!strcasecmp(val, "udp") || !strcasecmp(val, "tcp")) {
|
||||
register_transport = val;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: unsupported transport\n");
|
||||
goto skip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,21 +648,21 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
|
|||
}
|
||||
if (contact_params) {
|
||||
if (*contact_params == ';') {
|
||||
params = contact_params;
|
||||
params = switch_core_sprintf(gateway->pool, "%s&transport=%s", contact_params, register_transport);
|
||||
} else {
|
||||
params = switch_core_sprintf(gateway->pool, ";%s", contact_params);
|
||||
params = switch_core_sprintf(gateway->pool, ";%s&transport=%s", contact_params, register_transport);
|
||||
}
|
||||
} else {
|
||||
params = "";
|
||||
params = switch_core_sprintf(gateway->pool, ";transport=%s", register_transport);
|
||||
}
|
||||
|
||||
|
||||
gateway->register_url = switch_core_sprintf(gateway->pool, "sip:%s", register_proxy);
|
||||
gateway->register_from = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, from_domain);
|
||||
gateway->register_url = switch_core_sprintf(gateway->pool, "sip:%s;transport=%s", register_proxy,register_transport);
|
||||
gateway->register_from = switch_core_sprintf(gateway->pool, "<sip:%s@%s;transport=%s>", username, from_domain, register_transport);
|
||||
gateway->register_contact = switch_core_sprintf(gateway->pool, "<sip:%s@%s:%d%s>", extension,
|
||||
profile->extsipip ? profile->extsipip : profile->sipip, profile->sip_port, params);
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
|
|
@ -549,6 +549,9 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
if (!tech_pvt->nh) {
|
||||
char *d_url = NULL, *url = NULL;
|
||||
sofia_private_t *sofia_private;
|
||||
char *invite_contact = NULL, *to_str, *use_from_str, *from_str, *url_str;
|
||||
char *transport = "udp", *t_var;
|
||||
|
||||
if (switch_strlen_zero(tech_pvt->dest)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "URL Error! [%s]\n", tech_pvt->dest);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -560,29 +563,52 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
|||
url = tech_pvt->dest;
|
||||
}
|
||||
|
||||
url_str = url;
|
||||
|
||||
if (switch_strlen_zero(tech_pvt->invite_contact)) {
|
||||
tech_pvt->invite_contact = tech_pvt->profile->url;
|
||||
}
|
||||
|
||||
if (switch_stristr("port=tcp", url)) {
|
||||
char *tmp;
|
||||
if (!switch_strlen_zero(tech_pvt->gateway_from_str)) {
|
||||
use_from_str = tech_pvt->gateway_from_str;
|
||||
} else {
|
||||
use_from_str = tech_pvt->from_str;
|
||||
}
|
||||
|
||||
if (strchr(tech_pvt->invite_contact, ';')) {
|
||||
tmp = switch_core_session_sprintf(session, "<%s&transport=tcp>", tech_pvt->invite_contact);
|
||||
} else {
|
||||
tmp = switch_core_session_sprintf(session, "<%s;transport=tcp>", tech_pvt->invite_contact);
|
||||
if (switch_stristr("port=tcp", url)) {
|
||||
transport = "tcp";
|
||||
} else {
|
||||
if ((t_var = switch_channel_get_variable(channel, "sip_transport"))) {
|
||||
if (!strcasecmp(t_var, "tcp") || !strcasecmp(t_var, "udp")) {
|
||||
transport = t_var;
|
||||
}
|
||||
}
|
||||
assert(tmp);
|
||||
tech_pvt->invite_contact = tmp;
|
||||
url_str = switch_core_session_sprintf(session, "%s;transport=%s", url, transport);
|
||||
}
|
||||
|
||||
if (strchr(tech_pvt->invite_contact, ';')) {
|
||||
invite_contact = switch_core_session_sprintf(session, "<%s&transport=%s>", tech_pvt->invite_contact, transport);
|
||||
} else {
|
||||
invite_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", tech_pvt->invite_contact, transport);
|
||||
}
|
||||
|
||||
if (strchr(use_from_str, '>')) {
|
||||
from_str = switch_core_session_sprintf(session, "%s;transport=%s", use_from_str, transport);
|
||||
} else {
|
||||
from_str = switch_core_session_sprintf(session, "<%s;transport=%s>", use_from_str, transport);
|
||||
}
|
||||
|
||||
if (strchr(tech_pvt->dest_to, '>')) {
|
||||
to_str = switch_core_session_sprintf(session, "%s;transport=%s", tech_pvt->dest_to, transport);
|
||||
} else {
|
||||
to_str = switch_core_session_sprintf(session, "<%s;transport=%s>", tech_pvt->dest_to, transport);
|
||||
}
|
||||
|
||||
tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL,
|
||||
NUTAG_URL(url),
|
||||
SIPTAG_TO_STR(tech_pvt->dest_to),
|
||||
TAG_IF(tech_pvt->gateway_from_str, SIPTAG_FROM_STR(tech_pvt->gateway_from_str)),
|
||||
TAG_IF(!tech_pvt->gateway_from_str, SIPTAG_FROM_STR(tech_pvt->from_str)),
|
||||
SIPTAG_CONTACT_STR(tech_pvt->invite_contact),
|
||||
NUTAG_URL(url_str),
|
||||
SIPTAG_TO_STR(to_str),
|
||||
SIPTAG_FROM_STR(from_str),
|
||||
SIPTAG_CONTACT_STR(invite_contact),
|
||||
TAG_END());
|
||||
|
||||
switch_safe_free(d_url);
|
||||
|
|
|
@ -75,6 +75,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
|||
nua_unregister(gateway_ptr->nh,
|
||||
NUTAG_URL(gateway_ptr->register_url),
|
||||
SIPTAG_FROM_STR(gateway_ptr->register_from),
|
||||
SIPTAG_TO_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),
|
||||
|
@ -99,6 +100,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
|||
if (now) {
|
||||
nua_register(gateway_ptr->nh,
|
||||
NUTAG_URL(gateway_ptr->register_url),
|
||||
SIPTAG_TO_STR(gateway_ptr->register_from),
|
||||
SIPTAG_FROM_STR(gateway_ptr->register_from),
|
||||
SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
|
||||
SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
|
||||
|
@ -109,6 +111,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
|||
nua_unregister(gateway_ptr->nh,
|
||||
NUTAG_URL(gateway_ptr->register_url),
|
||||
SIPTAG_FROM_STR(gateway_ptr->register_from),
|
||||
SIPTAG_TO_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),
|
||||
|
|
Loading…
Reference in New Issue