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 2287ee3..485fc0e 100644
--- a/contrib/debug/flags.c
+++ b/contrib/debug/flags.c
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 
 #include <types/channel.h>
-#include <types/connection.h>
+#include <haproxy/connection-t.h>
 #include <types/http_ana.h>
 #include <types/stream.h>
 #include <types/stream_interface.h>
diff --git a/include/haproxy/compat.h b/include/haproxy/compat.h
index fdd6fa4..97cde46 100644
--- a/include/haproxy/compat.h
+++ b/include/haproxy/compat.h
@@ -240,6 +240,11 @@
 #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 dfc8694..b7b97a5 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 <stdlib.h>
 #include <sys/socket.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip6.h>
 
-#include <haproxy/api-t.h>
 #include <import/ist.h>
 
-#include <haproxy/obj_type-t.h>
+#include <haproxy/list-t.h>
 #include <haproxy/listener-t.h>
+#include <haproxy/obj_type-t.h>
 #include <haproxy/port_range-t.h>
 #include <haproxy/protocol-t.h>
-
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip6.h>
+#include <haproxy/api-t.h>
 
 /* referenced below */
 struct connection;
@@ -47,15 +47,6 @@
 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 @@
 	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 @@
 	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 @@
 	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 <init> function will automatically be
@@ -396,7 +416,6 @@
 /* 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 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 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 @@
 #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 @@
 	} 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 @@
 	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 98%
rename from include/proto/connection.h
rename to include/haproxy/connection.h
index baa801f..d90724f 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 <import/ist.h>
+
 #include <haproxy/api.h>
+#include <haproxy/connection-t.h>
+#include <haproxy/fd.h>
 #include <haproxy/listener-t.h>
 #include <haproxy/obj_type.h>
 #include <haproxy/pool.h>
-#include <types/connection.h>
-#include <haproxy/fd.h>
+#include <haproxy/task-t.h>
+
 #include <proto/session.h>
-#include <haproxy/task.h>
 
 extern struct pool_head *pool_head_connection;
 extern struct pool_head *pool_head_connstream;
@@ -1084,7 +1086,7 @@
 	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 832016b..e75edc5 100644
--- a/include/haproxy/dns-t.h
+++ b/include/haproxy/dns-t.h
@@ -24,11 +24,11 @@
 
 #include <import/eb32tree.h>
 
+#include <haproxy/connection-t.h>
 #include <haproxy/obj_type-t.h>
 #include <haproxy/list-t.h>
 #include <haproxy/thread.h>
 
-#include <types/connection.h>
 #include <haproxy/proto_udp-t.h>
 #include <haproxy/task-t.h>
 
diff --git a/include/haproxy/obj_type.h b/include/haproxy/obj_type.h
index ad49502..5659705 100644
--- a/include/haproxy/obj_type.h
+++ b/include/haproxy/obj_type.h
@@ -23,11 +23,11 @@
 #define _HAPROXY_OBJ_TYPE_H
 
 #include <haproxy/api.h>
+#include <haproxy/connection-t.h>
 #include <haproxy/listener-t.h>
 #include <haproxy/obj_type-t.h>
 #include <haproxy/pool.h>
 #include <types/applet.h>
-#include <types/connection.h>
 #include <types/proxy.h>
 #include <types/server.h>
 #include <types/stream.h>
diff --git a/include/haproxy/proto_tcp.h b/include/haproxy/proto_tcp.h
index 426fa2e..c9ce231 100644
--- a/include/haproxy/proto_tcp.h
+++ b/include/haproxy/proto_tcp.h
@@ -24,9 +24,9 @@
 
 #include <haproxy/arg-t.h>
 #include <haproxy/api.h>
+#include <haproxy/connection-t.h>
 #include <haproxy/listener-t.h>
 #include <haproxy/sample-t.h>
-#include <types/connection.h>
 
 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 40a9b7e..93bb322 100644
--- a/include/proto/peers.h
+++ b/include/proto/peers.h
@@ -23,9 +23,9 @@
 #define _PROTO_PEERS_H
 
 #include <haproxy/api.h>
+#include <haproxy/connection.h>
 #include <haproxy/ticks.h>
 #include <haproxy/time.h>
-#include <proto/connection.h>
 #include <types/stream.h>
 #include <types/peers.h>
 
diff --git a/include/proto/ssl_sock.h b/include/proto/ssl_sock.h
index e29c1e7..e22d9a3 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 <haproxy/connection.h>
 #include <haproxy/openssl-compat.h>
 
-#include <types/connection.h>
 #include <types/proxy.h>
 #include <types/ssl_sock.h>
 #include <types/stream_interface.h>
 
-#include <proto/connection.h>
 
 extern int sslconns;
 extern int totalsslconns;
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 98ccb28..e381d84 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -25,11 +25,11 @@
 #include <stdlib.h>
 
 #include <haproxy/api.h>
+#include <haproxy/connection.h>
 #include <types/stream.h>
 #include <types/stream_interface.h>
 #include <proto/applet.h>
 #include <proto/channel.h>
-#include <proto/connection.h>
 
 
 extern struct si_ops si_embedded_ops;
diff --git a/include/types/checks.h b/include/types/checks.h
index c7f08b2..9d05ffc 100644
--- a/include/types/checks.h
+++ b/include/types/checks.h
@@ -17,12 +17,12 @@
 #include <import/ebpttree.h>
 
 #include <import/ist.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 <types/connection.h>
 #include <haproxy/sample-t.h>
 #include <types/session.h>
 #include <haproxy/task-t.h>
diff --git a/include/types/server.h b/include/types/server.h
index a2f1fe3..38326b0 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -36,7 +36,7 @@
 
 #include <import/eb32tree.h>
 
-#include <types/connection.h>
+#include <haproxy/connection-t.h>
 #include <haproxy/freq_ctr-t.h>
 #include <types/queue.h>
 #include <types/ssl_sock.h>
diff --git a/include/types/ssl_sock.h b/include/types/ssl_sock.h
index f7366d3..d2851c6 100644
--- a/include/types/ssl_sock.h
+++ b/include/types/ssl_sock.h
@@ -27,7 +27,7 @@
 #include <import/ebmbtree.h>
 #include <import/eb64tree.h>
 
-#include <types/connection.h> /* struct wait_event */
+#include <haproxy/connection-t.h> /* struct wait_event */
 
 #include <haproxy/buf-t.h>
 #include <haproxy/thread.h>
diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c
index 0e255af..205fbef 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -16,6 +16,7 @@
 
 #include <haproxy/capture-t.h>
 #include <haproxy/compression-t.h>
+#include <haproxy/connection.h>
 #include <haproxy/http_htx.h>
 #include <haproxy/http_rules.h>
 #include <haproxy/listener.h>
@@ -24,7 +25,6 @@
 
 #include <proto/acl.h>
 #include <proto/checks.h>
-#include <proto/connection.h>
 #include <haproxy/protocol.h>
 #include <proto/proxy.h>
 #include <proto/server.h>
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 970b60f..c5b3944 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -39,6 +39,7 @@
 #include <haproxy/capture.h>
 #include <common/cfgparse.h>
 #include <haproxy/chunk.h>
+#include <haproxy/connection.h>
 #include <haproxy/dns.h>
 #include <haproxy/errors.h>
 #include <haproxy/frontend.h>
@@ -81,7 +82,6 @@
 #include <proto/stream.h>
 #include <proto/stick_table.h>
 #include <haproxy/tcp_rules.h>
-#include <proto/connection.h>
 
 
 /* Used to chain configuration sections definitions. This list
diff --git a/src/connection.c b/src/connection.c
index 133a6d6..a777b9f 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -14,12 +14,12 @@
 
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
+#include <haproxy/connection.h>
 #include <haproxy/frontend.h>
 #include <haproxy/namespace.h>
 #include <haproxy/hash.h>
 #include <haproxy/net_helper.h>
 
-#include <proto/connection.h>
 #include <haproxy/fd.h>
 #include <haproxy/proto_tcp.h>
 #include <proto/stream_interface.h>
diff --git a/src/haproxy.c b/src/haproxy.c
index 92fdd42..9b0d767 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -85,6 +85,7 @@
 #include <haproxy/base64.h>
 #include <common/cfgparse.h>
 #include <haproxy/chunk.h>
+#include <haproxy/connection.h>
 #include <haproxy/dns.h>
 #include <haproxy/dynbuf.h>
 #include <haproxy/errors.h>
@@ -122,7 +123,6 @@
 #include <proto/backend.h>
 #include <proto/channel.h>
 #include <proto/cli.h>
-#include <proto/connection.h>
 #include <haproxy/fd.h>
 #include <proto/filters.h>
 #include <proto/log.h>
diff --git a/src/hlua.c b/src/hlua.c
index adb5316..0b75bf7 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -25,6 +25,7 @@
 #include <import/ebpttree.h>
 
 #include <common/cfgparse.h>
+#include <haproxy/connection.h>
 #include <haproxy/http_htx.h>
 #include <haproxy/thread.h>
 #include <haproxy/regex.h>
@@ -51,7 +52,6 @@
 #include <proto/applet.h>
 #include <proto/channel.h>
 #include <proto/cli.h>
-#include <proto/connection.h>
 #include <proto/stats.h>
 #include <proto/http_fetch.h>
 #include <proto/queue.h>
diff --git a/src/http_ana.c b/src/http_ana.c
index f7e5932..546e139 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -13,6 +13,7 @@
 #include <haproxy/action-t.h>
 #include <haproxy/api.h>
 #include <haproxy/base64.h>
+#include <haproxy/connection.h>
 #include <haproxy/http.h>
 #include <haproxy/http_htx.h>
 #include <haproxy/htx.h>
@@ -26,7 +27,6 @@
 #include <proto/acl.h>
 #include <proto/channel.h>
 #include <proto/checks.h>
-#include <proto/connection.h>
 #include <proto/filters.h>
 #include <proto/log.h>
 #include <proto/http_ana.h>
diff --git a/src/http_fetch.c b/src/http_fetch.c
index 6f367fe..67dd989 100644
--- a/src/http_fetch.c
+++ b/src/http_fetch.c
@@ -20,6 +20,7 @@
 #include <haproxy/api.h>
 #include <haproxy/base64.h>
 #include <haproxy/chunk.h>
+#include <haproxy/connection.h>
 #include <haproxy/global.h>
 #include <haproxy/h1.h>
 #include <haproxy/h1_htx.h>
@@ -34,7 +35,6 @@
 
 #include <haproxy/arg.h>
 #include <proto/channel.h>
-#include <proto/connection.h>
 #include <proto/http_fetch.h>
 #include <proto/log.h>
 #include <proto/http_ana.h>
diff --git a/src/listener.c b/src/listener.c
index 4d1d2de..6a13b1c 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -20,6 +20,7 @@
 
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
+#include <haproxy/connection.h>
 #include <haproxy/errors.h>
 #include <haproxy/global.h>
 #include <haproxy/list.h>
@@ -31,7 +32,6 @@
 #include <haproxy/protocol-t.h>
 
 #include <proto/acl.h>
-#include <proto/connection.h>
 #include <haproxy/fd.h>
 #include <haproxy/freq_ctr.h>
 #include <proto/log.h>
diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c
index 3c95b64..05e67a6 100644
--- a/src/mux_fcgi.c
+++ b/src/mux_fcgi.c
@@ -12,6 +12,7 @@
 
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
+#include <haproxy/connection.h>
 #include <haproxy/fcgi.h>
 #include <haproxy/h1.h>
 #include <haproxy/h1_htx.h>
@@ -25,7 +26,6 @@
 #include <types/proxy.h>
 #include <types/session.h>
 
-#include <proto/connection.h>
 #include <proto/fcgi-app.h>
 #include <proto/log.h>
 #include <proto/session.h>
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 107794c..36478c3 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -12,6 +12,7 @@
 #include <haproxy/api.h>
 #include <haproxy/istbuf.h>
 #include <common/cfgparse.h>
+#include <haproxy/connection.h>
 #include <haproxy/h1.h>
 #include <haproxy/h1_htx.h>
 #include <haproxy/h2.h>
@@ -23,7 +24,6 @@
 #include <types/proxy.h>
 #include <types/session.h>
 
-#include <proto/connection.h>
 #include <haproxy/http_htx.h>
 #include <proto/log.h>
 #include <proto/session.h>
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 02f6a5f..b8c4741 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -13,6 +13,7 @@
 #include <haproxy/api.h>
 #include <haproxy/istbuf.h>
 #include <common/cfgparse.h>
+#include <haproxy/connection.h>
 #include <haproxy/h1.h>
 #include <haproxy/h2.h>
 #include <haproxy/hpack-dec.h>
@@ -21,7 +22,6 @@
 #include <haproxy/http_htx.h>
 #include <haproxy/htx.h>
 #include <haproxy/net_helper.h>
-#include <proto/connection.h>
 #include <proto/trace.h>
 #include <proto/session.h>
 #include <proto/stream.h>
diff --git a/src/mux_pt.c b/src/mux_pt.c
index d405e95..08d6cea 100644
--- a/src/mux_pt.c
+++ b/src/mux_pt.c
@@ -12,8 +12,8 @@
 
 #include <haproxy/api.h>
 #include <haproxy/buf.h>
+#include <haproxy/connection.h>
 #include <haproxy/task.h>
-#include <proto/connection.h>
 #include <proto/stream.h>
 
 struct mux_pt_ctx {
diff --git a/src/payload.c b/src/payload.c
index af4ae1c..5664ec7 100644
--- a/src/payload.c
+++ b/src/payload.c
@@ -14,6 +14,7 @@
 #include <string.h>
 
 #include <haproxy/api.h>
+#include <haproxy/connection.h>
 #include <haproxy/net_helper.h>
 #include <haproxy/payload.h>
 #include <haproxy/pattern.h>
@@ -21,7 +22,6 @@
 #include <proto/acl.h>
 #include <haproxy/arg.h>
 #include <proto/channel.h>
-#include <proto/connection.h>
 #include <haproxy/sample.h>
 #include <proto/http_ana.h>
 
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index cca9d72..cb18536 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -27,6 +27,7 @@
 #include <sys/un.h>
 
 #include <haproxy/api.h>
+#include <haproxy/connection.h>
 #include <haproxy/errors.h>
 #include <haproxy/global.h>
 #include <haproxy/list.h>
@@ -35,7 +36,6 @@
 #include <haproxy/time.h>
 #include <haproxy/version.h>
 
-#include <proto/connection.h>
 #include <haproxy/fd.h>
 #include <haproxy/freq_ctr.h>
 #include <proto/log.h>
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index e43eaf7..43a0029 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -32,6 +32,7 @@
 
 #include <haproxy/action-t.h>
 #include <haproxy/api.h>
+#include <haproxy/connection.h>
 #include <haproxy/errors.h>
 #include <haproxy/global.h>
 #include <haproxy/http_rules.h>
@@ -41,12 +42,10 @@
 #include <haproxy/tools.h>
 #include <haproxy/namespace.h>
 
-#include <types/connection.h>
 #include <types/stream.h>
 
 #include <haproxy/arg.h>
 #include <proto/channel.h>
-#include <proto/connection.h>
 #include <haproxy/fd.h>
 #include <proto/log.h>
 #include <haproxy/port_range.h>
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index c826546..33c79e9 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -27,6 +27,7 @@
 #include <sys/un.h>
 
 #include <haproxy/api.h>
+#include <haproxy/connection.h>
 #include <haproxy/errors.h>
 #include <haproxy/global.h>
 #include <haproxy/list.h>
@@ -35,7 +36,6 @@
 #include <haproxy/time.h>
 #include <haproxy/version.h>
 
-#include <proto/connection.h>
 #include <haproxy/fd.h>
 #include <proto/log.h>
 #include <haproxy/protocol.h>
diff --git a/src/raw_sock.c b/src/raw_sock.c
index 396a07c..2f5b98d 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -24,12 +24,12 @@
 
 #include <haproxy/api.h>
 #include <haproxy/buf.h>
+#include <haproxy/connection.h>
 #include <haproxy/global.h>
 #include <haproxy/tools.h>
 #include <haproxy/ticks.h>
 #include <haproxy/time.h>
 
-#include <proto/connection.h>
 #include <haproxy/fd.h>
 #include <haproxy/freq_ctr.h>
 #include <proto/log.h>
diff --git a/src/server.c b/src/server.c
index 694d5ae..243dcaf 100644
--- a/src/server.c
+++ b/src/server.c
@@ -18,6 +18,7 @@
 #include <import/xxhash.h>
 
 #include <common/cfgparse.h>
+#include <haproxy/connection.h>
 #include <haproxy/dict-t.h>
 #include <haproxy/dns.h>
 #include <haproxy/errors.h>
@@ -35,7 +36,6 @@
 #include <proto/applet.h>
 #include <proto/cli.h>
 #include <proto/checks.h>
-#include <proto/connection.h>
 #include <haproxy/port_range.h>
 #include <haproxy/protocol.h>
 #include <proto/queue.h>
diff --git a/src/session.c b/src/session.c
index efc1335..2b52ec8 100644
--- a/src/session.c
+++ b/src/session.c
@@ -11,6 +11,7 @@
  */
 
 #include <haproxy/api.h>
+#include <haproxy/connection.h>
 #include <haproxy/global.h>
 #include <haproxy/http.h>
 #include <haproxy/listener.h>
@@ -20,7 +21,6 @@
 
 #include <types/session.h>
 
-#include <proto/connection.h>
 #include <proto/log.h>
 #include <proto/proxy.h>
 #include <proto/session.h>
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index b83ef5c..12e9575 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -46,6 +46,7 @@
 
 #include <haproxy/dynbuf.h>
 #include <haproxy/chunk.h>
+#include <haproxy/connection.h>
 #include <haproxy/errors.h>
 #include <haproxy/frontend.h>
 #include <haproxy/global.h>
@@ -74,7 +75,6 @@
 #include <proto/acl.h>
 #include <haproxy/arg.h>
 #include <proto/channel.h>
-#include <proto/connection.h>
 #include <proto/cli.h>
 #include <haproxy/fd.h>
 #include <haproxy/freq_ctr.h>
diff --git a/src/stream.c b/src/stream.c
index c319923..28ce2e5 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -18,6 +18,7 @@
 #include <haproxy/api.h>
 #include <haproxy/capture.h>
 #include <common/cfgparse.h>
+#include <haproxy/connection.h>
 #include <haproxy/dict.h>
 #include <haproxy/dns.h>
 #include <haproxy/dynbuf.h>
@@ -45,7 +46,6 @@
 #include <proto/channel.h>
 #include <proto/checks.h>
 #include <proto/cli.h>
-#include <proto/connection.h>
 #include <proto/stats.h>
 #include <haproxy/fd.h>
 #include <proto/filters.h>
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 23f639f..a51fa14 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -20,6 +20,7 @@
 #include <sys/types.h>
 
 #include <haproxy/api.h>
+#include <haproxy/connection.h>
 #include <haproxy/dynbuf.h>
 #include <haproxy/http_htx.h>
 #include <haproxy/tools.h>
@@ -29,7 +30,6 @@
 
 #include <proto/applet.h>
 #include <proto/channel.h>
-#include <proto/connection.h>
 #include <haproxy/pipe.h>
 #include <proto/proxy.h>
 #include <proto/stream.h>
diff --git a/src/tcp_rules.c b/src/tcp_rules.c
index 1820ce5..6b51be4 100644
--- a/src/tcp_rules.c
+++ b/src/tcp_rules.c
@@ -13,6 +13,7 @@
 #include <haproxy/api.h>
 #include <haproxy/capture-t.h>
 #include <common/cfgparse.h>
+#include <haproxy/connection.h>
 #include <haproxy/global.h>
 #include <haproxy/list.h>
 #include <haproxy/sample.h>
@@ -22,11 +23,9 @@
 #include <haproxy/time.h>
 
 #include <haproxy/arg-t.h>
-#include <types/connection.h>
 
 #include <proto/acl.h>
 #include <proto/channel.h>
-#include <proto/connection.h>
 #include <proto/log.h>
 #include <proto/proxy.h>
 #include <proto/stick_table.h>
diff --git a/src/xprt_handshake.c b/src/xprt_handshake.c
index bfbd522..1290d23 100644
--- a/src/xprt_handshake.c
+++ b/src/xprt_handshake.c
@@ -10,7 +10,7 @@
  *
  */
 
-#include <proto/connection.h>
+#include <haproxy/connection.h>
 #include <proto/stream_interface.h>
 
 struct xprt_handshake_ctx {