Browse code

tm module parameters are changed to use the configuration framework, that means the parameters are changeable on-the-fly. ("fr_timer_avp", "fr_inv_timer_avp", and "tw_append" are left untouched)

Miklos Tirpak authored on 15/02/2008 12:11:46
Showing 20 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,170 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2008 iptelorg GmbH
5
+ *
6
+ * This file is part of ser, a free SIP server.
7
+ *
8
+ * ser is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version
12
+ *
13
+ * For a license to use the ser software under conditions
14
+ * other than those described here, or to purchase support for this
15
+ * software, please contact iptel.org by e-mail at the following addresses:
16
+ *    info@iptel.org
17
+ *
18
+ * ser is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program; if not, write to the Free Software
25
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
+ *
27
+ * History
28
+ * -------
29
+ *  2008-02-05	adapting tm module for the configuration framework (Miklos)
30
+ */
31
+
32
+#include "../../cfg/cfg.h"
33
+#include "../../parser/msg_parser.h" /* method types */
34
+#include "timer.h"
35
+#include "t_fwd.h"
36
+#include "config.h"
37
+
38
+struct cfg_group_tm	default_tm_cfg = {
39
+	/* should be request-uri matching used as a part of pre-3261
40
+	 * transaction matching, as the standard wants us to do so
41
+	 * (and is reasonable to do so, to be able to distinguish
42
+	 * spirals)? turn only off for better interaction with
43
+	 * devices that are broken and send different r-uri in
44
+	 * CANCEL/ACK than in original INVITE
45
+	 */
46
+	1,	/* ruri_matching */
47
+	1,	/* via1_matching */
48
+	FR_TIME_OUT,	/* fr_timeout */
49
+	INV_FR_TIME_OUT,	/* fr_inv_timeout */
50
+	WT_TIME_OUT,	/* wait_timeout */
51
+	DEL_TIME_OUT,	/* delete_timeout */
52
+	RETR_T1,	/* rt_t1_timeout */
53
+	RETR_T2,	/* rt_t2_timeout */
54
+
55
+	/* maximum time an invite or noninv transaction will live, from
56
+	 * the moment of creation (overrides larger fr/fr_inv timeouts,
57
+	 * extensions due to dns failover, fr_inv restart a.s.o)
58
+	 * Note: after this time the transaction will not be deleted
59
+	 *  immediately, but forced to go in the wait state or in wait for ack state
60
+	 *  and then wait state, so it will still be alive for either wait_timeout in
61
+	 *  the non-inv or "silent" inv. case and for fr_timeout + wait_timeout for an
62
+	 *  invite transaction (for which  we must wait for the neg. reply ack)
63
+	 */
64
+	MAX_INV_LIFETIME,	/* tm_max_inv_lifetime */
65
+	MAX_NONINV_LIFETIME,	/* tm_max_noninv_lifetime */
66
+	1,	/* noisy_ctimer */
67
+	1,	/* tm_auto_inv_100 */
68
+	500,	/* tm_unix_tx_timeout -- 500 ms by default */
69
+	1,	/* restart_fr_on_each_reply */
70
+	0,	/* pass_provisional_replies */
71
+	1,	/* tm_aggregate_auth */
72
+	UM_CANCEL_STATEFULL,	/* unmatched_cancel */
73
+	500,	/* default_code */
74
+	"Server Internal Error",	/* default_reason */
75
+	1,	/* reparse_invite */
76
+	STR_NULL,	/* ac_extra_hdrs */
77
+
78
+	0,	/* tm_blst_503 -- if 1 blacklist 503 sources, using tm_blst_503_min,
79
+		 * tm_blst_503_max, tm_blst_503_default and the Retry-After header
80
+		 * in the 503 reply */
81
+	0,	/* tm_blst_503_default -- rfc conformant: do not blacklist if
82
+		 * no retry-after header is present */
83
+	0,	/* tm_blst_503 -- minimum 503 blacklist time is 0 sec */
84
+	3600,	/* tm_blst_503_max -- maximum 503 blacklist time is 3600 sec */
85
+	METHOD_INVITE,	/* tm_blst_methods_add -- backlist only INVITE
86
+			 * timeouts by default */
87
+	~METHOD_BYE,	/* tm_blst_methods_lookup -- look-up the blacklist
88
+			 * for every method except BYE by default */
89
+};
90
+
91
+void	*tm_cfg = &default_tm_cfg;
92
+
93
+cfg_def_t	tm_cfg_def[] = {
94
+	{"ruri_matching",	CFG_VAR_INT,	0, 1, 0, 0,
95
+		"perform Request URI check in tranaction matching"},
96
+	{"via1_matching",	CFG_VAR_INT,	0, 1, 0, 0,
97
+		"perform first Via header check in tranaction matching"},
98
+	{"fr_timer",		CFG_VAR_INT,	0, 0, timer_fixup, 0,
99
+		"timer which hits if no final reply for a request "
100
+		"or ACK for a negative INVITE reply arrives "
101
+		"(in milliseconds)"},
102
+	{"fr_inv_timer",	CFG_VAR_INT,	0, 0, timer_fixup, 0,
103
+		"timer which hits if no final reply for an INVITE arrives "
104
+		"after a provisional message was received (in milliseconds)"},
105
+	{"wt_timer",		CFG_VAR_INT,	0, 0, timer_fixup, 0,
106
+		"time for which a transaction stays in memory to absorb "
107
+		"delayed messages after it completed"},
108
+	{"delete_timer",	CFG_VAR_INT,	0, 0, timer_fixup, 0,
109
+		"time after which a to-be-deleted transaction currently "
110
+		"ref-ed by a process will be tried to be deleted again."},
111
+	{"retr_timer1",		CFG_VAR_INT,	0, 0, timer_fixup, 0,
112
+		"initial retransmission period (in milliseconds)"},
113
+	{"retr_timer2",		CFG_VAR_INT,	0, 0, timer_fixup, 0,
114
+		"maximum retransmission period (in milliseconds)"},
115
+	{"max_inv_lifetime",	CFG_VAR_INT,	0, 0, timer_fixup, 0,
116
+		"maximum time an invite transaction can live "
117
+		"from the moment of creation"},
118
+	{"max_noninv_lifetime",	CFG_VAR_INT,	0, 0, timer_fixup, 0,
119
+		"maximum time a non-invite transaction can live "
120
+		"from the moment of creation"},
121
+	{"noisy_ctimer",	CFG_VAR_INT,	0, 1, 0, 0,
122
+		"if set, INVITE transactions that time-out (FR INV timer) "
123
+		"will be always replied"},
124
+	{"auto_inv_100",	CFG_VAR_INT,	0, 1, 0, 0,
125
+		"automatically send 100 to an INVITE"},
126
+	{"unix_tx_timeout",	CFG_VAR_INT,	0, 0, 0, 0,
127
+		"Unix socket transmission timeout, in milliseconds"},
128
+	{"restart_fr_on_each_reply",	CFG_VAR_INT,	0, 1, 0, 0,
129
+		"restart final response timer on each provisional reply"},
130
+	{"pass_provisional_replies",	CFG_VAR_INT,	0, 1, 0, 0,
131
+		"enable/disable passing of provisional replies "
132
+		"to FIFO applications"},
133
+	{"aggregate_challenges",	CFG_VAR_INT,	0, 1, 0, 0,
134
+		"if the final response is a 401 or a 407, aggregate all the "
135
+		"authorization headers (challenges) "
136
+		"(rfc3261 requires this to be on)"},
137
+	{"unmatched_cancel",	CFG_VAR_INT,	0, 2, 0, 0,
138
+		"determines how CANCELs with no matching transaction are handled "
139
+		"(0: statefull forwarding, 1: stateless forwarding, 2: drop)"},
140
+	{"default_code",	CFG_VAR_INT,	400, 699, 0, 0,
141
+		"default SIP response code sent by t_reply(), if the function "
142
+		"cannot retrieve its parameters"},
143
+	{"default_reason",	CFG_VAR_STRING,	0, 0, 0, 0,
144
+		"default SIP reason phrase sent by t_reply(), if the function "
145
+		"cannot retrieve its parameters"},
146
+	{"reparse_invite",	CFG_VAR_INT,	0, 1, 0, 0,
147
+		"if set to 1, the CANCEL and negative ACK requests are "
148
+		"constructed from the INVITE message which was sent out "
149
+		"instead of building them from the received request"},
150
+	{"ac_extra_hdrs",	CFG_VAR_STR,	0, 0, 0, 0,
151
+		"header fields prefixed by this parameter value are included "
152
+		"in the CANCEL and negative ACK messages if they were present "
153
+		"in the outgoing INVITE (depends on reparse_invite)"},
154
+	{"blst_503",		CFG_VAR_INT,	0, 1, 0, 0,
155
+		"if set to 1, blacklist 503 SIP response sources"},
156
+	{"blst_503_def_timeout",	CFG_VAR_INT,	0, 0, 0, 0,
157
+		"default 503 blacklist time (in s), when no Retry-After "
158
+		"header is present"},
159
+	{"blst_503_min_timeout",	CFG_VAR_INT,	0, 0, 0, 0,
160
+		"minimum 503 blacklist time (in s)"},
161
+	{"blst_503_max_timeout",	CFG_VAR_INT,	0, 0, 0, 0,
162
+		"maximum 503 blacklist time (in s)"},
163
+	{"blst_methods_add",	CFG_VAR_INT,	0, 0, 0, 0,
164
+		"bitmap of method types that trigger blacklisting on "
165
+		"transaction timeouts"},
166
+	{"blst_methods_lookup",	CFG_VAR_INT,	0, 0, 0, 0,
167
+		"Bitmap of method types that are looked-up in the blacklist "
168
+		"before statefull forwarding"},
169
+	{0, 0, 0, 0, 0, 0}
170
+};
... ...
@@ -41,6 +41,9 @@
41 41
 */
42 42
 #include "../../hash_func.h"
43 43
 
44
+#include "../../cfg/cfg.h"
45
+#include "../../str.h"
46
+
44 47
 /* maximum length of localy generated acknowledgment */
45 48
 #define MAX_ACK_LEN   1024
46 49
 
... ...
@@ -95,4 +98,38 @@
95 98
 /* FIFO substitution character */
96 99
 #define SUBST_CHAR '!'
97 100
 
101
+struct cfg_group_tm {
102
+	int	ruri_matching;
103
+	int	via1_matching;
104
+	unsigned int	fr_timeout;
105
+	unsigned int	fr_inv_timeout;
106
+	unsigned int	wait_timeout;
107
+	unsigned int	delete_timeout;
108
+	unsigned int	rt_t1_timeout;
109
+	unsigned int	rt_t2_timeout;
110
+	unsigned int	tm_max_inv_lifetime;
111
+	unsigned int	tm_max_noninv_lifetime;
112
+	int	noisy_ctimer;
113
+	int	tm_auto_inv_100;
114
+	int	tm_unix_tx_timeout;
115
+	int	restart_fr_on_each_reply;
116
+	int	pass_provisional_replies;
117
+	int	tm_aggregate_auth;
118
+	int	unmatched_cancel;
119
+	int	default_code;
120
+	char	*default_reason;
121
+	int	reparse_invite;
122
+	str	ac_extra_hdrs;
123
+	int	tm_blst_503;
124
+	int	tm_blst_503_default;
125
+	int	tm_blst_503_min;
126
+	int	tm_blst_503_max;
127
+	unsigned int	tm_blst_methods_add;
128
+	unsigned int	tm_blst_methods_lookup;
129
+};
130
+
131
+extern struct cfg_group_tm	default_tm_cfg;
132
+extern void	*tm_cfg;
133
+extern cfg_def_t	tm_cfg_def[];
134
+
98 135
 #endif
... ...
@@ -43,7 +43,7 @@
43 43
 #include <stdio.h> /* for FILE* in fifo_uac_cancel */
44 44
 
45 45
 #include "defs.h"
46
-
46
+#include "config.h"
47 47
 
48 48
 #include "t_funcs.h"
49 49
 #include "../../dprint.h"
... ...
@@ -199,7 +199,7 @@ int cancel_branch( struct cell *t, int branch, int flags )
199 199
 		}
200 200
 	}
201 201
 
202
-	if (reparse_invite) {
202
+	if (cfg_get(tm, tm_cfg, reparse_invite)) {
203 203
 		/* build the CANCEL from the INVITE which was sent out */
204 204
 		cancel = build_local_reparse(t, branch, &len, CANCEL, CANCEL_LEN, &t->to);
205 205
 	} else {
... ...
@@ -57,6 +57,7 @@
57 57
 #include "../../parser/parse_hname2.h"
58 58
 #include "../../parser/contact/parse_contact.h"
59 59
 #include "../../tsend.h"
60
+#include "config.h"
60 61
 #include "t_lookup.h"
61 62
 #include "t_fwd.h"
62 63
 #include "t_fifo.h"
... ...
@@ -82,8 +83,6 @@
82 83
 
83 84
 
84 85
 
85
-int tm_unix_tx_timeout = 500; /* Default is 500 ms */
86
-
87 86
 #define TWRITE_PARAMS          20
88 87
 #define TWRITE_VERSION_S       "0.3"
89 88
 #define TWRITE_VERSION_LEN     (sizeof(TWRITE_VERSION_S)-1)
... ...
@@ -960,7 +959,8 @@ static int write_to_unixsock(char* sockname, int cnt)
960 959
 		return -1;
961 960
 	}
962 961
 
963
-	if (tsend_dgram_ev(sock, iov_lines_eol, 2 * cnt, tm_unix_tx_timeout) < 0) {
962
+	if (tsend_dgram_ev(sock, iov_lines_eol, 2 * cnt,
963
+			cfg_get(tm, tm_cfg, tm_unix_tx_timeout)) < 0) {
964 964
 		LOG(L_ERR, "write_to_unixsock: writev failed: %s\n", strerror(errno));
965 965
 		return -1;
966 966
 	}
... ...
@@ -38,8 +38,6 @@
38 38
 #include "../../parser/msg_parser.h"
39 39
 #include "../../sr_module.h"
40 40
 
41
-extern int tm_unix_tx_timeout;
42
-
43 41
 int fixup_t_write( void** param, int param_no);
44 42
 
45 43
 int parse_tw_append( modparam_t type, void* val);
... ...
@@ -86,7 +86,6 @@ static int     fr_inv_timer_index = 0;
86 86
 
87 87
 int tm_error = 0; /* delayed tm error */
88 88
 
89
-int tm_auto_inv_100=1; /* automatically send 100 to an INVITE, default on*/
90 89
 struct msgid_var user_auto_inv_100;
91 90
 
92 91
 /* ----------------------------------------------------- */
... ...
@@ -171,7 +170,7 @@ void put_on_wait(  struct cell  *Trans  )
171 170
 		4.									WAIT timer executed,
172 171
 											transaction deleted
173 172
 	*/
174
-	if (timer_add(&Trans->wait_timer, wait_timeout)==0){
173
+	if (timer_add(&Trans->wait_timer, cfg_get(tm, tm_cfg, wait_timeout))==0){
175 174
 		/* sucess */
176 175
 		t_stats_wait();
177 176
 	}else{
... ...
@@ -74,8 +74,6 @@ struct entry;
74 74
 struct cell;
75 75
 
76 76
 extern int tm_error; /* delayed tm error */
77
-extern int noisy_ctimer;
78
-extern int tm_auto_inv_100; /*automatically send 100 to an INVITE, default on*/
79 77
 extern struct msgid_var user_auto_inv_100;
80 78
 
81 79
 /* default names for timer's AVPs  */
... ...
@@ -112,8 +112,6 @@
112 112
 /* cancel hop by hop */
113 113
 #define E2E_CANCEL_HOP_BY_HOP
114 114
 
115
-int unmatched_cancel=UM_CANCEL_STATEFULL;
116
-
117 115
 static int goto_on_branch = 0, branch_route = 0;
118 116
 
119 117
 void t_on_branch( unsigned int go_to )
... ...
@@ -465,7 +463,7 @@ int e2e_cancel_branch( struct sip_msg *cancel_msg, struct cell *t_cancel,
465 463
 	*/
466 464
 
467 465
 	/* print */
468
-	if (reparse_invite) {
466
+	if (cfg_get(tm, tm_cfg, reparse_invite)) {
469 467
 		/* buffer is built localy from the INVITE which was sent out */
470 468
 		if (cancel_msg->add_rm || cancel_msg->body_lumps) {
471 469
 			LOG(L_WARN, "WARNING: e2e_cancel_branch: CANCEL is built locally, "
... ...
@@ -694,7 +692,7 @@ int t_send_branch( struct cell *t, int branch, struct sip_msg* p_msg ,
694 692
 #ifdef USE_DST_BLACKLIST
695 693
 	if (cfg_get(core, core_cfg, use_dst_blacklist)
696 694
 		&& p_msg
697
-		&& (p_msg->REQ_METHOD & tm_blst_methods_lookup)
695
+		&& (p_msg->REQ_METHOD & cfg_get(tm, tm_cfg, tm_blst_methods_lookup))
698 696
 	){
699 697
 		if (dst_is_blacklisted(&uac->request.dst, p_msg)){
700 698
 			su2ip_addr(&ip, &uac->request.dst.to);
... ...
@@ -942,7 +940,7 @@ int t_forward_cancel(struct sip_msg* p_msg , struct proxy_l * proxy, int proto,
942 940
 	
943 941
 	t=0;
944 942
 	/* handle cancels for which no transaction was created yet */
945
-	if (unmatched_cancel==UM_CANCEL_STATEFULL){
943
+	if (cfg_get(tm, tm_cfg, unmatched_cancel)==UM_CANCEL_STATEFULL){
946 944
 		/* create cancel transaction */
947 945
 		new_tran=t_newtran(p_msg);
948 946
 		if (new_tran<=0 && new_tran!=E_SCRIPT){
... ...
@@ -979,7 +977,7 @@ int t_forward_cancel(struct sip_msg* p_msg , struct proxy_l * proxy, int proto,
979 977
 		ret=1;
980 978
 		goto end;
981 979
 	}else /* no coresponding INVITE transaction */
982
-	     if (unmatched_cancel==UM_CANCEL_DROP){
980
+	     if (cfg_get(tm, tm_cfg, unmatched_cancel)==UM_CANCEL_DROP){
983 981
 				DBG("t_forward_nonack: non matching cancel dropped\n");
984 982
 				ret=1; /* do nothing -> drop */
985 983
 				goto end;
... ...
@@ -44,8 +44,6 @@
44 44
 enum unmatched_cancel_t { UM_CANCEL_STATEFULL=0, UM_CANCEL_STATELESS,
45 45
 							UM_CANCEL_DROP };
46 46
 
47
-extern int unmatched_cancel;
48
-
49 47
 typedef int (*tfwd_f)(struct sip_msg* p_msg , struct proxy_l * proxy );
50 48
 typedef int (*taddblind_f)( /*struct cell *t */ );
51 49
 
... ...
@@ -150,16 +150,6 @@
150 150
 
151 151
 #define HF_LEN(_hf) ((_hf)->len)
152 152
 
153
-/* should be request-uri matching used as a part of pre-3261 
154
- * transaction matching, as the standard wants us to do so
155
- * (and is reasonable to do so, to be able to distinguish
156
- * spirals)? turn only off for better interaction with 
157
- * devices that are broken and send different r-uri in
158
- * CANCEL/ACK than in original INVITE
159
- */
160
-int ruri_matching=1;
161
-int via1_matching=1;
162
-
163 153
 /* presumably matching transaction for an e2e ACK */
164 154
 static struct cell *t_ack;
165 155
 
... ...
@@ -503,8 +493,8 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked,
503 493
 				continue;
504 494
 			if (!EQ_LEN(from)) continue;
505 495
 			if (!EQ_LEN(to)) continue;
506
-			if (ruri_matching && !EQ_REQ_URI_LEN) continue;
507
-			if (via1_matching && !EQ_VIA_LEN(via1)) continue;
496
+			if (cfg_get(tm, tm_cfg, ruri_matching) && !EQ_REQ_URI_LEN) continue;
497
+			if (cfg_get(tm, tm_cfg, via1_matching) && !EQ_VIA_LEN(via1)) continue;
508 498
 
509 499
 			/* length ok -- move on */
510 500
 			if (!EQ_STR(callid)) continue;
... ...
@@ -512,8 +502,8 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked,
512 502
 				get_cseq(p_msg)->number.len)!=0) continue;
513 503
 			if (!EQ_STR(from)) continue;
514 504
 			if (!EQ_STR(to)) continue;
515
-			if (ruri_matching && !EQ_REQ_URI_STR) continue;
516
-			if (via1_matching && !EQ_VIA_STR(via1)) continue;
505
+			if (cfg_get(tm, tm_cfg, ruri_matching) && !EQ_REQ_URI_STR) continue;
506
+			if (cfg_get(tm, tm_cfg, via1_matching) && !EQ_VIA_STR(via1)) continue;
517 507
 			
518 508
 			if ((t_msg->REQ_METHOD==METHOD_CANCEL) &&
519 509
 				(p_msg->REQ_METHOD!=METHOD_CANCEL)){
... ...
@@ -564,10 +554,10 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked,
564 554
 			 * more elements to match: r-uri and via; allow
565 555
 			 * mismatching r-uri as an config option for broken
566 556
 			 * UACs */
567
-			if (ruri_matching && !EQ_REQ_URI_LEN ) continue;
568
-			if (via1_matching && !EQ_VIA_LEN(via1)) continue;
569
-			if (ruri_matching && !EQ_REQ_URI_STR) continue;
570
-			if (via1_matching && !EQ_VIA_STR(via1)) continue;
557
+			if (cfg_get(tm, tm_cfg, ruri_matching) && !EQ_REQ_URI_LEN ) continue;
558
+			if (cfg_get(tm, tm_cfg, via1_matching) && !EQ_VIA_LEN(via1)) continue;
559
+			if (cfg_get(tm, tm_cfg, ruri_matching) && !EQ_REQ_URI_STR) continue;
560
+			if (cfg_get(tm, tm_cfg, via1_matching) && !EQ_VIA_STR(via1)) continue;
571 561
 
572 562
 			/* wow -- we survived all the check! we matched! */
573 563
 			DBG("DEBUG: non-2xx ACK matched\n");
... ...
@@ -698,9 +688,9 @@ struct cell* t_lookupOriginalT(  struct sip_msg* p_msg )
698 688
 		if (get_to(t_msg)->uri.len!=get_to(p_msg)->uri.len)
699 689
 			continue;
700 690
 #endif
701
-		if (ruri_matching && !EQ_REQ_URI_LEN)
691
+		if (cfg_get(tm, tm_cfg, ruri_matching) && !EQ_REQ_URI_LEN)
702 692
 			continue;
703
-		if (via1_matching && !EQ_VIA_LEN(via1))
693
+		if (cfg_get(tm, tm_cfg, via1_matching) && !EQ_VIA_LEN(via1))
704 694
 			continue;
705 695
 
706 696
 		/* check the content now */
... ...
@@ -719,9 +709,9 @@ struct cell* t_lookupOriginalT(  struct sip_msg* p_msg )
719 709
 					get_to(t_msg)->uri.len)!=0)
720 710
 			continue;
721 711
 #endif
722
-		if (ruri_matching && !EQ_REQ_URI_STR)
712
+		if (cfg_get(tm, tm_cfg, ruri_matching) && !EQ_REQ_URI_STR)
723 713
 			continue;
724
-		if (via1_matching && !EQ_VIA_STR(via1))
714
+		if (cfg_get(tm, tm_cfg, via1_matching) && !EQ_VIA_STR(via1))
725 715
 			continue;
726 716
 
727 717
 		/* found */
... ...
@@ -982,7 +972,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
982 972
 			   and we need all the WWW/Proxy Authenticate headers for
983 973
 			   401 & 407 replies
984 974
 			*/
985
-			if (tm_aggregate_auth && 
975
+			if (cfg_get(tm, tm_cfg, tm_aggregate_auth) && 
986 976
 					(p_msg->REPLY_STATUS==401 || p_msg->REPLY_STATUS==407)){
987 977
 				if (parse_headers(p_msg, HDR_EOH_F,0)==-1){
988 978
 					LOG(L_WARN, "WARNING: the reply cannot be "
... ...
@@ -1105,16 +1095,17 @@ static inline void init_new_t(struct cell *new_cell, struct sip_msg *p_msg)
1105 1095
 			/* 1 = set, -1 = reset */
1106 1096
 			new_cell->flags|=T_AUTO_INV_100 & (!(v+1)-1);
1107 1097
 		else
1108
-			new_cell->flags|=T_AUTO_INV_100 & ( !tm_auto_inv_100 -1);
1098
+			new_cell->flags|=T_AUTO_INV_100 &
1099
+					(!cfg_get(tm, tm_cfg, tm_auto_inv_100) -1);
1109 1100
 		lifetime=(ticks_t)get_msgid_val(user_inv_max_lifetime,
1110 1101
 												p_msg->id, int);
1111 1102
 		if (likely(lifetime==0))
1112
-			lifetime=tm_max_inv_lifetime;
1103
+			lifetime=cfg_get(tm, tm_cfg, tm_max_inv_lifetime);
1113 1104
 	}else{
1114 1105
 		lifetime=(ticks_t)get_msgid_val(user_noninv_max_lifetime, 
1115 1106
 											p_msg->id, int);
1116 1107
 		if (likely(lifetime==0))
1117
-			lifetime=tm_max_noninv_lifetime;
1108
+			lifetime=cfg_get(tm, tm_cfg, tm_max_noninv_lifetime);
1118 1109
 	}
1119 1110
 	new_cell->on_negative=get_on_negative();
1120 1111
 	new_cell->on_reply=get_on_reply();
... ...
@@ -1128,7 +1119,7 @@ static inline void init_new_t(struct cell *new_cell, struct sip_msg *p_msg)
1128 1119
 			DBG("init_new_t: FR__TIMER = %d s\n", timeout);
1129 1120
 			new_cell->fr_timeout=S_TO_TICKS((ticks_t)timeout);
1130 1121
 		}else{
1131
-			new_cell->fr_timeout=fr_timeout;
1122
+			new_cell->fr_timeout=cfg_get(tm, tm_cfg, fr_timeout);
1132 1123
 		}
1133 1124
 	}
1134 1125
 	if (likely(new_cell->fr_inv_timeout==0)){
... ...
@@ -1137,18 +1128,18 @@ static inline void init_new_t(struct cell *new_cell, struct sip_msg *p_msg)
1137 1128
 			new_cell->fr_inv_timeout=S_TO_TICKS((ticks_t)timeout);
1138 1129
 			new_cell->flags |= T_NOISY_CTIMER_FLAG;
1139 1130
 		}else{
1140
-			new_cell->fr_inv_timeout=fr_inv_timeout;
1131
+			new_cell->fr_inv_timeout=cfg_get(tm, tm_cfg, fr_inv_timeout);
1141 1132
 		}
1142 1133
 	}
1143 1134
 #ifdef TM_DIFF_RT_TIMEOUT
1144 1135
 	new_cell->rt_t1_timeout=(ticks_t)get_msgid_val(user_rt_t1_timeout,
1145 1136
 												p_msg->id, int);
1146 1137
 	if (likely(new_cell->rt_t1_timeout==0))
1147
-		new_cell->rt_t1_timeout=rt_t1_timeout;
1138
+		new_cell->rt_t1_timeout=cfg_get(tm, tm_cfg, rt_t1_timeout);
1148 1139
 	new_cell->rt_t2_timeout=(ticks_t)get_msgid_val(user_rt_t2_timeout,
1149 1140
 												p_msg->id, int);
1150 1141
 	if (likely(new_cell->rt_t2_timeout==0))
1151
-		new_cell->rt_t2_timeout=rt_t2_timeout;
1142
+		new_cell->rt_t2_timeout=cfg_get(tm, tm_cfg, rt_t2_timeout);
1152 1143
 #endif
1153 1144
 	new_cell->on_branch=get_on_branch();
1154 1145
 }
... ...
@@ -48,8 +48,6 @@
48 48
 #define T_NULL_CELL       ( (struct cell*) 0 )
49 49
 
50 50
 extern unsigned int     global_msg_id;
51
-extern int ruri_matching;
52
-extern int via1_matching;
53 51
 
54 52
 
55 53
 
... ...
@@ -88,9 +88,6 @@
88 88
 		(_p)+=(_str).len;  \
89 89
  	} while(0);
90 90
 
91
-str ac_extra_hdrs = STR_STATIC_INIT("");
92
-int reparse_invite = 1;
93
-
94 91
 
95 92
 /* Build a local request based on a previous request; main
96 93
    customers of this function are local ACK and local CANCEL
... ...
@@ -355,9 +352,12 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
355 352
 			default:
356 353
 				s = lw_next_line(s, invite_buf_end);
357 354
 
358
-				if (ac_extra_hdrs.len
359
-				&& (s1 + ac_extra_hdrs.len < invite_buf_end)
360
-				&& (strncasecmp(s1, ac_extra_hdrs.s, ac_extra_hdrs.len) == 0)) {
355
+				if (cfg_get(tm, tm_cfg, ac_extra_hdrs).len
356
+				&& (s1 + cfg_get(tm, tm_cfg, ac_extra_hdrs).len < invite_buf_end)
357
+				&& (strncasecmp(s1,
358
+						cfg_get(tm, tm_cfg, ac_extra_hdrs).s,
359
+						cfg_get(tm, tm_cfg, ac_extra_hdrs).len) == 0)
360
+				) {
361 361
 					append_mem_block(d, s1, s - s1);
362 362
 				} /* else skip this line */
363 363
 				break;
... ...
@@ -66,9 +66,6 @@
66 66
 		(_d) += (_len);\
67 67
 	}while(0);
68 68
 
69
-extern str ac_extra_hdrs;
70
-extern int reparse_invite;
71
-
72 69
 char *build_local(struct cell *Trans, unsigned int branch,
73 70
 	unsigned int *len, char *method, int method_len, str *to);
74 71
 
... ...
@@ -116,6 +116,7 @@
116 116
 #endif
117 117
 
118 118
 #include "defs.h"
119
+#include "config.h"
119 120
 #include "h_table.h"
120 121
 #include "t_hooks.h"
121 122
 #include "t_funcs.h"
... ...
@@ -129,31 +130,6 @@
129 130
 #include "uac.h"
130 131
 
131 132
 
132
-/* restart fr timer on each provisional reply, default yes */
133
-int restart_fr_on_each_reply=1;
134
-/* if the final reponse is a 401 or a 407, aggregate all the 
135
- * authorization headers (challenges) (rfc3261 requires this to be on) */
136
-int tm_aggregate_auth=1;
137
-
138
-/* if 1 blacklist 503 sources, using tm_blst_503_min, tm_blst_503_max,
139
- * tm_blst_503_default and the Retry-After header in the 503 reply */
140
-int tm_blst_503=0;
141
-/* default 503 blacklist time (when no Retry-After header is present */
142
-#ifndef DEFAULT_BLST_TIMEOUT
143
-#define DEFAULT_BLST_TIMEOUT 60
144
-#endif
145
-int tm_blst_503_default=0; /* rfc conformant: do not blacklist if 
146
-							  no retry-after */
147
-/* minimum 503 blacklist time */
148
-int tm_blst_503_min=0; /* in s */
149
-/* maximum 503 blacklist time */
150
-int tm_blst_503_max=3600; /* in s */
151
-
152
-/* backlist only INVITE timeouts by default */
153
-unsigned int tm_blst_methods_add=METHOD_INVITE;
154
-/* look-up the blacklist for every method except BYE by default */
155
-unsigned int tm_blst_methods_lookup=~METHOD_BYE;
156
-
157 133
 /* are we processing original or shmemed request ? */
158 134
 enum route_mode rmode=MODE_REQUEST;
159 135
 
... ...
@@ -364,7 +340,7 @@ static char *build_ack(struct sip_msg* rpl,struct cell *trans,int branch,
364 340
 	to.s=rpl->to->name.s;
365 341
 	to.len=rpl->to->len;
366 342
 
367
-	if (reparse_invite) {
343
+	if (cfg_get(tm, tm_cfg, reparse_invite)) {
368 344
 		/* build the ACK from the INVITE which was sent out */
369 345
 		return build_local_reparse( trans, branch, ret_len,
370 346
 					ACK, ACK_LEN, &to );
... ...
@@ -1386,7 +1362,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1386 1362
 			} else {
1387 1363
 				to_tag=0;
1388 1364
 			}
1389
-			if (tm_aggregate_auth && 
1365
+			if (cfg_get(tm, tm_cfg, tm_aggregate_auth) && 
1390 1366
 						(relayed_code==401 || relayed_code==407) &&
1391 1367
 						(auth_reply_count(t, p_msg)>1)){
1392 1368
 				/* aggregate 401 & 407 www & proxy authenticate headers in
... ...
@@ -1422,7 +1398,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1422 1398
 				buf=build_res_buf_from_sip_req(500, error_text(relayed_code),
1423 1399
 									to_tag, t->uas.request, &res_len, &bm);
1424 1400
 				relayed_code=500;
1425
-			}else if (tm_aggregate_auth && 
1401
+			}else if (cfg_get(tm, tm_cfg, tm_aggregate_auth) && 
1426 1402
 						(relayed_code==401 || relayed_code==407) &&
1427 1403
 						(auth_reply_count(t, p_msg)>1)){
1428 1404
 				/* aggregate 401 & 407 www & proxy authenticate headers in
... ...
@@ -1597,7 +1573,9 @@ enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1597 1573
 	}
1598 1574
 	UNLOCK_REPLIES(t);
1599 1575
  
1600
-        if (local_winner >= 0 && pass_provisional_replies && winning_code < 200) {
1576
+        if (local_winner >= 0
1577
+		&& cfg_get(tm, tm_cfg, pass_provisional_replies)
1578
+		&& winning_code < 200) {
1601 1579
 			if (unlikely(!totag_retr && 
1602 1580
 							has_tran_tmcbs(t, TMCB_LOCAL_RESPONSE_OUT) )) {
1603 1581
                         run_trans_callbacks( TMCB_LOCAL_RESPONSE_OUT, t, 0,
... ...
@@ -1810,8 +1788,11 @@ int reply_received( struct sip_msg  *p_msg )
1810 1788
 	}
1811 1789
 #ifdef USE_DST_BLACKLIST
1812 1790
 		/* add temporary to the blacklist the source of a 503 reply */
1813
-		if (tm_blst_503 && cfg_get(core, core_cfg, use_dst_blacklist) && (msg_status==503)){
1814
-			blst_503_timeout=tm_blst_503_default;
1791
+		if (cfg_get(tm, tm_cfg, tm_blst_503)
1792
+			&& cfg_get(core, core_cfg, use_dst_blacklist)
1793
+			&& (msg_status==503)
1794
+		){
1795
+			blst_503_timeout=cfg_get(tm, tm_cfg, tm_blst_503_default);
1815 1796
 			if ((parse_headers(p_msg, HDR_RETRY_AFTER_F, 0)==0) && 
1816 1797
 				(p_msg->parsed_flag & HDR_RETRY_AFTER_F)){
1817 1798
 				for (hf=p_msg->headers; hf; hf=hf->next)
... ...
@@ -1819,9 +1800,9 @@ int reply_received( struct sip_msg  *p_msg )
1819 1800
 						/* found */
1820 1801
 						blst_503_timeout=(unsigned)(unsigned long)hf->parsed;
1821 1802
 						blst_503_timeout=MAX_unsigned(blst_503_timeout, 
1822
-															tm_blst_503_min);
1803
+									cfg_get(tm, tm_cfg, tm_blst_503_min));
1823 1804
 						blst_503_timeout=MIN_unsigned(blst_503_timeout,
1824
-															tm_blst_503_max);
1805
+									cfg_get(tm, tm_cfg, tm_blst_503_max));
1825 1806
 						break;
1826 1807
 					}
1827 1808
 			}
... ...
@@ -1901,7 +1882,8 @@ int reply_received( struct sip_msg  *p_msg )
1901 1882
 		goto done;
1902 1883
 
1903 1884
 	/* update FR/RETR timers on provisional replies */
1904
-	if (is_invite(t) && msg_status<200 && ( restart_fr_on_each_reply ||
1885
+	if (is_invite(t) && msg_status<200 &&
1886
+		( cfg_get(tm, tm_cfg, restart_fr_on_each_reply) ||
1905 1887
 				( (last_uac_status<msg_status) &&
1906 1888
 					((msg_status>=180) || (last_uac_status==0)) )
1907 1889
 			) ) { /* provisional now */
... ...
@@ -37,16 +37,6 @@
37 37
 #include "h_table.h"
38 38
 
39 39
 
40
-extern int restart_fr_on_each_reply;
41
-extern int tm_aggregate_auth; /* aggregate authorization header value */
42
-
43
-extern int tm_blst_503;
44
-extern int tm_blst_503_default;  /* in s */
45
-extern int tm_blst_503_min;      /* in s */
46
-extern int tm_blst_503_max;      /* in s */
47
-extern unsigned int tm_blst_methods_add;
48
-extern unsigned int tm_blst_methods_lookup;
49
-
50 40
 /* reply processing status */
51 41
 enum rps {
52 42
 	/* something bad happened */
... ...
@@ -146,8 +146,6 @@
146 146
 
147 147
 
148 148
 
149
-int noisy_ctimer=1;
150
-
151 149
 struct msgid_var user_fr_timeout;
152 150
 struct msgid_var user_fr_inv_timeout;
153 151
 #ifdef TM_DIFF_RT_TIMEOUT
... ...
@@ -157,27 +155,6 @@ struct msgid_var user_rt_t2_timeout;
157 155
 struct msgid_var user_inv_max_lifetime;
158 156
 struct msgid_var user_noninv_max_lifetime;
159 157
 
160
-/* default values of timeouts for all the timer list */
161
-
162
-ticks_t fr_timeout		=	FR_TIME_OUT;
163
-ticks_t fr_inv_timeout	=	INV_FR_TIME_OUT;
164
-ticks_t wait_timeout	=	WT_TIME_OUT;
165
-ticks_t delete_timeout	=	DEL_TIME_OUT;
166
-ticks_t rt_t1_timeout	=	RETR_T1;
167
-ticks_t rt_t2_timeout	=	RETR_T2;
168
-
169
-/* maximum time and invite or noninv transaction will live, from
170
- * the moment of creation (overrides larger fr/fr_inv timeouts,
171
- * extensions due to dns failover, fr_inv restart a.s.o)
172
- * Note: after this time the transaction will not be deleted
173
- *  immediately, but forced to go in the wait state or in wait for ack state 
174
- *  and then wait state, so it will still be alive for either wait_timeout in 
175
- *  the non-inv or "silent" inv. case and for fr_timeout + wait_timeout for an
176
- *  invite transaction (for which  we must wait for the neg. reply ack)
177
- */
178
-ticks_t tm_max_inv_lifetime		=	MAX_INV_LIFETIME;
179
-ticks_t tm_max_noninv_lifetime	=	MAX_NONINV_LIFETIME;
180
-
181 158
 
182 159
 /* internal use, val should be unsigned or positive
183 160
  *  <= instead of < to get read of gcc warning when 
... ...
@@ -196,33 +173,33 @@ ticks_t tm_max_noninv_lifetime	=	MAX_NONINV_LIFETIME;
196 173
 /* fix timer values to ticks */
197 174
 int tm_init_timers()
198 175
 {
199
-	fr_timeout=MS_TO_TICKS(fr_timeout); 
200
-	fr_inv_timeout=MS_TO_TICKS(fr_inv_timeout);
201
-	wait_timeout=MS_TO_TICKS(wait_timeout);
202
-	delete_timeout=MS_TO_TICKS(delete_timeout);
203
-	rt_t1_timeout=MS_TO_TICKS(rt_t1_timeout);
204
-	rt_t2_timeout=MS_TO_TICKS(rt_t2_timeout);
205
-	tm_max_inv_lifetime=MS_TO_TICKS(tm_max_inv_lifetime);
206
-	tm_max_noninv_lifetime=MS_TO_TICKS(tm_max_noninv_lifetime);
176
+	default_tm_cfg.fr_timeout=MS_TO_TICKS(default_tm_cfg.fr_timeout); 
177
+	default_tm_cfg.fr_inv_timeout=MS_TO_TICKS(default_tm_cfg.fr_inv_timeout);
178
+	default_tm_cfg.wait_timeout=MS_TO_TICKS(default_tm_cfg.wait_timeout);
179
+	default_tm_cfg.delete_timeout=MS_TO_TICKS(default_tm_cfg.delete_timeout);
180
+	default_tm_cfg.rt_t1_timeout=MS_TO_TICKS(default_tm_cfg.rt_t1_timeout);
181
+	default_tm_cfg.rt_t2_timeout=MS_TO_TICKS(default_tm_cfg.rt_t2_timeout);
182
+	default_tm_cfg.tm_max_inv_lifetime=MS_TO_TICKS(default_tm_cfg.tm_max_inv_lifetime);
183
+	default_tm_cfg.tm_max_noninv_lifetime=MS_TO_TICKS(default_tm_cfg.tm_max_noninv_lifetime);
207 184
 	/* fix 0 values to 1 tick (minimum possible wait time ) */
208
-	if (fr_timeout==0) fr_timeout=1;
209
-	if (fr_inv_timeout==0) fr_inv_timeout=1;
210
-	if (wait_timeout==0) wait_timeout=1;
211
-	if (delete_timeout==0) delete_timeout=1;
212
-	if (rt_t2_timeout==0) rt_t2_timeout=1;
213
-	if (rt_t1_timeout==0) rt_t1_timeout=1;
214
-	if (tm_max_inv_lifetime==0) tm_max_inv_lifetime=1;
215
-	if (tm_max_noninv_lifetime==0) tm_max_noninv_lifetime=1;
185
+	if (default_tm_cfg.fr_timeout==0) default_tm_cfg.fr_timeout=1;
186
+	if (default_tm_cfg.fr_inv_timeout==0) default_tm_cfg.fr_inv_timeout=1;
187
+	if (default_tm_cfg.wait_timeout==0) default_tm_cfg.wait_timeout=1;
188
+	if (default_tm_cfg.delete_timeout==0) default_tm_cfg.delete_timeout=1;
189
+	if (default_tm_cfg.rt_t2_timeout==0) default_tm_cfg.rt_t2_timeout=1;
190
+	if (default_tm_cfg.rt_t1_timeout==0) default_tm_cfg.rt_t1_timeout=1;
191
+	if (default_tm_cfg.tm_max_inv_lifetime==0) default_tm_cfg.tm_max_inv_lifetime=1;
192
+	if (default_tm_cfg.tm_max_noninv_lifetime==0) default_tm_cfg.tm_max_noninv_lifetime=1;
216 193
 	
217 194
 	/* size fit checks */
218
-	SIZE_FIT_CHECK(fr_timeout, fr_timeout, "fr_timer");
219
-	SIZE_FIT_CHECK(fr_inv_timeout, fr_inv_timeout, "fr_inv_timer");
195
+	SIZE_FIT_CHECK(fr_timeout, default_tm_cfg.fr_timeout, "fr_timer");
196
+	SIZE_FIT_CHECK(fr_inv_timeout, default_tm_cfg.fr_inv_timeout, "fr_inv_timer");
220 197
 #ifdef TM_DIFF_RT_TIMEOUT
221
-	SIZE_FIT_CHECK(rt_t1_timeout, rt_t1_timeout, "retr_timer1");
222
-	SIZE_FIT_CHECK(rt_t2_timeout, rt_t2_timeout, "retr_timer2");
198
+	SIZE_FIT_CHECK(rt_t1_timeout, default_tm_cfg.rt_t1_timeout, "retr_timer1");
199
+	SIZE_FIT_CHECK(rt_t2_timeout, default_tm_cfg.rt_t2_timeout, "retr_timer2");
223 200
 #endif
224
-	SIZE_FIT_CHECK(end_of_life, tm_max_inv_lifetime, "max_inv_lifetime");
225
-	SIZE_FIT_CHECK(end_of_life, tm_max_noninv_lifetime, "max_noninv_lifetime");
201
+	SIZE_FIT_CHECK(end_of_life, default_tm_cfg.tm_max_inv_lifetime, "max_inv_lifetime");
202
+	SIZE_FIT_CHECK(end_of_life, default_tm_cfg.tm_max_noninv_lifetime, "max_noninv_lifetime");
226 203
 	
227 204
 	memset(&user_fr_timeout, 0, sizeof(user_fr_timeout));
228 205
 	memset(&user_fr_inv_timeout, 0, sizeof(user_fr_inv_timeout));
... ...
@@ -235,10 +212,48 @@ int tm_init_timers()
235 212
 	
236 213
 	DBG("tm: tm_init_timers: fr=%d fr_inv=%d wait=%d delete=%d t1=%d t2=%d"
237 214
 			" max_inv_lifetime=%d max_noninv_lifetime=%d\n",
238
-			fr_timeout, fr_inv_timeout, wait_timeout, delete_timeout,
239
-			rt_t1_timeout, rt_t2_timeout, tm_max_inv_lifetime,
240
-			tm_max_noninv_lifetime);
215
+			default_tm_cfg.fr_timeout, default_tm_cfg.fr_inv_timeout,
216
+			default_tm_cfg.wait_timeout, default_tm_cfg.delete_timeout,
217
+			default_tm_cfg.rt_t1_timeout, default_tm_cfg.rt_t2_timeout,
218
+			default_tm_cfg.tm_max_inv_lifetime, default_tm_cfg.tm_max_noninv_lifetime);
219
+	return 0;
220
+error:
221
+	return -1;
222
+}
223
+
224
+/* internal macro for timer_fixup()
225
+ * performs size fit check if the timer name matches
226
+ */
227
+#define IF_IS_TIMER_NAME(cell_member, cfg_name) \
228
+	if ((name->len == sizeof(cfg_name)-1) && \
229
+		(memcmp(name->s, cfg_name, sizeof(cfg_name)-1)==0)) { \
230
+			SIZE_FIT_CHECK(cell_member, t, cfg_name); \
231
+	}
232
+
233
+/* fixup function for the timer values
234
+ * (called by the configuration framework)
235
+ */
236
+int timer_fixup(void *handle, str *name, void **val)
237
+{
238
+	ticks_t	t;
239
+
240
+	t = MS_TO_TICKS((unsigned int)(long)(*val));
241
+	/* fix 0 values to 1 tick (minimum possible wait time ) */
242
+	if (t == 0) t = 1;
243
+
244
+	/* size fix checks */
245
+	IF_IS_TIMER_NAME(fr_timeout, "fr_timer")
246
+	else IF_IS_TIMER_NAME(fr_inv_timeout, "fr_inv_timer")
247
+#ifdef TM_DIFF_RT_TIMEOUT
248
+	else IF_IS_TIMER_NAME(rt_t1_timeout, "retr_timer1")
249
+	else IF_IS_TIMER_NAME(rt_t2_timeout, "retr_timer2")
250
+#endif
251
+	else IF_IS_TIMER_NAME(end_of_life, "max_inv_lifetime")
252
+	else IF_IS_TIMER_NAME(end_of_life, "max_noninv_lifetime")
253
+
254
+	*val = (void *)(long)t;
241 255
 	return 0;
256
+
242 257
 error:
243 258
 	return -1;
244 259
 }
... ...
@@ -264,7 +279,7 @@ inline static ticks_t  delete_cell( struct cell *p_cell, int unlock )
264 279
 				p_cell, p_cell->ref_count);
265 280
 		/* delay the delete */
266 281
 		/* TODO: change refcnts and delete on refcnt==0 */
267
-		return delete_timeout;
282
+		return cfg_get(tm, tm_cfg, delete_timeout);
268 283
 	} else {
269 284
 		if (unlock) UNLOCK_HASH(p_cell->hash_index);
270 285
 #ifdef EXTRA_DEBUG
... ...
@@ -422,7 +437,7 @@ inline static void final_response_handler(	struct retr_buf* r_buf,
422 437
 	   world */
423 438
 	silent=
424 439
 		/* don't go silent if disallowed globally ... */
425
-		noisy_ctimer==0
440
+		cfg_get(tm, tm_cfg, noisy_ctimer)==0
426 441
 		/* ... or for this particular transaction */
427 442
 		&& has_noisy_ctimer(t) == 0
428 443
 		/* not for UACs */
... ...
@@ -459,7 +474,7 @@ inline static void final_response_handler(	struct retr_buf* r_buf,
459 474
 		if (cfg_get(core, core_cfg, use_dst_blacklist)
460 475
         		&& r_buf->my_T
461 476
 			&& r_buf->my_T->uas.request
462
-			&& (r_buf->my_T->uas.request->REQ_METHOD & tm_blst_methods_add)
477
+			&& (r_buf->my_T->uas.request->REQ_METHOD & cfg_get(tm, tm_cfg, tm_blst_methods_add))
463 478
 		)
464 479
 			dst_blacklist_add( BLST_ERR_TIMEOUT, &r_buf->dst,
465 480
 						r_buf->my_T->uas.request);
... ...
@@ -48,6 +48,7 @@
48 48
 
49 49
 #include "../../timer.h"
50 50
 #include "h_table.h"
51
+#include "config.h"
51 52
 
52 53
 /* try to do fast retransmissions (but fall back to slow timer for FR */
53 54
 #define TM_FAST_RETR_TIMER
... ...
@@ -57,12 +58,14 @@
57 58
 #define RT_T1_TIMEOUT(rb)	((rb)->my_T->rt_t1_timeout)
58 59
 #define RT_T2_TIMEOUT(rb)	((rb)->my_T->rt_t2_timeout)
59 60
 #else
60
-#define RT_T1_TIMEOUT(rb)	(rt_t1_timeout)
61
-#define RT_T2_TIMEOUT(rb)	(rt_t2_timeout)
61
+#define RT_T1_TIMEOUT(rb)	(cfg_get(tm, tm_cfg, rt_t1_timeout))
62
+#define RT_T2_TIMEOUT(rb)	(cfg_get(tm, tm_cfg, rt_t2_timeout))
62 63
 #endif
63 64
 
64 65
 #define TM_REQ_TIMEOUT(t) \
65
-	(is_invite(t)?tm_max_inv_lifetime:tm_max_noninv_lifetime)
66
+	(is_invite(t)? \
67
+		cfg_get(tm, tm_cfg, tm_max_inv_lifetime): \
68
+		cfg_get(tm, tm_cfg, tm_max_noninv_lifetime))
66 69
 
67 70
 
68 71
 extern struct msgid_var user_fr_timeout;
... ...
@@ -74,18 +77,9 @@ extern struct msgid_var user_rt_t2_timeout;
74 77
 extern struct msgid_var user_inv_max_lifetime;
75 78
 extern struct msgid_var user_noninv_max_lifetime;
76 79
 
77
-extern ticks_t fr_timeout;
78
-extern ticks_t fr_inv_timeout;
79
-extern ticks_t wait_timeout;
80
-extern ticks_t delete_timeout;
81
-extern ticks_t rt_t1_timeout;
82
-extern ticks_t rt_t2_timeout;
83
-
84
-extern ticks_t tm_max_inv_lifetime;
85
-extern ticks_t tm_max_noninv_lifetime;
86
-
87 80
 
88 81
 extern int tm_init_timers();
82
+int timer_fixup(void *handle, str *name, void **val);
89 83
 
90 84
 ticks_t wait_handler(ticks_t t, struct timer_ln *tl, void* data);
91 85
 ticks_t retr_buf_handler(ticks_t t, struct timer_ln *tl, void* data);
... ...
@@ -84,6 +84,7 @@
84 84
  *              added w_t_relay_cancel() (Miklos)
85 85
  *  2007-06-05  added t_set_auto_inv_100() and auto_inv_100 (param);
86 86
  *               t_set_max_lifetime(), max_{non}inv_lifetime  (andrei)
87
+ *  2008-02-05	module config parameters use the configuration framework (Miklos)
87 88
  */
88 89
 
89 90
 
... ...
@@ -103,7 +104,9 @@
103 104
 #include "../../mem/mem.h"
104 105
 #include "../../route_struct.h"
105 106
 #include "../../route.h"
107
+#include "../../cfg/cfg.h"
106 108
 
109
+#include "config.h"
107 110
 #include "sip_msg.h"
108 111
 #include "h_table.h"
109 112
 #include "t_hooks.h"
... ...
@@ -208,9 +211,6 @@ static char *fr_inv_timer_param = 0 /*FR_INV_TIMER_AVP*/;
208 211
 
209 212
 static rpc_export_t tm_rpc[];
210 213
 
211
-static int default_code = 500;
212
-static str default_reason = STR_STATIC_INIT("Server Internal Error");
213
-
214 214
 static int fixup_t_check_status(void** param, int param_no);
215 215
 
216 216
 static cmd_export_t cmds[]={
... ...
@@ -334,38 +334,37 @@ static cmd_export_t cmds[]={
334 334
 
335 335
 
336 336
 static param_export_t params[]={
337
-	{"ruri_matching",       PARAM_INT, &ruri_matching                        },
338
-	{"via1_matching",       PARAM_INT, &via1_matching                        },
339
-	{"fr_timer",            PARAM_INT, &fr_timeout                           },
340
-	{"fr_inv_timer",        PARAM_INT, &fr_inv_timeout                       },
341
-	{"wt_timer",            PARAM_INT, &wait_timeout                         },
342
-	{"delete_timer",        PARAM_INT, &delete_timeout                       },
343
-	{"retr_timer1",         PARAM_INT, &rt_t1_timeout                        },
344
-	{"retr_timer2"  ,       PARAM_INT, &rt_t2_timeout                        },
345
-	{"max_inv_lifetime",    PARAM_INT, &tm_max_inv_lifetime                  },
346
-	{"max_noninv_lifetime", PARAM_INT, &tm_max_noninv_lifetime               },
347
-	{"noisy_ctimer",        PARAM_INT, &noisy_ctimer                         },
348
-	{"auto_inv_100",        PARAM_INT, &tm_auto_inv_100                      },
349
-	{"uac_from",            PARAM_STRING, &uac_from                          },
350
-	{"unix_tx_timeout",     PARAM_INT, &tm_unix_tx_timeout                   },
351
-	{"restart_fr_on_each_reply", PARAM_INT, &restart_fr_on_each_reply        },
337
+	{"ruri_matching",       PARAM_INT, &default_tm_cfg.ruri_matching         },
338
+	{"via1_matching",       PARAM_INT, &default_tm_cfg.via1_matching         },
339
+	{"fr_timer",            PARAM_INT, &default_tm_cfg.fr_timeout            },
340
+	{"fr_inv_timer",        PARAM_INT, &default_tm_cfg.fr_inv_timeout        },
341
+	{"wt_timer",            PARAM_INT, &default_tm_cfg.wait_timeout          },
342
+	{"delete_timer",        PARAM_INT, &default_tm_cfg.delete_timeout        },
343
+	{"retr_timer1",         PARAM_INT, &default_tm_cfg.rt_t1_timeout         },
344
+	{"retr_timer2"  ,       PARAM_INT, &default_tm_cfg.rt_t2_timeout         },
345
+	{"max_inv_lifetime",    PARAM_INT, &default_tm_cfg.tm_max_inv_lifetime   },
346
+	{"max_noninv_lifetime", PARAM_INT, &default_tm_cfg.tm_max_noninv_lifetime},
347
+	{"noisy_ctimer",        PARAM_INT, &default_tm_cfg.noisy_ctimer          },
348
+	{"auto_inv_100",        PARAM_INT, &default_tm_cfg.tm_auto_inv_100       },
349
+	{"unix_tx_timeout",     PARAM_INT, &default_tm_cfg.tm_unix_tx_timeout    },
350
+	{"restart_fr_on_each_reply", PARAM_INT, &default_tm_cfg.restart_fr_on_each_reply},
352 351
 	{"fr_timer_avp",        PARAM_STRING, &fr_timer_param                    },
353 352
 	{"fr_inv_timer_avp",    PARAM_STRING, &fr_inv_timer_param                },
354 353
 	{"tw_append",           PARAM_STRING|PARAM_USE_FUNC, 
355 354
 													(void*)parse_tw_append   },
356
-	{"pass_provisional_replies", PARAM_INT, &pass_provisional_replies        },
357
-	{"aggregate_challenges", PARAM_INT, &tm_aggregate_auth                   },
358
-	{"unmatched_cancel",    PARAM_INT, &unmatched_cancel                     },
359
-	{"default_code",        PARAM_INT, &default_code                         },
360
-	{"default_reason",      PARAM_STR, &default_reason                       },
361
-	{"reparse_invite",      PARAM_INT, &reparse_invite                       },
362
-	{"ac_extra_hdrs",       PARAM_STR, &ac_extra_hdrs                        },
363
-	{"blst_503",            PARAM_INT, &tm_blst_503                          },
364
-	{"blst_503_def_timeout",PARAM_INT, &tm_blst_503_default                  },
365
-	{"blst_503_min_timeout",PARAM_INT, &tm_blst_503_min                      },
366
-	{"blst_503_max_timeout",PARAM_INT, &tm_blst_503_max                      },
367
-	{"blst_methods_add",    PARAM_INT, &tm_blst_methods_add                  },
368
-	{"blst_methods_lookup", PARAM_INT, &tm_blst_methods_lookup               },
355
+	{"pass_provisional_replies", PARAM_INT, &default_tm_cfg.pass_provisional_replies},
356
+	{"aggregate_challenges", PARAM_INT, &default_tm_cfg.tm_aggregate_auth    },
357
+	{"unmatched_cancel",    PARAM_INT, &default_tm_cfg.unmatched_cancel      },
358
+	{"default_code",        PARAM_INT, &default_tm_cfg.default_code          },
359
+	{"default_reason",      PARAM_STRING, &default_tm_cfg.default_reason     },
360
+	{"reparse_invite",      PARAM_INT, &default_tm_cfg.reparse_invite        },
361
+	{"ac_extra_hdrs",       PARAM_STR, &default_tm_cfg.ac_extra_hdrs         },
362
+	{"blst_503",            PARAM_INT, &default_tm_cfg.tm_blst_503           },
363
+	{"blst_503_def_timeout",PARAM_INT, &default_tm_cfg.tm_blst_503_default   },
364
+	{"blst_503_min_timeout",PARAM_INT, &default_tm_cfg.tm_blst_503_min       },
365
+	{"blst_503_max_timeout",PARAM_INT, &default_tm_cfg.tm_blst_503_max       },
366
+	{"blst_methods_add",    PARAM_INT, &default_tm_cfg.tm_blst_methods_add   },
367
+	{"blst_methods_lookup", PARAM_INT, &default_tm_cfg.tm_blst_methods_lookup},
369 368
 	{0,0,0}
370 369
 };
371 370
 
... ...
@@ -554,6 +553,7 @@ static int mod_init(void)
554 553
 {
555 554
 	DBG( "TM - (sizeof cell=%ld, sip_msg=%ld) initializing...\n",
556 555
 			(long)sizeof(struct cell), (long)sizeof(struct sip_msg));
556
+
557 557
 	/* checking if we have sufficient bitmap capacity for given
558 558
 	   maximum number of  branches */
559 559
 	if (MAX_BRANCHES+1>31) {
... ...
@@ -580,12 +580,21 @@ static int mod_init(void)
580 580
 		LOG(L_ERR, "ERROR: mod_init: select init failed\n");
581 581
 		return -1;
582 582
 	}
583
-	
583
+
584
+	/* the defult timer values must be fixed-up before
585
+	 * declaring the configuration (Miklos) */
584 586
 	if (tm_init_timers()==-1) {
585 587
 		LOG(L_ERR, "ERROR: mod_init: timer init failed\n");
586 588
 		return -1;
587 589
 	}
588 590
 
591
+	/* declare the configuration */
592
+	if (cfg_declare("tm", tm_cfg_def, &default_tm_cfg, cfg_size(tm),
593
+			 &tm_cfg)) {
594
+		LOG(L_ERR, "ERROR: mod_init: failed to declare the configuration\n");
595
+		return -1;
596
+	}
597
+
589 598
 	     /* First tm_stat initialization function only allocates the top level stat
590 599
 	      * structure in shared memory, the initialization will complete in child
591 600
 	      * init with init_tm_stats_child when the final value of estimated_process_count is
... ...
@@ -976,16 +985,16 @@ inline static int w_t_reply(struct sip_msg* msg, char* p1, char* p2)
976 985
 	}
977 986
 
978 987
 	if (get_int_fparam(&code, msg, (fparam_t*)p1) < 0) {
979
-	    code = default_code;
988
+	    code = cfg_get(tm, tm_cfg, default_code);
980 989
 	}
981 990
 	
982 991
 	if (get_str_fparam(&reason, msg, (fparam_t*)p2) < 0) {
983
-	    reason = default_reason;
992
+		r = cfg_get(tm, tm_cfg, default_reason);
993
+	} else {
994
+		r = as_asciiz(&reason);
995
+		if (r == NULL) r = cfg_get(tm, tm_cfg, default_reason);
984 996
 	}
985 997
 	
986
-	r = as_asciiz(&reason);
987
-	if (r == NULL) r = default_reason.s;
988
-	
989 998
 	/* if called from reply_route, make sure that unsafe version
990 999
 	 * is called; we are already in a mutex and another mutex in
991 1000
 	 * the safe version would lead to a deadlock
... ...
@@ -1001,7 +1010,7 @@ inline static int w_t_reply(struct sip_msg* msg, char* p1, char* p2)
1001 1010
 		ret = -1;
1002 1011
 	}
1003 1012
 
1004
-	if (r) pkg_free(r);
1013
+	if (r && (r != cfg_get(tm, tm_cfg, default_reason))) pkg_free(r);
1005 1014
 	return ret;
1006 1015
 }
1007 1016
 
... ...
@@ -1227,7 +1236,7 @@ inline static int w_t_relay_cancel( struct sip_msg  *p_msg ,
1227 1236
 		return 1;
1228 1237
 
1229 1238
 	/* it makes no sense to use this function without reparse_invite=1 */
1230
-	if (!reparse_invite)
1239
+	if (!cfg_get(tm, tm_cfg, reparse_invite))
1231 1240
 		LOG(L_WARN, "WARNING: t_relay_cancel is probably used with "
1232 1241
 			"wrong configuration, check the readme for details\n");
1233 1242
 
... ...
@@ -69,6 +69,7 @@
69 69
 #include "../../ip_addr.h"
70 70
 #include "../../socket_info.h"
71 71
 #include "../../compiler_opt.h"
72
+#include "config.h"
72 73
 #include "ut.h"
73 74
 #include "h_table.h"
74 75
 #include "t_hooks.h"
... ...
@@ -87,11 +88,6 @@
87 88
 
88 89
 static char from_tag[FROM_TAG_LEN + 1];
89 90
 
90
-char* uac_from = "sip:foo@foo.bar"; /* Module parameter */
91
-
92
-/* Enable/disable passing of provisional replies to FIFO applications */
93
-int pass_provisional_replies = 0;
94
-
95 91
 /*
96 92
  * Initialize UAC
97 93
  */
... ...
@@ -259,23 +255,24 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
259 255
 	}
260 256
 	if (uac_r->method->len==INVITE_LEN && memcmp(uac_r->method->s, INVITE, INVITE_LEN)==0){
261 257
 		new_cell->flags |= T_IS_INVITE_FLAG;
262
-		new_cell->flags|=T_AUTO_INV_100 & (!tm_auto_inv_100 -1);
263
-		lifetime=tm_max_inv_lifetime;
258
+		new_cell->flags|=T_AUTO_INV_100 &
259
+				(!cfg_get(tm, tm_cfg, tm_auto_inv_100) -1);
260
+		lifetime=cfg_get(tm, tm_cfg, tm_max_inv_lifetime);
264 261
 	}else
265
-		lifetime=tm_max_noninv_lifetime;
262
+		lifetime=cfg_get(tm, tm_cfg, tm_max_noninv_lifetime);
266 263
 	new_cell->flags |= T_IS_LOCAL_FLAG;
267 264
 	/* init timers hack, new_cell->fr_timer and new_cell->fr_inv_timer
268 265
 	 * must be set, or else the fr will happen immediately
269 266
 	 * we can't call init_new_t() because we don't have a sip msg
270 267
 	 * => we'll ignore t_set_fr() or avp timer value and will use directly the
271 268
 	 * module params fr_inv_timer and fr_timer -- andrei */
272
-	new_cell->fr_timeout=fr_timeout;
273
-	new_cell->fr_inv_timeout=fr_inv_timeout;
269
+	new_cell->fr_timeout=cfg_get(tm, tm_cfg, fr_timeout);
270
+	new_cell->fr_inv_timeout=cfg_get(tm, tm_cfg, fr_inv_timeout);
274 271
 	new_cell->end_of_life=get_ticks_raw()+lifetime;
275 272
 #ifdef TM_DIFF_RT_TIMEOUT
276 273
 	/* same as above for retransmission intervals */
277
-	new_cell->rt_t1_timeout=rt_t1_timeout;
278
-	new_cell->rt_t2_timeout=rt_t2_timeout;
274
+	new_cell->rt_t1_timeout=cfg_get(tm, tm_cfg, rt_t1_timeout);
275
+	new_cell->rt_t2_timeout=cfg_get(tm, tm_cfg, rt_t2_timeout);
279 276
 #endif
280 277
 
281 278
 	/* better reset avp list now - anyhow, it's useless from
... ...
@@ -41,9 +41,6 @@
41 41
 
42 42
 #define DEFAULT_CSEQ 10 /* Default CSeq number */
43 43
 
44
-extern char *uac_from;  /* UAC From parameter */
45
-extern int pass_provisional_replies; /* Pass provisional replies to fifo applications */
46
-
47 44
 /* structure for UAC interface
48 45
  *
49 46
  * You can free the memory allocated