Thierry FOURNIER | a28a942 | 2015-08-04 19:35:46 +0200 | [diff] [blame] | 1 | /* |
| 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 FOURNIER | 5563e4b | 2015-08-14 19:20:07 +0200 | [diff] [blame] | 27 | enum 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 FOURNIER | 91f6ba0 | 2015-08-06 08:30:11 +0200 | [diff] [blame] | 35 | enum act_name { |
| 36 | ACT_ACTION_CONT = 0, |
| 37 | ACT_ACTION_STOP, |
| 38 | |
Thierry FOURNIER | 0ea5c7f | 2015-08-05 19:05:19 +0200 | [diff] [blame^] | 39 | /* 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 FOURNIER | 91f6ba0 | 2015-08-06 08:30:11 +0200 | [diff] [blame] | 58 | |
Thierry FOURNIER | 0ea5c7f | 2015-08-05 19:05:19 +0200 | [diff] [blame^] | 59 | /* http request actions. */ |
| 60 | ACT_HTTP_REQ_TARPIT, |
| 61 | ACT_HTTP_REQ_AUTH, |
| 62 | ACT_HTTP_REQ_SET_SRC, |
Thierry FOURNIER | 91f6ba0 | 2015-08-06 08:30:11 +0200 | [diff] [blame] | 63 | |
| 64 | /* tcp actions */ |
Thierry FOURNIER | 0ea5c7f | 2015-08-05 19:05:19 +0200 | [diff] [blame^] | 65 | 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 FOURNIER | 91f6ba0 | 2015-08-06 08:30:11 +0200 | [diff] [blame] | 73 | }; |
| 74 | |
Thierry FOURNIER | a28a942 | 2015-08-04 19:35:46 +0200 | [diff] [blame] | 75 | struct act_rule { |
| 76 | struct list list; |
| 77 | struct acl_cond *cond; /* acl condition to meet */ |
Thierry FOURNIER | 91f6ba0 | 2015-08-06 08:30:11 +0200 | [diff] [blame] | 78 | enum act_name action; /* ACT_ACTION_* */ |
Thierry FOURNIER | 5563e4b | 2015-08-14 19:20:07 +0200 | [diff] [blame] | 79 | enum act_from from; /* ACT_F_* */ |
Thierry FOURNIER | a28a942 | 2015-08-04 19:35:46 +0200 | [diff] [blame] | 80 | 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 FOURNIER | 0ea5c7f | 2015-08-05 19:05:19 +0200 | [diff] [blame^] | 94 | 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 FOURNIER | a28a942 | 2015-08-04 19:35:46 +0200 | [diff] [blame] | 98 | 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 FOURNIER | a002dc9 | 2015-07-31 08:50:51 +0200 | [diff] [blame] | 103 | struct sample_expr *expr; |
Thierry FOURNIER | 8855a92 | 2015-07-31 08:54:25 +0200 | [diff] [blame] | 104 | struct { |
| 105 | struct list logfmt; |
| 106 | int action; |
| 107 | } http; |
Thierry FOURNIER | 32b1500 | 2015-07-31 08:56:16 +0200 | [diff] [blame] | 108 | struct { |
Thierry FOURNIER | d0d65ae | 2015-08-04 08:21:12 +0200 | [diff] [blame] | 109 | struct sample_expr *expr; /* expression used as the key */ |
| 110 | struct cap_hdr *hdr; /* the capture storage */ |
Thierry FOURNIER | 32b1500 | 2015-07-31 08:56:16 +0200 | [diff] [blame] | 111 | } cap; |
Thierry FOURNIER | e209797 | 2015-07-31 08:56:35 +0200 | [diff] [blame] | 112 | struct { |
| 113 | struct sample_expr *expr; |
| 114 | int idx; |
| 115 | } capid; |
Thierry FOURNIER | 231ef1d | 2015-07-30 19:03:55 +0200 | [diff] [blame] | 116 | struct hlua_rule *hlua_rule; |
Thierry FOURNIER | a28a942 | 2015-08-04 19:35:46 +0200 | [diff] [blame] | 117 | struct { |
Thierry FOURNIER | f8c1dce | 2015-07-30 19:12:50 +0200 | [diff] [blame] | 118 | struct sample_expr *expr; |
| 119 | const char *name; |
| 120 | enum vars_scope scope; |
| 121 | } vars; |
Thierry FOURNIER | 5ec63e0 | 2015-08-04 09:09:48 +0200 | [diff] [blame] | 122 | struct track_ctr_prm trk_ctr; |
Thierry FOURNIER | f8c1dce | 2015-07-30 19:12:50 +0200 | [diff] [blame] | 123 | struct { |
Thierry FOURNIER | a28a942 | 2015-08-04 19:35:46 +0200 | [diff] [blame] | 124 | void *p[4]; |
| 125 | } act; /* generic pointers to be used by custom actions */ |
| 126 | } arg; /* arguments used by some actions */ |
Thierry FOURNIER | a28a942 | 2015-08-04 19:35:46 +0200 | [diff] [blame] | 127 | }; |
| 128 | |
| 129 | #endif /* _TYPES_ACTION_H */ |