mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
MINOR: actions: Declare all the embedded actions in the same header file
This patch group the action name in one file. Some action are called many times and need an action embedded in the action caller. The main goal is to have only one header file grouping all definitions.
This commit is contained in:
parent
22e49011b1
commit
91f6ba0f2c
@ -32,10 +32,70 @@ enum act_from {
|
||||
ACT_F_HTTP_RES, /* http-response */
|
||||
};
|
||||
|
||||
enum act_name {
|
||||
ACT_ACTION_CONT = 0,
|
||||
ACT_ACTION_STOP,
|
||||
|
||||
/* http request actions. */
|
||||
HTTP_REQ_ACT_UNKNOWN,
|
||||
HTTP_REQ_ACT_ALLOW,
|
||||
HTTP_REQ_ACT_DENY,
|
||||
HTTP_REQ_ACT_TARPIT,
|
||||
HTTP_REQ_ACT_AUTH,
|
||||
HTTP_REQ_ACT_ADD_HDR,
|
||||
HTTP_REQ_ACT_SET_HDR,
|
||||
HTTP_REQ_ACT_DEL_HDR,
|
||||
HTTP_REQ_ACT_REPLACE_HDR,
|
||||
HTTP_REQ_ACT_REPLACE_VAL,
|
||||
HTTP_REQ_ACT_REDIR,
|
||||
HTTP_REQ_ACT_SET_NICE,
|
||||
HTTP_REQ_ACT_SET_LOGL,
|
||||
HTTP_REQ_ACT_SET_TOS,
|
||||
HTTP_REQ_ACT_SET_MARK,
|
||||
HTTP_REQ_ACT_ADD_ACL,
|
||||
HTTP_REQ_ACT_DEL_ACL,
|
||||
HTTP_REQ_ACT_DEL_MAP,
|
||||
HTTP_REQ_ACT_SET_MAP,
|
||||
HTTP_REQ_ACT_SET_SRC,
|
||||
HTTP_REQ_ACT_TRK_SC0,
|
||||
/* SC1, SC2, ... SCn */
|
||||
HTTP_REQ_ACT_TRK_SCMAX = HTTP_REQ_ACT_TRK_SC0 + MAX_SESS_STKCTR - 1,
|
||||
|
||||
/* http response actions */
|
||||
HTTP_RES_ACT_UNKNOWN,
|
||||
HTTP_RES_ACT_ALLOW,
|
||||
HTTP_RES_ACT_DENY,
|
||||
HTTP_RES_ACT_ADD_HDR,
|
||||
HTTP_RES_ACT_REPLACE_HDR,
|
||||
HTTP_RES_ACT_REPLACE_VAL,
|
||||
HTTP_RES_ACT_SET_HDR,
|
||||
HTTP_RES_ACT_DEL_HDR,
|
||||
HTTP_RES_ACT_SET_NICE,
|
||||
HTTP_RES_ACT_SET_LOGL,
|
||||
HTTP_RES_ACT_SET_TOS,
|
||||
HTTP_RES_ACT_SET_MARK,
|
||||
HTTP_RES_ACT_ADD_ACL,
|
||||
HTTP_RES_ACT_DEL_ACL,
|
||||
HTTP_RES_ACT_DEL_MAP,
|
||||
HTTP_RES_ACT_SET_MAP,
|
||||
HTTP_RES_ACT_REDIR,
|
||||
|
||||
/* tcp actions */
|
||||
TCP_ACT_ACCEPT,
|
||||
TCP_ACT_REJECT,
|
||||
TCP_ACT_EXPECT_PX,
|
||||
TCP_ACT_TRK_SC0, /* TCP request tracking : must be contiguous and cover up to MAX_SESS_STKCTR values */
|
||||
TCP_ACT_TRK_SC1,
|
||||
TCP_ACT_TRK_SC2,
|
||||
TCP_ACT_TRK_SCMAX = TCP_ACT_TRK_SC0 + MAX_SESS_STKCTR - 1,
|
||||
TCP_ACT_CLOSE, /* close at the sender's */
|
||||
TCP_ACT_CAPTURE, /* capture a fetched sample */
|
||||
};
|
||||
|
||||
struct act_rule {
|
||||
struct list list;
|
||||
struct acl_cond *cond; /* acl condition to meet */
|
||||
unsigned int action; /* HTTP_REQ_* */
|
||||
enum act_name action; /* ACT_ACTION_* */
|
||||
enum act_from from; /* ACT_F_* */
|
||||
short deny_status; /* HTTP status to return to user when denying */
|
||||
int (*action_ptr)(struct act_rule *rule, struct proxy *px,
|
||||
|
@ -225,58 +225,6 @@ enum ht_auth_m {
|
||||
HTTP_AUTH_DIGEST,
|
||||
} __attribute__((packed));
|
||||
|
||||
/* actions for "http-request" */
|
||||
enum {
|
||||
HTTP_REQ_ACT_UNKNOWN = 0,
|
||||
HTTP_REQ_ACT_ALLOW,
|
||||
HTTP_REQ_ACT_DENY,
|
||||
HTTP_REQ_ACT_TARPIT,
|
||||
HTTP_REQ_ACT_AUTH,
|
||||
HTTP_REQ_ACT_ADD_HDR,
|
||||
HTTP_REQ_ACT_SET_HDR,
|
||||
HTTP_REQ_ACT_DEL_HDR,
|
||||
HTTP_REQ_ACT_REPLACE_HDR,
|
||||
HTTP_REQ_ACT_REPLACE_VAL,
|
||||
HTTP_REQ_ACT_REDIR,
|
||||
HTTP_REQ_ACT_SET_NICE,
|
||||
HTTP_REQ_ACT_SET_LOGL,
|
||||
HTTP_REQ_ACT_SET_TOS,
|
||||
HTTP_REQ_ACT_SET_MARK,
|
||||
HTTP_REQ_ACT_ADD_ACL,
|
||||
HTTP_REQ_ACT_DEL_ACL,
|
||||
HTTP_REQ_ACT_DEL_MAP,
|
||||
HTTP_REQ_ACT_SET_MAP,
|
||||
HTTP_REQ_ACT_CUSTOM_STOP,
|
||||
HTTP_REQ_ACT_CUSTOM_CONT,
|
||||
HTTP_REQ_ACT_SET_SRC,
|
||||
HTTP_REQ_ACT_TRK_SC0,
|
||||
/* SC1, SC2, ... SCn */
|
||||
HTTP_REQ_ACT_TRK_SCMAX = HTTP_REQ_ACT_TRK_SC0 + MAX_SESS_STKCTR - 1,
|
||||
};
|
||||
|
||||
/* actions for "http-response" */
|
||||
enum {
|
||||
HTTP_RES_ACT_UNKNOWN = 0,
|
||||
HTTP_RES_ACT_ALLOW,
|
||||
HTTP_RES_ACT_DENY,
|
||||
HTTP_RES_ACT_ADD_HDR,
|
||||
HTTP_RES_ACT_REPLACE_HDR,
|
||||
HTTP_RES_ACT_REPLACE_VAL,
|
||||
HTTP_RES_ACT_SET_HDR,
|
||||
HTTP_RES_ACT_DEL_HDR,
|
||||
HTTP_RES_ACT_SET_NICE,
|
||||
HTTP_RES_ACT_SET_LOGL,
|
||||
HTTP_RES_ACT_SET_TOS,
|
||||
HTTP_RES_ACT_SET_MARK,
|
||||
HTTP_RES_ACT_ADD_ACL,
|
||||
HTTP_RES_ACT_DEL_ACL,
|
||||
HTTP_RES_ACT_DEL_MAP,
|
||||
HTTP_RES_ACT_SET_MAP,
|
||||
HTTP_RES_ACT_REDIR,
|
||||
HTTP_RES_ACT_CUSTOM_STOP, /* used for module keywords */
|
||||
HTTP_RES_ACT_CUSTOM_CONT, /* used for module keywords */
|
||||
};
|
||||
|
||||
/* final results for http-request rules */
|
||||
enum rule_result {
|
||||
HTTP_RULE_RES_CONT = 0, /* nothing special, continue rules evaluation */
|
||||
|
@ -29,21 +29,6 @@
|
||||
#include <types/acl.h>
|
||||
#include <types/stream.h>
|
||||
|
||||
/* Layer4 accept/reject rules */
|
||||
enum {
|
||||
TCP_ACT_ACCEPT = 1,
|
||||
TCP_ACT_REJECT = 2,
|
||||
TCP_ACT_EXPECT_PX = 3,
|
||||
TCP_ACT_TRK_SC0 = 4, /* TCP request tracking : must be contiguous and cover up to MAX_SESS_STKCTR values */
|
||||
TCP_ACT_TRK_SC1 = 5,
|
||||
TCP_ACT_TRK_SC2 = 6,
|
||||
TCP_ACT_TRK_SCMAX = TCP_ACT_TRK_SC0 + MAX_SESS_STKCTR - 1,
|
||||
TCP_ACT_CLOSE, /* close at the sender's */
|
||||
TCP_ACT_CAPTURE, /* capture a fetched sample */
|
||||
TCP_ACT_CUSTOM, /* Use for custom registered keywords. */
|
||||
TCP_ACT_CUSTOM_CONT, /* Use for custom registered keywords. */
|
||||
};
|
||||
|
||||
struct tcp_action_kw {
|
||||
const char *kw;
|
||||
int (*parse)(const char **args, int *cur_arg, struct proxy *px,
|
||||
|
@ -4420,7 +4420,7 @@ static int tcp_req_action_register_lua(const char **args, int *cur_arg, struct p
|
||||
{
|
||||
if (!hlua_parse_rule(args, cur_arg, px, &rule->arg.hlua_rule, err))
|
||||
return 0;
|
||||
rule->action = TCP_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = hlua_tcp_req_act_wrapper;
|
||||
return 1;
|
||||
}
|
||||
@ -4431,7 +4431,7 @@ static int tcp_res_action_register_lua(const char **args, int *cur_arg, struct p
|
||||
{
|
||||
if (!hlua_parse_rule(args, cur_arg, px, &rule->arg.hlua_rule, err))
|
||||
return 0;
|
||||
rule->action = TCP_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = hlua_tcp_res_act_wrapper;
|
||||
return 1;
|
||||
}
|
||||
@ -4442,7 +4442,7 @@ static int http_req_action_register_lua(const char **args, int *cur_arg, struct
|
||||
{
|
||||
if (!hlua_parse_rule(args, cur_arg, px, &rule->arg.hlua_rule, err))
|
||||
return -1;
|
||||
rule->action = HTTP_REQ_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = hlua_http_req_act_wrapper;
|
||||
return 1;
|
||||
}
|
||||
@ -4453,7 +4453,7 @@ static int http_res_action_register_lua(const char **args, int *cur_arg, struct
|
||||
{
|
||||
if (!hlua_parse_rule(args, cur_arg, px, &rule->arg.hlua_rule, err))
|
||||
return -1;
|
||||
rule->action = HTTP_RES_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = hlua_http_res_act_wrapper;
|
||||
return 1;
|
||||
}
|
||||
|
@ -3628,14 +3628,14 @@ http_req_get_intercept_rule(struct proxy *px, struct list *rules, struct stream
|
||||
break;
|
||||
}
|
||||
|
||||
case HTTP_REQ_ACT_CUSTOM_CONT:
|
||||
case ACT_ACTION_CONT:
|
||||
if (!rule->action_ptr(rule, px, s->sess, s)) {
|
||||
s->current_rule = rule;
|
||||
return HTTP_RULE_RES_YIELD;
|
||||
}
|
||||
break;
|
||||
|
||||
case HTTP_REQ_ACT_CUSTOM_STOP:
|
||||
case ACT_ACTION_STOP:
|
||||
rule->action_ptr(rule, px, s->sess, s);
|
||||
return HTTP_RULE_RES_DONE;
|
||||
|
||||
@ -3908,14 +3908,14 @@ http_res_get_intercept_rule(struct proxy *px, struct list *rules, struct stream
|
||||
return HTTP_RULE_RES_BADREQ;
|
||||
return HTTP_RULE_RES_DONE;
|
||||
|
||||
case HTTP_RES_ACT_CUSTOM_CONT:
|
||||
case ACT_ACTION_CONT:
|
||||
if (!rule->action_ptr(rule, px, s->sess, s)) {
|
||||
s->current_rule = rule;
|
||||
return HTTP_RULE_RES_YIELD;
|
||||
}
|
||||
break;
|
||||
|
||||
case HTTP_RES_ACT_CUSTOM_STOP:
|
||||
case ACT_ACTION_STOP:
|
||||
rule->action_ptr(rule, px, s->sess, s);
|
||||
return HTTP_RULE_RES_STOP;
|
||||
|
||||
@ -12277,7 +12277,7 @@ int parse_set_req_line(const char **args, int *orig_arg, struct proxy *px, struc
|
||||
{
|
||||
int cur_arg = *orig_arg;
|
||||
|
||||
rule->action = HTTP_REQ_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
|
||||
switch (args[0][4]) {
|
||||
case 'm' :
|
||||
@ -12472,7 +12472,7 @@ int parse_http_req_capture(const char **args, int *orig_arg, struct proxy *px, s
|
||||
px->req_cap = hdr;
|
||||
px->to_log |= LW_REQHDR;
|
||||
|
||||
rule->action = HTTP_REQ_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = http_action_req_capture;
|
||||
rule->arg.cap.expr = expr;
|
||||
rule->arg.cap.hdr = hdr;
|
||||
@ -12500,7 +12500,7 @@ int parse_http_req_capture(const char **args, int *orig_arg, struct proxy *px, s
|
||||
|
||||
proxy->conf.args.ctx = ARGC_CAP;
|
||||
|
||||
rule->action = HTTP_REQ_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = http_action_req_capture_by_id;
|
||||
rule->arg.capid.expr = expr;
|
||||
rule->arg.capid.idx = id;
|
||||
@ -12622,7 +12622,7 @@ int parse_http_res_capture(const char **args, int *orig_arg, struct proxy *px, s
|
||||
|
||||
proxy->conf.args.ctx = ARGC_CAP;
|
||||
|
||||
rule->action = HTTP_RES_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = http_action_res_capture_by_id;
|
||||
rule->arg.capid.expr = expr;
|
||||
rule->arg.capid.idx = id;
|
||||
|
@ -1237,7 +1237,7 @@ int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit)
|
||||
}
|
||||
|
||||
/* accept */
|
||||
if (rule->action == TCP_ACT_CUSTOM)
|
||||
if (rule->action == ACT_ACTION_STOP)
|
||||
break;
|
||||
/* otherwise continue */
|
||||
}
|
||||
@ -1363,7 +1363,7 @@ int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
}
|
||||
|
||||
/* accept */
|
||||
if (rule->action == TCP_ACT_CUSTOM)
|
||||
if (rule->action == ACT_ACTION_STOP)
|
||||
break;
|
||||
/* otherwise continue */
|
||||
}
|
||||
@ -1442,7 +1442,7 @@ int tcp_exec_req_rules(struct session *sess)
|
||||
/* Custom keywords. */
|
||||
if (rule->action_ptr) {
|
||||
rule->action_ptr(rule, sess->fe, sess, NULL);
|
||||
if (rule->action == TCP_ACT_CUSTOM_CONT)
|
||||
if (rule->action == ACT_ACTION_CONT)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -610,7 +610,7 @@ static int parse_tcp_req_store(const char **args, int *arg, struct proxy *px,
|
||||
&rule->arg.vars.name,
|
||||
&rule->arg.vars.scope))
|
||||
return 0;
|
||||
rule->action = TCP_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = action_tcp_req_store;
|
||||
return 1;
|
||||
}
|
||||
@ -624,7 +624,7 @@ static int parse_tcp_res_store(const char **args, int *arg, struct proxy *px,
|
||||
&rule->arg.vars.name,
|
||||
&rule->arg.vars.scope))
|
||||
return 0;
|
||||
rule->action = TCP_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = action_tcp_res_store;
|
||||
return 1;
|
||||
}
|
||||
@ -638,7 +638,7 @@ static int parse_http_req_store(const char **args, int *arg, struct proxy *px,
|
||||
&rule->arg.vars.name,
|
||||
&rule->arg.vars.scope))
|
||||
return -1;
|
||||
rule->action = HTTP_REQ_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = action_http_req_store;
|
||||
return 0;
|
||||
}
|
||||
@ -652,7 +652,7 @@ static int parse_http_res_store(const char **args, int *arg, struct proxy *px,
|
||||
&rule->arg.vars.name,
|
||||
&rule->arg.vars.scope))
|
||||
return -1;
|
||||
rule->action = HTTP_RES_ACT_CUSTOM_CONT;
|
||||
rule->action = ACT_ACTION_CONT;
|
||||
rule->action_ptr = action_http_res_store;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user