blob: 9d8b2f959e9242c94630722cb6bb7872631aa0df [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 FOURNIER91f6ba02015-08-06 08:30:11 +020035enum act_name {
36 ACT_ACTION_CONT = 0,
37 ACT_ACTION_STOP,
38
39 /* http request actions. */
40 HTTP_REQ_ACT_UNKNOWN,
41 HTTP_REQ_ACT_ALLOW,
42 HTTP_REQ_ACT_DENY,
43 HTTP_REQ_ACT_TARPIT,
44 HTTP_REQ_ACT_AUTH,
45 HTTP_REQ_ACT_ADD_HDR,
46 HTTP_REQ_ACT_SET_HDR,
47 HTTP_REQ_ACT_DEL_HDR,
48 HTTP_REQ_ACT_REPLACE_HDR,
49 HTTP_REQ_ACT_REPLACE_VAL,
50 HTTP_REQ_ACT_REDIR,
51 HTTP_REQ_ACT_SET_NICE,
52 HTTP_REQ_ACT_SET_LOGL,
53 HTTP_REQ_ACT_SET_TOS,
54 HTTP_REQ_ACT_SET_MARK,
55 HTTP_REQ_ACT_ADD_ACL,
56 HTTP_REQ_ACT_DEL_ACL,
57 HTTP_REQ_ACT_DEL_MAP,
58 HTTP_REQ_ACT_SET_MAP,
59 HTTP_REQ_ACT_SET_SRC,
60 HTTP_REQ_ACT_TRK_SC0,
61 /* SC1, SC2, ... SCn */
62 HTTP_REQ_ACT_TRK_SCMAX = HTTP_REQ_ACT_TRK_SC0 + MAX_SESS_STKCTR - 1,
63
64 /* http response actions */
65 HTTP_RES_ACT_UNKNOWN,
66 HTTP_RES_ACT_ALLOW,
67 HTTP_RES_ACT_DENY,
68 HTTP_RES_ACT_ADD_HDR,
69 HTTP_RES_ACT_REPLACE_HDR,
70 HTTP_RES_ACT_REPLACE_VAL,
71 HTTP_RES_ACT_SET_HDR,
72 HTTP_RES_ACT_DEL_HDR,
73 HTTP_RES_ACT_SET_NICE,
74 HTTP_RES_ACT_SET_LOGL,
75 HTTP_RES_ACT_SET_TOS,
76 HTTP_RES_ACT_SET_MARK,
77 HTTP_RES_ACT_ADD_ACL,
78 HTTP_RES_ACT_DEL_ACL,
79 HTTP_RES_ACT_DEL_MAP,
80 HTTP_RES_ACT_SET_MAP,
81 HTTP_RES_ACT_REDIR,
82
83 /* tcp actions */
84 TCP_ACT_ACCEPT,
85 TCP_ACT_REJECT,
86 TCP_ACT_EXPECT_PX,
87 TCP_ACT_TRK_SC0, /* TCP request tracking : must be contiguous and cover up to MAX_SESS_STKCTR values */
88 TCP_ACT_TRK_SC1,
89 TCP_ACT_TRK_SC2,
90 TCP_ACT_TRK_SCMAX = TCP_ACT_TRK_SC0 + MAX_SESS_STKCTR - 1,
91 TCP_ACT_CLOSE, /* close at the sender's */
92 TCP_ACT_CAPTURE, /* capture a fetched sample */
93};
94
Thierry FOURNIERa28a9422015-08-04 19:35:46 +020095struct act_rule {
96 struct list list;
97 struct acl_cond *cond; /* acl condition to meet */
Thierry FOURNIER91f6ba02015-08-06 08:30:11 +020098 enum act_name action; /* ACT_ACTION_* */
Thierry FOURNIER5563e4b2015-08-14 19:20:07 +020099 enum act_from from; /* ACT_F_* */
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200100 short deny_status; /* HTTP status to return to user when denying */
101 int (*action_ptr)(struct act_rule *rule, struct proxy *px,
102 struct session *sess, struct stream *s); /* ptr to custom action */
103 union {
104 struct {
105 char *realm;
106 } auth; /* arg used by "auth" */
107 struct {
108 char *name; /* header name */
109 int name_len; /* header name's length */
110 struct list fmt; /* log-format compatible expression */
111 struct my_regex re; /* used by replace-header and replace-value */
112 } hdr_add; /* args used by "add-header" and "set-header" */
113 struct redirect_rule *redir; /* redirect rule or "http-request redirect" */
114 int nice; /* nice value for HTTP_REQ_ACT_SET_NICE */
115 int loglevel; /* log-level value for HTTP_REQ_ACT_SET_LOGL */
116 int tos; /* tos value for HTTP_REQ_ACT_SET_TOS */
117 int mark; /* nfmark value for HTTP_REQ_ACT_SET_MARK */
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200118 struct {
119 char *ref; /* MAP or ACL file name to update */
120 struct list key; /* pattern to retrieve MAP or ACL key */
121 struct list value; /* pattern to retrieve MAP value */
122 } map;
Thierry FOURNIERa002dc92015-07-31 08:50:51 +0200123 struct sample_expr *expr;
Thierry FOURNIER8855a922015-07-31 08:54:25 +0200124 struct {
125 struct list logfmt;
126 int action;
127 } http;
Thierry FOURNIER32b15002015-07-31 08:56:16 +0200128 struct {
Thierry FOURNIERd0d65ae2015-08-04 08:21:12 +0200129 struct sample_expr *expr; /* expression used as the key */
130 struct cap_hdr *hdr; /* the capture storage */
Thierry FOURNIER32b15002015-07-31 08:56:16 +0200131 } cap;
Thierry FOURNIERe2097972015-07-31 08:56:35 +0200132 struct {
133 struct sample_expr *expr;
134 int idx;
135 } capid;
Thierry FOURNIER231ef1d2015-07-30 19:03:55 +0200136 struct hlua_rule *hlua_rule;
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200137 struct {
Thierry FOURNIERf8c1dce2015-07-30 19:12:50 +0200138 struct sample_expr *expr;
139 const char *name;
140 enum vars_scope scope;
141 } vars;
Thierry FOURNIER5ec63e02015-08-04 09:09:48 +0200142 struct track_ctr_prm trk_ctr;
Thierry FOURNIERf8c1dce2015-07-30 19:12:50 +0200143 struct {
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200144 void *p[4];
145 } act; /* generic pointers to be used by custom actions */
146 } arg; /* arguments used by some actions */
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200147};
148
149#endif /* _TYPES_ACTION_H */