blob: 09c14c504b1aadbd5235725c8a31dfe3d0acd0cd [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
Thierry FOURNIER0ea5c7f2015-08-05 19:05:19 +020039 /* common action */
40 ACT_ACTION_ALLOW,
41 ACT_ACTION_DENY,
42
43 /* common http actions .*/
44 ACT_HTTP_ADD_HDR,
45 ACT_HTTP_REPLACE_HDR,
46 ACT_HTTP_REPLACE_VAL,
47 ACT_HTTP_SET_HDR,
48 ACT_HTTP_DEL_HDR,
49 ACT_HTTP_REDIR,
50 ACT_HTTP_SET_NICE,
51 ACT_HTTP_SET_LOGL,
52 ACT_HTTP_SET_TOS,
53 ACT_HTTP_SET_MARK,
54 ACT_HTTP_ADD_ACL,
55 ACT_HTTP_DEL_ACL,
56 ACT_HTTP_DEL_MAP,
57 ACT_HTTP_SET_MAP,
Thierry FOURNIER91f6ba02015-08-06 08:30:11 +020058
Thierry FOURNIER0ea5c7f2015-08-05 19:05:19 +020059 /* http request actions. */
60 ACT_HTTP_REQ_TARPIT,
61 ACT_HTTP_REQ_AUTH,
62 ACT_HTTP_REQ_SET_SRC,
Thierry FOURNIER91f6ba02015-08-06 08:30:11 +020063
64 /* tcp actions */
Thierry FOURNIER0ea5c7f2015-08-05 19:05:19 +020065 ACT_TCP_EXPECT_PX,
66 ACT_TCP_CLOSE, /* close at the sender's */
67 ACT_TCP_CAPTURE, /* capture a fetched sample */
68
69 /* track stick counters */
70 ACT_ACTION_TRK_SC0,
71 /* SC1, SC2, ... SCn */
72 ACT_ACTION_TRK_SCMAX = ACT_ACTION_TRK_SC0 + MAX_SESS_STKCTR - 1,
Thierry FOURNIER91f6ba02015-08-06 08:30:11 +020073};
74
Thierry FOURNIERa28a9422015-08-04 19:35:46 +020075struct act_rule {
76 struct list list;
77 struct acl_cond *cond; /* acl condition to meet */
Thierry FOURNIER91f6ba02015-08-06 08:30:11 +020078 enum act_name action; /* ACT_ACTION_* */
Thierry FOURNIER5563e4b2015-08-14 19:20:07 +020079 enum act_from from; /* ACT_F_* */
Thierry FOURNIERa28a9422015-08-04 19:35:46 +020080 short deny_status; /* HTTP status to return to user when denying */
81 int (*action_ptr)(struct act_rule *rule, struct proxy *px,
82 struct session *sess, struct stream *s); /* ptr to custom action */
83 union {
84 struct {
85 char *realm;
86 } auth; /* arg used by "auth" */
87 struct {
88 char *name; /* header name */
89 int name_len; /* header name's length */
90 struct list fmt; /* log-format compatible expression */
91 struct my_regex re; /* used by replace-header and replace-value */
92 } hdr_add; /* args used by "add-header" and "set-header" */
93 struct redirect_rule *redir; /* redirect rule or "http-request redirect" */
Thierry FOURNIER0ea5c7f2015-08-05 19:05:19 +020094 int nice; /* nice value for ACT_HTTP_SET_NICE */
95 int loglevel; /* log-level value for ACT_HTTP_SET_LOGL */
96 int tos; /* tos value for ACT_HTTP_SET_TOS */
97 int mark; /* nfmark value for ACT_HTTP_SET_MARK */
Thierry FOURNIERa28a9422015-08-04 19:35:46 +020098 struct {
99 char *ref; /* MAP or ACL file name to update */
100 struct list key; /* pattern to retrieve MAP or ACL key */
101 struct list value; /* pattern to retrieve MAP value */
102 } map;
Thierry FOURNIERa002dc92015-07-31 08:50:51 +0200103 struct sample_expr *expr;
Thierry FOURNIER8855a922015-07-31 08:54:25 +0200104 struct {
105 struct list logfmt;
106 int action;
107 } http;
Thierry FOURNIER32b15002015-07-31 08:56:16 +0200108 struct {
Thierry FOURNIERd0d65ae2015-08-04 08:21:12 +0200109 struct sample_expr *expr; /* expression used as the key */
110 struct cap_hdr *hdr; /* the capture storage */
Thierry FOURNIER32b15002015-07-31 08:56:16 +0200111 } cap;
Thierry FOURNIERe2097972015-07-31 08:56:35 +0200112 struct {
113 struct sample_expr *expr;
114 int idx;
115 } capid;
Thierry FOURNIER231ef1d2015-07-30 19:03:55 +0200116 struct hlua_rule *hlua_rule;
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200117 struct {
Thierry FOURNIERf8c1dce2015-07-30 19:12:50 +0200118 struct sample_expr *expr;
119 const char *name;
120 enum vars_scope scope;
121 } vars;
Thierry FOURNIER5ec63e02015-08-04 09:09:48 +0200122 struct track_ctr_prm trk_ctr;
Thierry FOURNIERf8c1dce2015-07-30 19:12:50 +0200123 struct {
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200124 void *p[4];
125 } act; /* generic pointers to be used by custom actions */
126 } arg; /* arguments used by some actions */
Thierry FOURNIERa28a9422015-08-04 19:35:46 +0200127};
128
129#endif /* _TYPES_ACTION_H */