blob: ffeef4e22069392887d09f7b47c5fcca2ece6875 [file] [log] [blame]
Willy TARREAU3dc06442006-06-15 21:48:13 +02001/*
Willy Tarreau4aa573d2020-06-04 18:21:56 +02002 * include/haproxy/check.h
3 * Functions prototypes for the checks.
4 *
5 * Copyright (C) 2000-2020 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 */
Willy TARREAU3dc06442006-06-15 21:48:13 +020021
Willy Tarreau4aa573d2020-06-04 18:21:56 +020022#ifndef _HAPROXY_CHECKS_H
23#define _HAPROXY_CHECKS_H
Willy Tarreaubaaee002006-06-26 02:48:02 +020024
Willy Tarreau4aa573d2020-06-04 18:21:56 +020025#include <haproxy/check-t.h>
Willy Tarreaua264d962020-06-04 22:29:18 +020026#include <haproxy/proxy-t.h>
Willy Tarreau1e56f922020-06-04 23:20:13 +020027#include <haproxy/server-t.h>
Gaetan Rivet13a50432020-02-21 18:13:44 +010028
Willy Tarreau51cd5952020-06-05 12:25:38 +020029extern struct data_cb check_conn_cb;
30extern struct proxy checks_fe;
Willy Tarreaucee013e2020-06-05 11:40:38 +020031
Christopher Faulet7aa32712021-02-01 13:11:50 +010032short get_check_status_result(short check_status);
Krzysztof Piotr Oledzki09605412009-09-23 22:09:24 +020033const char *get_check_status_description(short check_status);
34const char *get_check_status_info(short check_status);
Willy Tarreau51cd5952020-06-05 12:25:38 +020035int httpchk_build_status_header(struct server *s, struct buffer *buf);
Willy Tarreau9fe7aae2013-12-31 23:47:37 +010036void __health_adjust(struct server *s, short status);
Willy Tarreau51cd5952020-06-05 12:25:38 +020037void set_server_check_status(struct check *check, short status, const char *desc);
38void chk_report_conn_err(struct check *check, int errno_bck, int expired);
Willy Tarreaubcc67332020-06-05 15:31:31 +020039void check_notify_failure(struct check *check);
40void check_notify_stopping(struct check *check);
41void check_notify_success(struct check *check);
Willy Tarreaucee013e2020-06-05 11:40:38 +020042struct task *process_chk(struct task *t, void *context, unsigned short state);
Willy Tarreaubaaee002006-06-26 02:48:02 +020043
Christopher Fauletb381a502020-11-25 13:47:00 +010044int check_buf_available(void *target);
45struct buffer *check_get_buf(struct check *check, struct buffer *bptr);
46void check_release_buf(struct check *check, struct buffer *bptr);
Willy Tarreaucee013e2020-06-05 11:40:38 +020047const char *init_check(struct check *check, int type);
Simon Hormanbfb5d332015-01-30 11:22:55 +090048void free_check(struct check *check);
Christopher Faulet7a1e2e12020-04-02 18:05:11 +020049
Christopher Fauletba7bc162016-11-07 21:07:38 +010050/* Declared here, but the definitions are in flt_spoe.c */
Christopher Faulet8ef75252017-02-20 22:56:03 +010051int spoe_prepare_healthcheck_request(char **req, int *len);
52int spoe_handle_healthcheck_response(char *frame, size_t size, char *err, int errlen);
Christopher Fauletba7bc162016-11-07 21:07:38 +010053
Christopher Faulet0ae3d1d2020-04-06 17:54:24 +020054int set_srv_agent_send(struct server *srv, const char *send);
William Dauchy1c921cd2021-02-03 22:30:08 +010055void set_srv_agent_addr(struct server *srv, struct sockaddr_storage *sk);
William Dauchy4858fb22021-02-03 22:30:09 +010056void set_srv_agent_port(struct server *srv, int port);
Christopher Faulet0ae3d1d2020-04-06 17:54:24 +020057
Willy Tarreaucee013e2020-06-05 11:40:38 +020058/* Use this one only. This inline version only ensures that we don't
59 * call the function when the observe mode is disabled.
60 */
61static inline void health_adjust(struct server *s, short status)
62{
63 HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
64 /* return now if observing nor health check is not enabled */
65 if (!s->observe || !s->check.task) {
66 HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
67 return;
68 }
69
70 __health_adjust(s, status);
71 HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
72}
73
Willy Tarreau4aa573d2020-06-04 18:21:56 +020074#endif /* _HAPROXY_CHECKS_H */
Willy TARREAU3dc06442006-06-15 21:48:13 +020075
Willy Tarreaubaaee002006-06-26 02:48:02 +020076/*
77 * Local variables:
78 * c-indent-level: 8
79 * c-basic-offset: 8
80 * End:
81 */