[sr-dev] git:4.2:d7164b06: modules/rls: normalize RLS entry URIs
Daniel-Constantin Mierla
miconda at gmail.com
Wed Jul 29 12:38:39 CEST 2015
Module: kamailio
Branch: 4.2
Commit: d7164b062961c421c2b11f74a5826a52bc09d3aa
URL: https://github.com/kamailio/kamailio/commit/d7164b062961c421c2b11f74a5826a52bc09d3aa
Author: Juha Heinanen <jh at tutpro.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-07-29T12:33:16+02:00
modules/rls: normalize RLS entry URIs
- RLS entry URI is xs:AnyURI, which may be an absolute or relative URI.
In relative URI, URI scheme is missing.
(cherry picked from commit 68bb6b35098f5555ca35ddb21527660e46b7336a)
(cherry picked from commit 41a211e6c13dcecaa6752238d63dfae932433ea7)
---
Modified: modules/rls/subscribe.c
---
Diff: https://github.com/kamailio/kamailio/commit/d7164b062961c421c2b11f74a5826a52bc09d3aa.diff
Patch: https://github.com/kamailio/kamailio/commit/d7164b062961c421c2b11f74a5826a52bc09d3aa.patch
---
diff --git a/modules/rls/subscribe.c b/modules/rls/subscribe.c
index 801d5e4..223d375 100644
--- a/modules/rls/subscribe.c
+++ b/modules/rls/subscribe.c
@@ -987,23 +987,32 @@ int send_resource_subs(char* uri, void* param)
str pres_uri, *tmp_str;
struct sip_uri parsed_pres_uri;
int duplicate = 0;
+ str *normalized_uri;
subs_info_t *s = (subs_info_t *) ((void**)param)[0];
list_entry_t **rls_contact_list = (list_entry_t **) ((void**)param)[1];
pres_uri.s = uri;
pres_uri.len = strlen(uri);
- if (parse_uri(pres_uri.s, pres_uri.len, &parsed_pres_uri) < 0)
- {
- LM_ERR("bad uri: %.*s\n", pres_uri.len, pres_uri.s);
- return -1;
+
+ normalized_uri = normalize_sip_uri(&pres_uri);
+ if (normalized_uri->s == NULL || normalized_uri->len == 0) {
+ LM_ERR("failed to normalize RLS entry URI %.*s\n",
+ pres_uri.len, pres_uri.s);
+ return -1;
+ }
+
+ if (parse_uri(normalized_uri->s, normalized_uri->len, &parsed_pres_uri)
+ < 0) {
+ LM_ERR("bad uri: %.*s\n", normalized_uri->len, normalized_uri->s);
+ return -1;
}
if (check_self(&parsed_pres_uri.host, 0, PROTO_NONE) != 1
&& rls_disable_remote_presence != 0)
{
LM_WARN("Unable to subscribe to remote contact %.*s for watcher %.*s\n",
- pres_uri.len, pres_uri.s,
+ normalized_uri->len, normalized_uri->s,
s->watcher_uri->len,
s->watcher_uri->s);
return 1;
@@ -1014,8 +1023,8 @@ int send_resource_subs(char* uri, void* param)
if (rls_max_backend_subs > 0 && ++counter > rls_max_backend_subs)
return 1;
- s->pres_uri = &pres_uri;
- s->remote_target = &pres_uri;
+ s->pres_uri = normalized_uri;
+ s->remote_target = normalized_uri;
/* Build list of contacts... checking each contact exists only once */
if ((tmp_str = (str *)pkg_malloc(sizeof(str))) == NULL)
@@ -1029,8 +1038,8 @@ int send_resource_subs(char* uri, void* param)
LM_ERR("out of private memory\n");
return -1;
}
- memcpy(tmp_str->s, pres_uri.s, pres_uri.len);
- tmp_str->len = pres_uri.len;
+ memcpy(tmp_str->s, normalized_uri->s, normalized_uri->len);
+ tmp_str->len = normalized_uri->len;
*rls_contact_list = list_insert(tmp_str, *rls_contact_list, &duplicate);
if (duplicate != 0)
{
More information about the sr-dev
mailing list