Module: sip-router
Branch: tirpi/script_callbacks
Commit: b9ed8d84b2eb5a9af8b1980cea772c0290611513
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b9ed8d8…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Mon Jun 1 15:11:41 2009 +0200
script callbacks: support for failure and branch routes
- Executing pre- and post-script callbacks for failure
routes and branch routes.
---
modules/tm/t_fwd.c | 11 ++++++++---
modules/tm/t_reply.c | 21 ++++++++++++++++-----
modules/tm/t_suspend.c | 16 ++++++++++++----
3 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/modules/tm/t_fwd.c b/modules/tm/t_fwd.c
index 01a3699..d0dd613 100644
--- a/modules/tm/t_fwd.c
+++ b/modules/tm/t_fwd.c
@@ -78,6 +78,7 @@
* t saved, thus, are not available. Set reparse_on_dns_failover
* to 0 to revert the change. (Miklos)
* 2008-06-04 T_CANCELED is now set each time a CANCEL is received (andrei)
+ * 2009-06-01 Pre- and post-script callbacks of branch route are executed (Miklos)
*/
#include "defs.h"
@@ -98,6 +99,7 @@
#include "../../onsend.h"
#include "../../compiler_opt.h"
#include "../../route.h"
+#include "../../script_cb.h"
#include "t_funcs.h"
#include "t_hooks.h"
#include "t_msgbuilder.h"
@@ -191,9 +193,12 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
/* run branch_route actions if provided */
set_route_type(BRANCH_ROUTE);
tm_ctx_set_branch_index(branch+1);
- if (run_top_route(branch_rt.rlist[branch_route], i_req) < 0) {
- LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n");
- }
+ if (exec_pre_script_cb(i_req, BRANCH_CB_TYPE)>0) {
+ if (run_top_route(branch_rt.rlist[branch_route], i_req) < 0) {
+ LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n");
+ }
+ exec_post_script_cb(i_req, BRANCH_CB_TYPE);
+ }
tm_ctx_set_branch_index(0);
}
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 8ab79c2..e60d046 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -89,6 +89,7 @@
* 2008-03-12 use cancel_b_method on 6xx (andrei)
* 2008-05-30 make sure the wait timer is started after we don't need t
* anymore to allow safe calls from fr_timer (andrei)
+ * 2009-06-01 Pre- and post-script callbacks of branch route are executed (Miklos)
*
*/
@@ -106,6 +107,7 @@
#include "../../timer.h"
#include "../../error.h"
#include "../../action.h"
+#include "../../script_cb.h"
#include "../../dset.h"
#include "../../tags.h"
#include "../../route.h"
@@ -861,9 +863,12 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
* on failure */
on_failure = t->on_negative;
t->on_negative=0;
- /* run a reply_route action if some was marked */
- if (run_top_route(failure_rt.rlist[on_failure], &faked_req)<0)
- LOG(L_ERR, "ERROR: run_failure_handlers: Error in run_top_route\n");
+ 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)
+ LOG(L_ERR, "ERROR: run_failure_handlers: Error in run_top_route\n");
+ exec_post_script_cb(&faked_req, FAILURE_CB_TYPE);
+ }
}
/* restore original environment and free the fake msg */
@@ -1963,6 +1968,9 @@ int reply_received( struct sip_msg *p_msg )
backup_domain_from = set_avp_list(AVP_TRACK_FROM | AVP_CLASS_DOMAIN, &t->domain_avps_from );
backup_domain_to = set_avp_list(AVP_TRACK_TO | AVP_CLASS_DOMAIN, &t->domain_avps_to );
setbflagsval(0, uac->branch_flags);
+ /* 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)
LOG(L_ERR, "ERROR: on_reply processing failed\n");
/* transfer current message context back to t */
@@ -2090,8 +2098,11 @@ done:
trans_not_found:
/* transaction context was not found */
if (goto_on_sl_reply) {
- /* the script writer has a chance to decide whether to
- forward the reply or not */
+ /* The script writer has a chance to decide whether to
+ * forward the reply or not.
+ * 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);
} else {
/* let the core forward the reply */
diff --git a/modules/tm/t_suspend.c b/modules/tm/t_suspend.c
index c1dc1b1..e9802b9 100644
--- a/modules/tm/t_suspend.c
+++ b/modules/tm/t_suspend.c
@@ -27,10 +27,12 @@
* History:
* --------
* 2008-11-10 Initial version (Miklos)
+ * 2009-06-01 Pre- and post-script callbacks of failure route are executed (Miklos)
*
*/
-#include "../../select_buf.h" /* reset_static_buffer() */
+#include "../../action.h"
+#include "../../script_cb.h"
#include "sip_msg.h"
#include "t_reply.h"
@@ -151,9 +153,15 @@ int t_continue(unsigned int hash_index, unsigned int label,
}
faked_env( t, &faked_req);
- if (run_top_route(route, &faked_req)<0)
- LOG(L_ERR, "ERROR: t_continue: Error in run_top_route\n");
-
+ /* The sip msg is a faked msg just like in failure route
+ * therefore execute the pre- and post-script callbacks
+ * of failure route (Miklos)
+ */
+ if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
+ if (run_top_route(route, &faked_req)<0)
+ LOG(L_ERR, "ERROR: t_continue: Error in run_top_route\n");
+ exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE);
+ }
/* TODO: save_msg_lumps should clone the lumps to shm mem */
/* restore original environment and free the fake msg */
dpkg-shlibdeps complains about lots of symbols that it cannot find, for
example:
dpkg-shlibdeps: warning: symbol core_cfg used by debian/sip-router/usr/lib/sip-router/libkmi.so.1.0 found in none of the libraries.
...
dpkg-shlibdeps: warning: symbol core_cfg used by debian/sip-router/usr/lib/sip-router/libsrdb2.so.1.0 found in none of the libraries.
...
dpkg-shlibdeps: warning: symbol mem_lock used by debian/sip-router/usr/lib/sip-router/libkcore.so.1.0 found in none of the libraries.
should i get worried about that? am i missing some libraries?
--juha
Module: sip-router
Branch: master
Commit: e2a88d5b3a00bab7994174b7f37569d85774d997
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e2a88d5…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Jun 1 12:41:01 2009 +0200
make: required version is now 3.81
Updated required gnu make version from 3.80 to 3.81, because 3.80
has a bug when dealing with eval inside ifeq/endif
(see
https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=1516)).
It can be reverted back to 3.80, once workarounds are in place.
---
Makefile | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index ca97f78..7e0e197 100644
--- a/Makefile
+++ b/Makefile
@@ -65,8 +65,10 @@
#
# check make version
-# required 3.80, recommended 3.81
-req_ver=3.80
+# everything works with 3.80, except evals inside ifeq/endif
+# (see https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=1516).
+# recommended 3.81
+req_ver=3.81
# the check below works for version number of the type x.yy or x.yy.z*
# (from the GNU Make Cookbook)
ifeq (,$(filter $(req_ver),$(firstword $(sort $(MAKE_VERSION) $(req_ver)))))
Module: sip-router
Branch: master
Commit: 7ac811b4fda52b4294fe740d24cf71e321fc707a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7ac811b…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Jun 1 12:36:05 2009 +0200
test: gcc version test scripts
Test if gcc version is correctly detected with a large collection
of gcc version strings. To be used each time the gcc version
detection is changed.
---
test/gcc_version.sh | 17 +++++++++++++++++
test/gcc_version_test.sh | 26 ++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/test/gcc_version.sh b/test/gcc_version.sh
new file mode 100755
index 0000000..078b852
--- /dev/null
+++ b/test/gcc_version.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+#
+# wrapper arroung gcc, that intercepts --version and reports instead
+# $GCC_VERSION
+#
+
+if [ -n "$GCC_VERSION" ]; then
+ for o in $@; do
+ if [ "$o" = "--version" ] ; then
+ echo $GCC_VERSION
+ exit 0
+ fi
+ done
+fi
+
+gcc $@
diff --git a/test/gcc_version_test.sh b/test/gcc_version_test.sh
new file mode 100755
index 0000000..4a6912b
--- /dev/null
+++ b/test/gcc_version_test.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# test make cfg with all the gcc versions in gcc_versions.txt
+# should be run from the main sip-router directory
+# Depends on: test/gcc_version.sh and test/gcc_versions.txt
+
+if [ ! -e test/gcc_version.sh -o ! -r test/gcc_versions.txt -o ! -r Makefile ]
+then
+ echo "ERROR: wrong path, this test must be run from the main"\
+ " sip-router directory"
+ exit 1
+fi
+
+while read v ; do
+ GCC_VERSION=$v make CC=test/gcc_version.sh cfg-defs >/dev/null
+ if [ $? -ne 0 -o ! -r config.mak ]; then
+ echo "ERROR: make cfg failed for version \"$v\""
+ exit 1
+ fi
+ COMPILER=`egrep -o -- "-DCOMPILER='\"[^\"' ]+ [2-9]\.[0-9]{1,2}(\.[0-9]{1,2})?\"'" config.mak`
+ if [ $? -ne 0 -o -z "$COMPILER" ]; then
+ echo "ERROR: bad ver: \"$v\" => `egrep -o -- "-DCOMPILER='[^']*'" config.mak`"
+ exit 1
+ fi
+ echo "ok: \"$v\" => $COMPILER"
+done < test/gcc_versions.txt
when i run
/usr/sbin/sip-router -c -d -f /etc/sip-router/sip-router.cfg
i still get lots of debug messages.
how to start sip-router so that it only prints warning and errors?
-- juha