aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libtle_l4p/tle_tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libtle_l4p/tle_tcp.h')
-rw-r--r--lib/libtle_l4p/tle_tcp.h140
1 files changed, 138 insertions, 2 deletions
diff --git a/lib/libtle_l4p/tle_tcp.h b/lib/libtle_l4p/tle_tcp.h
index 9947041..860da92 100644
--- a/lib/libtle_l4p/tle_tcp.h
+++ b/lib/libtle_l4p/tle_tcp.h
@@ -23,6 +23,60 @@ extern "C" {
#endif
/**
+ * TCP stream states
+ */
+enum {
+ TLE_TCP_ST_CLOSED,
+ TLE_TCP_ST_LISTEN,
+ TLE_TCP_ST_SYN_SENT,
+ TLE_TCP_ST_SYN_RCVD,
+ TLE_TCP_ST_ESTABLISHED,
+ TLE_TCP_ST_FIN_WAIT_1,
+ TLE_TCP_ST_FIN_WAIT_2,
+ TLE_TCP_ST_CLOSE_WAIT,
+ TLE_TCP_ST_CLOSING,
+ TLE_TCP_ST_LAST_ACK,
+ TLE_TCP_ST_TIME_WAIT,
+ TLE_TCP_ST_NUM
+};
+
+/**
+ * User control operations for TCP stream
+ */
+enum {
+ TLE_TCP_OP_LISTEN = 0x1,
+ TLE_TCP_OP_ACCEPT = 0x2,
+ TLE_TCP_OP_CONNECT = 0x4,
+ TLE_TCP_OP_ESTABLISH = 0x8,
+ TLE_TCP_OP_SHUTDOWN = 0x10,
+ TLE_TCP_OP_CLOSE = 0x20,
+ TLE_TCP_OP_ABORT = 0x40,
+};
+
+#define TLE_TCP_OP_CLOSE_ABORT (TLE_TCP_OP_CLOSE | TLE_TCP_OP_ABORT)
+
+/**
+ * termination/error events from remote peer
+ */
+enum {
+ TLE_TCP_REV_FIN = 0x1, /** FIN received from peer*/
+ TLE_TCP_REV_RST = 0x2, /** RST received from peer */
+ TLE_TCP_REV_RTO = 0x4, /** receive timed-out */
+};
+
+/*
+ * flags for stream creation/establishment
+ */
+enum {
+ /**
+ * don't put stream into internal stream table
+ * Note that tle_tcp_rx_bulk() wouldn't able to properly process
+ * packets for such stream.
+ */
+ TLE_TCP_STREAM_F_PRIVATE = 0x1,
+};
+
+/**
* TCP stream creation parameters.
*/
struct tle_tcp_stream_addr {
@@ -35,6 +89,8 @@ struct tle_tcp_stream_addr {
struct tle_tcp_stream_cfg {
uint8_t nb_retries; /**< max number of retransmission attempts. */
+ uint64_t udata; /**< user data to be associated with the stream. */
+
/* _cb and _ev are mutually exclusive */
struct tle_event *err_ev; /**< error event to use. */
struct tle_stream_cb err_cb; /**< error callback to use. */
@@ -66,8 +122,12 @@ union tle_tcp_tsopt {
* SYN time option values.
*/
struct tle_tcp_syn_opts {
+ /* mss to use when communicating with the peer */
uint16_t mss;
+ /* peer window scaling factor */
uint8_t wscale;
+ /* local window scaling factor, only used via tcp_establish */
+ uint8_t l_wscale;
union tle_tcp_tsopt ts;
};
@@ -79,6 +139,18 @@ struct tle_tcp_conn_info {
};
/**
+ * TCP stream state information.
+ */
+struct tle_tcp_stream_state {
+ /** current TCP state (one of TLE_TCP_ST_*) */
+ uint16_t state;
+ /** bitmask of control ops performed by user (TLE_TCP_OP_*) */
+ uint16_t uop;
+ /** bitmask of remote termination events (TLE_TCP_REV_*) */
+ uint16_t rev;
+};
+
+/**
* create a new stream within given TCP context.
* @param ctx
* TCP context to create new stream within.
@@ -102,7 +174,7 @@ tle_tcp_stream_open(struct tle_ctx *ctx,
* - if stream contains unsent data, then actual close will be postponed
* till either remaining data will be TX-ed, or timeout will expire.
* All packets that belong to that stream and remain in the device
- * TX queue will be kept for father transmission.
+ * TX queue will be kept for further transmission.
* @param s
* Pointer to the stream to close.
* @return
@@ -113,6 +185,40 @@ tle_tcp_stream_open(struct tle_ctx *ctx,
int tle_tcp_stream_close(struct tle_stream *s);
/**
+ * half-close for open stream.
+ * if the stream is in connected or close-wait state, then:
+ * - FIN packet will be generated and stream state will be changed accordingly.
+ * Note that stream will remain open till user will call actual close()
+ * for that stream (even if actual connection was already terminated).
+ * @param s
+ * Pointer to the stream to close.
+ * @return
+ * zero on successful completion.
+ * - -EINVAL - invalid parameter passed to function
+ * - -EDEADLK - shutdown/close was already invoked on that stream
+ */
+int tle_tcp_stream_shutdown(struct tle_stream *s);
+
+/**
+ * abnormal stream termination.
+ * if the stream is in connected state, then:
+ * - abnormal connection termination would be performed.
+ * - if stream contains unread data, then it will be wiped out.
+ * - if stream contains unsent data, then it will be wiped out,
+ * without further attempt to TX it.
+ * All packets that belong to that stream and remain in the device
+ * TX queue will be kept for further transmission.
+ * @param s
+ * Pointer to the stream to close.
+ * @return
+ * zero on successful completion.
+ * - -EINVAL - invalid parameter passed to function
+ * - -EDEADLK - close was already invoked on that stream
+ */
+int tle_tcp_stream_abort(struct tle_stream *s);
+
+
+/**
* close a group of open streams.
* if the stream is in connected state, then:
* - connection termination would be performed.
@@ -156,10 +262,40 @@ tle_tcp_stream_get_addr(const struct tle_stream *s,
*/
int tle_tcp_stream_get_mss(const struct tle_stream *ts);
+/**
+ * Get current TCP stream state
+ * @param ts
+ * Stream to retrieve state information from.
+ * @return
+ * zero on successful completion.
+ * - EINVAL - invalid parameter passed to function
+ */
+int tle_tcp_stream_get_state(const struct tle_stream *ts,
+ struct tle_tcp_stream_state *st);
+
+/**
+ * create a new stream within given TCP context.
+ * Stream is put into ESTABLISHED state stragithway.
+ * Connection state is recreated based on provided information.
+ * @param ctx
+ * TCP context to create new stream within.
+ * @param prm
+ * Parameters used to create and initialise the new stream.
+ * @param ci
+ * Connection state values to recreate.
+ * @param flags
+ * Combination of TLE_TCP_STREAM_F_* values.
+ * @return
+ * Pointer to TCP stream structure that can be used in future TCP API calls,
+ * or NULL on error, with error code set in rte_errno.
+ * Possible rte_errno errors include:
+ * - EINVAL - invalid parameter passed to function
+ * - ENOFILE - max limit of open streams reached for that context
+ */
struct tle_stream *
tle_tcp_stream_establish(struct tle_ctx *ctx,
const struct tle_tcp_stream_param *prm,
- const struct tle_tcp_conn_info *ci);
+ const struct tle_tcp_conn_info *ci, uint32_t flags);
/**
* Client mode connect API.