Module: kamailio
Branch: 5.3
Commit: ebd35b33f3afe9aa1b1858f07b672370267f532c
URL: 
https://github.com/kamailio/kamailio/commit/ebd35b33f3afe9aa1b1858f07b672370267f532c

Author: Aleksandar Yosifov <alexyosi...@gmail.com>
Committer: Henning Westerholt <h...@skalatan.de>
Date: 2020-05-13T10:05:18Z

ims_registrar_scscf: fix aor generation in lookup()

- Generate AoR in lookup() from parsed uri user and
  host. Skipping all user's and host's parameters.

(cherry picked from commit e53b25f89a14aba93d3c48a1b2f983114db1760c)

---

Modified: src/modules/ims_registrar_scscf/lookup.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/ebd35b33f3afe9aa1b1858f07b672370267f532c.diff
Patch: 
https://github.com/kamailio/kamailio/commit/ebd35b33f3afe9aa1b1858f07b672370267f532c.patch

---

diff --git a/src/modules/ims_registrar_scscf/lookup.c 
b/src/modules/ims_registrar_scscf/lookup.c
index 0e7b06cf60..640dbb9707 100644
--- a/src/modules/ims_registrar_scscf/lookup.c
+++ b/src/modules/ims_registrar_scscf/lookup.c
@@ -61,13 +61,12 @@
  */
 int lookup(struct sip_msg* _m, udomain_t* _d, char* ue_type_c) {
     impurecord_t* r;
-    str aor;
+    str aor, tmp_aor;
     ucontact_t* ptr = 0;
     int res;
     int ret;
     str path_dst;
     flag_t old_bflags;
-    int i = 0;
     int ue_type;    /*0=any, 1=3gpp, 2=sip */
        impu_contact_t *impucontact;
 
@@ -91,29 +90,35 @@ int lookup(struct sip_msg* _m, udomain_t* _d, char* 
ue_type_c) {
             ue_type=0;
     }
 
-    if (_m->new_uri.s) {
-                       aor.s = pkg_malloc(_m->new_uri.len);
-                       if (aor.s == NULL) {
-                               LM_ERR("memory allocation failure\n");
-                               return -1;
-                       }
-                       memcpy(aor.s, _m->new_uri.s, _m->new_uri.len);
-                       aor.len = _m->new_uri.len;
-               } else {
-                       aor.s = pkg_malloc(_m->first_line.u.request.uri.len);
-                       if (aor.s == NULL) {
-                               LM_ERR("memory allocation failure\n");
-                               return -1;
-                       }
-                       memcpy(aor.s, _m->first_line.u.request.uri.s, 
_m->first_line.u.request.uri.len);
-                       aor.len = _m->first_line.u.request.uri.len;
-               }
-
-    for (i = 4; i < aor.len; i++)
-        if (aor.s[i] == ':' || aor.s[i] == ';' || aor.s[i] == '?') {
-            aor.len = i;
-            break;
-        }
+       if (parse_sip_msg_uri(_m) < 0) {
+               LM_ERR("Error while parsing the Request-URI\n");
+               return -1;
+       }
+
+       if (_m->new_uri.s) {
+               tmp_aor = _m->new_uri;
+       } else {
+               tmp_aor = _m->first_line.u.request.uri;
+       }
+
+       aor.s = pkg_malloc(tmp_aor.len);
+       if (aor.s == NULL) {
+               LM_ERR("memory allocation failure\n");
+               return -1;
+       }
+
+       // build aor
+       // add 'sip:' or 'tel:'
+       memcpy(aor.s, tmp_aor.s, 4);
+       aor.len = 4;
+       // add user part
+       memcpy(aor.s + aor.len, _m->parsed_uri.user.s, _m->parsed_uri.user.len);
+       aor.len += _m->parsed_uri.user.len;
+       // add '@'
+       aor.s[aor.len++] = '@';
+       // add host part
+       memcpy(aor.s + aor.len, _m->parsed_uri.host.s, _m->parsed_uri.host.len);
+       aor.len += _m->parsed_uri.host.len;
 
     LM_DBG("Looking for <%.*s>\n", aor.len, aor.s);
 


_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to