MEDIUM: stream-int/conn-stream: Move si_ops in the conn-stream scope

The si_ops structure is renamed to cs_app_ops and the callback functions are
changed to manipulate a conn-stream instead of a stream-interface..
diff --git a/src/stream_interface.c b/src/stream_interface.c
index b119cff..7b94812 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -23,6 +23,8 @@
 #include <haproxy/applet.h>
 #include <haproxy/channel.h>
 #include <haproxy/connection.h>
+#include <haproxy/conn_stream.h>
+#include <haproxy/cs_utils.h>
 #include <haproxy/dynbuf.h>
 #include <haproxy/http_ana.h>
 #include <haproxy/http_htx.h>
@@ -40,23 +42,23 @@
 DECLARE_POOL(pool_head_streaminterface, "stream_interface", sizeof(struct stream_interface));
 
 
-/* functions used by default on a detached stream-interface */
-static void stream_int_shutr(struct stream_interface *si);
-static void stream_int_shutw(struct stream_interface *si);
-static void stream_int_chk_rcv(struct stream_interface *si);
-static void stream_int_chk_snd(struct stream_interface *si);
+/* functions used by default on a detached conn-stream */
+static void cs_app_shutr(struct conn_stream *cs);
+static void cs_app_shutw(struct conn_stream *cs);
+static void cs_app_chk_rcv(struct conn_stream *cs);
+static void cs_app_chk_snd(struct conn_stream *cs);
 
-/* functions used on a conn_stream-based stream-interface */
-static void stream_int_shutr_conn(struct stream_interface *si);
-static void stream_int_shutw_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);
+/* functions used on a mux-based conn-stream */
+static void cs_app_shutr_conn(struct conn_stream *cs);
+static void cs_app_shutw_conn(struct conn_stream *cs);
+static void cs_app_chk_rcv_conn(struct conn_stream *cs);
+static void cs_app_chk_snd_conn(struct conn_stream *cs);
 
-/* functions used on an applet-based stream-interface */
-static void stream_int_shutr_applet(struct stream_interface *si);
-static void stream_int_shutw_applet(struct stream_interface *si);
-static void stream_int_chk_rcv_applet(struct stream_interface *si);
-static void stream_int_chk_snd_applet(struct stream_interface *si);
+/* functions used on an applet-based conn-stream */
+static void cs_app_shutr_applet(struct conn_stream *cs);
+static void cs_app_shutw_applet(struct conn_stream *cs);
+static void cs_app_chk_rcv_applet(struct conn_stream *cs);
+static void cs_app_chk_snd_applet(struct conn_stream *cs);
 
 /* last read notification */
 static void stream_int_read0(struct stream_interface *si);
@@ -64,30 +66,30 @@
 /* post-IO notification callback */
 static void stream_int_notify(struct stream_interface *si);
 
-/* stream-interface operations for embedded tasks */
-struct si_ops si_embedded_ops = {
-	.chk_rcv = stream_int_chk_rcv,
-	.chk_snd = stream_int_chk_snd,
-	.shutr   = stream_int_shutr,
-	.shutw   = stream_int_shutw,
-};
 
-/* stream-interface operations for connections */
-struct si_ops si_conn_ops = {
-	.chk_rcv = stream_int_chk_rcv_conn,
-	.chk_snd = stream_int_chk_snd_conn,
-	.shutr   = stream_int_shutr_conn,
-	.shutw   = stream_int_shutw_conn,
+/* conn-stream operations for connections */
+struct cs_app_ops cs_app_conn_ops = {
+	.chk_rcv = cs_app_chk_rcv_conn,
+	.chk_snd = cs_app_chk_snd_conn,
+	.shutr   = cs_app_shutr_conn,
+	.shutw   = cs_app_shutw_conn,
 };
 
-/* stream-interface operations for connections */
-struct si_ops si_applet_ops = {
-	.chk_rcv = stream_int_chk_rcv_applet,
-	.chk_snd = stream_int_chk_snd_applet,
-	.shutr   = stream_int_shutr_applet,
-	.shutw   = stream_int_shutw_applet,
+/* conn-stream operations for embedded tasks */
+struct cs_app_ops cs_app_embedded_ops = {
+	.chk_rcv = cs_app_chk_rcv,
+	.chk_snd = cs_app_chk_snd,
+	.shutr   = cs_app_shutr,
+	.shutw   = cs_app_shutw,
 };
 
+/* conn-stream operations for connections */
+struct cs_app_ops cs_app_applet_ops = {
+	.chk_rcv = cs_app_chk_rcv_applet,
+	.chk_snd = cs_app_chk_snd_applet,
+	.shutr   = cs_app_shutr_applet,
+	.shutw   = cs_app_shutw_applet,
+};
 
 /* Functions used to communicate with a conn_stream. The first two may be used
  * directly, the last one is mostly a wake callback.
@@ -127,65 +129,66 @@
 	pool_free(pool_head_streaminterface, si);
 }
 
+
 /*
- * This function performs a shutdown-read on a detached stream interface in a
+ * This function performs a shutdown-read on a detached conn-stream in a
  * connected or init state (it does nothing for other states). It either shuts
  * the read side or marks itself as closed. The buffer flags are updated to
  * reflect the new state. If the stream interface has CS_FL_NOHALF, we also
  * forward the close to the write side. The owner task is woken up if it exists.
  */
-static void stream_int_shutr(struct stream_interface *si)
+static void cs_app_shutr(struct conn_stream *cs)
 {
-	struct channel *ic = si_ic(si);
+	struct channel *ic = cs_ic(cs);
 
-	si_rx_shut_blk(si);
+	si_rx_shut_blk(cs->si);
 	if (ic->flags & CF_SHUTR)
 		return;
 	ic->flags |= CF_SHUTR;
 	ic->rex = TICK_ETERNITY;
 
-	if (!cs_state_in(si->cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST))
+	if (!cs_state_in(cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST))
 		return;
 
-	if (si_oc(si)->flags & CF_SHUTW) {
-		si->cs->state = CS_ST_DIS;
-		__cs_strm(si->cs)->conn_exp = TICK_ETERNITY;
+	if (cs_oc(cs)->flags & CF_SHUTW) {
+		cs->state = CS_ST_DIS;
+		__cs_strm(cs)->conn_exp = TICK_ETERNITY;
 	}
-	else if (si->cs->flags & CS_FL_NOHALF) {
+	else if (cs->flags & CS_FL_NOHALF) {
 		/* we want to immediately forward this close to the write side */
-		return stream_int_shutw(si);
+		return cs_app_shutw(cs);
 	}
 
 	/* note that if the task exists, it must unregister itself once it runs */
-	if (!(si->cs->flags & CS_FL_DONT_WAKE))
-		task_wakeup(si_task(si), TASK_WOKEN_IO);
+	if (!(cs->flags & CS_FL_DONT_WAKE))
+		task_wakeup(cs_strm_task(cs), TASK_WOKEN_IO);
 }
 
 /*
- * This function performs a shutdown-write on a detached stream interface in a
+ * This function performs a shutdown-write on a detached conn-stream in a
  * connected or init state (it does nothing for other states). It either shuts
  * the write side or marks itself as closed. The buffer flags are updated to
  * reflect the new state. It does also close everything if the SI was marked as
  * being in error state. The owner task is woken up if it exists.
  */
-static void stream_int_shutw(struct stream_interface *si)
+static void cs_app_shutw(struct conn_stream *cs)
 {
-	struct channel *ic = si_ic(si);
-	struct channel *oc = si_oc(si);
+	struct channel *ic = cs_ic(cs);
+	struct channel *oc = cs_oc(cs);
 
 	oc->flags &= ~CF_SHUTW_NOW;
 	if (oc->flags & CF_SHUTW)
 		return;
 	oc->flags |= CF_SHUTW;
 	oc->wex = TICK_ETERNITY;
-	si_done_get(si);
+	si_done_get(cs->si);
 
-	if (tick_isset(si->cs->hcto)) {
-		ic->rto = si->cs->hcto;
+	if (tick_isset(cs->hcto)) {
+		ic->rto = cs->hcto;
 		ic->rex = tick_add(now_ms, ic->rto);
 	}
 
-	switch (si->cs->state) {
+	switch (cs->state) {
 	case CS_ST_RDY:
 	case CS_ST_EST:
 		/* we have to shut before closing, otherwise some short messages
@@ -194,7 +197,7 @@
 		 * However, if CS_FL_NOLINGER is explicitly set, we know there is
 		 * no risk so we close both sides immediately.
 		 */
-		if (!(si->cs->endp->flags & CS_EP_ERROR) && !(si->cs->flags & CS_FL_NOLINGER) &&
+		if (!(cs->endp->flags & CS_EP_ERROR) && !(cs->flags & CS_FL_NOLINGER) &&
 		    !(ic->flags & (CF_SHUTR|CF_DONT_READ)))
 			return;
 
@@ -204,66 +207,66 @@
 	case CS_ST_QUE:
 	case CS_ST_TAR:
 		/* Note that none of these states may happen with applets */
-		si->cs->state = CS_ST_DIS;
+		cs->state = CS_ST_DIS;
 		/* fall through */
 	default:
-		si->cs->flags &= ~CS_FL_NOLINGER;
-		si_rx_shut_blk(si);
+		cs->flags &= ~CS_FL_NOLINGER;
+		si_rx_shut_blk(cs->si);
 		ic->flags |= CF_SHUTR;
 		ic->rex = TICK_ETERNITY;
-		__cs_strm(si->cs)->conn_exp = TICK_ETERNITY;
+		__cs_strm(cs)->conn_exp = TICK_ETERNITY;
 	}
 
 	/* note that if the task exists, it must unregister itself once it runs */
-	if (!(si->cs->flags & CS_FL_DONT_WAKE))
-		task_wakeup(si_task(si), TASK_WOKEN_IO);
+	if (!(cs->flags & CS_FL_DONT_WAKE))
+		task_wakeup(cs_strm_task(cs), TASK_WOKEN_IO);
 }
 
 /* default chk_rcv function for scheduled tasks */
-static void stream_int_chk_rcv(struct stream_interface *si)
+static void cs_app_chk_rcv(struct conn_stream *cs)
 {
-	struct channel *ic = si_ic(si);
+	struct channel *ic = cs_ic(cs);
 
-	DPRINTF(stderr, "%s: si=%p, cs->state=%d ic->flags=%08x oc->flags=%08x\n",
+	DPRINTF(stderr, "%s: cs=%p, cs->state=%d ic->flags=%08x oc->flags=%08x\n",
 		__FUNCTION__,
-		si, si->cs->state, ic->flags, si_oc(si)->flags);
+		cs, cs->state, ic->flags, cs_oc(cs)->flags);
 
 	if (ic->pipe) {
 		/* stop reading */
-		si_rx_room_blk(si);
+		si_rx_room_blk(cs->si);
 	}
 	else {
 		/* (re)start reading */
-		if (!(si->cs->flags & CS_FL_DONT_WAKE))
-			task_wakeup(si_task(si), TASK_WOKEN_IO);
+		if (!(cs->flags & CS_FL_DONT_WAKE))
+			task_wakeup(cs_strm_task(cs), TASK_WOKEN_IO);
 	}
 }
 
 /* default chk_snd function for scheduled tasks */
-static void stream_int_chk_snd(struct stream_interface *si)
+static void cs_app_chk_snd(struct conn_stream *cs)
 {
-	struct channel *oc = si_oc(si);
+	struct channel *oc = cs_oc(cs);
 
-	DPRINTF(stderr, "%s: si=%p, cs->state=%d ic->flags=%08x oc->flags=%08x\n",
+	DPRINTF(stderr, "%s: cs=%p, cs->state=%d ic->flags=%08x oc->flags=%08x\n",
 		__FUNCTION__,
-		si, si->cs->state, si_ic(si)->flags, oc->flags);
+		cs, cs->state, cs_ic(cs)->flags, oc->flags);
 
-	if (unlikely(si->cs->state != CS_ST_EST || (oc->flags & CF_SHUTW)))
+	if (unlikely(cs->state != CS_ST_EST || (oc->flags & CF_SHUTW)))
 		return;
 
-	if (!(si->flags & SI_FL_WAIT_DATA) ||        /* not waiting for data */
-	    channel_is_empty(oc))           /* called with nothing to send ! */
+	if (!(cs->si->flags & SI_FL_WAIT_DATA) ||  /* not waiting for data */
+	    channel_is_empty(oc))                  /* called with nothing to send ! */
 		return;
 
 	/* Otherwise there are remaining data to be sent in the buffer,
 	 * so we tell the handler.
 	 */
-	si->flags &= ~SI_FL_WAIT_DATA;
+	cs->si->flags &= ~SI_FL_WAIT_DATA;
 	if (!tick_isset(oc->wex))
 		oc->wex = tick_add_ifset(now_ms, oc->wto);
 
-	if (!(si->cs->flags & CS_FL_DONT_WAKE))
-		task_wakeup(si_task(si), TASK_WOKEN_IO);
+	if (!(cs->flags & CS_FL_DONT_WAKE))
+		task_wakeup(cs_strm_task(cs), TASK_WOKEN_IO);
 }
 
 /* Register an applet to handle a stream_interface as a new appctx. The SI will
@@ -980,7 +983,7 @@
 }
 
 /*
- * This function performs a shutdown-read on a stream interface attached to
+ * This function performs a shutdown-read on a conn-stream attached to
  * a connection in a connected or init state (it does nothing for other
  * states). It either shuts the read side or marks itself as closed. The buffer
  * flags are updated to reflect the new state. If the stream interface has
@@ -989,14 +992,13 @@
  * descriptors are then shutdown or closed accordingly. The function
  * automatically disables polling if needed.
  */
-static void stream_int_shutr_conn(struct stream_interface *si)
+static void cs_app_shutr_conn(struct conn_stream *cs)
 {
-	struct conn_stream *cs = si->cs;
-	struct channel *ic = si_ic(si);
+	struct channel *ic = cs_ic(cs);
 
 	BUG_ON(!cs_conn(cs));
 
-	si_rx_shut_blk(si);
+	si_rx_shut_blk(cs->si);
 	if (ic->flags & CF_SHUTR)
 		return;
 	ic->flags |= CF_SHUTR;
@@ -1005,30 +1007,29 @@
 	if (!cs_state_in(cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST))
 		return;
 
-	if (si_oc(si)->flags & CF_SHUTW) {
+	if (cs_oc(cs)->flags & CF_SHUTW) {
 		cs_conn_close(cs);
 		cs->state = CS_ST_DIS;
 		__cs_strm(cs)->conn_exp = TICK_ETERNITY;
 	}
-	else if (si->cs->flags & CS_FL_NOHALF) {
+	else if (cs->flags & CS_FL_NOHALF) {
 		/* we want to immediately forward this close to the write side */
-		return stream_int_shutw_conn(si);
+		return cs_app_shutw_conn(cs);
 	}
 }
 
 /*
- * This function performs a shutdown-write on a stream interface attached to
+ * This function performs a shutdown-write on a conn-stream attached to
  * a connection in a connected or init state (it does nothing for other
  * states). It either shuts the write side or marks itself as closed. The
  * buffer flags are updated to reflect the new state.  It does also close
  * everything if the SI was marked as being in error state. If there is a
  * data-layer shutdown, it is called.
  */
-static void stream_int_shutw_conn(struct stream_interface *si)
+static void cs_app_shutw_conn(struct conn_stream *cs)
 {
-	struct conn_stream *cs = si->cs;
-	struct channel *ic = si_ic(si);
-	struct channel *oc = si_oc(si);
+	struct channel *ic = cs_ic(cs);
+	struct channel *oc = cs_oc(cs);
 
 	BUG_ON(!cs_conn(cs));
 
@@ -1037,10 +1038,10 @@
 		return;
 	oc->flags |= CF_SHUTW;
 	oc->wex = TICK_ETERNITY;
-	si_done_get(si);
+	si_done_get(cs->si);
 
-	if (tick_isset(si->cs->hcto)) {
-		ic->rto = si->cs->hcto;
+	if (tick_isset(cs->hcto)) {
+		ic->rto = cs->hcto;
 		ic->rex = tick_add(now_ms, ic->rto);
 	}
 
@@ -1092,36 +1093,37 @@
 		/* fall through */
 	default:
 		cs->flags &= ~CS_FL_NOLINGER;
-		si_rx_shut_blk(si);
+		si_rx_shut_blk(cs->si);
 		ic->flags |= CF_SHUTR;
 		ic->rex = TICK_ETERNITY;
 		__cs_strm(cs)->conn_exp = TICK_ETERNITY;
 	}
 }
 
-/* This function is used for inter-stream-interface calls. It is called by the
+/* This function is used for inter-conn-stream calls. It is called by the
  * consumer to inform the producer side that it may be interested in checking
  * for free space in the buffer. Note that it intentionally does not update
  * timeouts, so that we can still check them later at wake-up. This function is
  * dedicated to connection-based stream interfaces.
  */
-static void stream_int_chk_rcv_conn(struct stream_interface *si)
+static void cs_app_chk_rcv_conn(struct conn_stream *cs)
 {
+	BUG_ON(!cs_conn(cs));
+
 	/* (re)start reading */
-	if (cs_state_in(si->cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST))
-		tasklet_wakeup(si->cs->wait_event.tasklet);
+	if (cs_state_in(cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST))
+		tasklet_wakeup(cs->wait_event.tasklet);
 }
 
 
-/* This function is used for inter-stream-interface calls. It is called by the
+/* This function is used for inter-conn-stream calls. It is called by the
  * producer to inform the consumer side that it may be interested in checking
  * for data in the buffer. Note that it intentionally does not update timeouts,
  * so that we can still check them later at wake-up.
  */
-static void stream_int_chk_snd_conn(struct stream_interface *si)
+static void cs_app_chk_snd_conn(struct conn_stream *cs)
 {
-	struct channel *oc = si_oc(si);
-	struct conn_stream *cs = si->cs;
+	struct channel *oc = cs_oc(cs);
 
 	BUG_ON(!cs_conn(cs));
 
@@ -1133,13 +1135,13 @@
 		return;
 
 	if (!oc->pipe &&                          /* spliced data wants to be forwarded ASAP */
-	    !(si->flags & SI_FL_WAIT_DATA))       /* not waiting for data */
+	    !(cs->si->flags & SI_FL_WAIT_DATA))       /* not waiting for data */
 		return;
 
-	if (!(si->cs->wait_event.events & SUB_RETRY_SEND) && !channel_is_empty(si_oc(si)))
+	if (!(cs->wait_event.events & SUB_RETRY_SEND) && !channel_is_empty(cs_oc(cs)))
 		si_cs_send(cs);
 
-	if (cs->endp->flags & (CS_EP_ERROR|CS_EP_ERR_PENDING) || si_is_conn_error(si)) {
+	if (cs->endp->flags & (CS_EP_ERROR|CS_EP_ERR_PENDING) || si_is_conn_error(cs->si)) {
 		/* Write error on the file descriptor */
 		if (cs->state >= CS_ST_CON)
 			cs->endp->flags |= CS_EP_ERROR;
@@ -1626,21 +1628,22 @@
 		appctx_wakeup(__cs_appctx(si->cs));
 }
 
+
 /*
- * This function performs a shutdown-read on a stream interface attached to an
+ * This function performs a shutdown-read on a conn-stream attached to an
  * applet in a connected or init state (it does nothing for other states). It
  * either shuts the read side or marks itself as closed. The buffer flags are
  * updated to reflect the new state. If the stream interface has CS_FL_NOHALF,
  * we also forward the close to the write side. The owner task is woken up if
  * it exists.
  */
-static void stream_int_shutr_applet(struct stream_interface *si)
+static void cs_app_shutr_applet(struct conn_stream *cs)
 {
-	struct channel *ic = si_ic(si);
+	struct channel *ic = cs_ic(cs);
 
-	BUG_ON(!cs_appctx(si->cs));
+	BUG_ON(!cs_appctx(cs));
 
-	si_rx_shut_blk(si);
+	si_rx_shut_blk(cs->si);
 	if (ic->flags & CF_SHUTR)
 		return;
 	ic->flags |= CF_SHUTR;
@@ -1648,50 +1651,50 @@
 
 	/* Note: on shutr, we don't call the applet */
 
-	if (!cs_state_in(si->cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST))
+	if (!cs_state_in(cs->state, CS_SB_CON|CS_SB_RDY|CS_SB_EST))
 		return;
 
-	if (si_oc(si)->flags & CF_SHUTW) {
-		si_applet_release(si);
-		si->cs->state = CS_ST_DIS;
-		__cs_strm(si->cs)->conn_exp = TICK_ETERNITY;
+	if (cs_oc(cs)->flags & CF_SHUTW) {
+		si_applet_release(cs->si);
+		cs->state = CS_ST_DIS;
+		__cs_strm(cs)->conn_exp = TICK_ETERNITY;
 	}
-	else if (si->cs->flags & CS_FL_NOHALF) {
+	else if (cs->flags & CS_FL_NOHALF) {
 		/* we want to immediately forward this close to the write side */
-		return stream_int_shutw_applet(si);
+		return cs_app_shutw_applet(cs);
 	}
 }
 
 /*
- * This function performs a shutdown-write on a stream interface attached to an
+ * This function performs a shutdown-write on a conn-stream attached to an
  * applet in a connected or init state (it does nothing for other states). It
  * either shuts the write side or marks itself as closed. The buffer flags are
  * updated to reflect the new state. It does also close everything if the SI
  * was marked as being in error state. The owner task is woken up if it exists.
  */
-static void stream_int_shutw_applet(struct stream_interface *si)
+static void cs_app_shutw_applet(struct conn_stream *cs)
 {
-	struct channel *ic = si_ic(si);
-	struct channel *oc = si_oc(si);
+	struct channel *ic = cs_ic(cs);
+	struct channel *oc = cs_oc(cs);
 
-	BUG_ON(!cs_appctx(si->cs));
+	BUG_ON(!cs_appctx(cs));
 
 	oc->flags &= ~CF_SHUTW_NOW;
 	if (oc->flags & CF_SHUTW)
 		return;
 	oc->flags |= CF_SHUTW;
 	oc->wex = TICK_ETERNITY;
-	si_done_get(si);
+	si_done_get(cs->si);
 
-	if (tick_isset(si->cs->hcto)) {
-		ic->rto = si->cs->hcto;
+	if (tick_isset(cs->hcto)) {
+		ic->rto = cs->hcto;
 		ic->rex = tick_add(now_ms, ic->rto);
 	}
 
 	/* on shutw we always wake the applet up */
-	appctx_wakeup(__cs_appctx(si->cs));
+	appctx_wakeup(__cs_appctx(cs));
 
-	switch (si->cs->state) {
+	switch (cs->state) {
 	case CS_ST_RDY:
 	case CS_ST_EST:
 		/* we have to shut before closing, otherwise some short messages
@@ -1700,7 +1703,7 @@
 		 * However, if CS_FL_NOLINGER is explicitly set, we know there is
 		 * no risk so we close both sides immediately.
 		 */
-		if (!(si->cs->endp->flags & CS_EP_ERROR) && !(si->cs->flags & CS_FL_NOLINGER) &&
+		if (!(cs->endp->flags & CS_EP_ERROR) && !(cs->flags & CS_FL_NOLINGER) &&
 		    !(ic->flags & (CF_SHUTR|CF_DONT_READ)))
 			return;
 
@@ -1710,52 +1713,52 @@
 	case CS_ST_QUE:
 	case CS_ST_TAR:
 		/* Note that none of these states may happen with applets */
-		si_applet_release(si);
-		si->cs->state = CS_ST_DIS;
+		si_applet_release(cs->si);
+		cs->state = CS_ST_DIS;
 		/* fall through */
 	default:
-		si->cs->flags &= ~CS_FL_NOLINGER;
-		si_rx_shut_blk(si);
+		cs->flags &= ~CS_FL_NOLINGER;
+		si_rx_shut_blk(cs->si);
 		ic->flags |= CF_SHUTR;
 		ic->rex = TICK_ETERNITY;
-		__cs_strm(si->cs)->conn_exp = TICK_ETERNITY;
+		__cs_strm(cs)->conn_exp = TICK_ETERNITY;
 	}
 }
 
 /* chk_rcv function for applets */
-static void stream_int_chk_rcv_applet(struct stream_interface *si)
+static void cs_app_chk_rcv_applet(struct conn_stream *cs)
 {
-	struct channel *ic = si_ic(si);
+	struct channel *ic = cs_ic(cs);
 
-	BUG_ON(!cs_appctx(si->cs));
+	BUG_ON(!cs_appctx(cs));
 
-	DPRINTF(stderr, "%s: si=%p, cs->state=%d ic->flags=%08x oc->flags=%08x\n",
+	DPRINTF(stderr, "%s: cs=%p, cs->state=%d ic->flags=%08x oc->flags=%08x\n",
 		__FUNCTION__,
-		si, si->cs->state, ic->flags, si_oc(si)->flags);
+		cs, cs->state, ic->flags, cs_oc(cs)->flags);
 
 	if (!ic->pipe) {
 		/* (re)start reading */
-		appctx_wakeup(__cs_appctx(si->cs));
+		appctx_wakeup(__cs_appctx(cs));
 	}
 }
 
 /* chk_snd function for applets */
-static void stream_int_chk_snd_applet(struct stream_interface *si)
+static void cs_app_chk_snd_applet(struct conn_stream *cs)
 {
-	struct channel *oc = si_oc(si);
+	struct channel *oc = cs_oc(cs);
 
-	BUG_ON(!cs_appctx(si->cs));
+	BUG_ON(!cs_appctx(cs));
 
-	DPRINTF(stderr, "%s: si=%p, cs->state=%d ic->flags=%08x oc->flags=%08x\n",
+	DPRINTF(stderr, "%s: cs=%p, cs->state=%d ic->flags=%08x oc->flags=%08x\n",
 		__FUNCTION__,
-		si, si->cs->state, si_ic(si)->flags, oc->flags);
+		cs, cs->state, cs_ic(cs)->flags, oc->flags);
 
-	if (unlikely(si->cs->state != CS_ST_EST || (oc->flags & CF_SHUTW)))
+	if (unlikely(cs->state != CS_ST_EST || (oc->flags & CF_SHUTW)))
 		return;
 
 	/* we only wake the applet up if it was waiting for some data */
 
-	if (!(si->flags & SI_FL_WAIT_DATA))
+	if (!(cs->si->flags & SI_FL_WAIT_DATA))
 		return;
 
 	if (!tick_isset(oc->wex))
@@ -1763,7 +1766,7 @@
 
 	if (!channel_is_empty(oc)) {
 		/* (re)start sending */
-		appctx_wakeup(__cs_appctx(si->cs));
+		appctx_wakeup(__cs_appctx(cs));
 	}
 }