Index: uspace/srv/net/tcp/Makefile
===================================================================
--- uspace/srv/net/tcp/Makefile	(revision 12dcd5f73a02a8127ce5b7b479d11e8a2e8890a4)
+++ uspace/srv/net/tcp/Makefile	(revision 975d528567e7c0e0be4d004eed670b95ea360ac1)
@@ -62,5 +62,6 @@
 	test/rqueue.c \
 	test/segment.c \
-	test/seq_no.c
+	test/seq_no.c \
+	test/tqueue.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/net/tcp/conn.c
===================================================================
--- uspace/srv/net/tcp/conn.c	(revision 12dcd5f73a02a8127ce5b7b479d11e8a2e8890a4)
+++ uspace/srv/net/tcp/conn.c	(revision 975d528567e7c0e0be4d004eed670b95ea360ac1)
@@ -44,5 +44,7 @@
 #include <stdlib.h>
 #include "conn.h"
+#include "inet.h"
 #include "iqueue.h"
+#include "pdu.h"
 #include "segment.h"
 #include "seq_no.h"
@@ -62,7 +64,12 @@
 static amap_t *amap;
 
-static void tcp_conn_seg_process(tcp_conn_t *conn, tcp_segment_t *seg);
-static void tcp_conn_tw_timer_set(tcp_conn_t *conn);
-static void tcp_conn_tw_timer_clear(tcp_conn_t *conn);
+static void tcp_conn_seg_process(tcp_conn_t *, tcp_segment_t *);
+static void tcp_conn_tw_timer_set(tcp_conn_t *);
+static void tcp_conn_tw_timer_clear(tcp_conn_t *);
+static void tcp_transmit_segment(inet_ep2_t *, tcp_segment_t *);
+
+static tcp_tqueue_cb_t tcp_conn_tqueue_cb = {
+	.transmit_seg = tcp_transmit_segment
+};
 
 /** Initialize connections. */
@@ -130,6 +137,8 @@
 
 	/* Initialize retransmission queue */
-	if (tcp_tqueue_init(&conn->retransmit, conn) != EOK)
+	if (tcp_tqueue_init(&conn->retransmit, conn, &tcp_conn_tqueue_cb)
+	    != EOK) {
 		goto error;
+	}
 
 	tqueue_inited = true;
@@ -295,4 +304,7 @@
 void tcp_conn_remove(tcp_conn_t *conn)
 {
+	if (!link_used(&conn->link))
+		return;
+
 	fibril_mutex_lock(&conn_list_lock);
 	amap_remove(amap, &conn->ident);
@@ -1346,4 +1358,29 @@
 }
 
+static void tcp_transmit_segment(inet_ep2_t *epp, tcp_segment_t *seg)
+{
+	log_msg(LOG_DEFAULT, LVL_DEBUG,
+	    "tcp_transmit_segment(l:(%u),f:(%u), %p)",
+	    epp->local.port, epp->remote.port, seg);
+
+	log_msg(LOG_DEFAULT, LVL_DEBUG, "SEG.SEQ=%" PRIu32 ", SEG.WND=%" PRIu32,
+	    seg->seq, seg->wnd);
+
+	tcp_segment_dump(seg);
+
+//	tcp_rqueue_bounce_seg(sp, seg);
+//	tcp_ncsim_bounce_seg(sp, seg);
+
+	tcp_pdu_t *pdu;
+
+	if (tcp_pdu_encode(epp, seg, &pdu) != EOK) {
+		log_msg(LOG_DEFAULT, LVL_WARN, "Not enough memory. Segment dropped.");
+		return;
+	}
+
+	tcp_transmit_pdu(pdu);
+	tcp_pdu_delete(pdu);
+}
+
 /** Compute flipped endpoint pair for response.
  *
Index: uspace/srv/net/tcp/tcp_type.h
===================================================================
--- uspace/srv/net/tcp/tcp_type.h	(revision 12dcd5f73a02a8127ce5b7b479d11e8a2e8890a4)
+++ uspace/srv/net/tcp/tcp_type.h	(revision 975d528567e7c0e0be4d004eed670b95ea360ac1)
@@ -126,13 +126,4 @@
 } tcp_iqueue_t;
 
-/** Retransmission queue */
-typedef struct {
-	struct tcp_conn *conn;
-	list_t list;
-
-	/** Retransmission timer */
-	fibril_timer_t *timer;
-} tcp_tqueue_t;
-
 /** Active or passive connection */
 typedef enum {
@@ -156,4 +147,83 @@
 	void (*recv_data)(tcp_conn_t *, void *);
 } tcp_cb_t;
+
+/** Data returned by Status user call */
+typedef struct {
+	/** Connection state */
+	tcp_cstate_t cstate;
+} tcp_conn_status_t;
+
+typedef struct {
+	/** SYN, FIN */
+	tcp_control_t ctrl;
+
+	/** Segment sequence number */
+	uint32_t seq;
+	/** Segment acknowledgement number */
+	uint32_t ack;
+	/** Segment length in sequence space */
+	uint32_t len;
+	/** Segment window */
+	uint32_t wnd;
+	/** Segment urgent pointer */
+	uint32_t up;
+
+	/** Segment data, may be moved when trimming segment */
+	void *data;
+	/** Segment data, original pointer used to free data */
+	void *dfptr;
+} tcp_segment_t;
+
+/** Receive queue entry */
+typedef struct {
+	link_t link;
+	inet_ep2_t epp;
+	tcp_segment_t *seg;
+} tcp_rqueue_entry_t;
+
+/** Receive queue callbacks */
+typedef struct {
+	/** Segment received */
+	void (*seg_received)(inet_ep2_t *, tcp_segment_t *);
+} tcp_rqueue_cb_t;
+
+/** NCSim queue entry */
+typedef struct {
+	link_t link;
+	suseconds_t delay;
+	inet_ep2_t epp;
+	tcp_segment_t *seg;
+} tcp_squeue_entry_t;
+
+/** Incoming queue entry */
+typedef struct {
+	link_t link;
+	tcp_segment_t *seg;
+} tcp_iqueue_entry_t;
+
+/** Retransmission queue entry */
+typedef struct {
+	link_t link;
+	tcp_conn_t *conn;
+	tcp_segment_t *seg;
+} tcp_tqueue_entry_t;
+
+/** Retransmission queue callbacks */
+typedef struct {
+	/** Segment received */
+	void (*transmit_seg)(inet_ep2_t *, tcp_segment_t *);
+} tcp_tqueue_cb_t;
+
+/** Retransmission queue */
+typedef struct {
+	struct tcp_conn *conn;
+	list_t list;
+
+	/** Retransmission timer */
+	fibril_timer_t *timer;
+
+	/** Callbacks */
+	tcp_tqueue_cb_t *cb;
+} tcp_tqueue_t;
 
 /** Connection */
@@ -246,65 +316,4 @@
 };
 
-/** Data returned by Status user call */
-typedef struct {
-	/** Connection state */
-	tcp_cstate_t cstate;
-} tcp_conn_status_t;
-
-typedef struct {
-	/** SYN, FIN */
-	tcp_control_t ctrl;
-
-	/** Segment sequence number */
-	uint32_t seq;
-	/** Segment acknowledgement number */
-	uint32_t ack;
-	/** Segment length in sequence space */
-	uint32_t len;
-	/** Segment window */
-	uint32_t wnd;
-	/** Segment urgent pointer */
-	uint32_t up;
-
-	/** Segment data, may be moved when trimming segment */
-	void *data;
-	/** Segment data, original pointer used to free data */
-	void *dfptr;
-} tcp_segment_t;
-
-/** Receive queue entry */
-typedef struct {
-	link_t link;
-	inet_ep2_t epp;
-	tcp_segment_t *seg;
-} tcp_rqueue_entry_t;
-
-/** Receive queue callbacks */
-typedef struct {
-	/** Segment received */
-	void (*seg_received)(inet_ep2_t *, tcp_segment_t *);
-} tcp_rqueue_cb_t;
-
-/** NCSim queue entry */
-typedef struct {
-	link_t link;
-	suseconds_t delay;
-	inet_ep2_t epp;
-	tcp_segment_t *seg;
-} tcp_squeue_entry_t;
-
-/** Incoming queue entry */
-typedef struct {
-	link_t link;
-	tcp_segment_t *seg;
-} tcp_iqueue_entry_t;
-
-/** Retransmission queue entry */
-typedef struct {
-	link_t link;
-	tcp_conn_t *conn;
-	tcp_segment_t *seg;
-} tcp_tqueue_entry_t;
-
 /** Continuation of processing.
  *
Index: uspace/srv/net/tcp/test/main.c
===================================================================
--- uspace/srv/net/tcp/test/main.c	(revision 12dcd5f73a02a8127ce5b7b479d11e8a2e8890a4)
+++ uspace/srv/net/tcp/test/main.c	(revision 975d528567e7c0e0be4d004eed670b95ea360ac1)
@@ -62,4 +62,5 @@
 PCUT_IMPORT(segment);
 PCUT_IMPORT(seq_no);
+PCUT_IMPORT(tqueue);
 
 PCUT_MAIN()
Index: uspace/srv/net/tcp/test/tqueue.c
===================================================================
--- uspace/srv/net/tcp/test/tqueue.c	(revision 975d528567e7c0e0be4d004eed670b95ea360ac1)
+++ uspace/srv/net/tcp/test/tqueue.c	(revision 975d528567e7c0e0be4d004eed670b95ea360ac1)
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2017 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+//#include <inet/endpoint.h>
+#include <io/log.h>
+#include <pcut/pcut.h>
+
+#include "../conn.h"
+#include "../tqueue.h"
+
+PCUT_INIT
+
+PCUT_TEST_SUITE(tqueue);
+
+enum {
+	test_seg_max = 10
+};
+
+static int seg_cnt;
+static tcp_segment_t *trans_seg[test_seg_max];
+
+static void tqueue_test_transmit_seg(inet_ep2_t *, tcp_segment_t *);
+
+static tcp_tqueue_cb_t tqueue_test_cb = {
+	.transmit_seg = tqueue_test_transmit_seg
+};
+
+PCUT_TEST_BEFORE
+{
+	int rc;
+
+	/* We will be calling functions that perform logging */
+	rc = log_init("test-tcp");
+	PCUT_ASSERT_INT_EQUALS(EOK, rc);
+}
+
+/** Test  */
+PCUT_TEST(init_fini)
+{
+	tcp_conn_t *conn;
+	inet_ep2_t epp;
+
+	/* XXX tqueue can only be created via tcp_conn_new */
+	inet_ep2_init(&epp);
+	conn = tcp_conn_new(&epp);
+	PCUT_ASSERT_NOT_NULL(conn);
+
+	/* Redirect segment transmission */
+	conn->retransmit.cb = &tqueue_test_cb;
+	seg_cnt = 0;
+
+	tcp_conn_delete(conn);
+	PCUT_ASSERT_EQUALS(0, seg_cnt);
+}
+
+/** Test sending control segment and tearing down a non-empty queue */
+PCUT_TEST(ctrl_seg_teardown)
+{
+	tcp_conn_t *conn;
+	inet_ep2_t epp;
+
+	/* XXX tqueue can only be created via tcp_conn_new */
+	inet_ep2_init(&epp);
+	conn = tcp_conn_new(&epp);
+	PCUT_ASSERT_NOT_NULL(conn);
+
+	conn->snd_nxt = 10;
+
+	/* Redirect segment transmission */
+	conn->retransmit.cb = &tqueue_test_cb;
+	seg_cnt = 0;
+
+	tcp_conn_lock(conn);
+	tcp_tqueue_ctrl_seg(conn, CTL_SYN);
+	tcp_conn_reset(conn);
+	tcp_conn_unlock(conn);
+	PCUT_ASSERT_EQUALS(11, conn->snd_nxt);
+
+	tcp_conn_delete(conn);
+	PCUT_ASSERT_EQUALS(1, seg_cnt);
+	PCUT_ASSERT_EQUALS(CTL_SYN, trans_seg[0]->ctrl);
+	PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq);
+}
+
+/** Test sending data and FIN */
+PCUT_TEST(new_data_fin)
+{
+	tcp_conn_t *conn;
+	inet_ep2_t epp;
+	int i;
+
+	/* XXX tqueue can only be created via tcp_conn_new */
+	inet_ep2_init(&epp);
+	conn = tcp_conn_new(&epp);
+	PCUT_ASSERT_NOT_NULL(conn);
+
+	conn->cstate = st_established;
+	conn->snd_una = 10;
+	conn->snd_nxt = 10;
+	conn->snd_wnd = 1024;
+	conn->snd_buf_used = 20;
+	conn->snd_buf_fin = true;
+	for (i = 0; i < 20; i++)
+		conn->snd_buf[i] = i;
+
+	/* Redirect segment transmission */
+	conn->retransmit.cb = &tqueue_test_cb;
+	seg_cnt = 0;
+
+	tcp_conn_lock(conn);
+	tcp_tqueue_new_data(conn);
+	tcp_conn_reset(conn);
+	tcp_conn_unlock(conn);
+	PCUT_ASSERT_EQUALS(31, conn->snd_nxt);
+	PCUT_ASSERT_EQUALS(0, conn->snd_buf_used);
+	PCUT_ASSERT_FALSE(conn->snd_buf_fin);
+
+	tcp_conn_delete(conn);
+	PCUT_ASSERT_EQUALS(1, seg_cnt);
+	PCUT_ASSERT_EQUALS(CTL_FIN | CTL_ACK, trans_seg[0]->ctrl);
+	PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq);
+}
+
+/** Test sending data when send window is smaller */
+PCUT_TEST(new_data_small_win)
+{
+	tcp_conn_t *conn;
+	inet_ep2_t epp;
+	int i;
+
+	/* XXX tqueue can only be created via tcp_conn_new */
+	inet_ep2_init(&epp);
+	conn = tcp_conn_new(&epp);
+	PCUT_ASSERT_NOT_NULL(conn);
+
+	conn->cstate = st_established;
+	conn->snd_una = 10;
+	conn->snd_nxt = 10;
+	conn->snd_wnd = 5;
+	conn->snd_buf_used = 30;
+	conn->snd_buf_fin = false;
+	for (i = 0; i < 30; i++)
+		conn->snd_buf[i] = i;
+
+	/* Redirect segment transmission */
+	conn->retransmit.cb = &tqueue_test_cb;
+	seg_cnt = 0;
+
+	tcp_conn_lock(conn);
+	tcp_tqueue_new_data(conn);
+	tcp_conn_reset(conn);
+	tcp_conn_unlock(conn);
+
+	PCUT_ASSERT_EQUALS(15, conn->snd_nxt);
+	PCUT_ASSERT_EQUALS(25, conn->snd_buf_used);
+	PCUT_ASSERT_FALSE(conn->snd_buf_fin);
+	for (i = 0; i < 25; i++)
+		PCUT_ASSERT_INT_EQUALS(5 + i, conn->snd_buf[i]);
+
+	tcp_conn_delete(conn);
+	PCUT_ASSERT_EQUALS(1, seg_cnt);
+	PCUT_ASSERT_EQUALS(CTL_ACK, trans_seg[0]->ctrl);
+	PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq);
+}
+
+/** Test flushing tqueue due to receiving an ACK */
+PCUT_TEST(ack_received)
+{
+	tcp_conn_t *conn;
+	inet_ep2_t epp;
+	int i;
+
+	/* XXX tqueue can only be created via tcp_conn_new */
+	inet_ep2_init(&epp);
+	conn = tcp_conn_new(&epp);
+	PCUT_ASSERT_NOT_NULL(conn);
+
+	conn->cstate = st_established;
+	conn->snd_una = 10;
+	conn->snd_nxt = 10;
+	conn->snd_wnd = 1024;
+
+	/* Redirect segment transmission */
+	conn->retransmit.cb = &tqueue_test_cb;
+	seg_cnt = 0;
+
+	tcp_conn_lock(conn);
+
+	/* Queue first data segment */
+	conn->snd_buf_used = 10;
+	conn->snd_buf_fin = false;
+	for (i = 0; i < 10; i++)
+		conn->snd_buf[i] = i;
+	tcp_tqueue_new_data(conn);
+
+	PCUT_ASSERT_EQUALS(20, conn->snd_nxt);
+
+	/* Queue second data segment */
+	conn->snd_buf_used = 20;
+	conn->snd_buf_fin = false;
+	for (i = 0; i < 20; i++)
+		conn->snd_buf[i] = i;
+	tcp_tqueue_new_data(conn);
+
+	PCUT_ASSERT_EQUALS(40, conn->snd_nxt);
+
+	PCUT_ASSERT_INT_EQUALS(2, list_count(&conn->retransmit.list));
+
+	/* One of the two segments is acked */
+	conn->snd_una = 20;
+	tcp_tqueue_ack_received(conn);
+
+	PCUT_ASSERT_INT_EQUALS(1, list_count(&conn->retransmit.list));
+
+	tcp_conn_reset(conn);
+	tcp_conn_unlock(conn);
+	tcp_conn_delete(conn);
+}
+
+static void tqueue_test_transmit_seg(inet_ep2_t *epp, tcp_segment_t *seg)
+{
+	trans_seg[seg_cnt++] = seg;
+}
+
+PCUT_EXPORT(tqueue);
Index: uspace/srv/net/tcp/tqueue.c
===================================================================
--- uspace/srv/net/tcp/tqueue.c	(revision 12dcd5f73a02a8127ce5b7b479d11e8a2e8890a4)
+++ uspace/srv/net/tcp/tqueue.c	(revision 975d528567e7c0e0be4d004eed670b95ea360ac1)
@@ -47,5 +47,4 @@
 #include "inet.h"
 #include "ncsim.h"
-#include "pdu.h"
 #include "rqueue.h"
 #include "segment.h"
@@ -56,12 +55,18 @@
 #define RETRANSMIT_TIMEOUT	(2*1000*1000)
 
-static void retransmit_timeout_func(void *arg);
-static void tcp_tqueue_timer_set(tcp_conn_t *conn);
-static void tcp_tqueue_timer_clear(tcp_conn_t *conn);
-
-int tcp_tqueue_init(tcp_tqueue_t *tqueue, tcp_conn_t *conn)
+static void retransmit_timeout_func(void *);
+static void tcp_tqueue_timer_set(tcp_conn_t *);
+static void tcp_tqueue_timer_clear(tcp_conn_t *);
+static void tcp_tqueue_seg(tcp_conn_t *, tcp_segment_t *);
+static void tcp_conn_transmit_segment(tcp_conn_t *, tcp_segment_t *);
+static void tcp_prepare_transmit_segment(tcp_conn_t *, tcp_segment_t *);
+static void tcp_tqueue_send_immed(tcp_conn_t *, tcp_segment_t *);
+
+int tcp_tqueue_init(tcp_tqueue_t *tqueue, tcp_conn_t *conn,
+    tcp_tqueue_cb_t *cb)
 {
 	tqueue->conn = conn;
 	tqueue->timer = fibril_timer_create(&conn->lock);
+	tqueue->cb = cb;
 	if (tqueue->timer == NULL)
 		return ENOMEM;
@@ -79,8 +84,20 @@
 void tcp_tqueue_fini(tcp_tqueue_t *tqueue)
 {
+	link_t *link;
+	tcp_tqueue_entry_t *tqe;
+
 	if (tqueue->timer != NULL) {
 		fibril_timer_destroy(tqueue->timer);
 		tqueue->timer = NULL;
 	}
+
+	while (!list_empty(&tqueue->list)) {
+		link = list_first(&tqueue->list);
+		tqe = list_get_instance(link, tcp_tqueue_entry_t, link);
+		list_remove(link);
+
+		tcp_segment_delete(tqe->seg);
+		free(tqe);
+	}
 }
 
@@ -96,5 +113,5 @@
 }
 
-void tcp_tqueue_seg(tcp_conn_t *conn, tcp_segment_t *seg)
+static void tcp_tqueue_seg(tcp_conn_t *conn, tcp_segment_t *seg)
 {
 	tcp_segment_t *rt_seg;
@@ -136,5 +153,5 @@
 }
 
-void tcp_prepare_transmit_segment(tcp_conn_t *conn, tcp_segment_t *seg)
+static void tcp_prepare_transmit_segment(tcp_conn_t *conn, tcp_segment_t *seg)
 {
 	/*
@@ -268,5 +285,5 @@
 }
 
-void tcp_conn_transmit_segment(tcp_conn_t *conn, tcp_segment_t *seg)
+static void tcp_conn_transmit_segment(tcp_conn_t *conn, tcp_segment_t *seg)
 {
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_conn_transmit_segment(%p, %p)",
@@ -280,12 +297,12 @@
 		seg->ack = 0;
 
-	tcp_transmit_segment(&conn->ident, seg);
-}
-
-void tcp_transmit_segment(inet_ep2_t *epp, tcp_segment_t *seg)
+	tcp_tqueue_send_immed(conn, seg);
+}
+
+void tcp_tqueue_send_immed(tcp_conn_t *conn, tcp_segment_t *seg)
 {
 	log_msg(LOG_DEFAULT, LVL_DEBUG,
-	    "tcp_transmit_segment(l:(%u),f:(%u), %p)",
-	    epp->local.port, epp->remote.port, seg);
+	    "tcp_tqueue_send_immed(l:(%u),f:(%u), %p)",
+	    conn->ident.local.port, conn->ident.remote.port, seg);
 
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "SEG.SEQ=%" PRIu32 ", SEG.WND=%" PRIu32,
@@ -293,20 +310,6 @@
 
 	tcp_segment_dump(seg);
-/*
-	tcp_pdu_prepare(conn, seg, &data, &len);
-	tcp_pdu_transmit(data, len);
-*/
-//	tcp_rqueue_bounce_seg(sp, seg);
-//	tcp_ncsim_bounce_seg(sp, seg);
-
-	tcp_pdu_t *pdu;
-
-	if (tcp_pdu_encode(epp, seg, &pdu) != EOK) {
-		log_msg(LOG_DEFAULT, LVL_WARN, "Not enough memory. Segment dropped.");
-		return;
-	}
-
-	tcp_transmit_pdu(pdu);
-	tcp_pdu_delete(pdu);
+
+	conn->retransmit.cb->transmit_seg(&conn->ident, seg);
 }
 
Index: uspace/srv/net/tcp/tqueue.h
===================================================================
--- uspace/srv/net/tcp/tqueue.h	(revision 12dcd5f73a02a8127ce5b7b479d11e8a2e8890a4)
+++ uspace/srv/net/tcp/tqueue.h	(revision 975d528567e7c0e0be4d004eed670b95ea360ac1)
@@ -40,16 +40,11 @@
 #include "tcp_type.h"
 
-extern int tcp_tqueue_init(tcp_tqueue_t *, tcp_conn_t *);
+extern int tcp_tqueue_init(tcp_tqueue_t *, tcp_conn_t *,
+    tcp_tqueue_cb_t *);
 extern void tcp_tqueue_clear(tcp_tqueue_t *);
 extern void tcp_tqueue_fini(tcp_tqueue_t *);
 extern void tcp_tqueue_ctrl_seg(tcp_conn_t *, tcp_control_t);
-extern void tcp_tqueue_seg(tcp_conn_t *, tcp_segment_t *);
 extern void tcp_tqueue_new_data(tcp_conn_t *);
 extern void tcp_tqueue_ack_received(tcp_conn_t *);
-extern void tcp_prepare_transmit_segment(tcp_conn_t *, tcp_segment_t *);
-extern void tcp_conn_transmit_segment(tcp_conn_t *, tcp_segment_t *);
-extern void tcp_transmit_segment(inet_ep2_t *, tcp_segment_t *);
-extern void tcp_header_setup(tcp_conn_t *, tcp_segment_t *, tcp_header_t *);
-extern void tcp_phdr_setup(tcp_conn_t *, tcp_segment_t *, tcp_phdr_t *);
 
 #endif
