REORG/MINOR: stream_interface: move si->fd to struct connection
The socket fd is used only when in socket mode and with a connection.
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 9a619f8..83c389a 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -52,6 +52,11 @@
return si->conn.data;
}
+static inline int si_fd(struct stream_interface *si)
+{
+ return si->conn.t.sock.fd;
+}
+
static inline void clear_target(struct target *dest)
{
dest->type = TARG_TYPE_NONE;
@@ -121,7 +126,7 @@
if (!si_ctrl(si) || !si_ctrl(si)->get_src)
return;
- if (si_ctrl(si)->get_src(si->fd, (struct sockaddr *)&si->addr.from,
+ if (si_ctrl(si)->get_src(si_fd(si), (struct sockaddr *)&si->addr.from,
sizeof(si->addr.from),
si->target.type != TARG_TYPE_CLIENT) == -1)
return;
@@ -137,7 +142,7 @@
if (!si_ctrl(si) || !si_ctrl(si)->get_dst)
return;
- if (si_ctrl(si)->get_dst(si->fd, (struct sockaddr *)&si->addr.to,
+ if (si_ctrl(si)->get_dst(si_fd(si), (struct sockaddr *)&si->addr.to,
sizeof(si->addr.to),
si->target.type != TARG_TYPE_CLIENT) == -1)
return;
diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h
index d573c58..ccaa1eb 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -105,6 +105,11 @@
struct connection {
const struct sock_ops *data; /* operations at the data layer */
const struct protocol *ctrl; /* operations at the control layer, generally a protocol */
+ union { /* definitions which depend on connection type */
+ struct { /*** information used by socket-based connections ***/
+ int fd; /* file descriptor for a stream driver when known */
+ } sock;
+ } t;
};
struct target {
@@ -158,7 +163,6 @@
struct target target; /* the target to connect to (server, proxy, applet, ...) */
int conn_retries; /* number of connect retries left */
int send_proxy_ofs; /* <0 = offset to (re)send from the end, >0 = send all */
- int fd; /* file descriptor for a stream driver when known */
struct {
int state; /* applet state, initialized to zero */
void *private; /* may be used by any function above */