[sr-dev] git:4.0: tm: re-added the option for no-internal reply on error
Daniel-Constantin Mierla
miconda at gmail.com
Wed Sep 4 11:50:29 CEST 2013
Module: sip-router
Branch: 4.0
Commit: 3d836040bdb6d191e6f6a54e37fe680e1e3973d0
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3d836040bdb6d191e6f6a54e37fe680e1e3973d0
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: Wed Sep 4 11:47:36 2013 +0200
tm: re-added the option for no-internal reply on error
- new function t_set_disable_internal_reply(0|1) to disable|enable this
option per transaction
- t_relay_to() flags re-enabled for this option
- backport of 0f2f9c85eff0b6ad35b4c58dfcde74c8a65559d6
---
modules/tm/h_table.h | 2 ++
modules/tm/t_funcs.c | 9 +++++++++
modules/tm/tm.c | 13 +++++++++----
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/modules/tm/h_table.h b/modules/tm/h_table.h
index f30bd45..d13cd9b 100644
--- a/modules/tm/h_table.h
+++ b/modules/tm/h_table.h
@@ -299,6 +299,8 @@ struct totag_elem {
# define pass_provisional(_t_) ((_t_)->flags&T_PASS_PROVISIONAL_FLAG)
#endif
+#define T_DISABLE_INTERNAL_REPLY (1<<12) /* don't send internal negative reply */
+
/* unsigned short should be enough for a retr. timer: max. 65535 ms =>
* max retr. = 65 s which should be enough and saves us 2*2 bytes */
typedef unsigned short retr_timeout_t;
diff --git a/modules/tm/t_funcs.c b/modules/tm/t_funcs.c
index e9d9598..729b537 100644
--- a/modules/tm/t_funcs.c
+++ b/modules/tm/t_funcs.c
@@ -358,6 +358,15 @@ handle_ret:
/* we don't want to pass upstream any reply regarding replicating
* a request; replicated branch must stop at us*/
if (likely(!replicate)) {
+ if(t->flags&T_DISABLE_INTERNAL_REPLY) {
+ /* flag set to don't generate the internal negative reply
+ * - let the transaction live further, processing should
+ * continue in config */
+ DBG("not generating immediate reply for error %d\n", ser_error);
+ tm_error=ser_error;
+ ret = -4;
+ goto done;
+ }
#ifdef TM_DELAYED_REPLY
/* current error in tm_error */
tm_error=ser_error;
diff --git a/modules/tm/tm.c b/modules/tm/tm.c
index a1ca634..6b03081 100644
--- a/modules/tm/tm.c
+++ b/modules/tm/tm.c
@@ -289,6 +289,7 @@ static int t_set_disable_failover(struct sip_msg* msg, char* on_off, char* f);
static int t_set_no_e2e_cancel_reason(struct sip_msg* msg, char* on_off,
char* f);
#endif /* CANCEL_REASON_SUPPORT */
+static int t_set_disable_internal_reply(struct sip_msg* msg, char* on_off, char* f);
static int t_branch_timeout(struct sip_msg* msg, char*, char*);
static int t_branch_replied(struct sip_msg* msg, char*, char*);
static int t_any_timeout(struct sip_msg* msg, char*, char*);
@@ -448,6 +449,8 @@ static cmd_export_t cmds[]={
fixup_var_int_1,
REQUEST_ROUTE|TM_ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
#endif /* CANCEL_REASON_SUPPORT */
+ {"t_set_disable_internal_reply", t_set_disable_internal_reply, 1, fixup_var_int_1,
+ REQUEST_ROUTE|TM_ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
{"t_branch_timeout", t_branch_timeout, 0, 0, FAILURE_ROUTE},
{"t_branch_replied", t_branch_replied, 0, 0, FAILURE_ROUTE},
{"t_any_timeout", t_any_timeout, 0, 0,
@@ -1827,6 +1830,10 @@ T_SET_FLAG_GEN_FUNC(t_set_no_e2e_cancel_reason, T_NO_E2E_CANCEL_REASON)
#endif /* CANCEL_REASON_SUPPORT */
+/* disable internal negative reply for the current transaction */
+T_SET_FLAG_GEN_FUNC(t_set_disable_internal_reply, T_DISABLE_INTERNAL_REPLY)
+
+
/* script function, FAILURE_ROUTE only, returns true if the
* choosed "failure" branch failed because of a timeout,
* -1 otherwise */
@@ -2220,13 +2227,11 @@ inline static int w_t_relay_to(struct sip_msg *msg, char *proxy, char *flags)
param.v.i = 0;
t_set_auto_inv_100(msg, (char*)(¶m), 0);
}
- /* no auto negative reply - not implemented */
- /*
+ /* no auto negative reply */
if(fl&2) {
param.v.i = 1;
- t_set_disable_internal_reply(msg, (char*)param, 0);
+ t_set_disable_internal_reply(msg, (char*)(¶m), 0);
}
- */
/* no dns failover */
if(fl&4) {
param.v.i = 1;
More information about the sr-dev
mailing list