[Freeswitch-svn] [commit] r6274 - in freeswitch/trunk/src: . include mod/applications/mod_dptools mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Thu Nov 15 11:22:19 EST 2007
Author: anthm
Date: Thu Nov 15 11:22:18 2007
New Revision: 6274
Modified:
freeswitch/trunk/src/include/switch_utils.h
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
freeswitch/trunk/src/switch_utils.c
freeswitch/trunk/src/switch_xml.cpp
Log:
fix uri nonsense and backwards stristr
Modified: freeswitch/trunk/src/include/switch_utils.h
==============================================================================
--- freeswitch/trunk/src/include/switch_utils.h (original)
+++ freeswitch/trunk/src/include/switch_utils.h Thu Nov 15 11:22:18 2007
@@ -301,7 +301,7 @@
SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str);
SWITCH_DECLARE(char *) switch_strip_spaces(const char *str);
SWITCH_DECLARE(char *) switch_separate_paren_args(char *str);
-SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr);
+SWITCH_DECLARE(const char *) switch_stristr(const char *instr, const char *str);
SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip);
SWITCH_DECLARE(char *) switch_replace_char(char *str, char from, char to, switch_bool_t dup);
SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len);
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Thu Nov 15 11:22:18 2007
@@ -1337,7 +1337,7 @@
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;
@@ -1346,7 +1346,7 @@
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;
}
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 Thu Nov 15 11:22:18 2007
@@ -481,6 +481,7 @@
void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip);
void sofia_glue_sql_close(sofia_profile_t *profile);
int sofia_glue_init_sql(sofia_profile_t *profile);
+char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const char *transport);
switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile,
switch_bool_t master,
switch_mutex_t *mutex,
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 Thu Nov 15 11:22:18 2007
@@ -470,6 +470,34 @@
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;
@@ -562,7 +590,6 @@
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);
@@ -586,7 +613,7 @@
} else {
use_from_str = tech_pvt->from_str;
}
-
+
if (switch_stristr("port=tcp", url)) {
transport = "tcp";
} else {
@@ -595,33 +622,13 @@
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),
@@ -630,7 +637,6 @@
TAG_END());
switch_safe_free(d_url);
- switch_safe_free(d_contact);
if (!(sofia_private = malloc(sizeof(*sofia_private)))) {
abort();
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 Thu Nov 15 11:22:18 2007
@@ -155,7 +155,7 @@
{
char *r = in;
- if (in && (switch_stristr(in, "null"))) {
+ if (in && (switch_stristr("null", in))) {
in = NULL;
}
Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c (original)
+++ freeswitch/trunk/src/switch_utils.c Thu Nov 15 11:22:18 2007
@@ -334,7 +334,7 @@
}
-SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr)
+SWITCH_DECLARE(const char *) switch_stristr(const char *instr, const char *str)
{
/*
** Rev History: 16/07/97 Greg Thayer Optimized
Modified: freeswitch/trunk/src/switch_xml.cpp
==============================================================================
--- freeswitch/trunk/src/switch_xml.cpp (original)
+++ freeswitch/trunk/src/switch_xml.cpp Thu Nov 15 11:22:18 2007
@@ -1018,7 +1018,7 @@
}
}
- 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';
@@ -1027,15 +1027,15 @@
}
}
- 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;
}
@@ -1046,15 +1046,15 @@
*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;
}
@@ -1694,7 +1694,7 @@
}
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);
More information about the Freeswitch-svn
mailing list