[MEDIUM] stream_interface: store the target pointer and type

When doing a connect() on a stream interface, some information is needed
from the server and from the backend. In some situations, we don't have
a server and only a backend (eg: peers). In other cases, we know we have
an applet and we don't want to connect to anything, but we'd still like
to have the info about the applet being used.

For this, we now store a pointer to the "target" into the stream interface.
The target describes what's on the other side before trying to connect. It
can be a server, a proxy or an applet for now. Later we'll probably have
descriptors for multiple-stage chains so that the final information may
still be found.

This will help removing many specific cases in the code. It already made
it possible to remove the "srv" and "be" parameters to tcpv4_connect_server().
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 174d661..2d79e22 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -181,10 +181,12 @@
 
 
 /*
- * This function initiates a connection to the server assigned to this session
- * (s->srv, si->addr.s.to). A source address may be pointed to by si->addr.s.from.
- * Note that this is only used in case of transparent proxying. Normal source bind
- * addresses are still determined locally (due to the possible need of a source port).
+ * This function initiates a connection to the target assigned to this session
+ * (si->{target,addr.s.to}). A source address may be pointed to by si->addr.s.from
+ * in case of transparent proxying. Normal source bind addresses are still
+ * determined locally (due to the possible need of a source port).
+ * si->target may point either to a valid server or to a backend, depending
+ * on si->target.type. Only TARG_TYPE_PROXY and TARG_TYPE_SERVER are supported.
  *
  * It can return one of :
  *  - SN_ERR_NONE if everything's OK
@@ -196,9 +198,24 @@
  * Additionnally, in the case of SN_ERR_RESOURCE, an emergency log will be emitted.
  */
 
-int tcpv4_connect_server(struct stream_interface *si, struct proxy *be, struct server *srv)
+int tcpv4_connect_server(struct stream_interface *si)
 {
 	int fd;
+	struct server *srv;
+	struct proxy *be;
+
+	switch (si->target.type) {
+	case TARG_TYPE_PROXY:
+		be = si->target.ptr.p;
+		srv = NULL;
+		break;
+	case TARG_TYPE_SERVER:
+		srv = si->target.ptr.s;
+		be = srv->proxy;
+		break;
+	default:
+		return SN_ERR_INTERNAL;
+	}
 
 	if ((fd = si->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
 		qfprintf(stderr, "Cannot get a server socket.\n");