blob: b887d25c7b44b621d4e3ee27311a02ef177f0262 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 include/types/server.h
3 This file defines everything related to servers.
4
5 Copyright (C) 2000-2006 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_SERVER_H
23#define _TYPES_SERVER_H
24
25#include <netinet/in.h>
26#include <arpa/inet.h>
27
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020028#include <common/config.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020029#include <common/mini-clist.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020030
31#include <types/buffers.h>
32#include <types/proxy.h>
33#include <types/queue.h>
34#include <types/task.h>
35
36
37/* server flags */
Willy Tarreau77074d52006-11-12 23:57:19 +010038#define SRV_RUNNING 0x0001 /* the server is UP */
39#define SRV_BACKUP 0x0002 /* this server is a backup server */
40#define SRV_MAPPORTS 0x0004 /* this server uses mapped ports */
41#define SRV_BIND_SRC 0x0008 /* this server uses a specific source address */
42#define SRV_CHECKED 0x0010 /* this server needs to be checked */
43
44#define SRV_TPROXY_ADDR 0x0020 /* bind to this non-local address to reach this server */
45#define SRV_TPROXY_CIP 0x0040 /* bind to the client's IP address to reach this server */
46#define SRV_TPROXY_CLI 0x0060 /* bind to the client's IP+port to reach this server */
47#define SRV_TPROXY_MASK 0x0060 /* bind to a non-local address to reach this server */
Willy Tarreaubaaee002006-06-26 02:48:02 +020048
49/* function which act on servers need to return various errors */
50#define SRV_STATUS_OK 0 /* everything is OK. */
51#define SRV_STATUS_INTERNAL 1 /* other unrecoverable errors. */
52#define SRV_STATUS_NOSRV 2 /* no server is available */
53#define SRV_STATUS_FULL 3 /* the/all server(s) are saturated */
54#define SRV_STATUS_QUEUED 4 /* the/all server(s) are saturated but the connection was queued */
55
56
57struct server {
58 struct server *next;
59 int state; /* server state (SRV_*) */
60 int cklen; /* the len of the cookie, to speed up checks */
Willy Tarreau91b6f322007-03-25 21:03:01 +020061 char *cookie; /* the id set in the cookie */
62
63 struct proxy *proxy; /* the proxy this server belongs to */
64 int cur_sess, cur_sess_max; /* number of currently active sessions (including syn_sent) */
65 unsigned maxconn, minconn; /* max # of active sessions (0 = unlimited), min# for dynamic limit. */
66 int nbpend, nbpend_max; /* number of pending connections */
67 struct list pendconns; /* pending connections */
68 struct task *queue_mgt; /* the task associated to the queue processing */
69
Willy Tarreaubaaee002006-06-26 02:48:02 +020070 struct sockaddr_in addr; /* the address to connect to */
Willy Tarreau91b6f322007-03-25 21:03:01 +020071 struct sockaddr_in source_addr; /* the address to which we want to bind for connect() */
Willy Tarreau77074d52006-11-12 23:57:19 +010072#ifdef CONFIG_HAP_CTTPROXY
Willy Tarreau91b6f322007-03-25 21:03:01 +020073 struct sockaddr_in tproxy_addr; /* non-local address we want to bind to for connect() */
Willy Tarreau77074d52006-11-12 23:57:19 +010074#endif
Willy Tarreau91b6f322007-03-25 21:03:01 +020075
Willy Tarreau0f03c6f2007-03-25 20:46:19 +020076 struct sockaddr_in check_addr; /* the address to check, if different from <addr> */
Willy Tarreaubaaee002006-06-26 02:48:02 +020077 short check_port; /* the port to use for the health checks */
78 int health; /* 0->rise-1 = bad; rise->rise+fall-1 = good */
Willy Tarreau91b6f322007-03-25 21:03:01 +020079 int rise, fall; /* time in iterations */
Willy Tarreaubaaee002006-06-26 02:48:02 +020080 int inter; /* time in milliseconds */
81 int result; /* 0 = connect OK, -1 = connect KO */
82 int curfd; /* file desc used for current test, or -1 if not in test */
Willy Tarreau91b6f322007-03-25 21:03:01 +020083
84 char *id; /* just for identification */
Willy Tarreau417fae02007-03-25 21:16:40 +020085 unsigned uweight, eweight; /* user-specified weight, and effective weight */
86 unsigned wscore; /* weight score, used during srv map computation */
Willy Tarreau91b6f322007-03-25 21:03:01 +020087
Willy Tarreaubaaee002006-06-26 02:48:02 +020088 unsigned failed_checks, down_trans; /* failed checks and up-down transitions */
89 unsigned failed_conns, failed_resp; /* failed connect() and responses */
Willy Tarreau91b6f322007-03-25 21:03:01 +020090 unsigned failed_secu; /* blocked responses because of security concerns */
91 unsigned cum_sess; /* cumulated number of sessions really sent to this server */
92 long long bytes_in; /* number of bytes transferred from the client to the server */
93 long long bytes_out; /* number of bytes transferred from the server to the client */
Willy Tarreaubaaee002006-06-26 02:48:02 +020094};
95
96
97#endif /* _TYPES_SERVER_H */
98
99/*
100 * Local variables:
101 * c-indent-level: 8
102 * c-basic-offset: 8
103 * End:
104 */