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/src/backend.c b/src/backend.c
index d5c4a99..b777cc3 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -984,13 +984,11 @@
 
 	/* set the correct protocol on the output stream interface */
 	if (s->target.type == TARG_TYPE_SERVER) {
-		s->req->cons->conn.ctrl = target_srv(&s->target)->proto;
-		stream_interface_prepare(s->req->cons, target_srv(&s->target)->sock);
+		si_prepare_conn(s->req->cons, target_srv(&s->target)->proto, target_srv(&s->target)->data);
 	}
 	else if (s->target.type == TARG_TYPE_PROXY) {
 		/* proxies exclusively run on raw_sock right now */
-		s->req->cons->conn.ctrl = protocol_by_family(s->req->cons->addr.to.ss_family);
-		stream_interface_prepare(s->req->cons, &raw_sock);
+		si_prepare_conn(s->req->cons, protocol_by_family(s->req->cons->addr.to.ss_family), &raw_sock);
 		if (!si_ctrl(s->req->cons))
 			return SN_ERR_INTERNAL;
 	}
diff --git a/src/cfgparse.c b/src/cfgparse.c
index ea3b6cf..44397fc 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -266,7 +266,7 @@
 
 			l->fd = -1;
 			l->addr = ss;
-			l->sock = &raw_sock;
+			l->data = &raw_sock;
 			l->state = LI_INIT;
 
 			if (ss.ss_family == AF_INET) {
@@ -1275,7 +1275,7 @@
 		}
 		newpeer->addr = *sk;
 		newpeer->proto = protocol_by_family(newpeer->addr.ss_family);
-		newpeer->sock  = &raw_sock;
+		newpeer->data  = &raw_sock;
 		newpeer->sock_init_arg = NULL;
 
 		if (!sk) {
@@ -4093,8 +4093,7 @@
 			}
 			newsrv->addr = *sk;
 			newsrv->proto = protocol_by_family(newsrv->addr.ss_family);
-			newsrv->sock  = &raw_sock;
-			newsrv->sock_init_arg = NULL;
+			newsrv->data  = &raw_sock;
 
 			if (!sk) {
 				Alert("parsing [%s:%d] : Unknown protocol family %d '%s'\n",
diff --git a/src/connection.c b/src/connection.c
index 1eada2d..0abbe42 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -13,8 +13,7 @@
 #include <common/compat.h>
 #include <common/config.h>
 
-#include <types/connection.h>
-
+#include <proto/connection.h>
 #include <proto/proto_tcp.h>
 #include <proto/stream_interface.h>
 
@@ -49,7 +48,7 @@
 		__conn_sock_stop_both(conn);
 
 	if (fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
-		conn->data->read(conn);
+		conn->app_cb->recv(conn);
 
 	if (unlikely(conn->flags & CO_FL_ERROR))
 		goto leave;
@@ -61,7 +60,7 @@
 		goto process_handshake;
 
 	if (fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR))
-		conn->data->write(conn);
+		conn->app_cb->send(conn);
 
 	if (unlikely(conn->flags & CO_FL_ERROR))
 		goto leave;
diff --git a/src/dumpstats.c b/src/dumpstats.c
index 9112d2d..f7252a4 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -277,7 +277,7 @@
 			}
 		}
 
-		global.stats_sock.sock = &raw_sock;
+		global.stats_sock.data = &raw_sock;
 		uxst_add_listener(&global.stats_sock);
 		global.maxsock++;
 	}
diff --git a/src/peers.c b/src/peers.c
index 4be52a2..c293971 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1156,7 +1156,6 @@
 	s->si[0].state = s->si[0].prev_state = SI_ST_EST;
 	s->si[0].err_type = SI_ET_NONE;
 	s->si[0].err_loc = NULL;
-	s->si[0].conn.ctrl = NULL;
 	s->si[0].release = NULL;
 	s->si[0].send_proxy_ofs = 0;
 	set_target_client(&s->si[0].target, l);
@@ -1178,11 +1177,10 @@
 	s->si[1].conn_retries = p->conn_retries;
 	s->si[1].err_type = SI_ET_NONE;
 	s->si[1].err_loc = NULL;
-	s->si[1].conn.ctrl = peer->proto;
 	s->si[1].release = NULL;
 	s->si[1].send_proxy_ofs = 0;
 	set_target_proxy(&s->si[1].target, s->be);
-	stream_interface_prepare(&s->si[1], peer->sock);
+	si_prepare_conn(&s->si[1], peer->proto, peer->data);
 	s->si[1].exp = TICK_ETERNITY;
 	s->si[1].flags = SI_FL_NONE;
 	if (s->be->options2 & PR_O2_INDEPSTR)
diff --git a/src/raw_sock.c b/src/raw_sock.c
index 035d338..e13749e 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -318,22 +318,17 @@
 }
 
 
-/* stream sock operations */
-struct sock_ops raw_sock = {
-	.update  = stream_int_update_conn,
-	.shutr   = NULL,
-	.shutw   = NULL,
-	.chk_rcv = stream_int_chk_rcv_conn,
-	.chk_snd = stream_int_chk_snd_conn,
-	.read    = si_conn_recv_cb,
-	.write   = si_conn_send_cb,
-	.snd_buf = raw_sock_from_buf,
-	.rcv_buf = raw_sock_to_buf,
+/* data-layer operations for RAW sockets */
+struct data_ops raw_sock = {
+	.snd_buf  = raw_sock_from_buf,
+	.rcv_buf  = raw_sock_to_buf,
 #if defined(CONFIG_HAP_LINUX_SPLICE)
 	.rcv_pipe = raw_sock_to_pipe,
 	.snd_pipe = raw_sock_from_pipe,
 #endif
-	.close   = NULL,
+	.shutr    = NULL,
+	.shutw    = NULL,
+	.close    = NULL,
 };
 
 /*
diff --git a/src/session.c b/src/session.c
index 80415b3..f2330d6 100644
--- a/src/session.c
+++ b/src/session.c
@@ -180,7 +180,7 @@
 		s->si[0].flags |= SI_FL_INDEP_STR;
 
 	/* add the various callbacks */
-	stream_interface_prepare(&s->si[0], l->sock);
+	si_prepare_conn(&s->si[0], l->proto, l->data);
 
 	if ((s->si[0].conn.data->rcv_pipe && s->si[0].conn.data->snd_pipe) &&
 	    (addr->ss_family == AF_INET || addr->ss_family == AF_INET6))
@@ -196,11 +196,10 @@
 	s->si[1].err_type  = SI_ET_NONE;
 	s->si[1].conn_retries = 0;  /* used for logging too */
 	s->si[1].err_loc   = NULL;
-	s->si[1].conn.ctrl = NULL;
 	s->si[1].release   = NULL;
 	s->si[1].send_proxy_ofs = 0;
 	clear_target(&s->si[1].target);
-	stream_interface_prepare(&s->si[1], &stream_int_embedded);
+	si_prepare_embedded(&s->si[1]);
 	s->si[1].exp       = TICK_ETERNITY;
 	s->si[1].flags     = SI_FL_NONE;
 
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 4ce8902..764bb3b 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -41,31 +41,36 @@
 static void stream_int_update_embedded(struct stream_interface *si);
 static void stream_int_chk_rcv(struct stream_interface *si);
 static void stream_int_chk_snd(struct stream_interface *si);
+static void stream_int_update_conn(struct stream_interface *si);
+static void stream_int_chk_rcv_conn(struct stream_interface *si);
+static void stream_int_chk_snd_conn(struct stream_interface *si);
 
-/* socket operations for embedded tasks */
-struct sock_ops stream_int_embedded = {
+/* stream-interface operations for embedded tasks */
+struct si_ops si_embedded_ops = {
 	.update  = stream_int_update_embedded,
-	.shutr   = NULL,
-	.shutw   = NULL,
 	.chk_rcv = stream_int_chk_rcv,
 	.chk_snd = stream_int_chk_snd,
-	.read    = NULL,
-	.write   = NULL,
-	.close   = NULL,
 };
 
-/* socket operations for external tasks */
-struct sock_ops stream_int_task = {
+/* stream-interface operations for external tasks */
+struct si_ops si_task_ops = {
 	.update  = stream_int_update,
-	.shutr   = NULL,
-	.shutw   = NULL,
 	.chk_rcv = stream_int_chk_rcv,
 	.chk_snd = stream_int_chk_snd,
-	.read    = NULL,
-	.write   = NULL,
-	.close   = NULL,
 };
 
+/* stream-interface operations for connections */
+struct si_ops si_conn_ops = {
+	.update  = stream_int_update_conn,
+	.chk_rcv = stream_int_chk_rcv_conn,
+	.chk_snd = stream_int_chk_snd_conn,
+};
+
+struct app_cb si_conn_cb = {
+	.recv    = si_conn_recv_cb,
+	.send    = si_conn_send_cb,
+};
+
 /*
  * This function only has to be called once after a wakeup event in case of
  * suspected timeout. It controls the stream interface timeouts and sets
@@ -415,8 +420,7 @@
 {
 	DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", app, si, si->owner);
 
-	stream_interface_prepare(si, &stream_int_embedded);
-	si->conn.ctrl = NULL;
+	si_prepare_embedded(si);
 	set_target_applet(&si->target, app);
 	si->release   = app->release;
 	si->flags |= SI_FL_WAIT_DATA;
@@ -437,8 +441,7 @@
 
 	DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", fct, si, si->owner);
 
-	stream_interface_prepare(si, &stream_int_task);
-	si->conn.ctrl = NULL;
+	si_prepare_task(si);
 	clear_target(&si->target);
 	si->release   = NULL;
 	si->flags |= SI_FL_WAIT_DATA;
@@ -835,7 +838,7 @@
  * timeouts, so that we can still check them later at wake-up. This function is
  * dedicated to connection-based stream interfaces.
  */
-void stream_int_chk_rcv_conn(struct stream_interface *si)
+static void stream_int_chk_rcv_conn(struct stream_interface *si)
 {
 	struct channel *ib = si->ib;
 
@@ -866,7 +869,7 @@
  * for data in the buffer. Note that it intentionally does not update timeouts,
  * so that we can still check them later at wake-up.
  */
-void stream_int_chk_snd_conn(struct stream_interface *si)
+static void stream_int_chk_snd_conn(struct stream_interface *si)
 {
 	struct channel *ob = si->ob;
 
@@ -1275,7 +1278,6 @@
 	return;
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 8