Browse code

- Suppor for branch_route sections in the configuration file.

Jan Janak authored on 18/08/2005 15:46:46
Showing 7 changed files
... ...
@@ -113,6 +113,7 @@ ERROR	error
113 113
 ROUTE	route
114 114
 ROUTE_FAILURE failure_route
115 115
 ROUTE_ONREPLY onreply_route
116
+ROUTE_BRANCH branch_route
116 117
 EXEC	exec
117 118
 FORCE_RPORT		"force_rport"|"add_rport"
118 119
 FORCE_TCP_ALIAS		"force_tcp_alias"|"add_tcp_alias"
... ...
@@ -312,6 +313,7 @@ EAT_ABLE	[\ \t\b\r]
312 312
 								return ROUTE_ONREPLY; }
313 313
 <INITIAL>{ROUTE_FAILURE}	{ count(); yylval.strval=yytext;
314 314
 								return ROUTE_FAILURE; }
315
+<INITIAL>{ROUTE_BRANCH} { count(); yylval.strval=yytext; return ROUTE_BRANCH; }
315 316
 <INITIAL>{EXEC}	{ count(); yylval.strval=yytext; return EXEC; }
316 317
 <INITIAL>{SET_HOST}	{ count(); yylval.strval=yytext; return SET_HOST; }
317 318
 <INITIAL>{SET_HOSTPORT}	{ count(); yylval.strval=yytext; return SET_HOSTPORT; }
... ...
@@ -149,6 +149,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
149 149
 %token ROUTE
150 150
 %token ROUTE_FAILURE
151 151
 %token ROUTE_ONREPLY
152
+%token ROUTE_BRANCH
152 153
 %token EXEC
153 154
 %token SET_HOST
154 155
 %token SET_HOSTPORT
... ...
@@ -335,6 +336,7 @@ statement:	assign_stm
335 335
 		| {rt=REQUEST_ROUTE;} route_stm 
336 336
 		| {rt=FAILURE_ROUTE;} failure_route_stm
337 337
 		| {rt=ONREPLY_ROUTE;} onreply_route_stm
338
+		| {rt=BRANCH_ROUTE;} branch_route_stm
338 339
 
339 340
 		| CR	/* null statement*/
340 341
 	;
... ...
@@ -870,6 +872,19 @@ onreply_route_stm: ROUTE LBRACE actions RBRACE {
870 870
 										}
871 871
 		| ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
872 872
 	;
873
+branch_route_stm: ROUTE_BRANCH LBRACE actions RBRACE {
874
+										push($3, &branch_rlist[DEFAULT_RT]);
875
+											  }
876
+				| ROUTE_BRANCH LBRACK NUMBER RBRACK LBRACE actions RBRACE {
877
+										if (($3<BRANCH_RT_NO)&&($3>=1)){
878
+											push($6, &branch_rlist[$3]);
879
+										} else {
880
+											yyerror("invalid branch routing"
881
+												"table number");
882
+											YYABORT; }
883
+										}
884
+		| ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
885
+	;
873 886
 /*
874 887
 rules:	rules rule { push($2, &$1); $$=$1; }
875 888
 	| rule {$$=$1; }
... ...
@@ -60,6 +60,7 @@
60 60
 #define RT_NO 20 /* routing tables number */
61 61
 #define FAILURE_RT_NO RT_NO /* on_failure routing tables number */
62 62
 #define ONREPLY_RT_NO RT_NO /* on_reply routing tables number */
63
+#define BRANCH_RT_NO RT_NO /* branch_route routing tables number */
63 64
 #define DEFAULT_RT 0 /* default routing table */
64 65
 
65 66
 #define MAX_REC_LEV 100 /* maximum number of recursive calls */
... ...
@@ -75,7 +75,7 @@ enum lump_conditions {	COND_FALSE,         /* always false */
75 75
 						   proto = protocol (tcp, udp, tls)
76 76
 						*/
77 77
 
78
-enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2 };
78
+enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2, LUMPFLAG_BRANCH=4 };
79 79
 
80 80
 
81 81
 struct lump{
... ...
@@ -73,7 +73,7 @@ struct action* rlist[RT_NO];
73 73
 /* reply routing table */
74 74
 struct action* onreply_rlist[ONREPLY_RT_NO];
75 75
 struct action* failure_rlist[FAILURE_RT_NO];
76
-
76
+struct action* branch_rlist[BRANCH_RT_NO];
77 77
 
78 78
 static int fix_actions(struct action* a); /*fwd declaration*/
79 79
 
... ...
@@ -742,6 +742,13 @@ int fix_rls()
742 742
 			}
743 743
 		}
744 744
 	}
745
+	for(i=0;i<BRANCH_RT_NO;i++){
746
+		if(branch_rlist[i]){
747
+			if ((ret=fix_actions(branch_rlist[i]))!=0){
748
+				return ret;
749
+			}
750
+		}
751
+	}
745 752
 	return 0;
746 753
 }
747 754
 
... ...
@@ -783,6 +790,14 @@ void print_rl()
783 783
 		}
784 784
 		DBG("\n");
785 785
 	}
786
+	for(j=0; j<BRANCH_RT_NO; j++){
787
+		if (branch_rlist[j]==0){
788
+			continue;
789
+		}
790
+		DBG("branch routing table %d:\n",j);
791
+		for (t=branch_rlist[j],i=0; t; i++, t=t->next){
792
+			print_action(t);
793
+		}
794
+		DBG("\n");
795
+	}
786 796
 }
787
-
788
-
... ...
@@ -46,6 +46,7 @@ extern struct action* rlist[RT_NO];
46 46
 /* main reply route table */
47 47
 extern struct action* onreply_rlist[RT_NO];
48 48
 extern struct action* failure_rlist[RT_NO];
49
+extern struct action* branch_rlist[RT_NO];
49 50
 
50 51
 
51 52
 void push(struct action* a, struct action** head);
... ...
@@ -69,6 +69,7 @@ typedef int (*param_func_t)( modparam_t type, void* val);
69 69
 #define REQUEST_ROUTE 1  /* Function can be used in request route blocks */
70 70
 #define FAILURE_ROUTE 2  /* Function can be used in reply route blocks */
71 71
 #define ONREPLY_ROUTE 4  /* Function can be used in on_reply */
72
+#define BRANCH_ROUTE  8  /* Function can be used in branch_route blocks */
72 73
 
73 74
 /* Macros - used as rank in child_init function */
74 75
 #define PROC_MAIN      0  /* Main ser process */