[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/include/types/stream_interface.h b/include/types/stream_interface.h
index ea7b266..aae25c6 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -74,12 +74,30 @@
 	SI_FL_NOLINGER   = 0x0080,  /* may close without lingering. One-shot. */
 };
 
+/* target types */
+enum {
+	TARG_TYPE_NONE = 0,         /* no target set, pointer is NULL by definition */
+	TARG_TYPE_PROXY,            /* target is a proxy   ; use address with the proxy's settings */
+	TARG_TYPE_SERVER,           /* target is a server  ; use address with server's and its proxy's settings */
+	TARG_TYPE_APPLET,           /* target is an applet ; use only the applet */
+};
+
 #define SI_FL_CAP_SPLICE (SI_FL_CAP_SPLTCP)
 
 struct server;
 struct proxy;
 struct si_applet;
 
+struct target {
+	int type;
+	union {
+		void *v;              /* pointer value, for any type */
+		struct proxy *p;      /* when type is TARG_TYPE_PROXY  */
+		struct server *s;     /* when type is TARG_TYPE_SERVER */
+		struct si_applet *a;  /* when type is TARG_TYPE_APPLET */
+	} ptr;
+};
+
 /* A stream interface has 3 parts :
  *  - the buffer side, which interfaces to the buffers.
  *  - the remote side, which describes the state and address of the other side.
@@ -108,10 +126,11 @@
 	void (*shutw)(struct stream_interface *);  /* shutw function */
 	void (*chk_rcv)(struct stream_interface *);/* chk_rcv function */
 	void (*chk_snd)(struct stream_interface *);/* chk_snd function */
-	int (*connect)(struct stream_interface *, struct proxy *, struct server *); /* connect function if any */
+	int  (*connect)(struct stream_interface *); /* connect function if any */
 	void (*release)(struct stream_interface *); /* handler to call after the last close() */
 
 	/* struct members below are the "remote" part, as seen from the buffer side */
+	struct target target;	/* the target to connect to (server, proxy, applet, ...) */
 	int conn_retries;	/* number of connect retries left */
 	int fd;                 /* file descriptor for a stream driver when known */
 	struct {