Module: sip-router
Branch: master
Commit: 10eac9b125ff2a13a2ae240897a3f17bc1243c71
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=10eac9b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Sep 14 11:19:56 2011 +0200
rr(k): execute callbacks only for local route uri
- parameters callback are executed only if there is a list with
parameters in Route URI and for loose routing the URI has to match
myself condition
- should fix bogus value of Route URI params in callback function when
URI of top Route is not myself
- reported by Andreas Granig
---
modules_k/rr/loose.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/modules_k/rr/loose.c b/modules_k/rr/loose.c
index 53a52d6..7d2c0e2 100644
--- a/modules_k/rr/loose.c
+++ b/modules_k/rr/loose.c
@@ -497,6 +497,11 @@ static inline int after_strict(struct sip_msg* _m)
rt = (rr_t*)hdr->parsed;
uri = rt->nameaddr.uri;
+ /* reset rr handling static vars for safety in error case */
+ routed_msg_id = 0;
+ routed_params.s = NULL;
+ routed_params.len = 0;
+
if (parse_uri(uri.s, uri.len, &puri) < 0) {
LM_ERR("failed to parse the first route URI\n");
return RR_ERROR;
@@ -651,8 +656,9 @@ static inline int after_strict(struct sip_msg* _m)
}
}
- /* run RR callbacks */
- run_rr_callbacks( _m, &routed_params );
+ /* run RR callbacks only if we have Route URI parameters */
+ if(routed_params.len > 0)
+ run_rr_callbacks( _m, &routed_params );
return RR_DRIVEN;
}
@@ -681,6 +687,11 @@ static inline int after_loose(struct sip_msg* _m, int preloaded)
rt = (rr_t*)hdr->parsed;
uri = rt->nameaddr.uri;
+ /* reset rr handling static vars for safety in error case */
+ routed_msg_id = 0;
+ routed_params.s = NULL;
+ routed_params.len = 0;
+
if (parse_uri(uri.s, uri.len, &puri) < 0) {
LM_ERR("failed to parse the first route URI\n");
return RR_ERROR;
@@ -807,8 +818,9 @@ static inline int after_loose(struct sip_msg* _m, int preloaded)
status = RR_DRIVEN;
done:
- /* run RR callbacks */
- run_rr_callbacks( _m, &routed_params );
+ /* run RR callbacks only if we have Route URI parameters */
+ if(routed_params.len > 0)
+ run_rr_callbacks( _m, &routed_params );
return status;
}