CLEANUP: connection: split sock_ops into data_ops, app_cp and si_ops

Some parts of the sock_ops structure were only used by the stream
interface and have been moved into si_ops. Some of them were callbacks
to the stream interface from the connection and have been moved into
app_cp as they're the application seen from the connection (later,
health-checks will need to use them). The rest has moved to data_ops.

Normally at this point the connection could live without knowing about
stream interfaces at all.
diff --git a/include/types/connection.h b/include/types/connection.h
index 6d402cf..1714522 100644
--- a/include/types/connection.h
+++ b/include/types/connection.h
@@ -28,8 +28,10 @@
 #include <common/config.h>
 
 /* referenced below */
-struct sock_ops;
 struct protocol;
+struct connection;
+struct buffer;
+struct pipe;
 
 /* Polling flags that are manipulated by I/O callbacks and handshake callbacks
  * indicate what they expect from a file descriptor at each layer. For each
@@ -108,6 +110,29 @@
 	CO_FL_CURR_WR_POL   = CO_FL_WR_POL << 28,  /* sending needs to poll first */
 };
 
+
+/* data_ops describes data-layer operations for a connection. They generally
+ * run over a socket-based control layer, but not always.
+ */
+struct data_ops {
+	int  (*rcv_buf)(struct connection *conn, struct buffer *buf, int count); /* recv callback */
+	int  (*snd_buf)(struct connection *conn, struct buffer *buf, int flags); /* send callback */
+	int  (*rcv_pipe)(struct connection *conn, struct pipe *pipe, unsigned int count); /* recv-to-pipe callback */
+	int  (*snd_pipe)(struct connection *conn, struct pipe *pipe); /* send-to-pipe callback */
+	void (*shutr)(struct connection *, int);    /* shutr function */
+	void (*shutw)(struct connection *, int);    /* shutw function */
+	void (*close)(struct connection *);         /* close the data channel on the connection */
+};
+
+/* app_cb describes read and write callbacks which are called upon detected I/O
+ * activity at the data layer. These callbacks are supposed to make use of the
+ * data_ops above to exchange data from/to buffers and pipes.
+ */
+struct app_cb {
+	void (*recv)(struct connection *conn);  /* application-layer recv callback */
+	void (*send)(struct connection *conn);  /* application-layer send callback */
+};
+
 /* 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
@@ -116,8 +141,9 @@
  * 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 */
+	const struct data_ops *data;  /* operations at the data layer */
+	const struct protocol *ctrl;  /* operations at the socket layer */
+	const struct app_cb *app_cb;  /* application layer callbacks */
 	union {                       /* definitions which depend on connection type */
 		struct {              /*** information used by socket-based connections ***/
 			int fd;       /* file descriptor for a stream driver when known */
diff --git a/include/types/peers.h b/include/types/peers.h
index 9e33d6d..0b1a74c 100644
--- a/include/types/peers.h
+++ b/include/types/peers.h
@@ -74,7 +74,7 @@
 	time_t last_change;
 	struct sockaddr_storage addr;  /* peer address */
 	struct protocol *proto;	       /* peer address protocol */
-	struct sock_ops *sock;         /* peer socket operations */
+	struct data_ops *data;         /* peer socket operations at data layer */
 	void *sock_init_arg;           /* socket operations's opaque init argument if needed */
 	struct peer *next;	  /* next peer in the list */
 };
diff --git a/include/types/protocols.h b/include/types/protocols.h
index ac52a53..6869644 100644
--- a/include/types/protocols.h
+++ b/include/types/protocols.h
@@ -102,7 +102,7 @@
 	int options;			/* socket options : LI_O_* */
 	struct licounters *counters;	/* statistics counters */
 	struct protocol *proto;		/* protocol this listener belongs to */
-	struct sock_ops *sock;          /* listener socket operations */
+	struct data_ops *data;          /* data-layer operations operations for this socket */
 	int nbconn;			/* current number of connections on this listener */
 	int maxconn;			/* maximum connections allowed on this listener */
 	unsigned int backlog;		/* if set, listen backlog */
diff --git a/include/types/server.h b/include/types/server.h
index 7a405fd..c952885 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -151,8 +151,7 @@
 	int bind_hdr_occ;			/* occurrence number of header above: >0 = from first, <0 = from end, 0=disabled */
 #endif
 	struct protocol *proto;	                /* server address protocol */
-	struct sock_ops *sock;                  /* server socket operations */
-	void *sock_init_arg;                    /* socket operations's opaque init argument if needed */
+	struct data_ops *data;                  /* data-layer operations */
 	unsigned down_time;			/* total time the server was down */
 	time_t last_change;			/* last time, when the state was changed */
 	struct timeval check_start;		/* last health check start time */
diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h
index 921363f..5985619 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -91,12 +91,10 @@
 
 #define SI_FL_CAP_SPLICE (SI_FL_CAP_SPLTCP)
 
-struct buffer;
 struct server;
 struct proxy;
 struct si_applet;
 struct stream_interface;
-struct pipe;
 
 struct target {
 	int type;
@@ -110,19 +108,11 @@
 	} ptr;
 };
 
-struct sock_ops {
+/* operations available on a stream-interface */
+struct si_ops {
 	void (*update)(struct stream_interface *);  /* I/O update function */
-	void (*shutr)(struct connection *, int);    /* shutr function */
-	void (*shutw)(struct connection *, int);    /* shutw function */
 	void (*chk_rcv)(struct stream_interface *); /* chk_rcv function */
 	void (*chk_snd)(struct stream_interface *); /* chk_snd function */
-	void (*read)(struct connection *conn);      /* read callback after poll() */
-	void (*write)(struct connection *conn);     /* write callback after poll() */
-	void (*close)(struct connection *);         /* close the data channel on the connection */
-	int  (*rcv_buf)(struct connection *conn, struct buffer *buf, int count); /* recv callback */
-	int  (*snd_buf)(struct connection *conn, struct buffer *buf, int flags); /* send callback */
-	int  (*rcv_pipe)(struct connection *conn, struct pipe *pipe, unsigned int count); /* recv-to-pipe callback */
-	int  (*snd_pipe)(struct connection *conn, struct pipe *pipe); /* send-to-pipe callback */
 };
 
 /* A stream interface has 3 parts :
@@ -148,6 +138,7 @@
 	void *err_loc;          /* commonly the server, NULL when SI_ET_NONE */
 
 	struct connection conn; /* descriptor for a connection */
+	struct si_ops *ops;     /* general operations at the stream interface layer */
 
 	void (*release)(struct stream_interface *); /* handler to call after the last close() */