MAJOR: connection: move the addr field from the stream_interface

We need to have the source and destination addresses in the connection.
They were lying in the stream interface so let's move them. The flags
SI_FL_FROM_SET and SI_FL_TO_SET have been moved as well.

It's worth noting that tcp_connect_server() almost does not use the
stream interface anymore except for a few flags.

It has been identified that once we detach the connection from the SI,
it will probably be needed to keep a copy of the server-side addresses
in the SI just for logging purposes. This has not been implemented right
now though.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index abc7e22..7c8e2cb 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -371,6 +371,39 @@
 	return t->ptr.l;
 }
 
+/* Retrieves the connection's source address */
+static inline void conn_get_from_addr(struct connection *conn)
+{
+	if (conn->flags & CO_FL_ADDR_FROM_SET)
+		return;
+
+	if (!conn->ctrl || !conn->ctrl->get_src)
+		return;
+
+	if (conn->ctrl->get_src(conn->t.sock.fd, (struct sockaddr *)&conn->addr.from,
+	                         sizeof(conn->addr.from),
+	                         conn->target.type != TARG_TYPE_CLIENT) == -1)
+		return;
+	conn->flags |= CO_FL_ADDR_FROM_SET;
+}
+
+/* Retrieves the connection's original destination address */
+static inline void conn_get_to_addr(struct connection *conn)
+{
+	if (conn->flags & CO_FL_ADDR_TO_SET)
+		return;
+
+	if (!conn->ctrl || !conn->ctrl->get_dst)
+		return;
+
+	if (conn->ctrl->get_dst(conn->t.sock.fd, (struct sockaddr *)&conn->addr.to,
+	                         sizeof(conn->addr.to),
+	                         conn->target.type != TARG_TYPE_CLIENT) == -1)
+		return;
+	conn->flags |= CO_FL_ADDR_TO_SET;
+}
+
+
 #endif /* _PROTO_CONNECTION_H */
 
 /*
diff --git a/include/proto/proto_tcp.h b/include/proto/proto_tcp.h
index 6aadb5a..cdc1d37 100644
--- a/include/proto/proto_tcp.h
+++ b/include/proto/proto_tcp.h
@@ -46,12 +46,12 @@
  */
 static inline struct stktable_key *tcp_src_to_stktable_key(struct session *s)
 {
-	switch (s->si[0].addr.from.ss_family) {
+	switch (s->si[0].conn.addr.from.ss_family) {
 	case AF_INET:
-		static_table_key.key = (void *)&((struct sockaddr_in *)&s->si[0].addr.from)->sin_addr;
+		static_table_key.key = (void *)&((struct sockaddr_in *)&s->si[0].conn.addr.from)->sin_addr;
 		break;
 	case AF_INET6:
-		static_table_key.key = (void *)&((struct sockaddr_in6 *)&s->si[0].addr.from)->sin6_addr;
+		static_table_key.key = (void *)&((struct sockaddr_in6 *)&s->si[0].conn.addr.from)->sin6_addr;
 		break;
 	default:
 		return NULL;
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 7536e95..8cd4a31 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -93,38 +93,6 @@
 	si->conn.data_ctx = NULL;
 }
 
-/* Retrieves the source address for the stream interface. */
-static inline void si_get_from_addr(struct stream_interface *si)
-{
-	if (si->flags & SI_FL_FROM_SET)
-		return;
-
-	if (!si_ctrl(si) || !si_ctrl(si)->get_src)
-		return;
-
-	if (si_ctrl(si)->get_src(si_fd(si), (struct sockaddr *)&si->addr.from,
-	                         sizeof(si->addr.from),
-	                         si->conn.target.type != TARG_TYPE_CLIENT) == -1)
-		return;
-	si->flags |= SI_FL_FROM_SET;
-}
-
-/* Retrieves the original destination address for the stream interface. */
-static inline void si_get_to_addr(struct stream_interface *si)
-{
-	if (si->flags & SI_FL_TO_SET)
-		return;
-
-	if (!si_ctrl(si) || !si_ctrl(si)->get_dst)
-		return;
-
-	if (si_ctrl(si)->get_dst(si_fd(si), (struct sockaddr *)&si->addr.to,
-	                         sizeof(si->addr.to),
-	                         si->conn.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)
 {
diff --git a/include/types/connection.h b/include/types/connection.h
index b163730..2612eaf 100644
--- a/include/types/connection.h
+++ b/include/types/connection.h
@@ -80,6 +80,10 @@
 	 */
 	CO_FL_POLL_SOCK     = CO_FL_HANDSHAKE | CO_FL_WAIT_L4_CONN | CO_FL_WAIT_L6_CONN,
 
+	/* These flags are used to report whether the from/to addresses are set or not */
+	CO_FL_ADDR_FROM_SET = 0x00001000,  /* addr.from is set */
+	CO_FL_ADDR_TO_SET   = 0x00002000,  /* addr.to is set */
+
 	/* These flags are used by data layers to indicate to their iterators
 	 * whether they had to stop due to missing data or missing room. Their
 	 * callers must reset them before calling the data layer handlers.
@@ -181,8 +185,10 @@
 	int data_st;                  /* data layer state, initialized to zero */
 	void *data_ctx;               /* general purpose pointer, initialized to NULL */
 	struct target target;         /* the target to connect to (server, proxy, applet, ...) */
-	struct sockaddr *peeraddr;    /* pointer to peer's network address, or NULL if unset */
-	socklen_t peerlen;            /* peer's address length, or 0 if unset */
+	struct {
+		struct sockaddr_storage from;	/* client address, or address to spoof when connecting to the server */
+		struct sockaddr_storage to;	/* address reached by the client if SN_FRT_ADDR_SET is set, or address to connect to */
+	} addr; /* addresses of the remote side, client for producer and server for consumer */
 };
 
 #endif /* _TYPES_CONNECTION_H */
diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h
index 9001c60..edc97d0 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -75,8 +75,6 @@
 	SI_FL_NOLINGER   = 0x0080,  /* may close without lingering. One-shot. */
 	SI_FL_NOHALF     = 0x0100,  /* no half close, close both sides at once */
 	SI_FL_SRC_ADDR   = 0x1000,  /* get the source ip/port with getsockname */
-	SI_FL_TO_SET     = 0x2000,  /* addr.to is set */
-	SI_FL_FROM_SET   = 0x4000,  /* addr.from is set */
 };
 
 #define SI_FL_CAP_SPLICE (SI_FL_CAP_SPLTCP)
@@ -160,10 +158,6 @@
 			} cli;
 		} ctx;					/* used by stats I/O handlers to dump the stats */
 	} applet;
-	struct {
-		struct sockaddr_storage from;	/* client address, or address to spoof when connecting to the server */
-		struct sockaddr_storage to;	/* address reached by the client if SN_FRT_ADDR_SET is set, or address to connect to */
-	} addr; /* addresses of the remote side, client for producer and server for consumer */
 };
 
 /* An applet designed to run in a stream interface */