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> |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 29 | #include <common/chunk.h> |
| 30 | #include <common/config.h> |
| 31 | |
| 32 | struct appctx; |
| 33 | |
| 34 | /* Applet descriptor */ |
Willy Tarreau | 3057645 | 2015-04-13 13:50:30 +0200 | [diff] [blame] | 35 | struct applet { |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 36 | enum obj_type obj_type; /* object type = OBJ_TYPE_APPLET */ |
| 37 | /* 3 unused bytes here */ |
| 38 | char *name; /* applet's name to report in logs */ |
Thierry FOURNIER | c069cfd | 2015-09-11 08:50:34 +0200 | [diff] [blame] | 39 | int (*init)(struct appctx *, struct proxy *px, struct stream *strm); /* callback to init ressources, may be NULL. |
| 40 | 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] | 41 | void (*fct)(struct appctx *); /* internal I/O handler, may never be NULL */ |
| 42 | void (*release)(struct appctx *); /* callback to release resources, may be NULL */ |
Thierry FOURNIER | 1245a83 | 2015-09-22 00:02:58 +0200 | [diff] [blame] | 43 | unsigned int timeout; /* execution timeout. */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | /* Context of a running applet. */ |
| 47 | struct appctx { |
Willy Tarreau | 81f38d6 | 2015-04-13 17:11:11 +0200 | [diff] [blame] | 48 | struct list runq; /* chaining in the applet run queue */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 49 | enum obj_type obj_type; /* OBJ_TYPE_APPCTX */ |
| 50 | /* 3 unused bytes here */ |
| 51 | unsigned int st0; /* CLI state for stats, session state for peers */ |
| 52 | unsigned int st1; /* prompt for stats, session error for peers */ |
| 53 | unsigned int st2; /* output state for stats, unused by peers */ |
Willy Tarreau | 3057645 | 2015-04-13 13:50:30 +0200 | [diff] [blame] | 54 | struct applet *applet; /* applet this context refers to */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 55 | void *owner; /* pointer to upper layer's entity (eg: stream interface) */ |
Thierry FOURNIER | 5a363e7 | 2015-09-27 19:29:33 +0200 | [diff] [blame] | 56 | struct act_rule *rule; /* rule associated with the applet. */ |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 57 | |
| 58 | union { |
| 59 | struct { |
| 60 | struct proxy *px; |
| 61 | struct server *sv; |
| 62 | void *l; |
| 63 | int scope_str; /* limit scope to a frontend/backend substring */ |
| 64 | int scope_len; /* length of the string above in the buffer */ |
| 65 | int px_st; /* STAT_PX_ST* */ |
| 66 | unsigned int flags; /* STAT_* */ |
| 67 | int iid, type, sid; /* proxy id, type and service id if bounding of stats is enabled */ |
| 68 | int st_code; /* the status code returned by an action */ |
| 69 | } stats; |
| 70 | struct { |
| 71 | struct bref bref; /* back-reference from the session being dumped */ |
| 72 | void *target; /* session we want to dump, or NULL for all */ |
| 73 | unsigned int uid; /* if non-null, the uniq_id of the session being dumped */ |
| 74 | int section; /* section of the session being dumped */ |
| 75 | int pos; /* last position of the current session's buffer */ |
| 76 | } sess; |
| 77 | struct { |
| 78 | int iid; /* if >= 0, ID of the proxy to filter on */ |
| 79 | struct proxy *px; /* current proxy being dumped, NULL = not started yet. */ |
| 80 | unsigned int buf; /* buffer being dumped, 0 = req, 1 = rep */ |
| 81 | unsigned int sid; /* session ID of error being dumped */ |
| 82 | int ptr; /* <0: headers, >=0 : text pointer to restart from */ |
| 83 | int bol; /* pointer to beginning of current line */ |
| 84 | } errors; |
| 85 | struct { |
| 86 | void *target; /* table we want to dump, or NULL for all */ |
| 87 | struct proxy *proxy; /* table being currently dumped (first if NULL) */ |
| 88 | struct stksess *entry; /* last entry we were trying to dump (or first if NULL) */ |
| 89 | long long value; /* value to compare against */ |
| 90 | signed char data_type; /* type of data to compare, or -1 if none */ |
| 91 | signed char data_op; /* operator (STD_OP_*) when data_type set */ |
| 92 | } table; |
| 93 | struct { |
| 94 | const char *msg; /* pointer to a persistent message to be returned in PRINT state */ |
| 95 | char *err; /* pointer to a 'must free' message to be returned in PRINT_FREE state */ |
| 96 | } cli; |
| 97 | struct { |
| 98 | void *ptr; /* multi-purpose pointer for peers */ |
| 99 | } peers; |
| 100 | struct { |
| 101 | unsigned int display_flags; |
| 102 | struct pat_ref *ref; |
| 103 | struct pat_ref_elt *elt; |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 104 | struct pattern_expr *expr; |
| 105 | struct chunk chunk; |
| 106 | } map; |
Nenad Merdanovic | 200b0fa | 2015-05-09 08:46:01 +0200 | [diff] [blame] | 107 | #if (defined SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB && TLS_TICKETS_NO > 0) |
| 108 | struct { |
| 109 | struct tls_keys_ref *ref; |
| 110 | } tlskeys; |
| 111 | #endif |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 112 | struct { |
| 113 | int connected; |
| 114 | struct hlua_socket *socket; |
| 115 | struct list wake_on_read; |
| 116 | struct list wake_on_write; |
| 117 | } hlua; |
Baptiste Assmann | 3863f97 | 2015-05-17 00:33:24 +0200 | [diff] [blame] | 118 | struct { |
Thierry FOURNIER | f0a64b6 | 2015-09-19 12:36:17 +0200 | [diff] [blame] | 119 | struct hlua hlua; |
| 120 | int flags; |
| 121 | struct task *task; |
| 122 | } hlua_apptcp; |
| 123 | struct { |
Thierry FOURNIER | a30b5db | 2015-09-18 09:04:27 +0200 | [diff] [blame] | 124 | struct hlua hlua; |
| 125 | int left_bytes; /* The max amount of bytes that we can read. */ |
| 126 | int flags; |
| 127 | int status; |
| 128 | struct task *task; |
| 129 | } hlua_apphttp; |
| 130 | struct { |
Baptiste Assmann | 3863f97 | 2015-05-17 00:33:24 +0200 | [diff] [blame] | 131 | struct dns_resolvers *ptr; |
| 132 | } resolvers; |
Baptiste Assmann | 2828946 | 2015-07-03 08:01:20 +0200 | [diff] [blame] | 133 | struct { |
| 134 | struct proxy *backend; |
| 135 | } server_state; |
Willy Tarreau | 8a8d83b | 2015-04-13 13:24:54 +0200 | [diff] [blame] | 136 | } ctx; /* used by stats I/O handlers to dump the stats */ |
| 137 | }; |
| 138 | |
| 139 | #endif /* _TYPES_APPLET_H */ |
| 140 | |
| 141 | /* |
| 142 | * Local variables: |
| 143 | * c-indent-level: 8 |
| 144 | * c-basic-offset: 8 |
| 145 | * End: |
| 146 | */ |