Browse code

Merge branch 'master' of ssh://daniel@git.sip-router.org/sip-router

* 'master' of ssh://daniel@git.sip-router.org/sip-router:
core: run_top_route() can be give action context
core: internal difference between cfg drop and exit
kex: several K core stats implemented in callbacks
makefile: more modules groups and make modules-all
prefix_route(s): fix: the lock should be in shm
prefix_route(s): fix mod_destroy/tree_close()
debian: updated debian spec for sip-router
makefile: fix make cfg when the cfg vars are already exported
core: derive default config name from -DNAME

Daniel-Constantin Mierla authored on 09/07/2009 09:54:35
Showing 24 changed files
... ...
@@ -171,7 +171,11 @@ Compile SIP Router core only:
171 171
 make   #builds only sip-router core, equivalent to make sip-router
172 172
 
173 173
 Compile modules except some explicitly excepted (see below)
174
-make modules  
174
+make modules  - all modules in the modules/ directory (common modules)
175
+make modules_s - all modules in the modules_s/ directory (ser modules)
176
+make modules_k - all modules in the modules_k/ directory (kamailio modules)
177
+make modules-all or make every-module  - all the modules (modules, modules_s
178
+                                         and module_k)
175 179
 
176 180
 Compile all:
177 181
 make all
... ...
@@ -189,7 +193,12 @@ standard - Modules in this group are considered a standard part of SIP Router (d
189 193
     but they have no dependencies (note that some of these interplay with external systems.
190 194
     However, they don't have compile or link dependencies).
191 195
 
192
-standard-dep -  Modules in this group are considered a standard part of SIP Router (due to widespread usage)
196
+db - Modules in this group use databases and need a database driver to run.
197
+     Included are drivers for the text mode db (dbtext) and for dumping
198
+     large ammount of data to files (db_flatstore). See also the mysql or
199
+     postgres groups.
200
+
201
+standard_dep -  Modules in this group are considered a standard part of SIP Router (due to widespread usage)
193 202
     but they have dependencies that most be satisfied for compilation.
194 203
     NOTE! All presence modules (dialog, pa, presence_b2b, rls, xcap) have been included in this
195 204
     group due to interdependencies
... ...
@@ -208,7 +217,9 @@ make group_include="standard standard-dep stable experimental" all
208 217
 
209 218
 There are also in addition some "convenience" groups:
210 219
 
211
-mysql - Include all modules dependent on mysql
220
+mysql - Include all the db modules dependent and the mysql db driver
221
+
222
+postgres - Include all the db modules and the postgres db driver
212 223
 
213 224
 radius - Include all modules on radiusclient
214 225
 
... ...
@@ -155,9 +155,17 @@ module_group_standard_dep=acc_db acc_radius auth_db auth_radius avp_db \
155 155
 				db_ops domain lcr msilo mysql dialog pa postgres \
156 156
 				presence_b2b rls speeddial uri_db xcap xmlrpc
157 157
 
158
+# For db use (db modules, excluding drivers)
159
+module_group_db=acc_db auth_db avp_db db_ops db_flatstore dbtext db_text \
160
+				uri_db domain lcr msilo speeddial
161
+
158 162
 # For mysql
159
-module_group_mysql=acc_db auth_db avp_db db_ops uri_db domain lcr msilo mysql\
160
-				speeddial
163
+module_group_mysql_driver=db_mysql
164
+module_group_mysql=$(module_group_mysql_driver) $(module_group_db)
165
+
166
+# For postgress
167
+module_group_postgres_driver=db_postgres
168
+module_group_postgres=$(module_group_postgres_driver) $(module_group_db)
161 169
 
162 170
 # For radius
163 171
 module_group_radius=acc_radius auth_radius avp_radius misc_radius peering
... ...
@@ -212,32 +220,9 @@ endif
212 220
 override exclude_modules+= CVS $(skip_modules)
213 221
 
214 222
 # Test for the groups and add to include_modules
215
-ifneq (,$(findstring standard,$(group_include)))
216
-	override include_modules+= $(module_group_standard)
217
-endif
218
-
219
-ifneq (,$(findstring standard-dep,$(group_include)))
220
-	override include_modules+= $(module_group_standard_dep)
221
-endif
222
-
223
-ifneq (,$(findstring mysql,$(group_include)))
224
-	override include_modules+= $(module_group_mysql)
225
-endif
226
-
227
-ifneq (,$(findstring radius,$(group_include)))
228
-	override include_modules+= $(module_group_radius)
229
-endif
230
-
231
-ifneq (,$(findstring presence,$(group_include)))
232
-	override include_modules+= $(module_group_presence)
233
-endif
234
-
235
-ifneq (,$(findstring stable,$(group_include)))
236
-	override include_modules+= $(module_group_stable)
237
-endif
238
-
239
-ifneq (,$(findstring experimental,$(group_include)))
240
-	override include_modules+= $(module_group_experimental)
223
+ifneq (,$(group_include))
224
+override include_modules+=$(foreach grp, $(group_include), \
225
+								$(module_group_$(grp)) )
241 226
 endif
242 227
 
243 228
 # first 2 lines are excluded because of the experimental or incomplete
... ...
@@ -264,6 +249,9 @@ ifeq ($(makefile_defs),1)
264 249
 $(info config.mak loaded)
265 250
 # config_make valid & used
266 251
 config_mak=1
252
+ifeq ($(MAIN_NAME),)
253
+$(error "bad config.mak, try re-running make cfg")
254
+endif
267 255
 endif
268 256
 else # config.mak doesn't need to be used
269 257
 ifneq (,$(filter cfg config cfg-defs,$(word 1,$(MAKECMDGOALS))))
... ...
@@ -273,6 +261,9 @@ ifneq (,$(filter cfg config cfg-defs,$(word 1,$(MAKECMDGOALS))))
273 261
 # $(value ...) expansion or would cause some warning (if Makefile.defs exec. 
274 262
 # is skipped in the "main" makefile invocation).
275 263
 $(shell rm -rf config.mak)
264
+config_mak=0
265
+makefile_defs=0
266
+exported_vars=0
276 267
 endif
277 268
 endif
278 269
 
... ...
@@ -621,7 +612,7 @@ $(foreach mods,$(modules_dirs),$(eval $(call MODULES_RULES_template,$(mods))))
621 612
 #$(foreach mods,$(modules_dirs),$(eval  $(info DUMP: $(call MODULES_RULES_template,$(mods)))))
622 613
 
623 614
 # build all the modules
624
-every-module: $(modules_dirs)
615
+modules-all every-module: $(modules_dirs)
625 616
 
626 617
 $(extra_objs):
627 618
 	@echo "Extra objs: $(extra_objs)" 
... ...
@@ -14,6 +14,7 @@
14 14
 #create config if needed
15 15
 $(COREPATH)/config.mak: makefile_defs=0
16 16
 $(COREPATH)/config.mak: exported_vars=0
17
+$(COREPATH)/config.mak: config_mak=0
17 18
 
18 19
 $(COREPATH)/config.mak: $(COREPATH)/Makefile.defs
19 20
 	$(MAKE) -wC $(COREPATH) cfg-defs
... ...
@@ -35,9 +35,9 @@ doc_targets:=	README man install-doc install-man install-ser-man \
35 35
 # auxiliary: maintance, debugging, etc. (don't affect code/objects)
36 36
 aux_targets:=	TAGS tar dist cfg-defs cfg config config.mak print-modules \
37 37
 		dbg dbinstall librpath.lst makecfg.lst modules.lst modules-cfg \
38
-		modules-list modules-lst mk-install_dirs autover.h
38
+		modules-list modules-lst mk-install_dirs autover.h deb
39 39
 # other targets that don't produce code in the current directory ("external")
40
-ext_targets:=	every-module $(modules_dirs) libs utils \
40
+ext_targets:=	every-module modules-all $(modules_dirs) libs utils \
41 41
 		install-cfg install-utils  install-modules-all install-every-module\
42 42
 		$(foreach m,$(modules_dirs),install-$(m)) \
43 43
 		install-share
... ...
@@ -1292,11 +1292,13 @@ error:
1292 1292
 }
1293 1293
 
1294 1294
 
1295
-int run_top_route(struct action* a, sip_msg_t* msg)
1295
+int run_top_route(struct action* a, sip_msg_t* msg, struct run_act_ctx *c)
1296 1296
 {
1297 1297
 	struct run_act_ctx ctx;
1298
+	struct run_act_ctx *p;
1299
+	p = (c)?c:&ctx;
1298 1300
 	setsflagsval(0);
1299 1301
 	reset_static_buffer();
1300
-	init_run_actions_ctx(&ctx);
1301
-	return run_actions(&ctx, a, msg);
1302
+	init_run_actions_ctx(p);
1303
+	return run_actions(p, a, msg);
1302 1304
 }
... ...
@@ -59,6 +59,6 @@ struct run_act_ctx{
59 59
 int do_action(struct run_act_ctx* c, struct action* a, struct sip_msg* msg);
60 60
 int run_actions(struct run_act_ctx* c, struct action* a, struct sip_msg* msg);
61 61
 
62
-int run_top_route(struct action* a, sip_msg_t* msg);
62
+int run_top_route(struct action* a, sip_msg_t* msg, struct run_act_ctx* c);
63 63
 
64 64
 #endif
... ...
@@ -149,7 +149,8 @@ FORWARD_TCP	forward_tcp
149 149
 FORWARD_UDP	forward_udp
150 150
 FORWARD_TLS	forward_tls
151 151
 FORWARD_SCTP	forward_sctp
152
-DROP	"drop"|"exit"
152
+DROP	"drop"
153
+EXIT	"exit"
153 154
 RETURN	"return"
154 155
 BREAK	"break"
155 156
 SEND	send
... ...
@@ -486,6 +487,7 @@ EAT_ABLE	[\ \t\b\r]
486 487
 <INITIAL>{FORWARD_SCTP}	{count(); yylval.strval=yytext; return FORWARD_SCTP;}
487 488
 <INITIAL>{FORWARD_UDP}	{count(); yylval.strval=yytext; return FORWARD_UDP; }
488 489
 <INITIAL>{DROP}	{ count(); yylval.strval=yytext; return DROP; }
490
+<INITIAL>{EXIT}	{ count(); yylval.strval=yytext; return EXIT; }
489 491
 <INITIAL>{RETURN}	{ count(); yylval.strval=yytext; return RETURN; }
490 492
 <INITIAL>{BREAK}	{ count(); yylval.strval=yytext; return BREAK; }
491 493
 <INITIAL>{SEND}	{ count(); yylval.strval=yytext; return SEND; }
... ...
@@ -265,6 +265,7 @@ static int case_check_default(struct case_stms* stms);
265 265
 %token FORWARD_UDP
266 266
 %token SEND
267 267
 %token SEND_TCP
268
+%token EXIT
268 269
 %token DROP
269 270
 %token RETURN
270 271
 %token BREAK
... ...
@@ -2940,18 +2941,34 @@ func_param:
2940 2941
 
2941 2942
 ret_cmd:
2942 2943
 	DROP LPAREN RPAREN		{
2943
-		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); 
2944
+		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST,
2945
+						(void*)(DROP_R_F|EXIT_R_F)); 
2944 2946
 	}
2945 2947
 	| DROP rval_expr	{
2946
-		$$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST, (void*)EXIT_R_F);
2948
+		$$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST,
2949
+						(void*)(DROP_R_F|EXIT_R_F)); 
2947 2950
 	}
2948 2951
 	| DROP				{
2952
+		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, 
2953
+						(void*)(DROP_R_F|EXIT_R_F)); 
2954
+	}
2955
+	| EXIT LPAREN RPAREN		{
2956
+		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); 
2957
+	}
2958
+	| EXIT rval_expr	{
2959
+		$$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST, (void*)EXIT_R_F);
2960
+	}
2961
+	| EXIT				{
2949 2962
 		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); 
2950 2963
 	}
2951 2964
 	| RETURN			{
2952 2965
 		$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST,
2953 2966
 						(void*)RETURN_R_F);
2954 2967
 	}
2968
+	| RETURN  LPAREN RPAREN		{
2969
+		$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST,
2970
+						(void*)RETURN_R_F);
2971
+	}
2955 2972
 	| RETURN rval_expr	{
2956 2973
 		$$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST, (void*)RETURN_R_F);
2957 2974
 	}
... ...
@@ -44,7 +44,7 @@
44 44
 #define SIP_PORT  5060
45 45
 #define SIPS_PORT 5061
46 46
 
47
-#define CFG_FILE CFG_DIR "sip-router.cfg"
47
+#define CFG_FILE CFG_DIR NAME ".cfg"
48 48
 
49 49
 #define TLS_PKEY_FILE "cert.pem" 
50 50
 #define TLS_CERT_FILE "cert.pem"
... ...
@@ -196,7 +196,7 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
196 196
 		set_route_type(BRANCH_ROUTE);
197 197
 		tm_ctx_set_branch_index(branch+1);
198 198
 		if (exec_pre_script_cb(i_req, BRANCH_CB_TYPE)>0) {
199
-			if (run_top_route(branch_rt.rlist[branch_route], i_req) < 0) {
199
+			if (run_top_route(branch_rt.rlist[branch_route], i_req, 0) < 0) {
200 200
 				LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n");
201 201
 			}
202 202
 			exec_post_script_cb(i_req, BRANCH_CB_TYPE);
... ...
@@ -868,7 +868,7 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
868 868
 		t->on_negative=0;
869 869
 		if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
870 870
 			/* run a reply_route action if some was marked */
871
-			if (run_top_route(failure_rt.rlist[on_failure], &faked_req)<0)
871
+			if (run_top_route(failure_rt.rlist[on_failure], &faked_req, 0)<0)
872 872
 				LOG(L_ERR, "ERROR: run_failure_handlers: Error in run_top_route\n");
873 873
 			exec_post_script_cb(&faked_req, FAILURE_CB_TYPE);
874 874
 		}
... ...
@@ -1976,7 +1976,7 @@ int reply_received( struct sip_msg  *p_msg )
1976 1976
 		/* Pre- and post-script callbacks have already
1977 1977
 		 * been execueted by the core. (Miklos)
1978 1978
 		 */
1979
-		if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg)<0)
1979
+		if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg, 0)<0)
1980 1980
 			LOG(L_ERR, "ERROR: on_reply processing failed\n");
1981 1981
 		/* transfer current message context back to t */
1982 1982
 		if (t->uas.request) t->uas.request->flags=p_msg->flags;
... ...
@@ -2108,7 +2108,7 @@ trans_not_found:
2108 2108
 		 * Pre- and post-script callbacks have already
2109 2109
 		 * been execueted by the core. (Miklos)
2110 2110
 		 */
2111
-		return run_top_route(onreply_rt.rlist[goto_on_sl_reply], p_msg);
2111
+		return run_top_route(onreply_rt.rlist[goto_on_sl_reply], p_msg, 0);
2112 2112
 	} else {
2113 2113
 		/* let the core forward the reply */
2114 2114
 		return 1;
... ...
@@ -161,7 +161,7 @@ int t_continue(unsigned int hash_index, unsigned int label,
161 161
 	 * of failure route (Miklos)
162 162
 	 */
163 163
 	if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
164
-		if (run_top_route(route, &faked_req)<0)
164
+		if (run_top_route(route, &faked_req, 0)<0)
165 165
 			LOG(L_ERR, "ERROR: t_continue: Error in run_top_route\n");
166 166
 		exec_post_script_cb(&faked_req, FAILURE_CB_TYPE);
167 167
 	}
... ...
@@ -102,7 +102,7 @@ int cpl_proxy_to_loc_set( struct sip_msg *msg, struct location **locs,
102 102
 	/* run what proxy route is set */
103 103
 	if (cpl_env.proxy_route) {
104 104
 		/* do not alter route type - it might be REQUEST or FAILURE */
105
-		run_top_route( main_rt.rlist[cpl_env.proxy_route], msg);
105
+		run_top_route( main_rt.rlist[cpl_env.proxy_route], msg, 0);
106 106
 	}
107 107
 
108 108
 	/* do t_forward */
... ...
@@ -973,7 +973,7 @@ void dlg_ontimeout( struct dlg_tl *tl)
973 973
 		{
974 974
 			LM_DBG("executing route %d on timeout\n", dlg->toroute);
975 975
 			set_route_type(REQUEST_ROUTE);
976
-			run_top_route(main_rt.rlist[dlg->toroute], fmsg);
976
+			run_top_route(main_rt.rlist[dlg->toroute], fmsg, 0);
977 977
 			exec_post_script_cb(fmsg, REQUEST_CB_TYPE);
978 978
 		}
979 979
 	}
... ...
@@ -619,7 +619,7 @@ static int use_next_gw(struct sip_msg* msg)
619 619
 
620 620
 	if (!avp) return -1;
621 621
 
622
-	if (rewrite_ruri(msg, &val)==-1) {
622
+	if (rewrite_ruri(msg, val.s.s)==-1) {
623 623
 		LM_ERR("failed to rewite RURI\n");
624 624
 		return -1;
625 625
 	}
... ...
@@ -732,7 +732,7 @@ again:
732 732
 	}
733 733
 
734 734
 	if (rt_info->route_idx>0 && rt_info->route_idx<RT_NO) {
735
-		ret = run_top_route(main_rt.rlist[rt_info->route_idx], msg );
735
+		ret = run_top_route(main_rt.rlist[rt_info->route_idx], msg, 0);
736 736
 		if (ret<1) {
737 737
 			/* drop the action */
738 738
 			LM_DBG("script route %d drops routing "
... ...
@@ -184,7 +184,7 @@ static int child_init(int rank)
184 184
 		fmsg = faked_msg_next();
185 185
 		rtb = get_route_type();
186 186
 		set_route_type(REQUEST_ROUTE);
187
-		run_top_route(event_rt.rlist[rt], fmsg);
187
+		run_top_route(event_rt.rlist[rt], fmsg, 0);
188 188
 		set_route_type(rtb);
189 189
 	}
190 190
 
... ...
@@ -38,6 +38,8 @@
38 38
 #include "../../lib/kmi/mi.h"
39 39
 #include "../../dprint.h"
40 40
 #include "../../timer.h"
41
+#include "../../parser/msg_parser.h"
42
+#include "../../script_cb.h"
41 43
 #include "../../mem/meminfo.h"
42 44
 #include "../../mem/shm_mem.h"
43 45
 
... ...
@@ -102,12 +104,29 @@ static mi_export_t mi_stat_cmds[] = {
102 104
 int register_mi_stats(void)
103 105
 {
104 106
 	/* register MI commands */
105
-	if (register_mi_mod( "core", mi_stat_cmds)<0) {
107
+	if (register_mi_mod("core", mi_stat_cmds)<0) {
106 108
 		LM_ERR("unable to register MI cmds\n");
107 109
 		return -1;
108 110
 	}
109 111
 	return 0;
110 112
 }
113
+
114
+static int km_cb_req_stats(struct sip_msg *msg,
115
+		unsigned int flags, void *param)
116
+{
117
+	update_stat(rcv_reqs, 1);
118
+	if(msg->first_line.u.request.method_value==METHOD_OTHER)
119
+		update_stat(unsupported_methods, 1);
120
+	return 1;
121
+}
122
+
123
+static int km_cb_rpl_stats(struct sip_msg *msg,
124
+		unsigned int flags, void *param)
125
+{
126
+	update_stat(rcv_rpls, 1);
127
+	return 1;
128
+}
129
+
111 130
 int register_core_stats(void)
112 131
 {
113 132
 	/* register core statistics */
... ...
@@ -120,6 +139,15 @@ int register_core_stats(void)
120 139
 		LM_ERR("failed to register sh_mem statistics\n");
121 140
 		return -1;
122 141
 	}
142
+	if (register_script_cb(km_cb_req_stats, PRE_SCRIPT_CB|REQUEST_CB, 0)<0 ) {
143
+		LM_ERR("failed to register PRE request callback\n");
144
+		return -1;
145
+	}
146
+	if (register_script_cb(km_cb_rpl_stats, PRE_SCRIPT_CB|ONREPLY_CB, 0)<0 ) {
147
+		LM_ERR("failed to register PRE request callback\n");
148
+		return -1;
149
+	}
150
+
123 151
 	return 0;
124 152
 }
125 153
 
... ...
@@ -191,7 +191,7 @@ void stm_timer_exec(unsigned int ticks, void *param)
191 191
 		if (exec_pre_script_cb(&_stm_msg, REQUEST_CB_TYPE)==0 )
192 192
 			continue; /* drop the request */
193 193
 		set_route_type(REQUEST_ROUTE);
194
-		run_top_route(main_rt.rlist[rt->route], &_stm_msg);
194
+		run_top_route(main_rt.rlist[rt->route], &_stm_msg, 0);
195 195
 		exec_post_script_cb(&_stm_msg, REQUEST_CB_TYPE);
196 196
 	}
197 197
 }
... ...
@@ -34,6 +34,8 @@
34 34
 #include "../../atomic_ops.h"
35 35
 #include "../../mem/shm_mem.h"
36 36
 #include "../../str.h"
37
+#include "../../lock_alloc.h"
38
+#include "../../lock_ops.h"
37 39
 #include "tree.h"
38 40
 
39 41
 
... ...
@@ -59,7 +61,7 @@ struct tree {
59 61
 
60 62
 /* Local variables */
61 63
 static struct tree **shared_tree = NULL;
62
-static gen_lock_t shared_tree_lock;
64
+static gen_lock_t* shared_tree_lock;
63 65
 
64 66
 
65 67
 /**
... ...
@@ -286,9 +288,9 @@ static struct tree *tree_get(void)
286 288
 {
287 289
 	struct tree *tree;
288 290
 
289
-	lock_get(&shared_tree_lock);
291
+	lock_get(shared_tree_lock);
290 292
 	tree = *shared_tree;
291
-	lock_release(&shared_tree_lock);
293
+	lock_release(shared_tree_lock);
292 294
 
293 295
 	return tree;
294 296
 }
... ...
@@ -298,10 +300,10 @@ static struct tree *tree_ref(void)
298 300
 {
299 301
 	struct tree *tree;
300 302
 
301
-	lock_get(&shared_tree_lock);
303
+	lock_get(shared_tree_lock);
302 304
 	tree = *shared_tree;
303 305
 	atomic_inc(&tree->refcnt);
304
-	lock_release(&shared_tree_lock);
306
+	lock_release(shared_tree_lock);
305 307
 
306 308
 	return tree;
307 309
 }
... ...
@@ -318,11 +320,18 @@ struct tree *tree_deref(struct tree *tree)
318 320
 int tree_init(void)
319 321
 {
320 322
 	/* Initialize lock */
321
-	lock_init(&shared_tree_lock);
323
+	shared_tree_lock = lock_alloc();
324
+	if (NULL == shared_tree_lock) {
325
+		return -1;
326
+	}
327
+	lock_init(shared_tree_lock);
322 328
 
323 329
 	/* Pointer to global tree must be in shared memory */
324 330
 	shared_tree = (struct tree **)shm_malloc(sizeof(*shared_tree));
325 331
 	if (NULL == shared_tree) {
332
+		lock_destroy(shared_tree_lock);
333
+		lock_dealloc(shared_tree_lock);
334
+		shared_tree_lock=0;
326 335
 		return -1;
327 336
 	}
328 337
 
... ...
@@ -334,7 +343,14 @@ int tree_init(void)
334 343
 
335 344
 void tree_close(void)
336 345
 {
337
-	tree_flush(tree_get());
346
+	if (shared_tree)
347
+		tree_flush(tree_get());
348
+	shared_tree = NULL;
349
+	if (shared_tree_lock) {
350
+		lock_destroy(shared_tree_lock);
351
+		lock_dealloc(shared_tree_lock);
352
+		shared_tree_lock=0;
353
+	}
338 354
 }
339 355
 
340 356
 
... ...
@@ -352,9 +368,9 @@ int tree_swap(struct tree_item *root)
352 368
 	old_tree = tree_get();
353 369
 
354 370
 	/* Critical - swap trees */
355
-	lock_get(&shared_tree_lock);
371
+	lock_get(shared_tree_lock);
356 372
 	*shared_tree = new_tree;
357
-	lock_release(&shared_tree_lock);
373
+	lock_release(shared_tree_lock);
358 374
 
359 375
 	/* Flush old tree */
360 376
 	tree_flush(old_tree);
... ...
@@ -1,3 +1,9 @@
1
+ser (2.99.0-dev01) unstable; urgency=low
2
+
3
+  * Update Debian specification for sip-router.
4
+
5
+ -- Andrei Pelinescu-Onciul <andrei@iptel.org>  Wed, 08 Jul 2009 14:13:11 +0200
6
+
1 7
 ser (2.1.0-0dev15) unstable; urgency=low
2 8
 
3 9
   * Added installation of *.sql files for ser_mysql.sh script.
... ...
@@ -59,13 +59,20 @@ Description: contains the ser RADIUS modules
59 59
  depend upon libradius1. This modules will enable you to authenticate, 
60 60
  do group membership checking or check the messages uris using RADIUS.
61 61
 
62
-#Package: ser-postgres-module
63
-#Architecture: any
64
-#Depends: ${shlibs:Depends}, ser (= ${Source-Version})
65
-#Description: contains the PostgreSQL database connectivity module
66
-# This has been split out of the main ser package, so that ser will not
67
-# depend upon libpq. This module will enable you to use the digest
68
-# authentication module or persistent user location entries.
62
+Package: ser-postgres-module
63
+Architecture: any
64
+Depends: ${shlibs:Depends}, ser (= ${Source-Version})
65
+Description: contains the PostgreSQL database connectivity module
66
+ This has been split out of the main ser package, so that ser will not
67
+ depend upon libpq. This module will enable you to use the digest
68
+ authentication module or persistent user location entries.
69
+
70
+Package: ser-tls-module
71
+Architecture: any
72
+Depends: ${shlibs:Depends}, ser (= ${Source-Version})
73
+Description: contains the TLS ser transport module
74
+ This has been split out of the main ser package, so that ser will not
75
+ depend on openssl. This module will enable you to use the TLS transport.
69 76
 
70 77
 Package: ser-xmlrpc-module
71 78
 Architecture: any
... ...
@@ -78,7 +85,7 @@ Description: contains the XML-RPC based interface to SER
78 85
 
79 86
 Package: ser-oob
80 87
 Architecture: any
81
-Depends: ${shlibs:Depends}, ${misc:Depends}, ser, ser-mysql-modules, ser-xmlrpc-module, serctl
88
+Depends: ser, ser-mysql-modules, ser-xmlrpc-module, serctl
82 89
 Suggests: rttpproxy, logrotate, ngrep, ntp
83 90
 Description: Sip Express Router - package for "out of the box" installation
84 91
  This package conatins advanced configuration file for ser - SIP Express Router
... ...
@@ -87,14 +94,14 @@ Description: Sip Express Router - package for "out of the box" installation
87 94
 
88 95
 Package: ser-nth
89 96
 Architecture: any
90
-Depends: ${shlibs:Depends}, ${misc:Depends}, screen, gdb, binutils, gcc, bison, flex, ngrep, tcpdump, iftop, lsof, psmisc, vim, bvi, most, serctl, mc, sipsak
97
+Depends: screen, gdb, binutils, gcc, bison, flex, ngrep, tcpdump, iftop, lsof, psmisc, vim, bvi, most, serctl, mc, sipsak
91 98
 Description: Sip Express Router - package for "nice to have" installation
92 99
  This is a meta-package for easy installation various useful tools that may be
93 100
  handy on server with SER installed.
94 101
 
95 102
 Package: ser-ai1
96 103
 Architecture: any
97
-Depends: ${shlibs:Depends}, ${misc:Depends}, ser-oob, mysql-server, rtpproxy, mystun, sipsak, tcpdump, ngrep, iftop, serweb, sems
104
+Depends: ser-oob, mysql-server, rtpproxy, mystun, sipsak, tcpdump, ngrep, iftop, serweb, sems
98 105
 Suggests: ser-nth
99 106
 Description: Sip Express Router - package for "all in one" installation
100 107
  This is a meta-package for easy installation of complete server running ser - SIP Express
... ...
@@ -23,6 +23,7 @@
23 23
 #              added ser-oob package
24 24
 #                (pavel)
25 25
 #  2007-10-31  updated for cvs head (pavel)
26
+#  2009-07-08  updated for sip-router (andrei)
26 27
 
27 28
 
28 29
 # Uncomment this to turn on verbose mode.
... ...
@@ -43,31 +44,23 @@ EXCLUDED_MODULES=	jabber xmlrpc postgres cpl cpl-c
43 44
 #EXTRA_EXCLUDED_MODULES=	cpl-c avpops flatstore pdt lcr msilo bdb dbtext iptrtpproxy ldap oracle osp pa rls
44 45
 EXTRA_EXCLUDED_MODULES=
45 46
 
46
-### modules depending on mysql
47
-##MYSQL_MODULES=mysql
48
-#jabber related modules
49
-JABBER_MODULES=jabber
50
-###module depending on radiusclient
51
-##RADIUS_MODULES=acc_radius auth_radius group_radius uri_radius avp_radius
52
-#cpl related modules
53
-CPL_MODULES=cpl-c
54
-### pa related modules
55
-##PA_MODULES=pa rls dialog presence_b2b xcap
56 47
 # postgres modules
57
-POSTGRES_MODULES=postgres
48
+POSTGRES_MODULES=db_postgres
49
+# tls module
50
+TLS_MODULES=tls
58 51
 # xmlrpc module
59 52
 XMLRPC_MODULES=xmlrpc
60 53
 
61 54
 # the same but with path prepended (needed for modules="...")
62 55
 ##MYSQL_MOD_PATH=$(addprefix modules/, $(MYSQL_MODULES))
63
-JABBER_MOD_PATH=$(addprefix modules/, $(JABBER_MODULES))
56
+JABBER_MOD_PATH=$(addprefix modules_s/, $(JABBER_MODULES))
64 57
 ##RADIUS_MOD_PATH=$(addprefix modules/, $(RADIUS_MODULES))
65
-CPL_MOD_PATH=$(addprefix modules/, $(CPL_MODULES))
58
+CPL_MOD_PATH=$(addprefix modules_s/, $(CPL_MODULES))
66 59
 ##PA_MOD_PATH=$(addprefix modules/, $(PA_MODULES))
67 60
 POSTGRES_MOD_PATH=$(addprefix modules/, $(POSTGRES_MODULES))
68
-XMLRPC_MOD_PATH=$(addprefix modules/, $(XMLRPC_MODULES))
61
+TLS_MOD_PATH=$(addprefix modules/, $(TLS_MODULES))
62
+XMLRPC_MOD_PATH=$(addprefix modules_s/, $(XMLRPC_MODULES))
69 63
 
70
-SERCTL_PATH=tools/serctl
71 64
 
72 65
 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
73 66
 	CFLAGS += -g
... ...
@@ -80,6 +73,11 @@ configure: configure-stamp
80 73
 configure-stamp:
81 74
 	dh_testdir
82 75
 	# Add here commands to configure the package.
76
+	$(MAKE) cfg prefix=/usr cfg-prefix=$(CURDIR)/debian/ser \
77
+			cfg_target=/etc/ser/ \
78
+			basedir=$(CURDIR)/debian/ser \
79
+			skip_modules="$(EXCLUDED_MODULES) $(EXTRA_EXCLUDED_MODULES)" \
80
+			group_include="standard"
83 81
 
84 82
 	touch configure-stamp
85 83
 
... ...
@@ -88,41 +86,22 @@ build: build-stamp
88 86
 
89 87
 build-stamp: configure-stamp 
90 88
 	dh_testdir
91
-
92 89
 	# Add here commands to compile the package.
93
-	$(MAKE) clean_cfg
94
-	$(MAKE) clean_modules_cfg
95
-	$(MAKE) all group_include="standard" skip_modules="$(EXCLUDED_MODULES) $(EXTRA_EXCLUDED_MODULES)" cfg-target=/etc/ser/ prefix=/usr
96
-	$(MAKE) clean_cfg
97
-	$(MAKE) clean_modules_cfg
98
-	$(MAKE) modules group_include="mysql" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
99
-	#$(MAKE) modules modules="$(JABBER_MOD_PATH)" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
100
-	$(MAKE) clean_cfg
101
-	$(MAKE) clean_modules_cfg
102
-	$(MAKE) modules group_include="radius" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
103
-	#$(MAKE) modules modules="$(CPL_MOD_PATH)" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
104
-	#$(MAKE) modules group_include="presence" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
105
-	#$(MAKE) modules modules="$(POSTGRES_MOD_PATH)" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
106
-	$(MAKE) clean_cfg
107
-	$(MAKE) clean_modules_cfg
108
-	$(MAKE) modules modules="$(XMLRPC_MOD_PATH)" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
90
+	$(MAKE) all
91
+	$(MAKE) every-module group_include="mysql"
92
+	$(MAKE) every-module group_include="radius"
93
+	$(MAKE) modules modules="$(POSTGRES_MOD_PATH)"
94
+	$(MAKE) modules modules="$(TLS_MOD_PATH)"
95
+	$(MAKE) modules modules="$(XMLRPC_MOD_PATH)"
109 96
 	#/usr/bin/docbook-to-man debian/ser.sgml > ser.1
110
-
111 97
 	touch build-stamp
112 98
 
113 99
 clean:
114 100
 	dh_testdir
115 101
 	dh_testroot
116 102
 	rm -f build-stamp configure-stamp
117
-
118 103
 	# Add here commands to clean up after the build process.
119
-	#-$(MAKE) -C lib -f Makefile.ser proper
120
-	#-$(MAKE) include_modules=" $(JABBER_MODULES) $(CPL_MODULES) \
121
-	#	$(POSTGRES_MODULES) $(XMLRPC_MODULES)" proper
122
-	-$(MAKE) proper
123
-	-$(MAKE) clean_cfg
124
-	-$(MAKE) clean_modules_cfg
125
-
104
+	-$(MAKE) maintainer-clean
126 105
 	dh_clean
127 106
 
128 107
 install: build
... ...
@@ -130,89 +109,42 @@ install: build
130 109
 	dh_testroot
131 110
 	dh_clean -k
132 111
 	dh_installdirs
133
-
134 112
 	# Add here commands to install the package into debian/ser
135
-	$(MAKE) clean_cfg
136
-	$(MAKE) clean_modules_cfg
137
-	$(MAKE) install group_include="standard" skip_modules="$(EXCLUDED_MODULES) $(EXTRA_EXCLUDED_MODULES)" \
138
-		basedir=$(CURDIR)/debian/ser \
139
-		prefix=/usr \
140
-		cfg-prefix=$(CURDIR)/debian/ser \
141
-		cfg-target=/etc/ser/
142
-	# fix etc/ser dir location
143
-	mv -f $(CURDIR)/debian/ser/usr/etc $(CURDIR)/debian/ser
113
+	$(MAKE) install group_include="standard"
114
+	# fix etc/ser dir location -- not needed -- andrei
115
+	# mv -f $(CURDIR)/debian/ser/usr/etc $(CURDIR)/debian/ser
144 116
 	# install only the mysql module
145
-	$(MAKE) clean_cfg
146
-	$(MAKE) clean_modules_cfg
147 117
 	$(MAKE) install-modules-all group_include="mysql" \
148 118
 		basedir=$(CURDIR)/debian/ser-mysql-modules \
149
-		prefix=/usr \
150 119
 		cfg-prefix=$(CURDIR)/debian/ser-mysql-modules \
151
-		cfg-target=/etc/ser/ \
152
-		doc-dir=share/doc/ser-mysql-modules \
153
-		skip_modules="$(EXTRA_EXCLUDED_MODULES)"
154
-	#install only the jabber module
155
-	#$(MAKE) install-modules-all modules="$(JABBER_MOD_PATH)"  \
156
-	#	basedir=$(CURDIR)/debian/ser-jabber-module \
157
-	#	prefix=/usr \
158
-	#	cfg-prefix=$(CURDIR)/debian/ser-jabber-module \
159
-	#	cfg-target=/etc/ser/ \
160
-	#	doc-dir=share/doc/ser-jabber-module \
161
-	#	skip_modules="$(EXTRA_EXCLUDED_MODULES)"
162
-	#install only the radius modules
163
-	#$(MAKE) install-modules-all group_include="radius"  \
164
-	#	basedir=$(CURDIR)/debian/ser-radius-modules \
165
-	#	prefix=/usr \
166
-	#	cfg-prefix=$(CURDIR)/debian/ser-radius-modules \
167
-	#	cfg-target=/etc/ser/ \
168
-	#	doc-dir=share/doc/ser-radius-modules \
169
-	#	skip_modules="$(EXTRA_EXCLUDED_MODULES)"
170
-	#install only the cpl module
171
-	#$(MAKE) install-modules-all modules="$(CPL_MOD_PATH)"  \
172
-	#	basedir=$(CURDIR)/debian/ser-cpl-module \
173
-	#	prefix=/usr \
174
-	#	cfg-prefix=$(CURDIR)/debian/ser-cpl-module \
175
-	#	cfg-target=/etc/ser/ \
176
-	#	doc-dir=share/doc/ser-cpl-module \
177
-	#	skip_modules="$(EXTRA_EXCLUDED_MODULES)"
178
-	#install only the presence modules
179
-	#$(MAKE) install-modules-all group_include="presence"  \
180
-	#	basedir=$(CURDIR)/debian/ser-presence-modules \
181
-	#	prefix=/usr \
182
-	#	cfg-prefix=$(CURDIR)/debian/ser-presence-modules \
183
-	#	cfg-target=/etc/ser/ \
184
-	#	doc-dir=share/doc/ser-presence-modules \
185
-	#	skip_modules="$(EXTRA_EXCLUDED_MODULES)"
186
-	#install only the postgres module
187
-	#$(MAKE) install-modules-all modules="$(POSTGRES_MOD_PATH)"  \
188
-	#	basedir=$(CURDIR)/debian/ser-postgres-module \
189
-	#	prefix=/usr \
190
-	#	cfg-prefix=$(CURDIR)/debian/ser-postgres-module \
191
-	#	cfg-target=/etc/ser/ \
192
-	#	doc-dir=share/doc/ser-postgres-module \
193
-	#	skip_modules="$(EXTRA_EXCLUDED_MODULES)"
194
-	#install only the xmlrpc module
195
-	$(MAKE) clean_cfg
196
-	$(MAKE) clean_modules_cfg
197
-	$(MAKE) install-modules-all modules="$(XMLRPC_MOD_PATH)"  \
120
+		doc-dir=share/doc/ser-mysql-modules
121
+	$(MAKE) install-modules-all group_include="radius" \
122
+		basedir=$(CURDIR)/debian/ser-radius-modules \
123
+		cfg-prefix=$(CURDIR)/debian/ser-radius-modules \
124
+		doc-dir=share/doc/ser-radius-modules
125
+	$(MAKE) install-modules-all modules="$(POSTGRES_MOD_PATH)" \
126
+		modules_s="" modules_k="" \
127
+		basedir=$(CURDIR)/debian/ser-postgres-module \
128
+		doc-dir=share/doc/ser-postgress-module
129
+	$(MAKE) install-modules-all modules="$(TLS_MOD_PATH)" \
130
+		modules_s="" modules_k="" \
131
+		basedir=$(CURDIR)/debian/ser-tls-module \
132
+		doc-dir=share/doc/ser-tls-module
133
+	$(MAKE) install-modules-all modules="$(XMLRPC_MOD_PATH)" \
134
+		modules_s="" modules_k="" \
198 135
 		basedir=$(CURDIR)/debian/ser-xmlrpc-module \
199
-		prefix=/usr \
200
-		cfg-prefix=$(CURDIR)/debian/ser-xmlrpc-module \
201
-		cfg-target=/etc/ser/ \
202
-		doc-dir=share/doc/ser-xmlrpc-module \
203
-		skip_modules="$(EXTRA_EXCLUDED_MODULES)"
136
+		doc-dir=share/doc/ser-xmlrpc-module
204 137
 	# install /etc/default/ser file
205 138
 	mkdir -p $(CURDIR)/debian/ser/etc/default
206 139
 	cp -f debian/ser.default $(CURDIR)/debian/ser/etc/default/ser
207 140
 	# install the *.sql files for ser_mysql.sh script
208 141
 	cp -f scripts/mysql/*.sql $(CURDIR)/debian/ser/usr/lib/ser/
209 142
 	# and fix path to the *.sql files in ser_mysql.sh script
210
-	sed -i 's#DEFAULT_SCRIPT_DIR=.*#DEFAULT_SCRIPT_DIR="/usr/lib/ser/"#' $(CURDIR)/debian/ser/usr/sbin/ser_mysql.sh
143
+	sed -i 's#DEFAULT_SCRIPT_DIR=.*#DEFAULT_SCRIPT_DIR="/usr/lib/ser/"#' \
144
+		$(CURDIR)/debian/ser/usr/sbin/ser_mysql.sh
211 145
 	# install advanced ser config file for ser-oob package
212 146
 	mkdir -p $(CURDIR)/debian/ser-oob/etc/ser
213
-	cp -f etc/ser-oob.cfg $(CURDIR)/debian/ser-oob/etc/ser/
214
-	# and remove it from main ser package
215
-	rm -f $(CURDIR)/debian/ser/etc/ser/ser-oob.cfg
147
+	cp -f etc/sip-router-oob.cfg $(CURDIR)/debian/ser-oob/etc/ser/ser-oob.cfg
216 148
 	#dh_movefiles
217 149
 
218 150
 
... ...
@@ -179,7 +179,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
179 179
 
180 180
 		set_route_type(REQUEST_ROUTE);
181 181
 		/* exec the routing script */
182
-		if (run_top_route(main_rt.rlist[DEFAULT_RT], msg)<0){
182
+		if (run_top_route(main_rt.rlist[DEFAULT_RT], msg, 0)<0){
183 183
 			LOG(L_WARN, "WARNING: receive_msg: "
184 184
 					"error while trying script\n");
185 185
 			goto error_req;
... ...
@@ -222,7 +222,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
222 222
 		/* exec the onreply routing script */
223 223
 		if (onreply_rt.rlist[DEFAULT_RT]){
224 224
 			set_route_type(ONREPLY_ROUTE);
225
-			ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg);
225
+			ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg, 0);
226 226
 			if (ret<0){
227 227
 				LOG(L_WARN, "WARNING: receive_msg: "
228 228
 						"error while trying onreply script\n");
... ...
@@ -109,6 +109,7 @@ enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
109 109
 #define EXIT_R_F   1
110 110
 #define RETURN_R_F 2
111 111
 #define BREAK_R_F  4
112
+#define DROP_R_F   8
112 113
 
113 114
 
114 115
 struct cfg_pos{