Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * include/types/applet.h |
| 3 | * This file describes the applet struct and associated constants. |
| 4 | * |
| 5 | * Copyright (C) 2000-2015 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_APPLET_H |
| 23 | #define _TYPES_APPLET_H |
| 24 | |
| 25 | #include <types/hlua.h> |
| 26 | #include <types/obj_type.h> |
Thierry FOURNIER | c069cfd | 2015-09-11 08:50:34 +0200 | [diff] [blame] | 27 | #include <types/proxy.h> |
| 28 | #include <types/stream.h> |
Christopher Faulet | a73e59b | 2016-12-09 17:30:18 +0100 | [diff] [blame] | 29 | #include <common/buffer.h> |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 30 | #include <common/chunk.h> |
| 31 | #include <common/config.h> |
| 32 | |
| 33 | struct appctx; |
| 34 | |
| 35 | /* Applet descriptor */ |
Willy Tarreau | 3057645 | 2015-04-13 13:50:30 +0200 | [diff] [blame] | 36 | struct applet { |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 37 | enum obj_type obj_type; /* object type = OBJ_TYPE_APPLET */ |
| 38 | /* 3 unused bytes here */ |
| 39 | char *name; /* applet's name to report in logs */ |
Thierry FOURNIER | c069cfd | 2015-09-11 08:50:34 +0200 | [diff] [blame] | 40 | int (*init)(struct appctx *, struct proxy *px, struct stream *strm); /* callback to init ressources, may be NULL. |
| 41 | expect 1 if ok, 0 if an error occurs, -1 if miss data. */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 42 | void (*fct)(struct appctx *); /* internal I/O handler, may never be NULL */ |
| 43 | void (*release)(struct appctx *); /* callback to release resources, may be NULL */ |
Thierry FOURNIER | 1245a83 | 2015-09-22 00:02:58 +0200 | [diff] [blame] | 44 | unsigned int timeout; /* execution timeout. */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | /* Context of a running applet. */ |
| 48 | struct appctx { |
Willy Tarreau | 81f38d6 | 2015-04-13 17:11:11 +0200 | [diff] [blame] | 49 | struct list runq; /* chaining in the applet run queue */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 50 | enum obj_type obj_type; /* OBJ_TYPE_APPCTX */ |
| 51 | /* 3 unused bytes here */ |
| 52 | unsigned int st0; /* CLI state for stats, session state for peers */ |
| 53 | unsigned int st1; /* prompt for stats, session error for peers */ |
| 54 | unsigned int st2; /* output state for stats, unused by peers */ |
Willy Tarreau | 3057645 | 2015-04-13 13:50:30 +0200 | [diff] [blame] | 55 | struct applet *applet; /* applet this context refers to */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 56 | void *owner; /* pointer to upper layer's entity (eg: stream interface) */ |
Thierry FOURNIER | 5a363e7 | 2015-09-27 19:29:33 +0200 | [diff] [blame] | 57 | struct act_rule *rule; /* rule associated with the applet. */ |
Willy Tarreau | 3b6e547 | 2016-11-24 15:53:53 +0100 | [diff] [blame] | 58 | int (*io_handler)(struct appctx *appctx); /* used within the cli_io_handler when st0 = CLI_ST_CALLBACK */ |
| 59 | void (*io_release)(struct appctx *appctx); /* used within the cli_io_handler when st0 = CLI_ST_CALLBACK, |
Thierry FOURNIER / OZON.IO | 6a22dcb | 2016-11-12 10:51:33 +0100 | [diff] [blame] | 60 | if the command is terminated or the session released */ |
William Lallemand | 1e08cd8 | 2016-10-13 17:57:55 +0200 | [diff] [blame] | 61 | void *private; |
Christopher Faulet | a73e59b | 2016-12-09 17:30:18 +0100 | [diff] [blame] | 62 | struct buffer_wait buffer_wait; /* position in the list of objects waiting for a buffer */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 63 | |
| 64 | union { |
| 65 | struct { |
| 66 | struct proxy *px; |
| 67 | struct server *sv; |
| 68 | void *l; |
| 69 | int scope_str; /* limit scope to a frontend/backend substring */ |
| 70 | int scope_len; /* length of the string above in the buffer */ |
| 71 | int px_st; /* STAT_PX_ST* */ |
| 72 | unsigned int flags; /* STAT_* */ |
| 73 | int iid, type, sid; /* proxy id, type and service id if bounding of stats is enabled */ |
| 74 | int st_code; /* the status code returned by an action */ |
| 75 | } stats; |
| 76 | struct { |
| 77 | struct bref bref; /* back-reference from the session being dumped */ |
| 78 | void *target; /* session we want to dump, or NULL for all */ |
| 79 | unsigned int uid; /* if non-null, the uniq_id of the session being dumped */ |
| 80 | int section; /* section of the session being dumped */ |
| 81 | int pos; /* last position of the current session's buffer */ |
| 82 | } sess; |
| 83 | struct { |
| 84 | int iid; /* if >= 0, ID of the proxy to filter on */ |
| 85 | struct proxy *px; /* current proxy being dumped, NULL = not started yet. */ |
Willy Tarreau | 35069f8 | 2016-11-25 09:16:37 +0100 | [diff] [blame] | 86 | unsigned int flag; /* bit0: buffer being dumped, 0 = req, 1 = resp ; bit1=skip req ; bit2=skip resp. */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 87 | unsigned int sid; /* session ID of error being dumped */ |
| 88 | int ptr; /* <0: headers, >=0 : text pointer to restart from */ |
| 89 | int bol; /* pointer to beginning of current line */ |
| 90 | } errors; |
| 91 | struct { |
| 92 | void *target; /* table we want to dump, or NULL for all */ |
| 93 | struct proxy *proxy; /* table being currently dumped (first if NULL) */ |
| 94 | struct stksess *entry; /* last entry we were trying to dump (or first if NULL) */ |
| 95 | long long value; /* value to compare against */ |
| 96 | signed char data_type; /* type of data to compare, or -1 if none */ |
| 97 | signed char data_op; /* operator (STD_OP_*) when data_type set */ |
| 98 | } table; |
| 99 | struct { |
| 100 | const char *msg; /* pointer to a persistent message to be returned in PRINT state */ |
| 101 | char *err; /* pointer to a 'must free' message to be returned in PRINT_FREE state */ |
| 102 | } cli; |
| 103 | struct { |
| 104 | void *ptr; /* multi-purpose pointer for peers */ |
| 105 | } peers; |
| 106 | struct { |
| 107 | unsigned int display_flags; |
| 108 | struct pat_ref *ref; |
| 109 | struct pat_ref_elt *elt; |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 110 | struct pattern_expr *expr; |
| 111 | struct chunk chunk; |
| 112 | } map; |
Nenad Merdanovic | 200b0fa | 2015-05-09 08:46:01 +0200 | [diff] [blame] | 113 | #if (defined SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB && TLS_TICKETS_NO > 0) |
| 114 | struct { |
William Lallemand | cf9e788 | 2016-06-14 17:45:18 +0200 | [diff] [blame] | 115 | int dump_all; |
William Lallemand | 72a8a18 | 2016-06-14 18:58:55 +0200 | [diff] [blame] | 116 | int dump_keys_index; |
Nenad Merdanovic | 200b0fa | 2015-05-09 08:46:01 +0200 | [diff] [blame] | 117 | struct tls_keys_ref *ref; |
| 118 | } tlskeys; |
| 119 | #endif |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 120 | struct { |
| 121 | int connected; |
| 122 | struct hlua_socket *socket; |
| 123 | struct list wake_on_read; |
| 124 | struct list wake_on_write; |
| 125 | } hlua; |
Baptiste Assmann | 3863f97 | 2015-05-17 00:33:24 +0200 | [diff] [blame] | 126 | struct { |
Thierry FOURNIER | f0a64b6 | 2015-09-19 12:36:17 +0200 | [diff] [blame] | 127 | struct hlua hlua; |
Thierry FOURNIER / OZON.IO | a44fdd9 | 2016-11-13 13:19:20 +0100 | [diff] [blame] | 128 | struct task *task; |
| 129 | } hlua_cli; |
| 130 | struct { |
| 131 | struct hlua hlua; |
Thierry FOURNIER | f0a64b6 | 2015-09-19 12:36:17 +0200 | [diff] [blame] | 132 | int flags; |
| 133 | struct task *task; |
| 134 | } hlua_apptcp; |
| 135 | struct { |
Thierry FOURNIER | a30b5db | 2015-09-18 09:04:27 +0200 | [diff] [blame] | 136 | struct hlua hlua; |
| 137 | int left_bytes; /* The max amount of bytes that we can read. */ |
| 138 | int flags; |
| 139 | int status; |
| 140 | struct task *task; |
| 141 | } hlua_apphttp; |
| 142 | struct { |
Baptiste Assmann | 3863f97 | 2015-05-17 00:33:24 +0200 | [diff] [blame] | 143 | struct dns_resolvers *ptr; |
| 144 | } resolvers; |
Baptiste Assmann | 2828946 | 2015-07-03 08:01:20 +0200 | [diff] [blame] | 145 | struct { |
Cyril Bonté | 76a9978 | 2016-05-06 12:18:48 +0200 | [diff] [blame] | 146 | int iid; /* if >= 0, ID of the proxy to filter on */ |
| 147 | struct proxy *px; /* current proxy being dumped, NULL = not started yet. */ |
| 148 | struct server *sv; /* current server being dumped, NULL = not started yet. */ |
Baptiste Assmann | 2828946 | 2015-07-03 08:01:20 +0200 | [diff] [blame] | 149 | } server_state; |
Willy Tarreau | ae79572 | 2016-02-16 11:27:28 +0100 | [diff] [blame] | 150 | struct { |
Cyril Bonté | 6ca9e01 | 2016-05-06 12:18:49 +0200 | [diff] [blame] | 151 | struct proxy *px; /* current proxy being dumped, NULL = not started yet. */ |
| 152 | } be; /* used by "show backends" command */ |
| 153 | struct { |
Willy Tarreau | ae79572 | 2016-02-16 11:27:28 +0100 | [diff] [blame] | 154 | char **var; |
| 155 | } env; |
Christopher Faulet | f7e4e7e | 2016-10-27 22:29:49 +0200 | [diff] [blame] | 156 | struct { |
| 157 | struct task *task; |
| 158 | void *ctx; |
| 159 | void *agent; |
| 160 | unsigned int version; |
| 161 | unsigned int max_frame_size; |
| 162 | struct list list; |
| 163 | } spoe; /* used by SPOE filter */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 164 | } ctx; /* used by stats I/O handlers to dump the stats */ |
| 165 | }; |
| 166 | |
| 167 | #endif /* _TYPES_APPLET_H */ |
| 168 | |
| 169 | /* |
| 170 | * Local variables: |
| 171 | * c-indent-level: 8 |
| 172 | * c-basic-offset: 8 |
| 173 | * End: |
| 174 | */ |