From ace4313dfd1f17eac022e497bb412e8e290c05e3 Mon Sep 17 00:00:00 2001 From: Konstantin Ananyev Date: Tue, 6 Jul 2021 15:08:48 +0000 Subject: l4p/tcp: introduce tle_tcp_stream_get_state() API tle_tcp_stream_get_state() allows user to query information regarding stream state, control ops and remote termination events. Signed-off-by: Konstantin Ananyev Change-Id: Ica22a5fe2e63fdece882935b76572142433a4ae1 --- lib/libtle_l4p/tle_tcp.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'lib/libtle_l4p/tle_tcp.h') diff --git a/lib/libtle_l4p/tle_tcp.h b/lib/libtle_l4p/tle_tcp.h index 76f3476..df50a23 100644 --- a/lib/libtle_l4p/tle_tcp.h +++ b/lib/libtle_l4p/tle_tcp.h @@ -22,6 +22,44 @@ 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_CLOSE = 0x10, +}; + +/** + * 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 */ +}; + /** * TCP stream creation parameters. */ @@ -80,6 +118,18 @@ struct tle_tcp_conn_info { struct tle_tcp_syn_opts so; }; +/** + * 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 @@ -158,6 +208,17 @@ 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); + struct tle_stream * tle_tcp_stream_establish(struct tle_ctx *ctx, const struct tle_tcp_stream_param *prm, -- cgit 1.2.3-korg