Browse Source

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 16 years ago
parent
commit
58cbf7f7e1
4 changed files with 62 additions and 1 deletions
  1. 17 0
      action.c
  2. 12 0
      cfg.lex
  3. 28 0
      cfg.y
  4. 5 1
      route_struct.h

+ 17 - 0
action.c

@@ -50,6 +50,7 @@
  *  2008-12-03  use lvalues/rvalues for assignments (andrei)
  *  2008-12-03  use lvalues/rvalues for assignments (andrei)
  *  2008-12-17  added UDP_MTU_TRY_PROTO_T (andrei)
  *  2008-12-17  added UDP_MTU_TRY_PROTO_T (andrei)
  *  2009-05-04  switched IF_T to rval_expr (andrei)
  *  2009-05-04  switched IF_T to rval_expr (andrei)
+ *  2009-09-15  added SET_{FWD,RPL}_NO_CONNECT, SET_{FWD,RPL}_CLOSE (andrei)
  */
  */
 
 
 
 
@@ -1214,6 +1215,22 @@ match_cleanup:
 			else
 			else
 				ret=v;
 				ret=v;
 			break;
 			break;
+		case SET_FWD_NO_CONNECT_T:
+			msg->fwd_send_flags|= SND_F_FORCE_CON_REUSE;
+			ret=1; /* continue processing */
+			break;
+		case SET_RPL_NO_CONNECT_T:
+			msg->rpl_send_flags|= SND_F_FORCE_CON_REUSE;
+			ret=1; /* continue processing */
+			break;
+		case SET_FWD_CLOSE_T:
+			msg->fwd_send_flags|= SND_F_CON_CLOSE;
+			ret=1; /* continue processing */
+			break;
+		case SET_RPL_CLOSE_T:
+			msg->rpl_send_flags|= SND_F_CON_CLOSE;
+			ret=1; /* continue processing */
+			break;
 /*
 /*
 		default:
 		default:
 			LOG(L_CRIT, "BUG: do_action: unknown type %d\n", a->type);
 			LOG(L_CRIT, "BUG: do_action: unknown type %d\n", a->type);

+ 12 - 0
cfg.lex

@@ -215,6 +215,10 @@ ELSE			"else"
 SET_ADV_ADDRESS	"set_advertised_address"
 SET_ADV_ADDRESS	"set_advertised_address"
 SET_ADV_PORT	"set_advertised_port"
 SET_ADV_PORT	"set_advertised_port"
 FORCE_SEND_SOCKET	"force_send_socket"
 FORCE_SEND_SOCKET	"force_send_socket"
+SET_FWD_NO_CONNECT		"set_forward_no_connect"
+SET_RPL_NO_CONNECT	"set_reply_no_connect"
+SET_FWD_CLOSE	"set_forward_close"
+SET_RPL_CLOSE	"set_reply_close"
 SWITCH			"switch"
 SWITCH			"switch"
 CASE			"case"
 CASE			"case"
 DEFAULT			"default"
 DEFAULT			"default"
@@ -572,6 +576,14 @@ EAT_ABLE	[\ \t\b\r]
 										return SET_ADV_PORT; }
 										return SET_ADV_PORT; }
 <INITIAL>{FORCE_SEND_SOCKET}	{	count(); yylval.strval=yytext;
 <INITIAL>{FORCE_SEND_SOCKET}	{	count(); yylval.strval=yytext;
 									return FORCE_SEND_SOCKET; }
 									return FORCE_SEND_SOCKET; }
+<INITIAL>{SET_FWD_NO_CONNECT}	{ count(); yylval.strval=yytext;
+									return SET_FWD_NO_CONNECT; }
+<INITIAL>{SET_RPL_NO_CONNECT}	{ count(); yylval.strval=yytext;
+									return SET_RPL_NO_CONNECT; }
+<INITIAL>{SET_FWD_CLOSE}		{ count(); yylval.strval=yytext;
+									return SET_FWD_CLOSE; }
+<INITIAL>{SET_RPL_CLOSE}		{ count(); yylval.strval=yytext;
+									return SET_RPL_CLOSE; }
 <INITIAL>{SWITCH}	{ count(); yylval.strval=yytext; return SWITCH; }
 <INITIAL>{SWITCH}	{ count(); yylval.strval=yytext; return SWITCH; }
 <INITIAL>{CASE}	{ count(); yylval.strval=yytext; return CASE; }
 <INITIAL>{CASE}	{ count(); yylval.strval=yytext; return CASE; }
 <INITIAL>{DEFAULT}	{ count(); yylval.strval=yytext; return DEFAULT; }
 <INITIAL>{DEFAULT}	{ count(); yylval.strval=yytext; return DEFAULT; }

+ 28 - 0
cfg.y

@@ -319,6 +319,10 @@ extern char *finame;
 %token SET_ADV_ADDRESS
 %token SET_ADV_ADDRESS
 %token SET_ADV_PORT
 %token SET_ADV_PORT
 %token FORCE_SEND_SOCKET
 %token FORCE_SEND_SOCKET
+%token SET_FWD_NO_CONNECT
+%token SET_RPL_NO_CONNECT
+%token SET_FWD_CLOSE
+%token SET_RPL_CLOSE
 %token SWITCH
 %token SWITCH
 %token CASE
 %token CASE
 %token DEFAULT
 %token DEFAULT
@@ -2990,6 +2994,30 @@ cmd:
 		$$=0; yyerror("bad argument, [proto:]host[:port] expected");
 		$$=0; yyerror("bad argument, [proto:]host[:port] expected");
 	}
 	}
 	| FORCE_SEND_SOCKET error {$$=0; yyerror("missing '(' or ')' ?"); }
 	| FORCE_SEND_SOCKET error {$$=0; yyerror("missing '(' or ')' ?"); }
+	| SET_FWD_NO_CONNECT LPAREN RPAREN	{
+		$$=mk_action(SET_FWD_NO_CONNECT_T, 0); set_cfg_pos($$);
+	}
+	| SET_FWD_NO_CONNECT	{
+		$$=mk_action(SET_FWD_NO_CONNECT_T, 0); set_cfg_pos($$);
+	}
+	| SET_RPL_NO_CONNECT LPAREN RPAREN	{
+		$$=mk_action(SET_RPL_NO_CONNECT_T, 0); set_cfg_pos($$);
+	}
+	| SET_RPL_NO_CONNECT	{
+		$$=mk_action(SET_RPL_NO_CONNECT_T, 0); set_cfg_pos($$);
+	}
+	| SET_FWD_CLOSE LPAREN RPAREN	{
+		$$=mk_action(SET_FWD_CLOSE_T, 0); set_cfg_pos($$);
+	}
+	| SET_FWD_CLOSE	{
+		$$=mk_action(SET_FWD_CLOSE_T, 0); set_cfg_pos($$);
+	}
+	| SET_RPL_CLOSE LPAREN RPAREN	{
+		$$=mk_action(SET_RPL_CLOSE_T, 0); set_cfg_pos($$);
+	}
+	| SET_RPL_CLOSE	{
+		$$=mk_action(SET_RPL_CLOSE_T, 0); set_cfg_pos($$);
+	}
 	| ID {mod_func_action = mk_action(MODULE_T, 2, MODEXP_ST, NULL, NUMBER_ST,
 	| ID {mod_func_action = mk_action(MODULE_T, 2, MODEXP_ST, NULL, NUMBER_ST,
 			0); } LPAREN func_params RPAREN	{
 			0); } LPAREN func_params RPAREN	{
 		mod_func_action->val[0].u.data = 
 		mod_func_action->val[0].u.data = 

+ 5 - 1
route_struct.h

@@ -106,7 +106,11 @@ enum action_type{
 		FORCE_SEND_SOCKET_T,
 		FORCE_SEND_SOCKET_T,
 		ASSIGN_T,
 		ASSIGN_T,
 		ADD_T,
 		ADD_T,
-		UDP_MTU_TRY_PROTO_T
+		UDP_MTU_TRY_PROTO_T,
+		SET_FWD_NO_CONNECT_T,
+		SET_RPL_NO_CONNECT_T,
+		SET_FWD_CLOSE_T,
+		SET_RPL_CLOSE_T
 };
 };
 /* parameter types for actions or types for expression right operands
 /* parameter types for actions or types for expression right operands
    (WARNING right operands only, not working for left operands) */
    (WARNING right operands only, not working for left operands) */