/*
- * Health-checks.
+ * include/haproxy/check-t.h
+ * Health-checks definitions, enums, macros and bitfields.
*
* Copyright 2008-2009 Krzysztof Piotr Oledzki <ole@ans.pl>
+ * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
*
*/
-#ifndef _TYPES_CHECKS_H
-#define _TYPES_CHECKS_H
+#ifndef _HAPROXY_CHECKS_T_H
+#define _HAPROXY_CHECKS_T_H
-#include <haproxy/api-t.h>
#include <import/ebpttree.h>
-
#include <import/ist.h>
+#include <haproxy/buf-t.h>
#include <haproxy/connection-t.h>
#include <haproxy/list-t.h>
#include <haproxy/obj_type-t.h>
-#include <haproxy/regex-t.h>
-#include <haproxy/buf-t.h>
-
-#include <haproxy/sample-t.h>
-#include <types/session.h>
-#include <haproxy/task-t.h>
+#include <haproxy/api-t.h>
+#include <haproxy/vars-t.h>
+
+/* Please note: this file tends to commonly be part of circular dependencies,
+ * so it is important to keep its includes list to the minimum possible (i.e.
+ * only types whose size needs to be known). Since there are no function
+ * prototypes nor pointers here, forward declarations are not really necessary.
+ * This file oughtt to be split into multiple parts, at least regular checks vs
+ * tcp-checks.
+ */
/* enum used by check->result. Must remain in this order, as some code uses
* result >= CHK_RES_PASSED to declare success.
HANA_OBS_SIZE
};
-struct proxy;
-struct server;
+/* options for tcp-check connect */
+#define TCPCHK_OPT_NONE 0x0000 /* no options specified, default */
+#define TCPCHK_OPT_SEND_PROXY 0x0001 /* send proxy-protocol string */
+#define TCPCHK_OPT_SSL 0x0002 /* SSL connection */
+#define TCPCHK_OPT_LINGER 0x0004 /* Do not RST connection, let it linger */
+#define TCPCHK_OPT_DEFAULT_CONNECT 0x0008 /* Do a connect using server params */
+#define TCPCHK_OPT_IMPLICIT 0x0010 /* Implicit connect */
+#define TCPCHK_OPT_SOCKS4 0x0020 /* check the connection via socks4 proxy */
+
+enum tcpcheck_send_type {
+ TCPCHK_SEND_UNDEF = 0, /* Send is not parsed. */
+ TCPCHK_SEND_STRING, /* Send an ASCII string. */
+ TCPCHK_SEND_BINARY, /* Send a binary sequence. */
+ TCPCHK_SEND_STRING_LF, /* Send an ASCII log-format string. */
+ TCPCHK_SEND_BINARY_LF, /* Send a binary log-format sequence. */
+ TCPCHK_SEND_HTTP, /* Send an HTTP request */
+};
+
+/* flags for tcp-check send */
+#define TCPCHK_SND_HTTP_FL_URI_FMT 0x0001 /* Use a log-format string for the uri */
+#define TCPCHK_SND_HTTP_FL_BODY_FMT 0x0002 /* Use a log-format string for the body */
+#define TCPCHK_SND_HTTP_FROM_OPT 0x0004 /* Send rule coming from "option httpck" directive */
+
+enum tcpcheck_eval_ret {
+ TCPCHK_EVAL_WAIT = 0,
+ TCPCHK_EVAL_STOP,
+ TCPCHK_EVAL_CONTINUE,
+};
+
+enum tcpcheck_expect_type {
+ TCPCHK_EXPECT_UNDEF = 0, /* Match is not used. */
+ TCPCHK_EXPECT_STRING, /* Matches a string. */
+ TCPCHK_EXPECT_STRING_REGEX, /* Matches a regular pattern. */
+ TCPCHK_EXPECT_STRING_LF, /* Matches a log-format string. */
+ TCPCHK_EXPECT_BINARY, /* Matches a binary sequence on a hex-encoded text. */
+ TCPCHK_EXPECT_BINARY_REGEX, /* Matches a regular pattern on a hex-encoded text. */
+ TCPCHK_EXPECT_BINARY_LF, /* Matches a log-format binary sequence on a hex-encoded text. */
+ TCPCHK_EXPECT_CUSTOM, /* Execute a custom function. */
+ TCPCHK_EXPECT_HTTP_STATUS, /* Matches a list of codes on the HTTP status */
+ TCPCHK_EXPECT_HTTP_STATUS_REGEX, /* Matches a regular pattern on the HTTP status */
+ TCPCHK_EXPECT_HTTP_HEADER, /* Matches on HTTP headers */
+ TCPCHK_EXPECT_HTTP_BODY, /* Matches a string oa the HTTP payload */
+ TCPCHK_EXPECT_HTTP_BODY_REGEX, /* Matches a regular pattern on a HTTP payload */
+ TCPCHK_EXPECT_HTTP_BODY_LF, /* Matches a log-format string on the HTTP payload */
+};
+
+/* tcp-check expect flags */
+#define TCPCHK_EXPT_FL_INV 0x0001 /* Matching is inversed */
+#define TCPCHK_EXPT_FL_HTTP_HNAME_STR 0x0002 /* Exact match on the HTTP header name */
+#define TCPCHK_EXPT_FL_HTTP_HNAME_BEG 0x0004 /* Prefix match on the HTTP header name */
+#define TCPCHK_EXPT_FL_HTTP_HNAME_END 0x0008 /* Suffix match on the HTTP header name */
+#define TCPCHK_EXPT_FL_HTTP_HNAME_SUB 0x0010 /* Substring match on the HTTP header name */
+#define TCPCHK_EXPT_FL_HTTP_HNAME_REG 0x0020 /* Regex match on the HTTP header name */
+#define TCPCHK_EXPT_FL_HTTP_HNAME_FMT 0x0040 /* The HTTP header name is a log-format string */
+#define TCPCHK_EXPT_FL_HTTP_HVAL_NONE 0x0080 /* No match on the HTTP header value */
+#define TCPCHK_EXPT_FL_HTTP_HVAL_STR 0x0100 /* Exact match on the HTTP header value */
+#define TCPCHK_EXPT_FL_HTTP_HVAL_BEG 0x0200 /* Prefix match on the HTTP header value */
+#define TCPCHK_EXPT_FL_HTTP_HVAL_END 0x0400 /* Suffix match on the HTTP header value */
+#define TCPCHK_EXPT_FL_HTTP_HVAL_SUB 0x0800 /* Substring match on the HTTP header value */
+#define TCPCHK_EXPT_FL_HTTP_HVAL_REG 0x1000 /* Regex match on the HTTP header value*/
+#define TCPCHK_EXPT_FL_HTTP_HVAL_FMT 0x2000 /* The HTTP header value is a log-format string */
+#define TCPCHK_EXPT_FL_HTTP_HVAL_FULL 0x4000 /* Match the full header value ( no stop on commas ) */
+
+#define TCPCHK_EXPT_FL_HTTP_HNAME_TYPE 0x003E /* Mask to get matching method on header name */
+#define TCPCHK_EXPT_FL_HTTP_HVAL_TYPE 0x1F00 /* Mask to get matching method on header value */
+
+/* possible actions for tcpcheck_rule->action */
+enum tcpcheck_rule_type {
+ TCPCHK_ACT_SEND = 0, /* send action, regular string format */
+ TCPCHK_ACT_EXPECT, /* expect action, either regular or binary string */
+ TCPCHK_ACT_CONNECT, /* connect action, to probe a new port */
+ TCPCHK_ACT_COMMENT, /* no action, simply a comment used for logs */
+ TCPCHK_ACT_ACTION_KW, /* custom registered action_kw rule. */
+};
+
+#define TCPCHK_RULES_NONE 0x00000000
+#define TCPCHK_RULES_UNUSED_TCP_RS 0x00000001 /* An unused tcp-check ruleset exists */
+#define TCPCHK_RULES_UNUSED_HTTP_RS 0x00000002 /* An unused http-check ruleset exists */
+#define TCPCHK_RULES_UNUSED_RS 0x00000003 /* Mask for unused ruleset */
+
+#define TCPCHK_RULES_PGSQL_CHK 0x00000010
+#define TCPCHK_RULES_REDIS_CHK 0x00000020
+#define TCPCHK_RULES_SMTP_CHK 0x00000030
+#define TCPCHK_RULES_HTTP_CHK 0x00000040
+#define TCPCHK_RULES_MYSQL_CHK 0x00000050
+#define TCPCHK_RULES_LDAP_CHK 0x00000060
+#define TCPCHK_RULES_SSL3_CHK 0x00000070
+#define TCPCHK_RULES_AGENT_CHK 0x00000080
+#define TCPCHK_RULES_SPOP_CHK 0x00000090
+/* Unused 0x000000A0..0x00000FF0 (reserverd for futur proto) */
+#define TCPCHK_RULES_TCP_CHK 0x00000FF0
+#define TCPCHK_RULES_PROTO_CHK 0x00000FF0 /* Mask to cover protocol check */
+
struct check {
enum obj_type obj_type; /* object type == OBJ_TYPE_CHECK */
struct session *sess; /* Health check session. */
int via_socks4; /* check the connection via socks4 proxy */
};
-#define TCPCHK_OPT_NONE 0x0000 /* no options specified, default */
-#define TCPCHK_OPT_SEND_PROXY 0x0001 /* send proxy-protocol string */
-#define TCPCHK_OPT_SSL 0x0002 /* SSL connection */
-#define TCPCHK_OPT_LINGER 0x0004 /* Do not RST connection, let it linger */
-#define TCPCHK_OPT_DEFAULT_CONNECT 0x0008 /* Do a connect using server params */
-#define TCPCHK_OPT_IMPLICIT 0x0010 /* Implicit connect */
-#define TCPCHK_OPT_SOCKS4 0x0020 /* check the connection via socks4 proxy */
-
struct tcpcheck_connect {
char *sni; /* server name to use for SSL connections */
char *alpn; /* ALPN to use for the SSL connection */
struct sockaddr_storage addr; /* the address to the connect */
};
-enum tcpcheck_send_type {
- TCPCHK_SEND_UNDEF = 0, /* Send is not parsed. */
- TCPCHK_SEND_STRING, /* Send an ASCII string. */
- TCPCHK_SEND_BINARY, /* Send a binary sequence. */
- TCPCHK_SEND_STRING_LF, /* Send an ASCII log-format string. */
- TCPCHK_SEND_BINARY_LF, /* Send a binary log-format sequence. */
- TCPCHK_SEND_HTTP, /* Send an HTTP request */
-};
-
struct tcpcheck_http_hdr {
struct ist name; /* the header name */
struct list value; /* the log-format string value */
size_t num; /* number of entry in the array */
};
-#define TCPCHK_SND_HTTP_FL_URI_FMT 0x0001 /* Use a log-format string for the uri */
-#define TCPCHK_SND_HTTP_FL_BODY_FMT 0x0002 /* Use a log-format string for the body */
-#define TCPCHK_SND_HTTP_FROM_OPT 0x0004 /* Send rule coming from "option httpck" directive */
-
struct tcpcheck_send {
enum tcpcheck_send_type type;
union {
};
};
-enum tcpcheck_eval_ret {
- TCPCHK_EVAL_WAIT = 0,
- TCPCHK_EVAL_STOP,
- TCPCHK_EVAL_CONTINUE,
-};
-
-enum tcpcheck_expect_type {
- TCPCHK_EXPECT_UNDEF = 0, /* Match is not used. */
- TCPCHK_EXPECT_STRING, /* Matches a string. */
- TCPCHK_EXPECT_STRING_REGEX, /* Matches a regular pattern. */
- TCPCHK_EXPECT_STRING_LF, /* Matches a log-format string. */
- TCPCHK_EXPECT_BINARY, /* Matches a binary sequence on a hex-encoded text. */
- TCPCHK_EXPECT_BINARY_REGEX, /* Matches a regular pattern on a hex-encoded text. */
- TCPCHK_EXPECT_BINARY_LF, /* Matches a log-format binary sequence on a hex-encoded text. */
- TCPCHK_EXPECT_CUSTOM, /* Execute a custom function. */
- TCPCHK_EXPECT_HTTP_STATUS, /* Matches a list of codes on the HTTP status */
- TCPCHK_EXPECT_HTTP_STATUS_REGEX, /* Matches a regular pattern on the HTTP status */
- TCPCHK_EXPECT_HTTP_HEADER, /* Matches on HTTP headers */
- TCPCHK_EXPECT_HTTP_BODY, /* Matches a string oa the HTTP payload */
- TCPCHK_EXPECT_HTTP_BODY_REGEX, /* Matches a regular pattern on a HTTP payload */
- TCPCHK_EXPECT_HTTP_BODY_LF, /* Matches a log-format string on the HTTP payload */
-};
-
-/* tcp-check expect flags */
-#define TCPCHK_EXPT_FL_INV 0x0001 /* Matching is inversed */
-#define TCPCHK_EXPT_FL_HTTP_HNAME_STR 0x0002 /* Exact match on the HTTP header name */
-#define TCPCHK_EXPT_FL_HTTP_HNAME_BEG 0x0004 /* Prefix match on the HTTP header name */
-#define TCPCHK_EXPT_FL_HTTP_HNAME_END 0x0008 /* Suffix match on the HTTP header name */
-#define TCPCHK_EXPT_FL_HTTP_HNAME_SUB 0x0010 /* Substring match on the HTTP header name */
-#define TCPCHK_EXPT_FL_HTTP_HNAME_REG 0x0020 /* Regex match on the HTTP header name */
-#define TCPCHK_EXPT_FL_HTTP_HNAME_FMT 0x0040 /* The HTTP header name is a log-format string */
-#define TCPCHK_EXPT_FL_HTTP_HVAL_NONE 0x0080 /* No match on the HTTP header value */
-#define TCPCHK_EXPT_FL_HTTP_HVAL_STR 0x0100 /* Exact match on the HTTP header value */
-#define TCPCHK_EXPT_FL_HTTP_HVAL_BEG 0x0200 /* Prefix match on the HTTP header value */
-#define TCPCHK_EXPT_FL_HTTP_HVAL_END 0x0400 /* Suffix match on the HTTP header value */
-#define TCPCHK_EXPT_FL_HTTP_HVAL_SUB 0x0800 /* Substring match on the HTTP header value */
-#define TCPCHK_EXPT_FL_HTTP_HVAL_REG 0x1000 /* Regex match on the HTTP header value*/
-#define TCPCHK_EXPT_FL_HTTP_HVAL_FMT 0x2000 /* The HTTP header value is a log-format string */
-#define TCPCHK_EXPT_FL_HTTP_HVAL_FULL 0x4000 /* Match the full header value ( no stop on commas ) */
-
-#define TCPCHK_EXPT_FL_HTTP_HNAME_TYPE 0x003E /* Mask to get matching method on header name */
-#define TCPCHK_EXPT_FL_HTTP_HVAL_TYPE 0x1F00 /* Mask to get matching method on header value */
-
struct tcpcheck_expect {
enum tcpcheck_expect_type type; /* Type of pattern used for matching. */
unsigned int flags; /* TCPCHK_EXPT_FL_* */
struct act_rule *rule;
};
-/* possible actions for tcpcheck_rule->action */
-enum tcpcheck_rule_type {
- TCPCHK_ACT_SEND = 0, /* send action, regular string format */
- TCPCHK_ACT_EXPECT, /* expect action, either regular or binary string */
- TCPCHK_ACT_CONNECT, /* connect action, to probe a new port */
- TCPCHK_ACT_COMMENT, /* no action, simply a comment used for logs */
- TCPCHK_ACT_ACTION_KW, /* custom registered action_kw rule. */
-};
-
struct tcpcheck_rule {
struct list list; /* list linked to from the proxy */
enum tcpcheck_rule_type action; /* type of the rule. */
};
};
-#define TCPCHK_RULES_NONE 0x00000000
-#define TCPCHK_RULES_UNUSED_TCP_RS 0x00000001 /* An unused tcp-check ruleset exists */
-#define TCPCHK_RULES_UNUSED_HTTP_RS 0x00000002 /* An unused http-check ruleset exists */
-#define TCPCHK_RULES_UNUSED_RS 0x00000003 /* Mask for unused ruleset */
-
-#define TCPCHK_RULES_PGSQL_CHK 0x00000010
-#define TCPCHK_RULES_REDIS_CHK 0x00000020
-#define TCPCHK_RULES_SMTP_CHK 0x00000030
-#define TCPCHK_RULES_HTTP_CHK 0x00000040
-#define TCPCHK_RULES_MYSQL_CHK 0x00000050
-#define TCPCHK_RULES_LDAP_CHK 0x00000060
-#define TCPCHK_RULES_SSL3_CHK 0x00000070
-#define TCPCHK_RULES_AGENT_CHK 0x00000080
-#define TCPCHK_RULES_SPOP_CHK 0x00000090
-/* Unused 0x000000A0..0x00000FF0 (reserverd for futur proto) */
-#define TCPCHK_RULES_TCP_CHK 0x00000FF0
-#define TCPCHK_RULES_PROTO_CHK 0x00000FF0 /* Mask to cover protocol check */
-
/* A list of tcp-check vars, to be registered before executing a ruleset */
struct tcpcheck_var {
struct ist name; /* the variable name with the scope */
};
-#endif /* _TYPES_CHECKS_H */
+#endif /* _HAPROXY_CHECKS_T_H */