Browse Source

t_reset_fr(), t_reset_retr(), and t_reset_max_lifetime() are added,
they can be used to reset the timer values to the default setting.
Closes SER-360

Miklos Tirpak 17 years ago
parent
commit
16daadfde3
3 changed files with 98 additions and 3 deletions
  1. 64 0
      modules/tm/t_lookup.c
  2. 3 0
      modules/tm/t_lookup.h
  3. 31 3
      modules/tm/tm.c

+ 64 - 0
modules/tm/t_lookup.c

@@ -1542,6 +1542,25 @@ int t_set_fr(struct sip_msg* msg, unsigned int fr_inv_to, unsigned int fr_to)
 	return 1;
 	return 1;
 }
 }
 
 
+/* reset fr_timer and fr_inv_timer to the default values */
+int t_reset_fr()
+{
+	struct cell *t;
+
+	t=get_t();
+	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
+	 * in MODE_REQUEST T will be set only if the transaction was already
+	 * created; if not -> use the static variables */
+	if (!t || t==T_UNDEFINED ){
+		memset(&user_fr_inv_timeout, 0, sizeof(user_fr_inv_timeout));
+		memset(&user_fr_timeout, 0, sizeof(user_fr_timeout));
+	}else{
+		change_fr(t,
+			cfg_get(tm, tm_cfg, fr_inv_timeout),
+			cfg_get(tm, tm_cfg, fr_timeout)); /* change running uac timers */
+	}
+	return 1;
+}
 
 
 #ifdef TM_DIFF_RT_TIMEOUT
 #ifdef TM_DIFF_RT_TIMEOUT
 
 
@@ -1586,6 +1605,27 @@ int t_set_retr(struct sip_msg* msg, unsigned int t1_to, unsigned int t2_to)
 	}
 	}
 	return 1;
 	return 1;
 }
 }
+
+/* reset retr. t1 and t2 to the default values */
+int t_reset_retr()
+{
+	struct cell *t;
+
+	t=get_t();
+	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
+	 * in MODE_REQUEST T will be set only if the transaction was already
+	 * created; if not -> use the static variables */
+	if (!t || t==T_UNDEFINED ){
+		memset(&user_rt_t1_timeout, 0, sizeof(user_rt_t1_timeout));
+		memset(&user_rt_t2_timeout, 0, sizeof(user_rt_t2_timeout));
+	}else{
+		change_retr(t,
+			1,
+			cfg_get(tm, tm_cfg, rt_t1_timeout),
+			cfg_get(tm, tm_cfg, rt_t2_timeout)); /* change running uac timers */
+	}
+	return 1;
+}
 #endif
 #endif
 
 
 
 
@@ -1628,3 +1668,27 @@ int t_set_max_lifetime(struct sip_msg* msg,
 	}
 	}
 	return 1;
 	return 1;
 }
 }
+
+/* reset maximum invite/non-invite lifetime to the default value */
+int t_reset_max_lifetime()
+{
+	struct cell *t;
+
+	t=get_t();
+	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
+	 * in MODE_REQUEST T will be set only if the transaction was already
+	 * created; if not -> use the static variables */
+	if (!t || t==T_UNDEFINED ){
+		memset(&user_inv_max_lifetime, 0, sizeof(user_inv_max_lifetime));
+		memset(&user_noninv_max_lifetime, 0, sizeof(user_noninv_max_lifetime));
+	}else{
+		change_end_of_life(t,
+				1,
+				is_invite(t)?
+					cfg_get(tm, tm_cfg, tm_max_inv_lifetime):
+					cfg_get(tm, tm_cfg, tm_max_noninv_lifetime)
+				);
+	}
+	return 1;
+}
+

+ 3 - 0
modules/tm/t_lookup.h

@@ -99,10 +99,13 @@ int t_lookup_ident(struct cell** trans, unsigned int hash_index, unsigned int la
 int t_lookup_callid(struct cell** trans, str callid, str cseq);
 int t_lookup_callid(struct cell** trans, str callid, str cseq);
 
 
 int t_set_fr(struct sip_msg* msg, unsigned int fr_inv_to, unsigned int fr_to );
 int t_set_fr(struct sip_msg* msg, unsigned int fr_inv_to, unsigned int fr_to );
+int t_reset_fr();
 #ifdef TM_DIFF_RT_TIMEOUT
 #ifdef TM_DIFF_RT_TIMEOUT
 int t_set_retr(struct sip_msg* msg, unsigned int t1_to, unsigned int t2_to);
 int t_set_retr(struct sip_msg* msg, unsigned int t1_to, unsigned int t2_to);
+int t_reset_retr();
 #endif
 #endif
 int t_set_max_lifetime(struct sip_msg* msg, unsigned int eol_inv,
 int t_set_max_lifetime(struct sip_msg* msg, unsigned int eol_inv,
 											unsigned int eol_noninv);
 											unsigned int eol_noninv);
+int t_reset_max_lifetime();
 
 
 #endif
 #endif

+ 31 - 3
modules/tm/tm.c

@@ -194,8 +194,11 @@ inline static int w_t_on_reply(struct sip_msg* msg, char *go_to, char *foo );
 inline static int t_check_status(struct sip_msg* msg, char *match, char *foo);
 inline static int t_check_status(struct sip_msg* msg, char *match, char *foo);
 static int t_set_fr_inv(struct sip_msg* msg, char* fr_inv, char* foo);
 static int t_set_fr_inv(struct sip_msg* msg, char* fr_inv, char* foo);
 static int t_set_fr_all(struct sip_msg* msg, char* fr_inv, char* fr);
 static int t_set_fr_all(struct sip_msg* msg, char* fr_inv, char* fr);
+static int w_t_reset_fr(struct sip_msg* msg, char* foo, char* bar);
 static int w_t_set_retr(struct sip_msg* msg, char* retr_t1, char* retr_t2);
 static int w_t_set_retr(struct sip_msg* msg, char* retr_t1, char* retr_t2);
+static int w_t_reset_retr(struct sip_msg* msg, char* foo, char* bar);
 static int w_t_set_max_lifetime(struct sip_msg* msg, char* inv, char* noninv);
 static int w_t_set_max_lifetime(struct sip_msg* msg, char* inv, char* noninv);
+static int w_t_reset_max_lifetime(struct sip_msg* msg, char* foo, char* bar);
 static int t_set_auto_inv_100(struct sip_msg* msg, char* on_off, char* foo);
 static int t_set_auto_inv_100(struct sip_msg* msg, char* on_off, char* foo);
 static int t_branch_timeout(struct sip_msg* msg, char*, char*);
 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_branch_replied(struct sip_msg* msg, char*, char*);
@@ -288,10 +291,16 @@ static cmd_export_t cmds[]={
 			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
 			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
 	{"t_set_fr",          t_set_fr_all,             2, fixup_var_int_12,
 	{"t_set_fr",          t_set_fr_all,             2, fixup_var_int_12,
 			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
 			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
+	{"t_reset_fr",        w_t_reset_fr,             0, 0,
+			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
 	{"t_set_retr",        w_t_set_retr,               2, fixup_var_int_12,
 	{"t_set_retr",        w_t_set_retr,               2, fixup_var_int_12,
 			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
 			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
+	{"t_reset_retr",      w_t_reset_retr,           0, 0,
+			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
 	{"t_set_max_lifetime", w_t_set_max_lifetime,      2, fixup_var_int_12,
 	{"t_set_max_lifetime", w_t_set_max_lifetime,      2, fixup_var_int_12,
 			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
 			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
+	{"t_reset_max_lifetime", w_t_reset_max_lifetime, 0, 0,
+			REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
 	{"t_set_auto_inv_100", t_set_auto_inv_100,       1, fixup_var_int_1,
 	{"t_set_auto_inv_100", t_set_auto_inv_100,       1, fixup_var_int_1,
 													  REQUEST_ROUTE},
 													  REQUEST_ROUTE},
 	{"t_branch_timeout",  t_branch_timeout,         0, 0,  FAILURE_ROUTE},
 	{"t_branch_timeout",  t_branch_timeout,         0, 0,  FAILURE_ROUTE},
@@ -1263,7 +1272,11 @@ static int t_set_fr_inv(struct sip_msg* msg, char* fr_inv, char* foo)
 	return t_set_fr_all(msg, fr_inv, (char*)0);
 	return t_set_fr_all(msg, fr_inv, (char*)0);
 }
 }
 
 
-
+/* reset fr_timer and fr_inv_timer to the default values */
+static int w_t_reset_fr(struct sip_msg* msg, char* foo, char* bar)
+{
+	return t_reset_fr();
+}
 
 
 /* set retr. intervals per transaction; 0 means: use the default value */
 /* set retr. intervals per transaction; 0 means: use the default value */
 static int w_t_set_retr(struct sip_msg* msg, char* p1, char* p2)
 static int w_t_set_retr(struct sip_msg* msg, char* p1, char* p2)
@@ -1286,7 +1299,18 @@ static int w_t_set_retr(struct sip_msg* msg, char* p1, char* p2)
 #endif
 #endif
 }
 }
 
 
-
+/* reset retr. t1 and t2 to the default values */
+int w_t_reset_retr(struct sip_msg* msg, char* foo, char* bar)
+{
+#ifdef TM_DIFF_RT_TIMEOUT
+	return t_reset_retr();
+#else
+	ERR("w_t_reset_retr: support for changing retransmission intervals on "
+			"the fly not compiled in (re-compile tm with"
+			" -DTM_DIFF_RT_TIMEOUT)\n");
+	return -1;
+#endif
+}
 
 
 /* set maximum transaction lifetime for inv & noninv */
 /* set maximum transaction lifetime for inv & noninv */
 static int w_t_set_max_lifetime(struct sip_msg* msg, char* p1, char* p2)
 static int w_t_set_max_lifetime(struct sip_msg* msg, char* p1, char* p2)
@@ -1302,7 +1326,11 @@ static int w_t_set_max_lifetime(struct sip_msg* msg, char* p1, char* p2)
 	return t_set_max_lifetime(msg, t1, t2);
 	return t_set_max_lifetime(msg, t1, t2);
 }
 }
 
 
-
+/* reset maximum invite/non-invite lifetime to the default value */
+int w_t_reset_max_lifetime(struct sip_msg* msg, char* foo, char* bar)
+{
+	return t_reset_max_lifetime();
+}
 
 
 /* set automatically sending 100 replies on/off for the current or
 /* set automatically sending 100 replies on/off for the current or
  * next to be created transaction */
  * next to be created transaction */