]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3663 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 4 Nov 2011 18:16:47 +0000 (13:16 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 4 Nov 2011 18:16:54 +0000 (13:16 -0500)
src/include/switch_utils.h
src/mod/endpoints/mod_sofia/sofia.c
src/switch_utils.c

index a5ba8fc73b9c436841560f18d4bf0709f7f0b261..29da21dd5b4ccba694e9387134e23feb2c7042ab 100644 (file)
@@ -240,6 +240,7 @@ SWITCH_DECLARE(switch_status_t) switch_frame_alloc(switch_frame_t **frame, switc
 SWITCH_DECLARE(switch_status_t) switch_frame_dup(switch_frame_t *orig, switch_frame_t **clone);
 SWITCH_DECLARE(switch_status_t) switch_frame_free(switch_frame_t **frame);
 SWITCH_DECLARE(switch_bool_t) switch_is_number(const char *str);
+SWITCH_DECLARE(char *) switch_find_parameter(const char *str, const char *param, switch_memory_pool_t *pool);
 
 /*!
   \brief Evaluate the truthfullness of a string expression
index 2a768bcf760eae371cfcebaf30fe8cb809decbe8..59a9d5734a58d24e84af7dff2d0b713ac72bbb16 100644 (file)
@@ -7404,16 +7404,12 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
        }
 
        if (sip->sip_from && sip->sip_from->a_url) {
-               char *tmp;
                from_user = sip->sip_from->a_url->url_user;
                from_host = sip->sip_from->a_url->url_host;
                channel_name = url_set_chanvars(session, sip->sip_from->a_url, sip_from);
 
-               if (sip->sip_from->a_url->url_params && (tmp = sofia_glue_find_parameter(sip->sip_from->a_url->url_params, "isup-oli="))) {
-                       aniii = switch_core_session_strdup(session, tmp + 9);
-                       if ((tmp = strchr(aniii, ';'))) {
-                               tmp = '\0';
-                       }
+               if (sip->sip_from->a_url->url_params) {
+                       aniii = switch_find_parameter(sip->sip_from->a_url->url_params, "isup-oli", switch_core_session_get_pool(session));
                }
 
                if (!zstr(from_user)) {
@@ -7755,7 +7751,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
 
 
        if (sip->sip_request->rq_url->url_params) {
-               gw_param_name = sofia_glue_find_parameter_value(session, sip->sip_request->rq_url->url_params, "gw=");
+               gw_param_name = switch_find_parameter(sip->sip_request->rq_url->url_params, "gw", switch_core_session_get_pool(session));
        }
 
        if (strstr(destination_number, "gw+")) {
index a008830ef6a5230f6faa41ec66f47cb78565324a..b160089eed4c9255e8311116b372f53d285853e0 100644 (file)
@@ -122,6 +122,53 @@ SWITCH_DECLARE(switch_status_t) switch_frame_free(switch_frame_t **frame)
        return SWITCH_STATUS_SUCCESS;
 }
 
+
+SWITCH_DECLARE(char *) switch_find_parameter(const char *str, const char *param, switch_memory_pool_t *pool)
+{
+       char *e, *r = NULL, *ptr = NULL, *next = NULL;
+       size_t len;
+
+       ptr = (char *) str;
+
+       while (ptr) {
+               len = strlen(param);
+               e = ptr+len;
+               next = strchr(ptr, ';');
+
+               if (!strncasecmp(ptr, param, len) && *e == '=') {
+                       int mlen;
+
+                       ptr = ++e;
+
+                       if (next) {
+                               e = next;
+                       } else {
+                               e = ptr + strlen(ptr);
+                       }
+                       
+                       mlen = (e - ptr) + 1;
+
+                       if (pool) {
+                               r = switch_core_alloc(pool, mlen);
+                       } else {
+                               r = malloc(mlen);
+                       }
+
+                       *(r + mlen) = '\0';
+
+                       switch_snprintf(r, mlen, "%s", ptr);
+
+                       break;
+               }
+
+               if (next) {
+                       ptr = next + 1;
+               }
+       }
+
+       return r;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_network_list_create(switch_network_list_t **list, const char *name, switch_bool_t default_type,
                                                                                                                   switch_memory_pool_t *pool)
 {