MINOR: stream_interface: introduce a new "struct connection" type

We start to move everything needed to manage a connection to a special
entity "struct connection". We have the data layer operations and the
control operations there. We'll also have more info in the future such
as file descriptors and applet contexts, so that in the end it becomes
detachable from the stream interface, which will allow connections to
be reused between sessions.

For now on, we start with minimal changes.
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index ad5ae68..9a619f8 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -42,6 +42,16 @@
 					      struct task *(*fct)(struct task *));
 void stream_int_unregister_handler(struct stream_interface *si);
 
+static inline const struct protocol *si_ctrl(struct stream_interface *si)
+{
+	return si->conn.ctrl;
+}
+
+static inline const struct sock_ops *si_data(struct stream_interface *si)
+{
+	return si->conn.data;
+}
+
 static inline void clear_target(struct target *dest)
 {
 	dest->type = TARG_TYPE_NONE;
@@ -98,7 +108,7 @@
 
 static inline void stream_interface_prepare(struct stream_interface *si, const struct sock_ops *ops)
 {
-	memcpy(&si->sock, ops, sizeof(si->sock));
+	si->conn.data = ops;
 }
 
 
@@ -108,12 +118,12 @@
 	if (si->flags & SI_FL_FROM_SET)
 		return;
 
-	if (!si->proto || !si->proto->get_src)
+	if (!si_ctrl(si) || !si_ctrl(si)->get_src)
 		return;
 
-	if (si->proto->get_src(si->fd, (struct sockaddr *)&si->addr.from,
-			       sizeof(si->addr.from),
-			       si->target.type != TARG_TYPE_CLIENT) == -1)
+	if (si_ctrl(si)->get_src(si->fd, (struct sockaddr *)&si->addr.from,
+	                         sizeof(si->addr.from),
+	                         si->target.type != TARG_TYPE_CLIENT) == -1)
 		return;
 	si->flags |= SI_FL_FROM_SET;
 }
@@ -124,16 +134,53 @@
 	if (si->flags & SI_FL_TO_SET)
 		return;
 
-	if (!si->proto || !si->proto->get_dst)
+	if (!si_ctrl(si) || !si_ctrl(si)->get_dst)
 		return;
 
-	if (si->proto->get_dst(si->fd, (struct sockaddr *)&si->addr.to,
-			       sizeof(si->addr.to),
-			       si->target.type != TARG_TYPE_CLIENT) == -1)
+	if (si_ctrl(si)->get_dst(si->fd, (struct sockaddr *)&si->addr.to,
+	                         sizeof(si->addr.to),
+	                         si->target.type != TARG_TYPE_CLIENT) == -1)
 		return;
 	si->flags |= SI_FL_TO_SET;
 }
 
+/* Sends a shutr to the connection using the data layer */
+static inline void si_shutr(struct stream_interface *si)
+{
+	si_data(si)->shutr(si);
+}
+
+/* Sends a shutw to the connection using the data layer */
+static inline void si_shutw(struct stream_interface *si)
+{
+	si_data(si)->shutw(si);
+}
+
+/* Calls the data state update on the stream interfaace */
+static inline void si_update(struct stream_interface *si)
+{
+	si_data(si)->update(si);
+}
+
+/* Calls chk_rcv on the connection using the data layer */
+static inline void si_chk_rcv(struct stream_interface *si)
+{
+	si_data(si)->chk_rcv(si);
+}
+
+/* Calls chk_snd on the connection using the data layer */
+static inline void si_chk_snd(struct stream_interface *si)
+{
+	si_data(si)->chk_snd(si);
+}
+
+/* Calls chk_snd on the connection using the ctrl layer */
+static inline int si_connect(struct stream_interface *si)
+{
+	if (unlikely(!si_ctrl(si) || !si_ctrl(si)->connect))
+		return SN_ERR_INTERNAL;
+	return si_ctrl(si)->connect(si);
+}
 
 #endif /* _PROTO_STREAM_INTERFACE_H */
 
diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h
index 0eb3730..d573c58 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -95,6 +95,18 @@
 struct si_applet;
 struct stream_interface;
 
+/* This structure describes a connection with its methods and data.
+ * A connection may be performed to proxy or server via a local or remote
+ * socket, and can also be made to an internal applet. It can support
+ * several data schemes (applet, raw, ssl, ...). It can support several
+ * connection control schemes, generally a protocol for socket-oriented
+ * connections, but other methods for applets.
+ */
+struct connection {
+	const struct sock_ops *data;  /* operations at the data layer */
+	const struct protocol *ctrl;  /* operations at the control layer, generally a protocol */
+};
+
 struct target {
 	int type;
 	union {
@@ -138,8 +150,7 @@
 	unsigned int err_type;  /* first error detected, one of SI_ET_* */
 	void *err_loc;          /* commonly the server, NULL when SI_ET_NONE */
 
-	struct sock_ops sock;   /* socket level operations */
-	struct protocol *proto; /* socket protocol */
+	struct connection conn; /* descriptor for a connection */
 
 	void (*release)(struct stream_interface *); /* handler to call after the last close() */