From: Willy Tarreau Date: Thu, 4 Jun 2020 16:02:10 +0000 (+0200) Subject: REORG: include: move connection.h to haproxy/connection{,-t}.h X-Git-Tag: v2.2-dev9~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ea393d95eb2407ee77acff26801ca5e1193bc91;p=thirdparty%2Fhaproxy.git REORG: include: move connection.h to haproxy/connection{,-t}.h The type file is becoming a mess, half of it is for the proxy protocol, another good part describes conn_streams and mux ops, it would deserve being split again. At least it was reordered so that elements are easier to find, with the PP-stuff left at the end. The MAX_SEND_FD macro was moved to compat.h as it's said to be the value for Linux. --- diff --git a/contrib/debug/flags.c b/contrib/debug/flags.c index 2287ee3638..485fc0e6ce 100644 --- a/contrib/debug/flags.c +++ b/contrib/debug/flags.c @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/haproxy/compat.h b/include/haproxy/compat.h index fdd6fa4cd4..97cde46c3e 100644 --- a/include/haproxy/compat.h +++ b/include/haproxy/compat.h @@ -240,6 +240,11 @@ typedef struct { } empty_t; #endif #endif +/* Max number of file descriptors we send in one sendmsg(). Linux seems to be + * able to send 253 fds per sendmsg(), not sure about the other OSes. + */ +#define MAX_SEND_FD 253 + #endif /* _HAPROXY_COMPAT_H */ /* diff --git a/include/types/connection.h b/include/haproxy/connection-t.h similarity index 98% rename from include/types/connection.h rename to include/haproxy/connection-t.h index dfc86945e5..b7b97a5fe9 100644 --- a/include/types/connection.h +++ b/include/haproxy/connection-t.h @@ -1,5 +1,5 @@ /* - * include/types/connection.h + * include/haproxy/connection-t.h * This file describes the connection struct and associated constants. * * Copyright (C) 2000-2014 Willy Tarreau - w@1wt.eu @@ -19,23 +19,23 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _TYPES_CONNECTION_H -#define _TYPES_CONNECTION_H +#ifndef _HAPROXY_CONNECTION_T_H +#define _HAPROXY_CONNECTION_T_H #include #include +#include +#include +#include -#include #include -#include +#include #include +#include #include #include - -#include -#include -#include +#include /* referenced below */ struct connection; @@ -47,15 +47,6 @@ struct server; struct session; struct pipe; -/* socks4 upstream proxy definitions */ -struct socks4_request { - uint8_t version; /* SOCKS version number, 1 byte, must be 0x04 for this version */ - uint8_t command; /* 0x01 = establish a TCP/IP stream connection */ - uint16_t port; /* port number, 2 bytes (in network byte order) */ - uint32_t ip; /* IP address, 4 bytes (in network byte order) */ - char user_id[8]; /* the user ID string, variable length, terminated with a null (0x00); Using "HAProxy\0" */ -}; - /* Note: subscribing to these events is only valid after the caller has really * attempted to perform the operation, and failed to proceed or complete. */ @@ -64,23 +55,6 @@ enum sub_event_type { SUB_RETRY_SEND = 0x00000002, /* Schedule the tasklet when we can attempt to send again */ }; -/* Describes a set of subscriptions. Multiple events may be registered at the - * same time. The callee should assume everything not pending for completion is - * implicitly possible. It's illegal to change the tasklet if events are still - * registered. - */ -struct wait_event { - struct tasklet *tasklet; - int events; /* set of enum sub_event_type above */ -}; - -/* A connection handle is how we differentiate two connections on the lower - * layers. It usually is a file descriptor but can be a connection id. - */ -union conn_handle { - int fd; /* file descriptor, for regular sockets */ -}; - /* conn_stream flags */ enum { CS_FL_NONE = 0x00000000, /* Just for initialization purposes */ @@ -310,6 +284,58 @@ enum { MX_FL_HTX = 0x00000002, /* set if it is an HTX multiplexer */ }; +/* PROTO token registration */ +enum proto_proxy_mode { + PROTO_MODE_NONE = 0, + PROTO_MODE_TCP = 1 << 0, // must not be changed! + PROTO_MODE_HTTP = 1 << 1, // must not be changed! + PROTO_MODE_ANY = PROTO_MODE_TCP | PROTO_MODE_HTTP, +}; + +enum proto_proxy_side { + PROTO_SIDE_NONE = 0, + PROTO_SIDE_FE = 1, // same as PR_CAP_FE + PROTO_SIDE_BE = 2, // same as PR_CAP_BE + PROTO_SIDE_BOTH = PROTO_SIDE_FE | PROTO_SIDE_BE, +}; + +/* ctl command used by mux->ctl() */ +enum mux_ctl_type { + MUX_STATUS, /* Expects an int as output, sets it to a combinaison of MUX_STATUS flags */ +}; + +/* response for ctl MUX_STATUS */ +#define MUX_STATUS_READY (1 << 0) + +/* socks4 response length */ +#define SOCKS4_HS_RSP_LEN 8 + +/* socks4 upstream proxy definitions */ +struct socks4_request { + uint8_t version; /* SOCKS version number, 1 byte, must be 0x04 for this version */ + uint8_t command; /* 0x01 = establish a TCP/IP stream connection */ + uint16_t port; /* port number, 2 bytes (in network byte order) */ + uint32_t ip; /* IP address, 4 bytes (in network byte order) */ + char user_id[8]; /* the user ID string, variable length, terminated with a null (0x00); Using "HAProxy\0" */ +}; + +/* Describes a set of subscriptions. Multiple events may be registered at the + * same time. The callee should assume everything not pending for completion is + * implicitly possible. It's illegal to change the tasklet if events are still + * registered. + */ +struct wait_event { + struct tasklet *tasklet; + int events; /* set of enum sub_event_type above */ +}; + +/* A connection handle is how we differentiate two connections on the lower + * layers. It usually is a file descriptor but can be a connection id. + */ +union conn_handle { + int fd; /* file descriptor, for regular sockets */ +}; + /* xprt_ops describes transport-layer operations for a connection. They * generally run over a socket-based control layer, but not always. Some * of them are used for data transfer with the upper layer (rcv_*, snd_*) @@ -336,12 +362,6 @@ struct xprt_ops { int (*add_xprt)(struct connection *conn, void *xprt_ctx, void *toadd_ctx, const struct xprt_ops *toadd_ops, void **oldxprt_ctx, const struct xprt_ops **oldxprt_ops); /* Add a new XPRT as the new xprt, and return the old one */ }; -enum mux_ctl_type { - MUX_STATUS, /* Expects an int as output, sets it to a combinaison of MUX_STATUS flags */ -}; - -#define MUX_STATUS_READY (1 << 0) - /* mux_ops describes the mux operations, which are to be performed at the * connection level after data are exchanged with the transport layer in order * to propagate them to streams. The function will automatically be @@ -396,7 +416,6 @@ struct my_tcphdr { /* a connection source profile defines all the parameters needed to properly * bind an outgoing connection for a server or proxy. */ - struct conn_src { unsigned int opts; /* CO_SRC_* */ int iface_len; /* bind interface name length */ @@ -475,21 +494,6 @@ struct connection { struct ist proxy_unique_id; /* Value of the unique ID TLV received via PROXYv2 */ }; -/* PROTO token registration */ -enum proto_proxy_mode { - PROTO_MODE_NONE = 0, - PROTO_MODE_TCP = 1 << 0, // must not be changed! - PROTO_MODE_HTTP = 1 << 1, // must not be changed! - PROTO_MODE_ANY = PROTO_MODE_TCP | PROTO_MODE_HTTP, -}; - -enum proto_proxy_side { - PROTO_SIDE_NONE = 0, - PROTO_SIDE_FE = 1, // same as PR_CAP_FE - PROTO_SIDE_BE = 2, // same as PR_CAP_BE - PROTO_SIDE_BOTH = PROTO_SIDE_FE | PROTO_SIDE_BE, -}; - struct mux_proto_list { const struct ist token; /* token name and length. Empty is catch-all */ enum proto_proxy_mode mode; @@ -498,6 +502,8 @@ struct mux_proto_list { struct list list; }; +/* proxy protocol stuff below */ + /* proxy protocol v2 definitions */ #define PP2_SIGNATURE "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A" #define PP2_SIGNATURE_LEN 12 @@ -533,6 +539,28 @@ struct mux_proto_list { #define PP2_HDR_LEN_INET6 (PP2_HEADER_LEN + PP2_ADDR_LEN_INET6) #define PP2_HDR_LEN_UNIX (PP2_HEADER_LEN + PP2_ADDR_LEN_UNIX) +#define PP2_TYPE_ALPN 0x01 +#define PP2_TYPE_AUTHORITY 0x02 +#define PP2_TYPE_CRC32C 0x03 +#define PP2_TYPE_NOOP 0x04 +#define PP2_TYPE_UNIQUE_ID 0x05 +#define PP2_TYPE_SSL 0x20 +#define PP2_SUBTYPE_SSL_VERSION 0x21 +#define PP2_SUBTYPE_SSL_CN 0x22 +#define PP2_SUBTYPE_SSL_CIPHER 0x23 +#define PP2_SUBTYPE_SSL_SIG_ALG 0x24 +#define PP2_SUBTYPE_SSL_KEY_ALG 0x25 +#define PP2_TYPE_NETNS 0x30 + +#define PP2_CLIENT_SSL 0x01 +#define PP2_CLIENT_CERT_CONN 0x02 +#define PP2_CLIENT_CERT_SESS 0x04 + +/* Max length of the authority TLV */ +#define PP2_AUTHORITY_MAX 255 + +#define TLV_HEADER_SIZE 3 + struct proxy_hdr_v2 { uint8_t sig[12]; /* hex 0D 0A 0D 0A 00 0D 0A 51 55 49 54 0A */ uint8_t ver_cmd; /* protocol version and command */ @@ -558,20 +586,6 @@ struct proxy_hdr_v2 { } addr; }; -#define PP2_TYPE_ALPN 0x01 -#define PP2_TYPE_AUTHORITY 0x02 -#define PP2_TYPE_CRC32C 0x03 -#define PP2_TYPE_NOOP 0x04 -#define PP2_TYPE_UNIQUE_ID 0x05 -#define PP2_TYPE_SSL 0x20 -#define PP2_SUBTYPE_SSL_VERSION 0x21 -#define PP2_SUBTYPE_SSL_CN 0x22 -#define PP2_SUBTYPE_SSL_CIPHER 0x23 -#define PP2_SUBTYPE_SSL_SIG_ALG 0x24 -#define PP2_SUBTYPE_SSL_KEY_ALG 0x25 -#define PP2_TYPE_NETNS 0x30 - -#define TLV_HEADER_SIZE 3 struct tlv { uint8_t type; uint8_t length_hi; @@ -586,23 +600,8 @@ struct tlv_ssl { uint8_t sub_tlv[0]; }__attribute__((packed)); -#define PP2_CLIENT_SSL 0x01 -#define PP2_CLIENT_CERT_CONN 0x02 -#define PP2_CLIENT_CERT_SESS 0x04 - -/* Max length of the authority TLV */ -#define PP2_AUTHORITY_MAX 255 - -/* - * Linux seems to be able to send 253 fds per sendmsg(), not sure - * about the other OSes. - */ -/* Max number of file descriptors we send in one sendmsg() */ -#define MAX_SEND_FD 253 - -#define SOCKS4_HS_RSP_LEN 8 -#endif /* _TYPES_CONNECTION_H */ +#endif /* _HAPROXY_CONNECTION_T_H */ /* * Local variables: diff --git a/include/proto/connection.h b/include/haproxy/connection.h similarity index 99% rename from include/proto/connection.h rename to include/haproxy/connection.h index baa801f9cd..d90724f145 100644 --- a/include/proto/connection.h +++ b/include/haproxy/connection.h @@ -1,8 +1,8 @@ /* - * include/proto/connection.h + * include/haproxy/connection.h * This file contains connection function prototypes * - * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu + * Copyright (C) 2000-2002 Willy Tarreau - w@1wt.eu * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,18 +19,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _PROTO_CONNECTION_H -#define _PROTO_CONNECTION_H +#ifndef _HAPROXY_CONNECTION_H +#define _HAPROXY_CONNECTION_H #include + #include +#include +#include #include #include #include -#include -#include +#include + #include -#include extern struct pool_head *pool_head_connection; extern struct pool_head *pool_head_connstream; @@ -1084,7 +1086,7 @@ static inline int conn_upgrade_mux_fe(struct connection *conn, void *ctx, struct return 0; } -#endif /* _PROTO_CONNECTION_H */ +#endif /* _HAPROXY_CONNECTION_H */ /* * Local variables: diff --git a/include/haproxy/dns-t.h b/include/haproxy/dns-t.h index 832016b0ba..e75edc5f2d 100644 --- a/include/haproxy/dns-t.h +++ b/include/haproxy/dns-t.h @@ -24,11 +24,11 @@ #include +#include #include #include #include -#include #include #include diff --git a/include/haproxy/obj_type.h b/include/haproxy/obj_type.h index ad4950232c..56597056ed 100644 --- a/include/haproxy/obj_type.h +++ b/include/haproxy/obj_type.h @@ -23,11 +23,11 @@ #define _HAPROXY_OBJ_TYPE_H #include +#include #include #include #include #include -#include #include #include #include diff --git a/include/haproxy/proto_tcp.h b/include/haproxy/proto_tcp.h index 426fa2e795..c9ce231016 100644 --- a/include/haproxy/proto_tcp.h +++ b/include/haproxy/proto_tcp.h @@ -24,9 +24,9 @@ #include #include +#include #include #include -#include int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct sockaddr_storage *remote); int tcp_pause_listener(struct listener *l); diff --git a/include/proto/peers.h b/include/proto/peers.h index 40a9b7e2b0..93bb3224c1 100644 --- a/include/proto/peers.h +++ b/include/proto/peers.h @@ -23,9 +23,9 @@ #define _PROTO_PEERS_H #include +#include #include #include -#include #include #include diff --git a/include/proto/ssl_sock.h b/include/proto/ssl_sock.h index e29c1e7ad8..e22d9a3b6d 100644 --- a/include/proto/ssl_sock.h +++ b/include/proto/ssl_sock.h @@ -23,14 +23,13 @@ #define _PROTO_SSL_SOCK_H #ifdef USE_OPENSSL +#include #include -#include #include #include #include -#include extern int sslconns; extern int totalsslconns; diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index 98ccb2833d..e381d846e5 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -25,11 +25,11 @@ #include #include +#include #include #include #include #include -#include extern struct si_ops si_embedded_ops; diff --git a/include/types/checks.h b/include/types/checks.h index c7f08b2766..9d05ffc8e9 100644 --- a/include/types/checks.h +++ b/include/types/checks.h @@ -17,12 +17,12 @@ #include #include +#include #include #include #include #include -#include #include #include #include diff --git a/include/types/server.h b/include/types/server.h index a2f1fe368b..38326b0a15 100644 --- a/include/types/server.h +++ b/include/types/server.h @@ -36,7 +36,7 @@ #include -#include +#include #include #include #include diff --git a/include/types/ssl_sock.h b/include/types/ssl_sock.h index f7366d3d4d..d2851c668e 100644 --- a/include/types/ssl_sock.h +++ b/include/types/ssl_sock.h @@ -27,7 +27,7 @@ #include #include -#include /* struct wait_event */ +#include /* struct wait_event */ #include #include diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 0e255af568..205fbef2df 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -24,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/src/cfgparse.c b/src/cfgparse.c index 970b60f112..c5b3944ba5 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -81,7 +82,6 @@ #include #include #include -#include /* Used to chain configuration sections definitions. This list diff --git a/src/connection.c b/src/connection.c index 133a6d65e5..a777b9fa12 100644 --- a/src/connection.c +++ b/src/connection.c @@ -14,12 +14,12 @@ #include #include +#include #include #include #include #include -#include #include #include #include diff --git a/src/haproxy.c b/src/haproxy.c index 92fdd42266..9b0d767de1 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -85,6 +85,7 @@ #include #include #include +#include #include #include #include @@ -122,7 +123,6 @@ #include #include #include -#include #include #include #include diff --git a/src/hlua.c b/src/hlua.c index adb5316324..0b75bf723f 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -51,7 +52,6 @@ #include #include #include -#include #include #include #include diff --git a/src/http_ana.c b/src/http_ana.c index f7e59321f6..546e139573 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/src/http_fetch.c b/src/http_fetch.c index 6f367fed77..67dd989490 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -34,7 +35,6 @@ #include #include -#include #include #include #include diff --git a/src/listener.c b/src/listener.c index 4d1d2de110..6a13b1c5b0 100644 --- a/src/listener.c +++ b/src/listener.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -31,7 +32,6 @@ #include #include -#include #include #include #include diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 3c95b64753..05e67a67b4 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -25,7 +26,6 @@ #include #include -#include #include #include #include diff --git a/src/mux_h1.c b/src/mux_h1.c index 107794c3d9..36478c3f1a 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/src/mux_h2.c b/src/mux_h2.c index 02f6a5f964..b8c4741a8f 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -21,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mux_pt.c b/src/mux_pt.c index d405e95506..08d6cea309 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -12,8 +12,8 @@ #include #include +#include #include -#include #include struct mux_pt_ctx { diff --git a/src/payload.c b/src/payload.c index af4ae1caba..5664ec7dd5 100644 --- a/src/payload.c +++ b/src/payload.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -21,7 +22,6 @@ #include #include #include -#include #include #include diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c index cca9d72ecb..cb1853681b 100644 --- a/src/proto_sockpair.c +++ b/src/proto_sockpair.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/src/proto_tcp.c b/src/proto_tcp.c index e43eaf7630..43a0029e1d 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -41,12 +42,10 @@ #include #include -#include #include #include #include -#include #include #include #include diff --git a/src/proto_uxst.c b/src/proto_uxst.c index c826546d67..33c79e9a7a 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/src/raw_sock.c b/src/raw_sock.c index 396a07cc02..2f5b98d986 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -24,12 +24,12 @@ #include #include +#include #include #include #include #include -#include #include #include #include diff --git a/src/server.c b/src/server.c index 694d5ae914..243dcafd3b 100644 --- a/src/server.c +++ b/src/server.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/src/session.c b/src/session.c index efc1335702..2b52ec87c8 100644 --- a/src/session.c +++ b/src/session.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -20,7 +21,6 @@ #include -#include #include #include #include diff --git a/src/ssl_sock.c b/src/ssl_sock.c index b83ef5c611..12e95758dd 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -74,7 +75,6 @@ #include #include #include -#include #include #include #include diff --git a/src/stream.c b/src/stream.c index c3199230f9..28ce2e54df 100644 --- a/src/stream.c +++ b/src/stream.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/src/stream_interface.c b/src/stream_interface.c index 23f639fb38..a51fa14dd7 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/src/tcp_rules.c b/src/tcp_rules.c index 1820ce51f9..6b51be4796 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -22,11 +23,9 @@ #include #include -#include #include #include -#include #include #include #include diff --git a/src/xprt_handshake.c b/src/xprt_handshake.c index bfbd52237c..1290d23baf 100644 --- a/src/xprt_handshake.c +++ b/src/xprt_handshake.c @@ -10,7 +10,7 @@ * */ -#include +#include #include struct xprt_handshake_ctx {