[sr-dev] Registrar - check for local path

Charles Chance charles.chance at sipcentric.com
Mon Dec 8 15:42:05 CET 2014


Hi All,

Can anyone see a problem with doing (something like) the following, to
handle the situation like
http://lists.sip-router.org/pipermail/sr-users/2014-October/085251.html?

Admittedly, it is probably a less common use case, but it has been raised
several times on the list so I believe it is a genuine one.


diff --git a/modules/registrar/lookup.c b/modules/registrar/lookup.c
index 794d968..66730b4 100644
--- a/modules/registrar/lookup.c
+++ b/modules/registrar/lookup.c
@@ -41,6 +41,7 @@
 #include "../../action.h"
 #include "../../mod_fix.h"
 #include "../../parser/parse_rr.h"
+#include "../../forward.h"
 #include "../usrloc/usrloc.h"
 #include "common.h"
 #include "regtime.h"
@@ -121,6 +122,7 @@ int lookup_helper(struct sip_msg* _m, udomain_t* _d,
str* _uri, int _mode)
        sr_xavp_t *list=NULL;
        str xname = {"ruid", 4};
        sr_xval_t xval;
+       sip_uri_t path_uri;

        ret = -1;

@@ -265,6 +267,14 @@ int lookup_helper(struct sip_msg* _m, udomain_t* _d,
str* _uri, int _mode)
                                ret = -3;
                                goto done;
                        }
+                       if (parse_uri(path_dst.s, path_dst.len, &path_uri)
< 0){
+                               LM_ERR("failed to parse the Path URI\n");
+                               ret = -3;
+                               goto done;
+                       }
+               }
+               /* Only use path-uri if non-local */
+               if (path_uri.host.s && !check_self(&(path_uri.host), 0, 0))
{
                        if (set_path_vector(_m, &ptr->path) < 0) {
                                LM_ERR("failed to set path vector\n");
                                ret = -3;



The above needs to be repeated in lookup_branches function of same file,
but I wanted to check others' opinions first.

Best regards,

Charles

-- 
www.sipcentric.com

Follow us on twitter @sipcentric <http://twitter.com/sipcentric>

Sipcentric Ltd. Company registered in England & Wales no. 7365592. Registered 
office: Faraday Wharf, Innovation Birmingham Campus, Holt Street, 
Birmingham Science Park, Birmingham B7 4BB.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20141208/f6c17d45/attachment.html>


More information about the sr-dev mailing list