if the variable continue_on_fail is set it can be:
'true' to continue on all failures.
'false' to not continue.
- A list of codes either names or numbers eg "user_busy,normal_temporary_failure"
+ A list of codes either names or numbers eg "user_busy,normal_temporary_failure,603"
*/
if (continue_on_fail) {
const char *cause_str;
cause_str = switch_channel_cause2str(cause);
snprintf(cause_num, sizeof(cause_num), "%u", cause);
- if (switch_true(continue_on_fail) || switch_stristr(cause_str, continue_on_fail) || strstr(cause_str, cause_num)) {
+ if (switch_true(continue_on_fail) || switch_stristr(cause_str, continue_on_fail) || strstr(cause_num, continue_on_fail)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Continue on fail [%s]: Cause: %s\n", continue_on_fail, cause_str);
return;
}
return SWITCH_STATUS_SUCCESS;
}
+char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const char *transport)
+{
+ char *stripped = switch_core_session_strdup(session, uri);
+ char *new_uri = NULL;
+
+ stripped = sofia_glue_get_url_from_contact(stripped, 0);
+ if (transport && strcasecmp(transport, "udp")) {
+ if (switch_stristr("port=", stripped)) {
+ new_uri = switch_core_session_sprintf(session, "<%s>", stripped);
+ } else {
+ if (strchr(stripped, ';')) {
+ new_uri = switch_core_session_sprintf(session, "<%s&transport=%s>", stripped, transport);
+ } else {
+ new_uri = switch_core_session_sprintf(session, "<%s;transport=%s>", stripped, transport);
+ }
+ }
+ } else {
+ char *p;
+ if ((p = strrchr(stripped, ';'))) {
+ *p = '\0';
+ }
+ new_uri = stripped;
+ }
+
+ return new_uri;
+}
+
+
switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
{
char *rpid = NULL;
sofia_private_t *sofia_private;
char *invite_contact = NULL, *to_str, *use_from_str, *from_str, *url_str;
const char *transport = "udp", *t_var;
- char *d_contact = NULL;
if (switch_strlen_zero(tech_pvt->dest)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "URL Error! [%s]\n", tech_pvt->dest);
} else {
use_from_str = tech_pvt->from_str;
}
-
+
if (switch_stristr("port=tcp", url)) {
transport = "tcp";
} else {
transport = t_var;
}
}
- url_str = switch_core_session_sprintf(session, "%s;transport=%s", url, transport);
- }
-
- d_contact = sofia_glue_get_url_from_contact(tech_pvt->invite_contact, 1);
-
- if (switch_stristr("port=", d_contact)) {
- invite_contact = switch_core_session_sprintf(session, "<%s>", d_contact);
- } else {
- if (strchr(d_contact, ';')) {
- invite_contact = switch_core_session_sprintf(session, "<%s&transport=%s>", d_contact, transport);
- } else {
- invite_contact = switch_core_session_sprintf(session, "%s;transport=%s", d_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);
}
+ url_str = sofia_overcome_sip_uri_weakness(session, url, transport);
+ invite_contact = sofia_overcome_sip_uri_weakness(session, tech_pvt->invite_contact, transport);
+ from_str = sofia_overcome_sip_uri_weakness(session, use_from_str, NULL);
+ to_str = sofia_overcome_sip_uri_weakness(session, tech_pvt->dest_to, NULL);
+
tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL,
NUTAG_URL(url_str),
SIPTAG_TO_STR(to_str),
TAG_END());
switch_safe_free(d_url);
- switch_safe_free(d_contact);
if (!(sofia_private = malloc(sizeof(*sofia_private)))) {
abort();
}
}
- if ((tcmd = (char *)switch_stristr(bp, "<X-pre-process"))) {
+ if ((tcmd = (char *)switch_stristr("<X-pre-process", bp))) {
if ((e = strstr(tcmd, "/>"))) {
*e += 2;
*e = '\0';
}
}
- if (!(tcmd = (char *)switch_stristr(tcmd, "cmd"))) {
+ if (!(tcmd = (char *)switch_stristr("cmd", tcmd))) {
continue;
}
- if (!(tcmd = (char *)switch_stristr(tcmd, "="))) {
+ if (!(tcmd = (char *)switch_stristr("=", tcmd))) {
continue;
}
- if (!(tcmd = (char *)switch_stristr(tcmd, "\""))) {
+ if (!(tcmd = (char *)switch_stristr("\"", tcmd))) {
continue;
}
*e++ = '\0';
}
- if (!(targ = (char *)switch_stristr(e, "data"))) {
+ if (!(targ = (char *)switch_stristr("data", e))) {
continue;
}
- if (!(targ = (char *)switch_stristr(targ, "="))) {
+ if (!(targ = (char *)switch_stristr("=", targ))) {
continue;
}
- if (!(targ = (char *)switch_stristr(targ, "\""))) {
+ if (!(targ = (char *)switch_stristr("\"", targ))) {
continue;
}
}
if (xml->free_path) {
- if (!switch_stristr(xml->free_path, ".fsxml")) {
+ if (!switch_stristr(".fsxml", xml->free_path)) {
unlink(xml->free_path);
}
switch_safe_free(xml->free_path);