[sr-dev] git:master:c3755580: registrar: allow registered() in any route

Daniel-Constantin Mierla miconda at gmail.com
Fri Jul 31 18:40:44 CEST 2015


Module: kamailio
Branch: master
Commit: c3755580f8e2763e33be03b0370630d04af3a019
URL: https://github.com/kamailio/kamailio/commit/c3755580f8e2763e33be03b0370630d04af3a019

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-07-31T18:40:30+02:00

registrar: allow registered() in any route

- if used for a sip reply and URI is not provided, then To URI is used

---

Modified: modules/registrar/lookup.c
Modified: modules/registrar/reg_mod.c

---

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

---

diff --git a/modules/registrar/lookup.c b/modules/registrar/lookup.c
index efbe39c..6fb170b 100644
--- a/modules/registrar/lookup.c
+++ b/modules/registrar/lookup.c
@@ -36,6 +36,7 @@
 #include "../../action.h"
 #include "../../mod_fix.h"
 #include "../../parser/parse_rr.h"
+#include "../../parser/parse_to.h"
 #include "../../forward.h"
 #include "../usrloc/usrloc.h"
 #include "common.h"
@@ -642,8 +643,16 @@ int registered4(struct sip_msg* _m, udomain_t* _d, str* _uri, int match_flag, in
 	{
 		uri = *_uri;
 	} else {
-		if (_m->new_uri.s) uri = _m->new_uri;
-		else uri = _m->first_line.u.request.uri;
+		if(IS_SIP_REPLY(_m)) {
+			if (parse_to_header(_m) < 0) {
+				LM_ERR("failed to prepare the message\n");
+				return -1;
+			}
+			uri = get_to(_m)->uri;
+		} else {
+			if (_m->new_uri.s) uri = _m->new_uri;
+			else uri = _m->first_line.u.request.uri;
+		}
 	}
 	
 	if (extract_aor(&uri, &aor, NULL) < 0) {
diff --git a/modules/registrar/reg_mod.c b/modules/registrar/reg_mod.c
index 1b9ccae..7a57cb6 100644
--- a/modules/registrar/reg_mod.c
+++ b/modules/registrar/reg_mod.c
@@ -165,13 +165,13 @@ static cmd_export_t cmds[] = {
 	{"lookup_to_dset",  (cmd_function)w_lookup_to_dset,  2,  domain_uri_fixup, 0,
 			REQUEST_ROUTE | FAILURE_ROUTE },
 	{"registered",   (cmd_function)w_registered,  1,  domain_uri_fixup, 0,
-			REQUEST_ROUTE | FAILURE_ROUTE },
+			ANY_ROUTE },
 	{"registered",   (cmd_function)w_registered,  2,  domain_uri_fixup, 0,
-			REQUEST_ROUTE | FAILURE_ROUTE },
+			ANY_ROUTE },
 	{"registered",   (cmd_function)w_registered3, 3,  registered_fixup, 0,
-			REQUEST_ROUTE | FAILURE_ROUTE },
+			ANY_ROUTE },
 	{"registered",   (cmd_function)w_registered4, 4,  registered_fixup, 0,
-			REQUEST_ROUTE | FAILURE_ROUTE },
+			ANY_ROUTE },
 	{"add_sock_hdr", (cmd_function)add_sock_hdr,  1,  fixup_str_null, 0,
 			REQUEST_ROUTE },
 	{"unregister",   (cmd_function)w_unregister,  2,  unreg_fixup, 0,




More information about the sr-dev mailing list