Module: sip-router
Branch: hpw/branch_failure_route
Commit: a5946574cb9917f0a9a90ea547c9357f3f6477bd
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a594657…
Author: Hugh Waite <hugh.waite(a)crocodile-rcs.com>
Committer: Hugh Waite <hugh.waite(a)crocodile-rcs.com>
Date: Tue Mar 19 15:43:46 2013 +0000
core: Initial revision of branch_failure_route
- New branch_failure_route defined
- cfg route is called but xlog() causes segfault
---
cfg.lex | 3 +++
cfg.y | 24 ++++++++++++++++++++++++
route.c | 4 ++++
route.h | 2 ++
script_cb.c | 2 +-
script_cb.h | 5 +++--
6 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/cfg.lex b/cfg.lex
index 5a7ce8a..bafab4b 100644
--- a/cfg.lex
+++ b/cfg.lex
@@ -200,6 +200,7 @@ ERROR error
ROUTE route
ROUTE_REQUEST request_route
ROUTE_FAILURE failure_route
+ROUTE_BRANCH_FAILURE branch_failure_route
ROUTE_REPLY reply_route
ROUTE_ONREPLY onreply_route
ROUTE_BRANCH branch_route
@@ -623,6 +624,8 @@ IMPORTFILE "import_file"
<INITIAL>{ROUTE_REPLY} { count(); yylval.strval=yytext; return ROUTE_REPLY; }
<INITIAL>{ROUTE_FAILURE} { count(); yylval.strval=yytext;
return ROUTE_FAILURE; }
+<INITIAL>{ROUTE_BRANCH_FAILURE} { count(); yylval.strval=yytext;
+ return ROUTE_BRANCH_FAILURE; }
<INITIAL>{ROUTE_BRANCH} { count(); yylval.strval=yytext; return ROUTE_BRANCH; }
<INITIAL>{ROUTE_SEND} { count(); yylval.strval=yytext; return ROUTE_SEND; }
<INITIAL>{ROUTE_EVENT} { count(); yylval.strval=yytext; return ROUTE_EVENT; }
diff --git a/cfg.y b/cfg.y
index 0c4fb5d..477991f 100644
--- a/cfg.y
+++ b/cfg.y
@@ -314,6 +314,7 @@ extern char *finame;
%token ROUTE
%token ROUTE_REQUEST
%token ROUTE_FAILURE
+%token ROUTE_BRANCH_FAILURE
%token ROUTE_ONREPLY
%token ROUTE_REPLY
%token ROUTE_BRANCH
@@ -705,6 +706,7 @@ statement:
| module_stm
| {rt=REQUEST_ROUTE;} route_stm
| {rt=FAILURE_ROUTE;} failure_route_stm
+ | {rt=BRANCH_FAILURE_ROUTE;} branch_failure_route_stm
| onreply_route_stm
| {rt=BRANCH_ROUTE;} branch_route_stm
| {rt=ONSEND_ROUTE;} send_route_stm
@@ -1970,6 +1972,28 @@ failure_route_stm:
| ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
;
+branch_failure_route_stm:
+ ROUTE_BRANCH_FAILURE LBRACK route_name RBRACK LBRACE actions RBRACE {
+ #ifdef SHM_MEM
+ if (!shm_initialized() && init_shm()<0) {
+ yyerror("Can't initialize shared memory");
+ YYABORT;
+ }
+ #endif /* SHM_MEM */
+ i_tmp=route_get(&branch_failure_rt, $3);
+ if (i_tmp==-1){
+ yyerror("internal error");
+ YYABORT;
+ }
+ if (branch_failure_rt.rlist[i_tmp]){
+ yyerror("duplicate route");
+ YYABORT;
+ }
+ push($6, &branch_failure_rt.rlist[i_tmp]);
+ }
+ | ROUTE_BRANCH_FAILURE error { yyerror("invalid branch_failure_route
statement"); }
+ ;
+
route_reply_main: ROUTE_ONREPLY { ; }
| ROUTE_REPLY { ; }
diff --git a/route.c b/route.c
index 17c1b56..42fc496 100644
--- a/route.c
+++ b/route.c
@@ -102,6 +102,7 @@
struct route_list main_rt;
struct route_list onreply_rt;
struct route_list failure_rt;
+struct route_list branch_failure_rt;
struct route_list branch_rt;
struct route_list onsend_rt;
struct route_list event_rt;
@@ -142,6 +143,7 @@ void destroy_routes()
destroy_rlist(&main_rt);
destroy_rlist(&onreply_rt);
destroy_rlist(&failure_rt);
+ destroy_rlist(&branch_failure_rt);
destroy_rlist(&branch_rt);
destroy_rlist(&event_rt);
}
@@ -210,6 +212,8 @@ int init_routes()
goto error;
if (init_rlist("failure", &failure_rt, FAILURE_RT_NO, RT_HASH_SIZE)<0)
goto error;
+ if (init_rlist("branch_failure", &branch_failure_rt, FAILURE_RT_NO,
RT_HASH_SIZE)<0)
+ goto error;
if (init_rlist("branch", &branch_rt, BRANCH_RT_NO, RT_HASH_SIZE)<0)
goto error;
if (init_rlist("on_send", &onsend_rt, ONSEND_RT_NO, RT_HASH_SIZE)<0)
diff --git a/route.h b/route.h
index 8f25fe3..f824c0e 100644
--- a/route.h
+++ b/route.h
@@ -53,6 +53,7 @@
#define ERROR_ROUTE (1 << 5)
#define LOCAL_ROUTE (1 << 6)
#define CORE_ONREPLY_ROUTE (1 << 7)
+#define BRANCH_FAILURE_ROUTE (1 << 8)
#define ONREPLY_ROUTE (TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE)
#define EVENT_ROUTE REQUEST_ROUTE
#define ANY_ROUTE (0xFFFFFFFF)
@@ -85,6 +86,7 @@ extern struct route_list main_rt;
/* main reply route table */
extern struct route_list onreply_rt;
extern struct route_list failure_rt;
+extern struct route_list branch_failure_rt;
extern struct route_list branch_rt;
extern struct route_list onsend_rt;
extern struct route_list event_rt;
diff --git a/script_cb.c b/script_cb.c
index a10df7d..27156e2 100644
--- a/script_cb.c
+++ b/script_cb.c
@@ -53,7 +53,7 @@
#include "mem/mem.h"
/* Number of cb types = last cb type */
-#define SCRIPT_CB_NUM EVENT_CB_TYPE
+#define SCRIPT_CB_NUM (CB_TYPE_MAX-1)
static struct script_cb *pre_script_cb[SCRIPT_CB_NUM];
static struct script_cb *post_script_cb[SCRIPT_CB_NUM];
diff --git a/script_cb.h b/script_cb.h
index af557c7..596a503 100644
--- a/script_cb.h
+++ b/script_cb.h
@@ -49,14 +49,15 @@ typedef int (cb_function)(struct sip_msg *msg, unsigned int flags,
void *param);
*/
enum script_cb_flag { REQUEST_CB=1, FAILURE_CB=2, ONREPLY_CB=4,
BRANCH_CB=8, ONSEND_CB=16, ERROR_CB=32,
- LOCAL_CB=64, EVENT_CB=128 };
+ LOCAL_CB=64, EVENT_CB=128, BRANCH_FAILURE_CB=256 };
/* Callback types used for executing the callbacks.
* Keep in sync with script_cb_flag!!!
*/
enum script_cb_type { REQUEST_CB_TYPE=1, FAILURE_CB_TYPE, ONREPLY_CB_TYPE,
BRANCH_CB_TYPE, ONSEND_CB_TYPE, ERROR_CB_TYPE,
- LOCAL_CB_TYPE, EVENT_CB_TYPE };
+ LOCAL_CB_TYPE, EVENT_CB_TYPE, BRANCH_FAILURE_CB_TYPE,
+ CB_TYPE_MAX};
struct script_cb{
cb_function *cbf;