Browse code

core: new close after send and reuse only script functions

Added new script functions for setting send options for the
current message or its replies:

- set_forward_no_connect() - the message will be forwarded only if
there is already an open connection to the destination.
- set_reply_no_connect() - like above but for replies to the
current message.
- set_forward_close() - hint that after forwarding the current
message the connection should be closed.
- set reply_close() - like above but for replies.

Andrei Pelinescu-Onciul authored on 15/09/2009 15:47:33
Showing 4 changed files
... ...
@@ -50,6 +50,7 @@
50 50
  *  2008-12-03  use lvalues/rvalues for assignments (andrei)
51 51
  *  2008-12-17  added UDP_MTU_TRY_PROTO_T (andrei)
52 52
  *  2009-05-04  switched IF_T to rval_expr (andrei)
53
+ *  2009-09-15  added SET_{FWD,RPL}_NO_CONNECT, SET_{FWD,RPL}_CLOSE (andrei)
53 54
  */
54 55
 
55 56
 
... ...
@@ -1214,6 +1215,22 @@ match_cleanup:
1214 1214
 			else
1215 1215
 				ret=v;
1216 1216
 			break;
1217
+		case SET_FWD_NO_CONNECT_T:
1218
+			msg->fwd_send_flags|= SND_F_FORCE_CON_REUSE;
1219
+			ret=1; /* continue processing */
1220
+			break;
1221
+		case SET_RPL_NO_CONNECT_T:
1222
+			msg->rpl_send_flags|= SND_F_FORCE_CON_REUSE;
1223
+			ret=1; /* continue processing */
1224
+			break;
1225
+		case SET_FWD_CLOSE_T:
1226
+			msg->fwd_send_flags|= SND_F_CON_CLOSE;
1227
+			ret=1; /* continue processing */
1228
+			break;
1229
+		case SET_RPL_CLOSE_T:
1230
+			msg->rpl_send_flags|= SND_F_CON_CLOSE;
1231
+			ret=1; /* continue processing */
1232
+			break;
1217 1233
 /*
1218 1234
 		default:
1219 1235
 			LOG(L_CRIT, "BUG: do_action: unknown type %d\n", a->type);
... ...
@@ -215,6 +215,10 @@ ELSE			"else"
215 215
 SET_ADV_ADDRESS	"set_advertised_address"
216 216
 SET_ADV_PORT	"set_advertised_port"
217 217
 FORCE_SEND_SOCKET	"force_send_socket"
218
+SET_FWD_NO_CONNECT		"set_forward_no_connect"
219
+SET_RPL_NO_CONNECT	"set_reply_no_connect"
220
+SET_FWD_CLOSE	"set_forward_close"
221
+SET_RPL_CLOSE	"set_reply_close"
218 222
 SWITCH			"switch"
219 223
 CASE			"case"
220 224
 DEFAULT			"default"
... ...
@@ -572,6 +576,14 @@ EAT_ABLE	[\ \t\b\r]
572 572
 										return SET_ADV_PORT; }
573 573
 <INITIAL>{FORCE_SEND_SOCKET}	{	count(); yylval.strval=yytext;
574 574
 									return FORCE_SEND_SOCKET; }
575
+<INITIAL>{SET_FWD_NO_CONNECT}	{ count(); yylval.strval=yytext;
576
+									return SET_FWD_NO_CONNECT; }
577
+<INITIAL>{SET_RPL_NO_CONNECT}	{ count(); yylval.strval=yytext;
578
+									return SET_RPL_NO_CONNECT; }
579
+<INITIAL>{SET_FWD_CLOSE}		{ count(); yylval.strval=yytext;
580
+									return SET_FWD_CLOSE; }
581
+<INITIAL>{SET_RPL_CLOSE}		{ count(); yylval.strval=yytext;
582
+									return SET_RPL_CLOSE; }
575 583
 <INITIAL>{SWITCH}	{ count(); yylval.strval=yytext; return SWITCH; }
576 584
 <INITIAL>{CASE}	{ count(); yylval.strval=yytext; return CASE; }
577 585
 <INITIAL>{DEFAULT}	{ count(); yylval.strval=yytext; return DEFAULT; }
... ...
@@ -319,6 +319,10 @@ extern char *finame;
319 319
 %token SET_ADV_ADDRESS
320 320
 %token SET_ADV_PORT
321 321
 %token FORCE_SEND_SOCKET
322
+%token SET_FWD_NO_CONNECT
323
+%token SET_RPL_NO_CONNECT
324
+%token SET_FWD_CLOSE
325
+%token SET_RPL_CLOSE
322 326
 %token SWITCH
323 327
 %token CASE
324 328
 %token DEFAULT
... ...
@@ -2990,6 +2994,30 @@ cmd:
2990 2990
 		$$=0; yyerror("bad argument, [proto:]host[:port] expected");
2991 2991
 	}
2992 2992
 	| FORCE_SEND_SOCKET error {$$=0; yyerror("missing '(' or ')' ?"); }
2993
+	| SET_FWD_NO_CONNECT LPAREN RPAREN	{
2994
+		$$=mk_action(SET_FWD_NO_CONNECT_T, 0); set_cfg_pos($$);
2995
+	}
2996
+	| SET_FWD_NO_CONNECT	{
2997
+		$$=mk_action(SET_FWD_NO_CONNECT_T, 0); set_cfg_pos($$);
2998
+	}
2999
+	| SET_RPL_NO_CONNECT LPAREN RPAREN	{
3000
+		$$=mk_action(SET_RPL_NO_CONNECT_T, 0); set_cfg_pos($$);
3001
+	}
3002
+	| SET_RPL_NO_CONNECT	{
3003
+		$$=mk_action(SET_RPL_NO_CONNECT_T, 0); set_cfg_pos($$);
3004
+	}
3005
+	| SET_FWD_CLOSE LPAREN RPAREN	{
3006
+		$$=mk_action(SET_FWD_CLOSE_T, 0); set_cfg_pos($$);
3007
+	}
3008
+	| SET_FWD_CLOSE	{
3009
+		$$=mk_action(SET_FWD_CLOSE_T, 0); set_cfg_pos($$);
3010
+	}
3011
+	| SET_RPL_CLOSE LPAREN RPAREN	{
3012
+		$$=mk_action(SET_RPL_CLOSE_T, 0); set_cfg_pos($$);
3013
+	}
3014
+	| SET_RPL_CLOSE	{
3015
+		$$=mk_action(SET_RPL_CLOSE_T, 0); set_cfg_pos($$);
3016
+	}
2993 3017
 	| ID {mod_func_action = mk_action(MODULE_T, 2, MODEXP_ST, NULL, NUMBER_ST,
2994 3018
 			0); } LPAREN func_params RPAREN	{
2995 3019
 		mod_func_action->val[0].u.data = 
... ...
@@ -106,7 +106,11 @@ enum action_type{
106 106
 		FORCE_SEND_SOCKET_T,
107 107
 		ASSIGN_T,
108 108
 		ADD_T,
109
-		UDP_MTU_TRY_PROTO_T
109
+		UDP_MTU_TRY_PROTO_T,
110
+		SET_FWD_NO_CONNECT_T,
111
+		SET_RPL_NO_CONNECT_T,
112
+		SET_FWD_CLOSE_T,
113
+		SET_RPL_CLOSE_T
110 114
 };
111 115
 /* parameter types for actions or types for expression right operands
112 116
    (WARNING right operands only, not working for left operands) */