[sr-dev] git:pd/outbound: modules_k/rr: do not double RR when outbound is in use for a request
Peter Dunkley
peter.dunkley at crocodile-rcs.com
Sun Dec 30 20:27:51 CET 2012
Module: sip-router
Branch: pd/outbound
Commit: d55cce8e5f2558560bf38a8ff25ddbb80f697284
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d55cce8e5f2558560bf38a8ff25ddbb80f697284
Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date: Sun Dec 30 17:40:08 2012 +0000
modules_k/rr: do not double RR when outbound is in use for a request
---
modules_k/rr/record.c | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/modules_k/rr/record.c b/modules_k/rr/record.c
index fbed700..839f497 100644
--- a/modules_k/rr/record.c
+++ b/modules_k/rr/record.c
@@ -158,7 +158,7 @@ static inline struct lump *insert_rr_param_lump(struct lump *before,
* \return 0 on success, negative on failure
*/
static inline int build_rr(struct lump* _l, struct lump* _l2, str* user,
- str *tag, str *params, int _inbound)
+ str *tag, str *params, int _inbound, int _use_ob)
{
char* prefix, *suffix, *term, *r2;
int suffix_len, prefix_len;
@@ -232,7 +232,7 @@ static inline int build_rr(struct lump* _l, struct lump* _l2, str* user,
_l = insert_subst_lump_after(_l, _inbound?SUBST_RCV_ALL:SUBST_SND_ALL, 0);
if (_l ==0 )
goto lump_err;
- if (enable_double_rr) {
+ if (enable_double_rr && !_use_ob) {
if (!(_l = insert_cond_lump_after(_l, COND_IF_DIFF_REALMS, 0)))
goto lump_err;
if (!(_l = insert_new_lump_after(_l, r2, RR_R2_LEN, 0)))
@@ -307,7 +307,7 @@ int record_route(struct sip_msg* _m, str *params)
rr_param_buf.len = 0;
}
- if (enable_double_rr) {
+ if (enable_double_rr && !(rr_obb.use_outbound && rr_obb.use_outbound(_m))) {
l = anchor_lump(_m, _m->headers->name.s - _m->buf,0,HDR_RECORDROUTE_T);
l2 = anchor_lump(_m, _m->headers->name.s - _m->buf, 0, 0);
if (!l || !l2) {
@@ -320,7 +320,8 @@ int record_route(struct sip_msg* _m, str *params)
LM_ERR("failed to insert conditional lump\n");
return -6;
}
- if (build_rr(l, l2, &user, tag, params, OUTBOUND) < 0) {
+ if (build_rr(l, l2, &user, tag, params, OUTBOUND,
+ rr_obb.use_outbound ? rr_obb.use_outbound(_m) : 0) < 0) {
LM_ERR("failed to insert outbound Record-Route\n");
return -7;
}
@@ -333,7 +334,8 @@ int record_route(struct sip_msg* _m, str *params)
return -3;
}
- if (build_rr(l, l2, &user, tag, params, INBOUND) < 0) {
+ if (build_rr(l, l2, &user, tag, params, INBOUND,
+ rr_obb.use_outbound ? rr_obb.use_outbound(_m) : 0) < 0) {
LM_ERR("failed to insert inbound Record-Route\n");
return -4;
}
@@ -463,7 +465,7 @@ int record_route_preset(struct sip_msg* _m, str* _data)
#define RR_TRANS_LEN 11
#define RR_TRANS ";transport="
static inline int build_advertised_rr(struct lump* _l, struct lump* _l2, str *_data,
- str* user, str *tag, int _inbound)
+ str* user, str *tag, int _inbound, int _use_ob)
{
char *p;
char *hdr, *trans, *r2, *suffix, *term;
@@ -545,7 +547,7 @@ static inline int build_advertised_rr(struct lump* _l, struct lump* _l2, str *_d
goto lump_err;
if (!(_l = insert_subst_lump_after(_l, _inbound?SUBST_RCV_PROTO:SUBST_SND_PROTO, 0)))
goto lump_err;
- if (enable_double_rr) {
+ if (enable_double_rr && !_use_ob) {
if (!(_l = insert_cond_lump_after(_l, COND_IF_DIFF_REALMS, 0)))
goto lump_err;
if (!(_l = insert_new_lump_after(_l, r2, RR_R2_LEN, 0)))
@@ -598,7 +600,7 @@ int record_route_advertised_address(struct sip_msg* _m, str* _data)
tag = &((struct to_body*)_m->from->parsed)->tag_value;
}
- if (enable_double_rr) {
+ if (enable_double_rr && !(rr_obb.use_outbound && rr_obb.use_outbound(_m))) {
l = anchor_lump(_m, _m->headers->name.s - _m->buf,0,HDR_RECORDROUTE_T);
l2 = anchor_lump(_m, _m->headers->name.s - _m->buf, 0, 0);
if (!l || !l2) {
@@ -611,7 +613,8 @@ int record_route_advertised_address(struct sip_msg* _m, str* _data)
LM_ERR("failed to insert conditional lump\n");
return -4;
}
- if (build_advertised_rr(l, l2, _data, &user, tag, OUTBOUND) < 0) {
+ if (build_advertised_rr(l, l2, _data, &user, tag, OUTBOUND,
+ rr_obb.use_outbound ? rr_obb.use_outbound(_m) : 0) < 0) {
LM_ERR("failed to insert outbound Record-Route\n");
return -5;
}
@@ -624,7 +627,8 @@ int record_route_advertised_address(struct sip_msg* _m, str* _data)
return -6;
}
- if (build_advertised_rr(l, l2, _data, &user, tag, INBOUND) < 0) {
+ if (build_advertised_rr(l, l2, _data, &user, tag, INBOUND,
+ rr_obb.use_outbound ? rr_obb.use_outbound(_m) : 0) < 0) {
LM_ERR("failed to insert outbound Record-Route\n");
return -7;
}
@@ -676,7 +680,7 @@ int add_rr_param(struct sip_msg* msg, str* rr_param)
goto error;
}
/* double routing enabled? */
- if (enable_double_rr) {
+ if (enable_double_rr && !(rr_obb.use_outbound && rr_obb.use_outbound(msg))) {
if (root==0 || (last_param=get_rr_param_lump(&root))==0) {
LM_CRIT("failed to locate double RR lump\n");
goto error;
More information about the sr-dev
mailing list