Module: kamailio
Branch: master
Commit: c3755580f8e2763e33be03b0370630d04af3a019
URL:
https://github.com/kamailio/kamailio/commit/c3755580f8e2763e33be03b0370630d…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)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/c3755580f8e2763e33be03b0370630d…
Patch:
https://github.com/kamailio/kamailio/commit/c3755580f8e2763e33be03b0370630d…
---
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,