2
0
Эх сурвалжийг харах

Merge branch 'master' of ssh://[email protected]/sip-router

* 'master' of ssh://[email protected]/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 16 жил өмнө
parent
commit
b70792cb87

+ 14 - 3
INSTALL

@@ -171,7 +171,11 @@ Compile SIP Router core only:
 make   #builds only sip-router core, equivalent to make sip-router
 
 Compile modules except some explicitly excepted (see below)
-make modules  
+make modules  - all modules in the modules/ directory (common modules)
+make modules_s - all modules in the modules_s/ directory (ser modules)
+make modules_k - all modules in the modules_k/ directory (kamailio modules)
+make modules-all or make every-module  - all the modules (modules, modules_s
+                                         and module_k)
 
 Compile all:
 make all
@@ -189,7 +193,12 @@ standard - Modules in this group are considered a standard part of SIP Router (d
     but they have no dependencies (note that some of these interplay with external systems.
     However, they don't have compile or link dependencies).
 
-standard-dep -  Modules in this group are considered a standard part of SIP Router (due to widespread usage)
+db - Modules in this group use databases and need a database driver to run.
+     Included are drivers for the text mode db (dbtext) and for dumping
+     large ammount of data to files (db_flatstore). See also the mysql or
+     postgres groups.
+
+standard_dep -  Modules in this group are considered a standard part of SIP Router (due to widespread usage)
     but they have dependencies that most be satisfied for compilation.
     NOTE! All presence modules (dialog, pa, presence_b2b, rls, xcap) have been included in this
     group due to interdependencies
@@ -208,7 +217,9 @@ make group_include="standard standard-dep stable experimental" all
 
 There are also in addition some "convenience" groups:
 
-mysql - Include all modules dependent on mysql
+mysql - Include all the db modules dependent and the mysql db driver
+
+postgres - Include all the db modules and the postgres db driver
 
 radius - Include all modules on radiusclient
 

+ 20 - 29
Makefile

@@ -155,9 +155,17 @@ module_group_standard_dep=acc_db acc_radius auth_db auth_radius avp_db \
 				db_ops domain lcr msilo mysql dialog pa postgres \
 				presence_b2b rls speeddial uri_db xcap xmlrpc
 
+# For db use (db modules, excluding drivers)
+module_group_db=acc_db auth_db avp_db db_ops db_flatstore dbtext db_text \
+				uri_db domain lcr msilo speeddial
+
 # For mysql
-module_group_mysql=acc_db auth_db avp_db db_ops uri_db domain lcr msilo mysql\
-				speeddial
+module_group_mysql_driver=db_mysql
+module_group_mysql=$(module_group_mysql_driver) $(module_group_db)
+
+# For postgress
+module_group_postgres_driver=db_postgres
+module_group_postgres=$(module_group_postgres_driver) $(module_group_db)
 
 # For radius
 module_group_radius=acc_radius auth_radius avp_radius misc_radius peering
@@ -212,32 +220,9 @@ endif
 override exclude_modules+= CVS $(skip_modules)
 
 # Test for the groups and add to include_modules
-ifneq (,$(findstring standard,$(group_include)))
-	override include_modules+= $(module_group_standard)
-endif
-
-ifneq (,$(findstring standard-dep,$(group_include)))
-	override include_modules+= $(module_group_standard_dep)
-endif
-
-ifneq (,$(findstring mysql,$(group_include)))
-	override include_modules+= $(module_group_mysql)
-endif
-
-ifneq (,$(findstring radius,$(group_include)))
-	override include_modules+= $(module_group_radius)
-endif
-
-ifneq (,$(findstring presence,$(group_include)))
-	override include_modules+= $(module_group_presence)
-endif
-
-ifneq (,$(findstring stable,$(group_include)))
-	override include_modules+= $(module_group_stable)
-endif
-
-ifneq (,$(findstring experimental,$(group_include)))
-	override include_modules+= $(module_group_experimental)
+ifneq (,$(group_include))
+override include_modules+=$(foreach grp, $(group_include), \
+								$(module_group_$(grp)) )
 endif
 
 # first 2 lines are excluded because of the experimental or incomplete
@@ -264,6 +249,9 @@ ifeq ($(makefile_defs),1)
 $(info config.mak loaded)
 # config_make valid & used
 config_mak=1
+ifeq ($(MAIN_NAME),)
+$(error "bad config.mak, try re-running make cfg")
+endif
 endif
 else # config.mak doesn't need to be used
 ifneq (,$(filter cfg config cfg-defs,$(word 1,$(MAKECMDGOALS))))
@@ -273,6 +261,9 @@ ifneq (,$(filter cfg config cfg-defs,$(word 1,$(MAKECMDGOALS))))
 # $(value ...) expansion or would cause some warning (if Makefile.defs exec. 
 # is skipped in the "main" makefile invocation).
 $(shell rm -rf config.mak)
+config_mak=0
+makefile_defs=0
+exported_vars=0
 endif
 endif
 
@@ -621,7 +612,7 @@ $(foreach mods,$(modules_dirs),$(eval $(call MODULES_RULES_template,$(mods))))
 #$(foreach mods,$(modules_dirs),$(eval  $(info DUMP: $(call MODULES_RULES_template,$(mods)))))
 
 # build all the modules
-every-module: $(modules_dirs)
+modules-all every-module: $(modules_dirs)
 
 $(extra_objs):
 	@echo "Extra objs: $(extra_objs)" 

+ 1 - 0
Makefile.cfg

@@ -14,6 +14,7 @@
 #create config if needed
 $(COREPATH)/config.mak: makefile_defs=0
 $(COREPATH)/config.mak: exported_vars=0
+$(COREPATH)/config.mak: config_mak=0
 
 $(COREPATH)/config.mak: $(COREPATH)/Makefile.defs
 	$(MAKE) -wC $(COREPATH) cfg-defs

+ 2 - 2
Makefile.targets

@@ -35,9 +35,9 @@ doc_targets:=	README man install-doc install-man install-ser-man \
 # auxiliary: maintance, debugging, etc. (don't affect code/objects)
 aux_targets:=	TAGS tar dist cfg-defs cfg config config.mak print-modules \
 		dbg dbinstall librpath.lst makecfg.lst modules.lst modules-cfg \
-		modules-list modules-lst mk-install_dirs autover.h
+		modules-list modules-lst mk-install_dirs autover.h deb
 # other targets that don't produce code in the current directory ("external")
-ext_targets:=	every-module $(modules_dirs) libs utils \
+ext_targets:=	every-module modules-all $(modules_dirs) libs utils \
 		install-cfg install-utils  install-modules-all install-every-module\
 		$(foreach m,$(modules_dirs),install-$(m)) \
 		install-share

+ 5 - 3
action.c

@@ -1292,11 +1292,13 @@ error:
 }
 
 
-int run_top_route(struct action* a, sip_msg_t* msg)
+int run_top_route(struct action* a, sip_msg_t* msg, struct run_act_ctx *c)
 {
 	struct run_act_ctx ctx;
+	struct run_act_ctx *p;
+	p = (c)?c:&ctx;
 	setsflagsval(0);
 	reset_static_buffer();
-	init_run_actions_ctx(&ctx);
-	return run_actions(&ctx, a, msg);
+	init_run_actions_ctx(p);
+	return run_actions(p, a, msg);
 }

+ 1 - 1
action.h

@@ -59,6 +59,6 @@ struct run_act_ctx{
 int do_action(struct run_act_ctx* c, struct action* a, struct sip_msg* msg);
 int run_actions(struct run_act_ctx* c, struct action* a, struct sip_msg* msg);
 
-int run_top_route(struct action* a, sip_msg_t* msg);
+int run_top_route(struct action* a, sip_msg_t* msg, struct run_act_ctx* c);
 
 #endif

+ 3 - 1
cfg.lex

@@ -149,7 +149,8 @@ FORWARD_TCP	forward_tcp
 FORWARD_UDP	forward_udp
 FORWARD_TLS	forward_tls
 FORWARD_SCTP	forward_sctp
-DROP	"drop"|"exit"
+DROP	"drop"
+EXIT	"exit"
 RETURN	"return"
 BREAK	"break"
 SEND	send
@@ -486,6 +487,7 @@ EAT_ABLE	[\ \t\b\r]
 <INITIAL>{FORWARD_SCTP}	{count(); yylval.strval=yytext; return FORWARD_SCTP;}
 <INITIAL>{FORWARD_UDP}	{count(); yylval.strval=yytext; return FORWARD_UDP; }
 <INITIAL>{DROP}	{ count(); yylval.strval=yytext; return DROP; }
+<INITIAL>{EXIT}	{ count(); yylval.strval=yytext; return EXIT; }
 <INITIAL>{RETURN}	{ count(); yylval.strval=yytext; return RETURN; }
 <INITIAL>{BREAK}	{ count(); yylval.strval=yytext; return BREAK; }
 <INITIAL>{SEND}	{ count(); yylval.strval=yytext; return SEND; }

+ 19 - 2
cfg.y

@@ -265,6 +265,7 @@ static int case_check_default(struct case_stms* stms);
 %token FORWARD_UDP
 %token SEND
 %token SEND_TCP
+%token EXIT
 %token DROP
 %token RETURN
 %token BREAK
@@ -2940,18 +2941,34 @@ func_param:
 
 ret_cmd:
 	DROP LPAREN RPAREN		{
-		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); 
+		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST,
+						(void*)(DROP_R_F|EXIT_R_F)); 
 	}
 	| DROP rval_expr	{
-		$$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST, (void*)EXIT_R_F);
+		$$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST,
+						(void*)(DROP_R_F|EXIT_R_F)); 
 	}
 	| DROP				{
+		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, 
+						(void*)(DROP_R_F|EXIT_R_F)); 
+	}
+	| EXIT LPAREN RPAREN		{
+		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); 
+	}
+	| EXIT rval_expr	{
+		$$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST, (void*)EXIT_R_F);
+	}
+	| EXIT				{
 		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); 
 	}
 	| RETURN			{
 		$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST,
 						(void*)RETURN_R_F);
 	}
+	| RETURN  LPAREN RPAREN		{
+		$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST,
+						(void*)RETURN_R_F);
+	}
 	| RETURN rval_expr	{
 		$$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST, (void*)RETURN_R_F);
 	}

+ 1 - 1
config.h

@@ -44,7 +44,7 @@
 #define SIP_PORT  5060
 #define SIPS_PORT 5061
 
-#define CFG_FILE CFG_DIR "sip-router.cfg"
+#define CFG_FILE CFG_DIR NAME ".cfg"
 
 #define TLS_PKEY_FILE "cert.pem" 
 #define TLS_CERT_FILE "cert.pem"

+ 1 - 1
modules/tm/t_fwd.c

@@ -196,7 +196,7 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
 		set_route_type(BRANCH_ROUTE);
 		tm_ctx_set_branch_index(branch+1);
 		if (exec_pre_script_cb(i_req, BRANCH_CB_TYPE)>0) {
-			if (run_top_route(branch_rt.rlist[branch_route], i_req) < 0) {
+			if (run_top_route(branch_rt.rlist[branch_route], i_req, 0) < 0) {
 				LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n");
 			}
 			exec_post_script_cb(i_req, BRANCH_CB_TYPE);

+ 3 - 3
modules/tm/t_reply.c

@@ -868,7 +868,7 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 		t->on_negative=0;
 		if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
 			/* run a reply_route action if some was marked */
-			if (run_top_route(failure_rt.rlist[on_failure], &faked_req)<0)
+			if (run_top_route(failure_rt.rlist[on_failure], &faked_req, 0)<0)
 				LOG(L_ERR, "ERROR: run_failure_handlers: Error in run_top_route\n");
 			exec_post_script_cb(&faked_req, FAILURE_CB_TYPE);
 		}
@@ -1976,7 +1976,7 @@ int reply_received( struct sip_msg  *p_msg )
 		/* Pre- and post-script callbacks have already
 		 * been execueted by the core. (Miklos)
 		 */
-		if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg)<0)
+		if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg, 0)<0)
 			LOG(L_ERR, "ERROR: on_reply processing failed\n");
 		/* transfer current message context back to t */
 		if (t->uas.request) t->uas.request->flags=p_msg->flags;
@@ -2108,7 +2108,7 @@ trans_not_found:
 		 * Pre- and post-script callbacks have already
 		 * been execueted by the core. (Miklos)
 		 */
-		return run_top_route(onreply_rt.rlist[goto_on_sl_reply], p_msg);
+		return run_top_route(onreply_rt.rlist[goto_on_sl_reply], p_msg, 0);
 	} else {
 		/* let the core forward the reply */
 		return 1;

+ 1 - 1
modules/tm/t_suspend.c

@@ -161,7 +161,7 @@ int t_continue(unsigned int hash_index, unsigned int label,
 	 * of failure route (Miklos)
 	 */
 	if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
-		if (run_top_route(route, &faked_req)<0)
+		if (run_top_route(route, &faked_req, 0)<0)
 			LOG(L_ERR, "ERROR: t_continue: Error in run_top_route\n");
 		exec_post_script_cb(&faked_req, FAILURE_CB_TYPE);
 	}

+ 1 - 1
modules_k/cpl-c/cpl_sig.c

@@ -102,7 +102,7 @@ int cpl_proxy_to_loc_set( struct sip_msg *msg, struct location **locs,
 	/* run what proxy route is set */
 	if (cpl_env.proxy_route) {
 		/* do not alter route type - it might be REQUEST or FAILURE */
-		run_top_route( main_rt.rlist[cpl_env.proxy_route], msg);
+		run_top_route( main_rt.rlist[cpl_env.proxy_route], msg, 0);
 	}
 
 	/* do t_forward */

+ 1 - 1
modules_k/dialog/dlg_handlers.c

@@ -973,7 +973,7 @@ void dlg_ontimeout( struct dlg_tl *tl)
 		{
 			LM_DBG("executing route %d on timeout\n", dlg->toroute);
 			set_route_type(REQUEST_ROUTE);
-			run_top_route(main_rt.rlist[dlg->toroute], fmsg);
+			run_top_route(main_rt.rlist[dlg->toroute], fmsg, 0);
 			exec_post_script_cb(fmsg, REQUEST_CB_TYPE);
 		}
 	}

+ 2 - 2
modules_k/drouting/drouting.c

@@ -619,7 +619,7 @@ static int use_next_gw(struct sip_msg* msg)
 
 	if (!avp) return -1;
 
-	if (rewrite_ruri(msg, &val)==-1) {
+	if (rewrite_ruri(msg, val.s.s)==-1) {
 		LM_ERR("failed to rewite RURI\n");
 		return -1;
 	}
@@ -732,7 +732,7 @@ again:
 	}
 
 	if (rt_info->route_idx>0 && rt_info->route_idx<RT_NO) {
-		ret = run_top_route(main_rt.rlist[rt_info->route_idx], msg );
+		ret = run_top_route(main_rt.rlist[rt_info->route_idx], msg, 0);
 		if (ret<1) {
 			/* drop the action */
 			LM_DBG("script route %d drops routing "

+ 1 - 1
modules_k/htable/htable.c

@@ -184,7 +184,7 @@ static int child_init(int rank)
 		fmsg = faked_msg_next();
 		rtb = get_route_type();
 		set_route_type(REQUEST_ROUTE);
-		run_top_route(event_rt.rlist[rt], fmsg);
+		run_top_route(event_rt.rlist[rt], fmsg, 0);
 		set_route_type(rtb);
 	}
 

+ 29 - 1
modules_k/kex/core_stats.c

@@ -38,6 +38,8 @@
 #include "../../lib/kmi/mi.h"
 #include "../../dprint.h"
 #include "../../timer.h"
+#include "../../parser/msg_parser.h"
+#include "../../script_cb.h"
 #include "../../mem/meminfo.h"
 #include "../../mem/shm_mem.h"
 
@@ -102,12 +104,29 @@ static mi_export_t mi_stat_cmds[] = {
 int register_mi_stats(void)
 {
 	/* register MI commands */
-	if (register_mi_mod( "core", mi_stat_cmds)<0) {
+	if (register_mi_mod("core", mi_stat_cmds)<0) {
 		LM_ERR("unable to register MI cmds\n");
 		return -1;
 	}
 	return 0;
 }
+
+static int km_cb_req_stats(struct sip_msg *msg,
+		unsigned int flags, void *param)
+{
+	update_stat(rcv_reqs, 1);
+	if(msg->first_line.u.request.method_value==METHOD_OTHER)
+		update_stat(unsupported_methods, 1);
+	return 1;
+}
+
+static int km_cb_rpl_stats(struct sip_msg *msg,
+		unsigned int flags, void *param)
+{
+	update_stat(rcv_rpls, 1);
+	return 1;
+}
+
 int register_core_stats(void)
 {
 	/* register core statistics */
@@ -120,6 +139,15 @@ int register_core_stats(void)
 		LM_ERR("failed to register sh_mem statistics\n");
 		return -1;
 	}
+	if (register_script_cb(km_cb_req_stats, PRE_SCRIPT_CB|REQUEST_CB, 0)<0 ) {
+		LM_ERR("failed to register PRE request callback\n");
+		return -1;
+	}
+	if (register_script_cb(km_cb_rpl_stats, PRE_SCRIPT_CB|ONREPLY_CB, 0)<0 ) {
+		LM_ERR("failed to register PRE request callback\n");
+		return -1;
+	}
+
 	return 0;
 }
 

+ 1 - 1
modules_k/rtimer/rtimer_mod.c

@@ -191,7 +191,7 @@ void stm_timer_exec(unsigned int ticks, void *param)
 		if (exec_pre_script_cb(&_stm_msg, REQUEST_CB_TYPE)==0 )
 			continue; /* drop the request */
 		set_route_type(REQUEST_ROUTE);
-		run_top_route(main_rt.rlist[rt->route], &_stm_msg);
+		run_top_route(main_rt.rlist[rt->route], &_stm_msg, 0);
 		exec_post_script_cb(&_stm_msg, REQUEST_CB_TYPE);
 	}
 }

+ 25 - 9
modules_s/prefix_route/tree.c

@@ -34,6 +34,8 @@
 #include "../../atomic_ops.h"
 #include "../../mem/shm_mem.h"
 #include "../../str.h"
+#include "../../lock_alloc.h"
+#include "../../lock_ops.h"
 #include "tree.h"
 
 
@@ -59,7 +61,7 @@ struct tree {
 
 /* Local variables */
 static struct tree **shared_tree = NULL;
-static gen_lock_t shared_tree_lock;
+static gen_lock_t* shared_tree_lock;
 
 
 /**
@@ -286,9 +288,9 @@ static struct tree *tree_get(void)
 {
 	struct tree *tree;
 
-	lock_get(&shared_tree_lock);
+	lock_get(shared_tree_lock);
 	tree = *shared_tree;
-	lock_release(&shared_tree_lock);
+	lock_release(shared_tree_lock);
 
 	return tree;
 }
@@ -298,10 +300,10 @@ static struct tree *tree_ref(void)
 {
 	struct tree *tree;
 
-	lock_get(&shared_tree_lock);
+	lock_get(shared_tree_lock);
 	tree = *shared_tree;
 	atomic_inc(&tree->refcnt);
-	lock_release(&shared_tree_lock);
+	lock_release(shared_tree_lock);
 
 	return tree;
 }
@@ -318,11 +320,18 @@ struct tree *tree_deref(struct tree *tree)
 int tree_init(void)
 {
 	/* Initialize lock */
-	lock_init(&shared_tree_lock);
+	shared_tree_lock = lock_alloc();
+	if (NULL == shared_tree_lock) {
+		return -1;
+	}
+	lock_init(shared_tree_lock);
 
 	/* Pointer to global tree must be in shared memory */
 	shared_tree = (struct tree **)shm_malloc(sizeof(*shared_tree));
 	if (NULL == shared_tree) {
+		lock_destroy(shared_tree_lock);
+		lock_dealloc(shared_tree_lock);
+		shared_tree_lock=0;
 		return -1;
 	}
 
@@ -334,7 +343,14 @@ int tree_init(void)
 
 void tree_close(void)
 {
-	tree_flush(tree_get());
+	if (shared_tree)
+		tree_flush(tree_get());
+	shared_tree = NULL;
+	if (shared_tree_lock) {
+		lock_destroy(shared_tree_lock);
+		lock_dealloc(shared_tree_lock);
+		shared_tree_lock=0;
+	}
 }
 
 
@@ -352,9 +368,9 @@ int tree_swap(struct tree_item *root)
 	old_tree = tree_get();
 
 	/* Critical - swap trees */
-	lock_get(&shared_tree_lock);
+	lock_get(shared_tree_lock);
 	*shared_tree = new_tree;
-	lock_release(&shared_tree_lock);
+	lock_release(shared_tree_lock);
 
 	/* Flush old tree */
 	tree_flush(old_tree);

+ 6 - 0
pkg/debian/changelog

@@ -1,3 +1,9 @@
+ser (2.99.0-dev01) unstable; urgency=low
+
+  * Update Debian specification for sip-router.
+
+ -- Andrei Pelinescu-Onciul <[email protected]>  Wed, 08 Jul 2009 14:13:11 +0200
+
 ser (2.1.0-0dev15) unstable; urgency=low
 
   * Added installation of *.sql files for ser_mysql.sh script.

+ 17 - 10
pkg/debian/control

@@ -59,13 +59,20 @@ Description: contains the ser RADIUS modules
  depend upon libradius1. This modules will enable you to authenticate, 
  do group membership checking or check the messages uris using RADIUS.
 
-#Package: ser-postgres-module
-#Architecture: any
-#Depends: ${shlibs:Depends}, ser (= ${Source-Version})
-#Description: contains the PostgreSQL database connectivity module
-# This has been split out of the main ser package, so that ser will not
-# depend upon libpq. This module will enable you to use the digest
-# authentication module or persistent user location entries.
+Package: ser-postgres-module
+Architecture: any
+Depends: ${shlibs:Depends}, ser (= ${Source-Version})
+Description: contains the PostgreSQL database connectivity module
+ This has been split out of the main ser package, so that ser will not
+ depend upon libpq. This module will enable you to use the digest
+ authentication module or persistent user location entries.
+
+Package: ser-tls-module
+Architecture: any
+Depends: ${shlibs:Depends}, ser (= ${Source-Version})
+Description: contains the TLS ser transport module
+ This has been split out of the main ser package, so that ser will not
+ depend on openssl. This module will enable you to use the TLS transport.
 
 Package: ser-xmlrpc-module
 Architecture: any
@@ -78,7 +85,7 @@ Description: contains the XML-RPC based interface to SER
 
 Package: ser-oob
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, ser, ser-mysql-modules, ser-xmlrpc-module, serctl
+Depends: ser, ser-mysql-modules, ser-xmlrpc-module, serctl
 Suggests: rttpproxy, logrotate, ngrep, ntp
 Description: Sip Express Router - package for "out of the box" installation
  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
 
 Package: ser-nth
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, screen, gdb, binutils, gcc, bison, flex, ngrep, tcpdump, iftop, lsof, psmisc, vim, bvi, most, serctl, mc, sipsak
+Depends: screen, gdb, binutils, gcc, bison, flex, ngrep, tcpdump, iftop, lsof, psmisc, vim, bvi, most, serctl, mc, sipsak
 Description: Sip Express Router - package for "nice to have" installation
  This is a meta-package for easy installation various useful tools that may be
  handy on server with SER installed.
 
 Package: ser-ai1
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, ser-oob, mysql-server, rtpproxy, mystun, sipsak, tcpdump, ngrep, iftop, serweb, sems
+Depends: ser-oob, mysql-server, rtpproxy, mystun, sipsak, tcpdump, ngrep, iftop, serweb, sems
 Suggests: ser-nth
 Description: Sip Express Router - package for "all in one" installation
  This is a meta-package for easy installation of complete server running ser - SIP Express

+ 42 - 110
pkg/debian/rules

@@ -23,6 +23,7 @@
 #              added ser-oob package
 #                (pavel)
 #  2007-10-31  updated for cvs head (pavel)
+#  2009-07-08  updated for sip-router (andrei)
 
 
 # Uncomment this to turn on verbose mode.
@@ -43,31 +44,23 @@ EXCLUDED_MODULES=	jabber xmlrpc postgres cpl cpl-c
 #EXTRA_EXCLUDED_MODULES=	cpl-c avpops flatstore pdt lcr msilo bdb dbtext iptrtpproxy ldap oracle osp pa rls
 EXTRA_EXCLUDED_MODULES=
 
-### modules depending on mysql
-##MYSQL_MODULES=mysql
-#jabber related modules
-JABBER_MODULES=jabber
-###module depending on radiusclient
-##RADIUS_MODULES=acc_radius auth_radius group_radius uri_radius avp_radius
-#cpl related modules
-CPL_MODULES=cpl-c
-### pa related modules
-##PA_MODULES=pa rls dialog presence_b2b xcap
 # postgres modules
-POSTGRES_MODULES=postgres
+POSTGRES_MODULES=db_postgres
+# tls module
+TLS_MODULES=tls
 # xmlrpc module
 XMLRPC_MODULES=xmlrpc
 
 # the same but with path prepended (needed for modules="...")
 ##MYSQL_MOD_PATH=$(addprefix modules/, $(MYSQL_MODULES))
-JABBER_MOD_PATH=$(addprefix modules/, $(JABBER_MODULES))
+JABBER_MOD_PATH=$(addprefix modules_s/, $(JABBER_MODULES))
 ##RADIUS_MOD_PATH=$(addprefix modules/, $(RADIUS_MODULES))
-CPL_MOD_PATH=$(addprefix modules/, $(CPL_MODULES))
+CPL_MOD_PATH=$(addprefix modules_s/, $(CPL_MODULES))
 ##PA_MOD_PATH=$(addprefix modules/, $(PA_MODULES))
 POSTGRES_MOD_PATH=$(addprefix modules/, $(POSTGRES_MODULES))
-XMLRPC_MOD_PATH=$(addprefix modules/, $(XMLRPC_MODULES))
+TLS_MOD_PATH=$(addprefix modules/, $(TLS_MODULES))
+XMLRPC_MOD_PATH=$(addprefix modules_s/, $(XMLRPC_MODULES))
 
-SERCTL_PATH=tools/serctl
 
 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
 	CFLAGS += -g
@@ -80,6 +73,11 @@ configure: configure-stamp
 configure-stamp:
 	dh_testdir
 	# Add here commands to configure the package.
+	$(MAKE) cfg prefix=/usr cfg-prefix=$(CURDIR)/debian/ser \
+			cfg_target=/etc/ser/ \
+			basedir=$(CURDIR)/debian/ser \
+			skip_modules="$(EXCLUDED_MODULES) $(EXTRA_EXCLUDED_MODULES)" \
+			group_include="standard"
 
 	touch configure-stamp
 
@@ -88,41 +86,22 @@ build: build-stamp
 
 build-stamp: configure-stamp 
 	dh_testdir
-
 	# Add here commands to compile the package.
-	$(MAKE) clean_cfg
-	$(MAKE) clean_modules_cfg
-	$(MAKE) all group_include="standard" skip_modules="$(EXCLUDED_MODULES) $(EXTRA_EXCLUDED_MODULES)" cfg-target=/etc/ser/ prefix=/usr
-	$(MAKE) clean_cfg
-	$(MAKE) clean_modules_cfg
-	$(MAKE) modules group_include="mysql" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	#$(MAKE) modules modules="$(JABBER_MOD_PATH)" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	$(MAKE) clean_cfg
-	$(MAKE) clean_modules_cfg
-	$(MAKE) modules group_include="radius" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	#$(MAKE) modules modules="$(CPL_MOD_PATH)" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	#$(MAKE) modules group_include="presence" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	#$(MAKE) modules modules="$(POSTGRES_MOD_PATH)" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	$(MAKE) clean_cfg
-	$(MAKE) clean_modules_cfg
-	$(MAKE) modules modules="$(XMLRPC_MOD_PATH)" cfg-target=/etc/ser/ prefix=/usr skip_modules="$(EXTRA_EXCLUDED_MODULES)"
+	$(MAKE) all
+	$(MAKE) every-module group_include="mysql"
+	$(MAKE) every-module group_include="radius"
+	$(MAKE) modules modules="$(POSTGRES_MOD_PATH)"
+	$(MAKE) modules modules="$(TLS_MOD_PATH)"
+	$(MAKE) modules modules="$(XMLRPC_MOD_PATH)"
 	#/usr/bin/docbook-to-man debian/ser.sgml > ser.1
-
 	touch build-stamp
 
 clean:
 	dh_testdir
 	dh_testroot
 	rm -f build-stamp configure-stamp
-
 	# Add here commands to clean up after the build process.
-	#-$(MAKE) -C lib -f Makefile.ser proper
-	#-$(MAKE) include_modules=" $(JABBER_MODULES) $(CPL_MODULES) \
-	#	$(POSTGRES_MODULES) $(XMLRPC_MODULES)" proper
-	-$(MAKE) proper
-	-$(MAKE) clean_cfg
-	-$(MAKE) clean_modules_cfg
-
+	-$(MAKE) maintainer-clean
 	dh_clean
 
 install: build
@@ -130,89 +109,42 @@ install: build
 	dh_testroot
 	dh_clean -k
 	dh_installdirs
-
 	# Add here commands to install the package into debian/ser
-	$(MAKE) clean_cfg
-	$(MAKE) clean_modules_cfg
-	$(MAKE) install group_include="standard" skip_modules="$(EXCLUDED_MODULES) $(EXTRA_EXCLUDED_MODULES)" \
-		basedir=$(CURDIR)/debian/ser \
-		prefix=/usr \
-		cfg-prefix=$(CURDIR)/debian/ser \
-		cfg-target=/etc/ser/
-	# fix etc/ser dir location
-	mv -f $(CURDIR)/debian/ser/usr/etc $(CURDIR)/debian/ser
+	$(MAKE) install group_include="standard"
+	# fix etc/ser dir location -- not needed -- andrei
+	# mv -f $(CURDIR)/debian/ser/usr/etc $(CURDIR)/debian/ser
 	# install only the mysql module
-	$(MAKE) clean_cfg
-	$(MAKE) clean_modules_cfg
 	$(MAKE) install-modules-all group_include="mysql" \
 		basedir=$(CURDIR)/debian/ser-mysql-modules \
-		prefix=/usr \
 		cfg-prefix=$(CURDIR)/debian/ser-mysql-modules \
-		cfg-target=/etc/ser/ \
-		doc-dir=share/doc/ser-mysql-modules \
-		skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	#install only the jabber module
-	#$(MAKE) install-modules-all modules="$(JABBER_MOD_PATH)"  \
-	#	basedir=$(CURDIR)/debian/ser-jabber-module \
-	#	prefix=/usr \
-	#	cfg-prefix=$(CURDIR)/debian/ser-jabber-module \
-	#	cfg-target=/etc/ser/ \
-	#	doc-dir=share/doc/ser-jabber-module \
-	#	skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	#install only the radius modules
-	#$(MAKE) install-modules-all group_include="radius"  \
-	#	basedir=$(CURDIR)/debian/ser-radius-modules \
-	#	prefix=/usr \
-	#	cfg-prefix=$(CURDIR)/debian/ser-radius-modules \
-	#	cfg-target=/etc/ser/ \
-	#	doc-dir=share/doc/ser-radius-modules \
-	#	skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	#install only the cpl module
-	#$(MAKE) install-modules-all modules="$(CPL_MOD_PATH)"  \
-	#	basedir=$(CURDIR)/debian/ser-cpl-module \
-	#	prefix=/usr \
-	#	cfg-prefix=$(CURDIR)/debian/ser-cpl-module \
-	#	cfg-target=/etc/ser/ \
-	#	doc-dir=share/doc/ser-cpl-module \
-	#	skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	#install only the presence modules
-	#$(MAKE) install-modules-all group_include="presence"  \
-	#	basedir=$(CURDIR)/debian/ser-presence-modules \
-	#	prefix=/usr \
-	#	cfg-prefix=$(CURDIR)/debian/ser-presence-modules \
-	#	cfg-target=/etc/ser/ \
-	#	doc-dir=share/doc/ser-presence-modules \
-	#	skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	#install only the postgres module
-	#$(MAKE) install-modules-all modules="$(POSTGRES_MOD_PATH)"  \
-	#	basedir=$(CURDIR)/debian/ser-postgres-module \
-	#	prefix=/usr \
-	#	cfg-prefix=$(CURDIR)/debian/ser-postgres-module \
-	#	cfg-target=/etc/ser/ \
-	#	doc-dir=share/doc/ser-postgres-module \
-	#	skip_modules="$(EXTRA_EXCLUDED_MODULES)"
-	#install only the xmlrpc module
-	$(MAKE) clean_cfg
-	$(MAKE) clean_modules_cfg
-	$(MAKE) install-modules-all modules="$(XMLRPC_MOD_PATH)"  \
+		doc-dir=share/doc/ser-mysql-modules
+	$(MAKE) install-modules-all group_include="radius" \
+		basedir=$(CURDIR)/debian/ser-radius-modules \
+		cfg-prefix=$(CURDIR)/debian/ser-radius-modules \
+		doc-dir=share/doc/ser-radius-modules
+	$(MAKE) install-modules-all modules="$(POSTGRES_MOD_PATH)" \
+		modules_s="" modules_k="" \
+		basedir=$(CURDIR)/debian/ser-postgres-module \
+		doc-dir=share/doc/ser-postgress-module
+	$(MAKE) install-modules-all modules="$(TLS_MOD_PATH)" \
+		modules_s="" modules_k="" \
+		basedir=$(CURDIR)/debian/ser-tls-module \
+		doc-dir=share/doc/ser-tls-module
+	$(MAKE) install-modules-all modules="$(XMLRPC_MOD_PATH)" \
+		modules_s="" modules_k="" \
 		basedir=$(CURDIR)/debian/ser-xmlrpc-module \
-		prefix=/usr \
-		cfg-prefix=$(CURDIR)/debian/ser-xmlrpc-module \
-		cfg-target=/etc/ser/ \
-		doc-dir=share/doc/ser-xmlrpc-module \
-		skip_modules="$(EXTRA_EXCLUDED_MODULES)"
+		doc-dir=share/doc/ser-xmlrpc-module
 	# install /etc/default/ser file
 	mkdir -p $(CURDIR)/debian/ser/etc/default
 	cp -f debian/ser.default $(CURDIR)/debian/ser/etc/default/ser
 	# install the *.sql files for ser_mysql.sh script
 	cp -f scripts/mysql/*.sql $(CURDIR)/debian/ser/usr/lib/ser/
 	# and fix path to the *.sql files in ser_mysql.sh script
-	sed -i 's#DEFAULT_SCRIPT_DIR=.*#DEFAULT_SCRIPT_DIR="/usr/lib/ser/"#' $(CURDIR)/debian/ser/usr/sbin/ser_mysql.sh
+	sed -i 's#DEFAULT_SCRIPT_DIR=.*#DEFAULT_SCRIPT_DIR="/usr/lib/ser/"#' \
+		$(CURDIR)/debian/ser/usr/sbin/ser_mysql.sh
 	# install advanced ser config file for ser-oob package
 	mkdir -p $(CURDIR)/debian/ser-oob/etc/ser
-	cp -f etc/ser-oob.cfg $(CURDIR)/debian/ser-oob/etc/ser/
-	# and remove it from main ser package
-	rm -f $(CURDIR)/debian/ser/etc/ser/ser-oob.cfg
+	cp -f etc/sip-router-oob.cfg $(CURDIR)/debian/ser-oob/etc/ser/ser-oob.cfg
 	#dh_movefiles
 
 

+ 2 - 2
receive.c

@@ -179,7 +179,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 
 		set_route_type(REQUEST_ROUTE);
 		/* exec the routing script */
-		if (run_top_route(main_rt.rlist[DEFAULT_RT], msg)<0){
+		if (run_top_route(main_rt.rlist[DEFAULT_RT], msg, 0)<0){
 			LOG(L_WARN, "WARNING: receive_msg: "
 					"error while trying script\n");
 			goto error_req;
@@ -222,7 +222,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 		/* exec the onreply routing script */
 		if (onreply_rt.rlist[DEFAULT_RT]){
 			set_route_type(ONREPLY_ROUTE);
-			ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg);
+			ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg, 0);
 			if (ret<0){
 				LOG(L_WARN, "WARNING: receive_msg: "
 						"error while trying onreply script\n");

+ 1 - 0
route_struct.h

@@ -109,6 +109,7 @@ enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
 #define EXIT_R_F   1
 #define RETURN_R_F 2
 #define BREAK_R_F  4
+#define DROP_R_F   8
 
 
 struct cfg_pos{