Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | 5ab04ec | 2011-03-20 10:32:26 +0100 | [diff] [blame] | 2 | * include/types/server.h |
| 3 | * This file defines everything related to servers. |
| 4 | * |
Willy Tarreau | f09c660 | 2012-02-13 17:12:08 +0100 | [diff] [blame] | 5 | * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu |
Willy Tarreau | 5ab04ec | 2011-03-20 10:32:26 +0100 | [diff] [blame] | 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 | */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 21 | |
| 22 | #ifndef _TYPES_SERVER_H |
| 23 | #define _TYPES_SERVER_H |
| 24 | |
| 25 | #include <netinet/in.h> |
| 26 | #include <arpa/inet.h> |
| 27 | |
Emeric Brun | c6545ac | 2012-05-18 15:46:21 +0200 | [diff] [blame] | 28 | #ifdef USE_OPENSSL |
| 29 | #include <openssl/ssl.h> |
| 30 | #endif |
| 31 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 32 | #include <common/config.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 33 | #include <common/mini-clist.h> |
Willy Tarreau | 45cb4fb | 2009-10-26 21:10:04 +0100 | [diff] [blame] | 34 | #include <eb32tree.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 35 | |
Willy Tarreau | da92e2f | 2012-07-06 09:40:59 +0200 | [diff] [blame] | 36 | #include <types/connection.h> |
Krzysztof Piotr Oledzki | 052d4fd | 2009-10-04 14:52:57 +0200 | [diff] [blame] | 37 | #include <types/counters.h> |
Willy Tarreau | 7f062c4 | 2009-03-05 18:43:00 +0100 | [diff] [blame] | 38 | #include <types/freq_ctr.h> |
Willy Tarreau | 3fdb366 | 2012-11-12 00:42:33 +0100 | [diff] [blame] | 39 | #include <types/obj_type.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 40 | #include <types/proxy.h> |
| 41 | #include <types/queue.h> |
| 42 | #include <types/task.h> |
Krzysztof Piotr Oledzki | 0960541 | 2009-09-23 22:09:24 +0200 | [diff] [blame] | 43 | #include <types/checks.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 44 | |
| 45 | |
Godbach | f2dd68d | 2014-12-10 10:21:30 +0800 | [diff] [blame] | 46 | /* server states. Only SRV_ST_STOPPED indicates a down server. */ |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 47 | enum srv_state { |
Willy Tarreau | 892337c | 2014-05-13 23:41:20 +0200 | [diff] [blame] | 48 | SRV_ST_STOPPED = 0, /* the server is down. Please keep set to zero. */ |
| 49 | SRV_ST_STARTING, /* the server is warming up (up but throttled) */ |
| 50 | SRV_ST_RUNNING, /* the server is fully up */ |
| 51 | SRV_ST_STOPPING, /* the server is up but soft-stopping (eg: 404) */ |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 52 | }; |
| 53 | |
Willy Tarreau | bfc7b7a | 2014-05-22 16:14:34 +0200 | [diff] [blame] | 54 | /* Administrative status : a server runs in one of these 3 stats : |
| 55 | * - READY : normal mode |
| 56 | * - DRAIN : takes no new visitor, equivalent to weight == 0 |
| 57 | * - MAINT : maintenance mode, no more traffic nor health checks. |
| 58 | * |
| 59 | * Each server may be in maintenance by itself or may inherit this status from |
| 60 | * another server it tracks. It can also be in drain mode by itself or inherit |
| 61 | * it from another server. Let's store these origins here as flags. These flags |
| 62 | * are combined this way : |
| 63 | * |
| 64 | * FMAINT IMAINT FDRAIN IDRAIN Resulting state |
| 65 | * 0 0 0 0 READY |
| 66 | * 0 0 0 1 DRAIN |
| 67 | * 0 0 1 x DRAIN |
| 68 | * 0 1 x x MAINT |
| 69 | * 1 x x x MAINT |
| 70 | * |
| 71 | * This can be simplified this way : |
| 72 | * |
| 73 | * state_str = (state & MAINT) ? "MAINT" : (state & DRAIN) : "DRAIN" : "READY" |
Willy Tarreau | 2012521 | 2014-05-13 19:44:56 +0200 | [diff] [blame] | 74 | */ |
| 75 | enum srv_admin { |
| 76 | SRV_ADMF_FMAINT = 0x1, /* the server was explicitly forced into maintenance */ |
| 77 | SRV_ADMF_IMAINT = 0x2, /* the server has inherited the maintenance status from a tracked server */ |
| 78 | SRV_ADMF_MAINT = 0x3, /* mask to check if any maintenance flag is present */ |
Willy Tarreau | bfc7b7a | 2014-05-22 16:14:34 +0200 | [diff] [blame] | 79 | SRV_ADMF_FDRAIN = 0x4, /* the server was explicitly forced into drain state */ |
| 80 | SRV_ADMF_IDRAIN = 0x8, /* the server has inherited the drain status from a tracked server */ |
| 81 | SRV_ADMF_DRAIN = 0xC, /* mask to check if any drain flag is present */ |
Willy Tarreau | 2012521 | 2014-05-13 19:44:56 +0200 | [diff] [blame] | 82 | }; |
| 83 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 84 | /* server flags */ |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 85 | #define SRV_F_BACKUP 0x0001 /* this server is a backup server */ |
| 86 | #define SRV_F_MAPPORTS 0x0002 /* this server uses mapped ports */ |
| 87 | #define SRV_F_NON_STICK 0x0004 /* never add connections allocated to this server to a stick table */ |
KOVACS Krisztian | b3e54fe | 2014-11-17 15:11:45 +0100 | [diff] [blame] | 88 | #define SRV_F_USE_NS_FROM_PP 0x0008 /* use namespace associated with connection if present */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 89 | |
David S | afb7683 | 2014-05-08 23:42:08 -0400 | [diff] [blame] | 90 | /* configured server options for send-proxy (server->pp_opts) */ |
| 91 | #define SRV_PP_V1 0x0001 /* proxy protocol version 1 */ |
| 92 | #define SRV_PP_V2 0x0002 /* proxy protocol version 2 */ |
| 93 | #define SRV_PP_V2_SSL 0x0004 /* proxy protocol version 2 with SSL*/ |
| 94 | #define SRV_PP_V2_SSL_CN 0x0008 /* proxy protocol version 2 with SSL and CN*/ |
| 95 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 96 | /* function which act on servers need to return various errors */ |
| 97 | #define SRV_STATUS_OK 0 /* everything is OK. */ |
| 98 | #define SRV_STATUS_INTERNAL 1 /* other unrecoverable errors. */ |
| 99 | #define SRV_STATUS_NOSRV 2 /* no server is available */ |
| 100 | #define SRV_STATUS_FULL 3 /* the/all server(s) are saturated */ |
| 101 | #define SRV_STATUS_QUEUED 4 /* the/all server(s) are saturated but the connection was queued */ |
| 102 | |
Willy Tarreau | b698f0f | 2007-12-02 11:01:23 +0100 | [diff] [blame] | 103 | /* various constants */ |
| 104 | #define SRV_UWGHT_RANGE 256 |
Godbach | a34bdc0 | 2013-07-22 07:44:53 +0800 | [diff] [blame] | 105 | #define SRV_UWGHT_MAX (SRV_UWGHT_RANGE) |
Willy Tarreau | b698f0f | 2007-12-02 11:01:23 +0100 | [diff] [blame] | 106 | #define SRV_EWGHT_RANGE (SRV_UWGHT_RANGE * BE_WEIGHT_SCALE) |
| 107 | #define SRV_EWGHT_MAX (SRV_UWGHT_MAX * BE_WEIGHT_SCALE) |
| 108 | |
Emeric Brun | 8967549 | 2012-10-05 13:48:26 +0200 | [diff] [blame] | 109 | #ifdef USE_OPENSSL |
| 110 | /* server ssl options */ |
| 111 | #define SRV_SSL_O_NONE 0x0000 |
Emeric Brun | 992adc9 | 2012-10-11 18:36:21 +0200 | [diff] [blame] | 112 | #define SRV_SSL_O_NO_VMASK 0x000F /* force version mask */ |
Emeric Brun | 8967549 | 2012-10-05 13:48:26 +0200 | [diff] [blame] | 113 | #define SRV_SSL_O_NO_SSLV3 0x0001 /* disable SSLv3 */ |
| 114 | #define SRV_SSL_O_NO_TLSV10 0x0002 /* disable TLSv1.0 */ |
| 115 | #define SRV_SSL_O_NO_TLSV11 0x0004 /* disable TLSv1.1 */ |
| 116 | #define SRV_SSL_O_NO_TLSV12 0x0008 /* disable TLSv1.2 */ |
| 117 | /* 0x000F reserved for 'no' protocol version options */ |
Emeric Brun | 992adc9 | 2012-10-11 18:36:21 +0200 | [diff] [blame] | 118 | #define SRV_SSL_O_USE_VMASK 0x00F0 /* force version mask */ |
| 119 | #define SRV_SSL_O_USE_SSLV3 0x0010 /* force SSLv3 */ |
| 120 | #define SRV_SSL_O_USE_TLSV10 0x0020 /* force TLSv1.0 */ |
| 121 | #define SRV_SSL_O_USE_TLSV11 0x0040 /* force TLSv1.1 */ |
| 122 | #define SRV_SSL_O_USE_TLSV12 0x0080 /* force TLSv1.2 */ |
Emeric Brun | 8694b9a | 2012-10-05 14:39:07 +0200 | [diff] [blame] | 123 | /* 0x00F0 reserved for 'force' protocol version options */ |
Emeric Brun | f9c5c47 | 2012-10-11 15:28:34 +0200 | [diff] [blame] | 124 | #define SRV_SSL_O_NO_TLS_TICKETS 0x0100 /* disable session resumption tickets */ |
Willy Tarreau | 2a3fb1c | 2015-02-05 16:47:07 +0100 | [diff] [blame] | 125 | #define SRV_SSL_O_NO_REUSE 0x200 /* disable session reuse */ |
Emeric Brun | 8967549 | 2012-10-05 13:48:26 +0200 | [diff] [blame] | 126 | #endif |
| 127 | |
Simon Horman | 98637e5 | 2014-06-20 12:30:16 +0900 | [diff] [blame] | 128 | struct pid_list { |
| 129 | struct list list; |
| 130 | pid_t pid; |
| 131 | struct task *t; |
| 132 | int status; |
| 133 | int exited; |
| 134 | }; |
| 135 | |
Willy Tarreau | 6b2e11b | 2009-10-01 07:52:15 +0200 | [diff] [blame] | 136 | /* A tree occurrence is a descriptor of a place in a tree, with a pointer back |
| 137 | * to the server itself. |
| 138 | */ |
| 139 | struct server; |
| 140 | struct tree_occ { |
| 141 | struct server *server; |
| 142 | struct eb32_node node; |
| 143 | }; |
| 144 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 145 | struct server { |
Willy Tarreau | 3fdb366 | 2012-11-12 00:42:33 +0100 | [diff] [blame] | 146 | enum obj_type obj_type; /* object type == OBJ_TYPE_SERVER */ |
Willy Tarreau | 892337c | 2014-05-13 23:41:20 +0200 | [diff] [blame] | 147 | enum srv_state state, prev_state; /* server state among SRV_ST_* */ |
Willy Tarreau | 2012521 | 2014-05-13 19:44:56 +0200 | [diff] [blame] | 148 | enum srv_admin admin, prev_admin; /* server maintenance status : SRV_ADMF_* */ |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 149 | unsigned char flags; /* server flags (SRV_F_*) */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 150 | struct server *next; |
Krzysztof Piotr Oledzki | 0960541 | 2009-09-23 22:09:24 +0200 | [diff] [blame] | 151 | int cklen; /* the len of the cookie, to speed up checks */ |
Willy Tarreau | 21d2af3 | 2008-02-14 20:25:24 +0100 | [diff] [blame] | 152 | int rdr_len; /* the length of the redirection prefix */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 153 | char *cookie; /* the id set in the cookie */ |
Willy Tarreau | 21d2af3 | 2008-02-14 20:25:24 +0100 | [diff] [blame] | 154 | char *rdr_pfx; /* the redirection prefix */ |
David S | afb7683 | 2014-05-08 23:42:08 -0400 | [diff] [blame] | 155 | int pp_opts; /* proxy protocol options (SRV_PP_*) */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 156 | |
| 157 | struct proxy *proxy; /* the proxy this server belongs to */ |
Willy Tarreau | 7c669d7 | 2008-06-20 15:04:11 +0200 | [diff] [blame] | 158 | int served; /* # of active sessions currently being served (ie not pending) */ |
Willy Tarreau | ac68c5d | 2009-10-04 23:12:44 +0200 | [diff] [blame] | 159 | int cur_sess; /* number of currently active sessions (including syn_sent) */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 160 | unsigned maxconn, minconn; /* max # of active sessions (0 = unlimited), min# for dynamic limit. */ |
Willy Tarreau | ac68c5d | 2009-10-04 23:12:44 +0200 | [diff] [blame] | 161 | int nbpend; /* number of pending connections */ |
Elijah Epifanov | acafc5f | 2007-10-25 20:15:38 +0200 | [diff] [blame] | 162 | int maxqueue; /* maximum number of pending connections allowed */ |
Willy Tarreau | 7b81563 | 2011-10-21 18:51:57 +0200 | [diff] [blame] | 163 | struct freq_ctr sess_per_sec; /* sessions per second on this server */ |
Willy Tarreau | ac68c5d | 2009-10-04 23:12:44 +0200 | [diff] [blame] | 164 | struct srvcounters counters; /* statistics counters */ |
| 165 | |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 166 | struct list pendconns; /* pending connections */ |
Simon Horman | af51495 | 2011-06-21 14:34:57 +0900 | [diff] [blame] | 167 | struct list actconns; /* active connections */ |
Willy Tarreau | 2e99390 | 2011-10-31 11:53:20 +0100 | [diff] [blame] | 168 | struct task *warmup; /* the task dedicated to the warmup when slowstart is set */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 169 | |
Willy Tarreau | ef9a360 | 2012-12-08 22:29:20 +0100 | [diff] [blame] | 170 | struct conn_src conn_src; /* connection source settings */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 171 | |
Willy Tarreau | 1a53a3a | 2013-12-11 15:27:05 +0100 | [diff] [blame] | 172 | struct server *track; /* the server we're currently tracking, if any */ |
| 173 | struct server *trackers; /* the list of servers tracking us, if any */ |
| 174 | struct server *tracknext; /* next server tracking <track> in <track>'s trackers list */ |
Krzysztof Piotr Oledzki | c8b16fc | 2008-02-18 01:26:35 +0100 | [diff] [blame] | 175 | char *trackit; /* temporary variable to make assignment deferrable */ |
Krzysztof Piotr Oledzki | 97f07b8 | 2009-12-15 22:31:24 +0100 | [diff] [blame] | 176 | int consecutive_errors; /* current number of consecutive errors */ |
Krzysztof Piotr Oledzki | 97f07b8 | 2009-12-15 22:31:24 +0100 | [diff] [blame] | 177 | int consecutive_errors_limit; /* number of consecutive errors that triggers an event */ |
| 178 | short observe, onerror; /* observing mode: one of HANA_OBS_*; what to do on error: on of ANA_ONERR_* */ |
Justin Karneges | eb2c24a | 2012-05-24 15:28:52 -0700 | [diff] [blame] | 179 | short onmarkeddown; /* what to do when marked down: one of HANA_ONMARKEDDOWN_* */ |
| 180 | short onmarkedup; /* what to do when marked up: one of HANA_ONMARKEDUP_* */ |
Willy Tarreau | 9909fc1 | 2007-11-30 17:42:05 +0100 | [diff] [blame] | 181 | int slowstart; /* slowstart time in seconds (ms in the conf) */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 182 | |
| 183 | char *id; /* just for identification */ |
Willy Tarreau | 975c50b | 2009-10-10 19:34:06 +0200 | [diff] [blame] | 184 | unsigned iweight,uweight, eweight; /* initial weight, user-specified weight, and effective weight */ |
Willy Tarreau | 417fae0 | 2007-03-25 21:16:40 +0200 | [diff] [blame] | 185 | unsigned wscore; /* weight score, used during srv map computation */ |
Willy Tarreau | b625a08 | 2007-11-26 01:15:43 +0100 | [diff] [blame] | 186 | unsigned prev_eweight; /* eweight before last change */ |
| 187 | unsigned rweight; /* remainer of weight in the current LB tree */ |
| 188 | unsigned npos, lpos; /* next and last positions in the LB tree */ |
| 189 | struct eb32_node lb_node; /* node used for tree-based load balancing */ |
| 190 | struct eb_root *lb_tree; /* we want to know in what tree the server is */ |
| 191 | struct server *next_full; /* next server in the temporary full list */ |
Willy Tarreau | 6b2e11b | 2009-10-01 07:52:15 +0200 | [diff] [blame] | 192 | unsigned lb_nodes_tot; /* number of allocated lb_nodes (C-HASH) */ |
| 193 | unsigned lb_nodes_now; /* number of lb_nodes placed in the tree (C-HASH) */ |
| 194 | struct tree_occ *lb_nodes; /* lb_nodes_tot * struct tree_occ */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 195 | |
KOVACS Krisztian | b3e54fe | 2014-11-17 15:11:45 +0100 | [diff] [blame] | 196 | const struct netns_entry *netns; /* contains network namespace name or NULL. Network namespace comes from configuration */ |
Willy Tarreau | 7b81563 | 2011-10-21 18:51:57 +0200 | [diff] [blame] | 197 | /* warning, these structs are huge, keep them at the bottom */ |
| 198 | struct sockaddr_storage addr; /* the address to connect to */ |
Willy Tarreau | f7bc57c | 2012-10-03 00:19:48 +0200 | [diff] [blame] | 199 | struct xprt_ops *xprt; /* transport-layer operations */ |
Krzysztof Oledzki | 8513094 | 2007-10-22 16:21:10 +0200 | [diff] [blame] | 200 | unsigned down_time; /* total time the server was down */ |
| 201 | time_t last_change; /* last time, when the state was changed */ |
| 202 | |
Willy Tarreau | f09c660 | 2012-02-13 17:12:08 +0100 | [diff] [blame] | 203 | int puid; /* proxy-unique server ID, used for SNMP, and "first" LB algo */ |
Krzysztof Piotr Oledzki | 052d4fd | 2009-10-04 14:52:57 +0200 | [diff] [blame] | 204 | |
Simon Horman | 6618300 | 2013-02-23 10:16:43 +0900 | [diff] [blame] | 205 | struct check check; /* health-check specific configuration */ |
Simon Horman | d60d691 | 2013-11-25 10:46:36 +0900 | [diff] [blame] | 206 | struct check agent; /* agent specific configuration */ |
Nick Chalk | 57b1bf7 | 2010-03-16 15:50:46 +0000 | [diff] [blame] | 207 | |
Emeric Brun | c6545ac | 2012-05-18 15:46:21 +0200 | [diff] [blame] | 208 | #ifdef USE_OPENSSL |
Emeric Brun | 01f8e2f | 2012-05-18 16:02:00 +0200 | [diff] [blame] | 209 | int use_ssl; /* ssl enabled */ |
Emeric Brun | c6545ac | 2012-05-18 15:46:21 +0200 | [diff] [blame] | 210 | struct { |
| 211 | SSL_CTX *ctx; |
| 212 | SSL_SESSION *reused_sess; |
Willy Tarreau | d7aacbf | 2012-09-03 23:34:19 +0200 | [diff] [blame] | 213 | char *ciphers; /* cipher suite to use if non-null */ |
Emeric Brun | 8967549 | 2012-10-05 13:48:26 +0200 | [diff] [blame] | 214 | int options; /* ssl options */ |
Emeric Brun | ef42d92 | 2012-10-11 16:11:36 +0200 | [diff] [blame] | 215 | int verify; /* verify method (set of SSL_VERIFY_* flags) */ |
Evan Broder | be55431 | 2013-06-27 00:05:25 -0700 | [diff] [blame] | 216 | char *verify_host; /* hostname of certificate must match this host */ |
Emeric Brun | ef42d92 | 2012-10-11 16:11:36 +0200 | [diff] [blame] | 217 | char *ca_file; /* CAfile to use on verify */ |
| 218 | char *crl_file; /* CRLfile to use on verify */ |
Emeric Brun | a7aa309 | 2012-10-26 12:58:00 +0200 | [diff] [blame] | 219 | char *client_crt; /* client certificate to send */ |
Emeric Brun | c6545ac | 2012-05-18 15:46:21 +0200 | [diff] [blame] | 220 | } ssl_ctx; |
| 221 | #endif |
Willy Tarreau | 90a570f | 2009-10-04 20:54:54 +0200 | [diff] [blame] | 222 | struct { |
| 223 | const char *file; /* file where the section appears */ |
| 224 | int line; /* line where the section appears */ |
Willy Tarreau | 53fb4ae | 2009-10-04 23:04:08 +0200 | [diff] [blame] | 225 | struct eb32_node id; /* place in the tree of used IDs */ |
Willy Tarreau | 90a570f | 2009-10-04 20:54:54 +0200 | [diff] [blame] | 226 | } conf; /* config information */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 227 | }; |
| 228 | |
Willy Tarreau | 21faa91 | 2012-10-10 08:27:36 +0200 | [diff] [blame] | 229 | /* Descriptor for a "server" keyword. The ->parse() function returns 0 in case of |
| 230 | * success, or a combination of ERR_* flags if an error is encountered. The |
| 231 | * function pointer can be NULL if not implemented. The function also has an |
| 232 | * access to the current "server" config line. The ->skip value tells the parser |
| 233 | * how many words have to be skipped after the keyword. If the function needs to |
| 234 | * parse more keywords, it needs to update cur_arg. |
| 235 | */ |
| 236 | struct srv_kw { |
| 237 | const char *kw; |
| 238 | int (*parse)(char **args, int *cur_arg, struct proxy *px, struct server *srv, char **err); |
| 239 | int skip; /* nb min of args to skip, for use when kw is not handled */ |
| 240 | int default_ok; /* non-zero if kw is supported in default-server section */ |
| 241 | }; |
| 242 | |
| 243 | /* |
| 244 | * A keyword list. It is a NULL-terminated array of keywords. It embeds a |
| 245 | * struct list in order to be linked to other lists, allowing it to easily |
| 246 | * be declared where it is needed, and linked without duplicating data nor |
| 247 | * allocating memory. It is also possible to indicate a scope for the keywords. |
| 248 | */ |
| 249 | struct srv_kw_list { |
| 250 | const char *scope; |
| 251 | struct list list; |
| 252 | struct srv_kw kw[VAR_ARRAY]; |
| 253 | }; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 254 | |
| 255 | #endif /* _TYPES_SERVER_H */ |
| 256 | |
| 257 | /* |
| 258 | * Local variables: |
| 259 | * c-indent-level: 8 |
| 260 | * c-basic-offset: 8 |
| 261 | * End: |
| 262 | */ |