Module: sip-router Branch: andrei/send_flags Commit: 58cbf7f7e13fa383a76d9f67d38a686ae5e8babe URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=58cbf7f7...
Author: Andrei Pelinescu-Onciul andrei@iptel.org Committer: Andrei Pelinescu-Onciul andrei@iptel.org Date: Tue Sep 15 17:47:33 2009 +0200
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.
---
action.c | 17 +++++++++++++++++ cfg.lex | 12 ++++++++++++ cfg.y | 28 ++++++++++++++++++++++++++++ route_struct.h | 6 +++++- 4 files changed, 62 insertions(+), 1 deletions(-)
diff --git a/action.c b/action.c index 352dd90..13a9817 100644 --- a/action.c +++ b/action.c @@ -50,6 +50,7 @@ * 2008-12-03 use lvalues/rvalues for assignments (andrei) * 2008-12-17 added UDP_MTU_TRY_PROTO_T (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 ret=v; 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: LOG(L_CRIT, "BUG: do_action: unknown type %d\n", a->type); diff --git a/cfg.lex b/cfg.lex index 9723877..bedf79c 100644 --- a/cfg.lex +++ b/cfg.lex @@ -215,6 +215,10 @@ ELSE "else" SET_ADV_ADDRESS "set_advertised_address" SET_ADV_PORT "set_advertised_port" 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" CASE "case" DEFAULT "default" @@ -572,6 +576,14 @@ EAT_ABLE [\ \t\b\r] return SET_ADV_PORT; } <INITIAL>{FORCE_SEND_SOCKET} { count(); yylval.strval=yytext; 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>{CASE} { count(); yylval.strval=yytext; return CASE; } <INITIAL>{DEFAULT} { count(); yylval.strval=yytext; return DEFAULT; } diff --git a/cfg.y b/cfg.y index 3344b03..af5335c 100644 --- a/cfg.y +++ b/cfg.y @@ -319,6 +319,10 @@ extern char *finame; %token SET_ADV_ADDRESS %token SET_ADV_PORT %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 CASE %token DEFAULT @@ -2990,6 +2994,30 @@ cmd: $$=0; yyerror("bad argument, [proto:]host[:port] expected"); } | 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, 0); } LPAREN func_params RPAREN { mod_func_action->val[0].u.data = diff --git a/route_struct.h b/route_struct.h index 4dc84e9..4894bd5 100644 --- a/route_struct.h +++ b/route_struct.h @@ -106,7 +106,11 @@ enum action_type{ FORCE_SEND_SOCKET_T, ASSIGN_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 (WARNING right operands only, not working for left operands) */