blob: 9fb087889d7304dc7fe7fcb8d0799cae97055090 [file] [log] [blame]
Thierry FOURNIERa28a9422015-08-04 19:35:46 +02001/*
2 * include/types/action.h
3 * This file contains TCP protocol definitions.
4 *
5 * Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation, version 2.1
10 * exclusively.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef _TYPES_ACTION_H
23#define _TYPES_ACTION_H
24
25#include <types/stick_table.h>
26
Thierry FOURNIER5563e4b2015-08-14 19:20:07 +020027enum act_from {
28 ACT_F_TCP_REQ_CON, /* tcp-request connection */
29 ACT_F_TCP_REQ_CNT, /* tcp-request content */
30 ACT_F_TCP_RES_CNT, /* tcp-response content */
31 ACT_F_HTTP_REQ, /* http-request */
32 ACT_F_HTTP_RES, /* http-response */
33};
34
Thierry FOURNIER24ff6c62015-08-06 08:52:53 +020035enum act_return {
36 ACT_RET_CONT, /* continue processing. */
37 ACT_RET_YIELD, /* call me again. */
38 ACT_RET_ERR, /* processing error. */
39};
40
Thierry FOURNIER91f6ba02015-08-06 08:30:11 +020041enum act_name {
42 ACT_ACTION_CONT = 0,
43 ACT_ACTION_STOP,
44
Thierry FOURNIER0ea5c7f2015-08-05 19:05:19 +020045 /* common action */
46 ACT_ACTION_ALLOW,
47 ACT_ACTION_DENY,
48
49 /* common http actions .*/
50 ACT_HTTP_ADD_HDR,
51 ACT_HTTP_REPLACE_HDR,
52 ACT_HTTP_REPLACE_VAL,
53 ACT_HTTP_SET_HDR,
54 ACT_HTTP_DEL_HDR,
55 ACT_HTTP_REDIR,
56 ACT_HTTP_SET_NICE,
57 ACT_HTTP_SET_LOGL,
58 ACT_HTTP_SET_TOS,
59 ACT_HTTP_SET_MARK,
60 ACT_HTTP_ADD_ACL,
61 ACT_HTTP_DEL_ACL,
62 ACT_HTTP_DEL_MAP,
63 ACT_HTTP_SET_MAP,
Thierry FOURNIER91f6ba02015-08-06 08:30:11 +020064
Thierry FOURNIER0ea5c7f2015-08-05 19:05:19 +020065 /* http request actions. */
66 ACT_HTTP_REQ_TARPIT,
67 ACT_HTTP_REQ_AUTH,
68 ACT_HTTP_REQ_SET_SRC,
Thierry FOURNIER91f6ba02015-08-06 08:30:11 +020069
70 /* tcp actions */
Thierry FOURNIER0ea5c7f2015-08-05 19:05:19 +020071 ACT_TCP_EXPECT_PX,
72 ACT_TCP_CLOSE, /* close at the sender's */
73 ACT_TCP_CAPTURE, /* capture a fetched sample */
74
75 /* track stick counters */
76 ACT_ACTION_TRK_SC0,
77 /* SC1, SC2, ... SCn */
78 ACT_ACTION_TRK_SCMAX = ACT_ACTION_TRK_SC0 + MAX_SESS_STKCTR - 1,
Thierry FOURNIER91f6ba02015-08-06 08:30:11 +020079};
80
Thierry FOURNIERa28a9422015-08-04 19:35:46 +020081struct act_rule {
82 struct list list;
83 struct acl_cond *cond; /* acl condition to meet */
Thierry FOURNIER91f6ba02015-08-06 08:30:11 +020084 enum act_name action; /* ACT_ACTION_* */
Thierry FOURNIER5563e4b2015-08-14 19:20:07 +020085 enum act_from from; /* ACT_F_* */
Thierry FOURNIERa28a9422015-08-04 19:35:46 +020086 short deny_status; /* HTTP status to return to user when denying */
Thierry FOURNIER24ff6c62015-08-06 08:52:53 +020087 enum act_return (*action_ptr)(struct act_rule *rule, struct proxy *px,
88 struct session *sess, struct stream *s); /* ptr to custom action */
Thierry FOURNIERa28a9422015-08-04 19:35:46 +020089 union {
90 struct {
91 char *realm;
92 } auth; /* arg used by "auth" */
93 struct {
94 char *name; /* header name */
95 int name_len; /* header name's length */
96 struct list fmt; /* log-format compatible expression */
97 struct my_regex re; /* used by replace-header and replace-value */
98 } hdr_add; /* args used by "add-header" and "set-header" */
99 struct redirect_rule *redir; /* redirect rule or "http-request redirect" */
Thierry FOURNIER0ea5c7f2015-08-05 19:05:19 +0200100 int nice; /* nice value for ACT_HTTP_SET_NICE */
101 int loglevel; /* log-level value for ACT_HTTP_SET_LOGL */
102 int tos; /* tos value for ACT_HTTP_SET_TOS */
103 int mark; /* nfmark value for ACT_HTTP_SET_MARK */
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200104 struct {
105 char *ref; /* MAP or ACL file name to update */
106 struct list key; /* pattern to retrieve MAP or ACL key */
107 struct list value; /* pattern to retrieve MAP value */
108 } map;
Thierry FOURNIERa002dc92015-07-31 08:50:51 +0200109 struct sample_expr *expr;
Thierry FOURNIER8855a922015-07-31 08:54:25 +0200110 struct {
111 struct list logfmt;
112 int action;
113 } http;
Thierry FOURNIER32b15002015-07-31 08:56:16 +0200114 struct {
Thierry FOURNIERd0d65ae2015-08-04 08:21:12 +0200115 struct sample_expr *expr; /* expression used as the key */
116 struct cap_hdr *hdr; /* the capture storage */
Thierry FOURNIER32b15002015-07-31 08:56:16 +0200117 } cap;
Thierry FOURNIERe2097972015-07-31 08:56:35 +0200118 struct {
119 struct sample_expr *expr;
120 int idx;
121 } capid;
Thierry FOURNIER231ef1d2015-07-30 19:03:55 +0200122 struct hlua_rule *hlua_rule;
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200123 struct {
Thierry FOURNIERf8c1dce2015-07-30 19:12:50 +0200124 struct sample_expr *expr;
125 const char *name;
126 enum vars_scope scope;
127 } vars;
Thierry FOURNIER5ec63e02015-08-04 09:09:48 +0200128 struct track_ctr_prm trk_ctr;
Thierry FOURNIERf8c1dce2015-07-30 19:12:50 +0200129 struct {
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200130 void *p[4];
131 } act; /* generic pointers to be used by custom actions */
132 } arg; /* arguments used by some actions */
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200133};
134
Thierry FOURNIER36481b82015-08-19 09:01:53 +0200135struct action_kw {
136 const char *kw;
137 int (*parse)(const char **args, int *cur_arg, struct proxy *px,
138 struct act_rule *rule, char **err);
139 int match_pfx;
140};
141
142struct action_kw_list {
143 struct list list;
144 struct action_kw kw[VAR_ARRAY];
145};
146
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200147#endif /* _TYPES_ACTION_H */