]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: actions: Declare all the embedded actions in the same header file
authorThierry FOURNIER <tfournier@arpalert.org>
Thu, 6 Aug 2015 06:30:11 +0000 (08:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Aug 2015 15:13:47 +0000 (17:13 +0200)
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.

include/types/action.h
include/types/proto_http.h
include/types/proto_tcp.h
src/hlua.c
src/proto_http.c
src/proto_tcp.c
src/vars.c

index 77ce92814e709916872e0e4f06688bcf620c82fd..9d8b2f959e9242c94630722cb6bb7872631aa0df 100644 (file)
@@ -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,
index 62016da08c1ea1784429cb9990aa2307e6defb28..16be842df402097d931e61c562d6b761a916e81d 100644 (file)
@@ -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 */
index 4ab09856bf56f9394e4f8430824411d7479f5f85..df969a145bf0dd51a976b2977fc9b78e7f3a078c 100644 (file)
 #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,
index 83c66ae99c38ef3d93bd6bfdacdd7be29576aa2f..0c03b775c0b43f90b0c02b81339fdecc6825ae06 100644 (file)
@@ -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;
 }
index 0d8f50cf9b6f78eaf3397c18b0b5f258b8122a66..17278aa0fba0edfd0bd4ecc8121ff202fc6b3c3c 100644 (file)
@@ -3628,14 +3628,14 @@ resume_execution:
                        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 @@ resume_execution:
                                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;
index 2dab423e8374da796df9c49205940263fdcfe8d7..ef32207bd09f70fd03533545ffe2975d6d7e3bb7 100644 (file)
@@ -1237,7 +1237,7 @@ resume_execution:
                                }
 
                                /* accept */
-                               if (rule->action == TCP_ACT_CUSTOM)
+                               if (rule->action == ACT_ACTION_STOP)
                                        break;
                                /* otherwise continue */
                        }
@@ -1363,7 +1363,7 @@ resume_execution:
                                }
 
                                /* 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;
                                }
 
index 50fb36a05dfe28c22ff72dca70542abf9d1593c3..86ac93b7b67ae7a89f1b6308e3f9de7d5c9007a1 100644 (file)
@@ -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;
 }