diff --git a/common/include/tfe_stream.h b/common/include/tfe_stream.h index 5970e45..1e0176e 100644 --- a/common/include/tfe_stream.h +++ b/common/include/tfe_stream.h @@ -5,12 +5,12 @@ #include #include -enum tfe_session_proto +enum tfe_stream_proto { - SESSION_PROTO_PLAIN = 0, - SESSION_PROTO_SSL, - SESSION_PROTO_QUIC, - SESSION_PROTO_SPDY + STREAM_PROTO_PLAIN = 0, + STREAM_PROTO_SSL, + STREAM_PROTO_QUIC, + STREAM_PROTO_SPDY }; enum tfe_app_proto @@ -18,7 +18,7 @@ enum tfe_app_proto APP_PROTO_HTTP1, APP_PROTO_HTTP2, APP_PROTO_WS, //websocket - APP_PROTO_QUIC //QUIC is a protocol that cross session layer and application layer. + APP_PROTO_QUIC //QUIC is a protocol that cross session layer and application layer. }; enum tfe_conn_dir @@ -37,13 +37,13 @@ enum tfe_conn_status /* single dst or src socket bufferevent descriptor */ struct tfe_conn { - struct layer_addr addr; enum tfe_conn_status status; - struct bufferevent * bev; }; struct tfe_stream { + struct layer_addr addr; + enum tfe_stream_proto proto; struct tfe_conn upstream; struct tfe_conn downstream; }; @@ -88,10 +88,10 @@ void tfe_stream_write_frag_end(struct tfe_stream_write_ctx * w_ctx); //Return 1 for identify as its traffic; //Return 0 for unknown traffic; -typedef tfe_stream_action stream_open_cb_t(const struct tfe_stream * stream, unsigned int thread_id, +typedef enum tfe_stream_action stream_open_cb_t(const struct tfe_stream * stream, unsigned int thread_id, enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme); -typedef tfe_stream_action stream_data_cb_t(const struct tfe_stream * stream, unsigned int thread_id, +typedef enum tfe_stream_action stream_data_cb_t(const struct tfe_stream * stream, unsigned int thread_id, enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme); typedef void stream_close_cb_t(const struct tfe_stream * stream, unsigned int thread_id, @@ -100,11 +100,11 @@ typedef void stream_close_cb_t(const struct tfe_stream * stream, unsigned int th void tfe_stream_detach(const struct tfe_stream * stream); int tfe_stream_preempt(const struct tfe_stream * stream); struct promise * tfe_stream_suspend(const struct tfe_stream * stream); -void tfe_stream_resume(struct promisc * promisc); +void tfe_stream_resume(struct promise * promise); //close both sides of the stream. -int stream_shutdown(const struct tfe_stream * stream); -int stream_shutdown_dir(const struct tfe_stream * stream, enum tfe_conn_dir dir); +int tfe_stream_shutdown(const struct tfe_stream * stream); +int tfe_stream_shutdown_dir(const struct tfe_stream * stream, enum tfe_conn_dir dir); struct tfe_plugin { diff --git a/platform/include/internal/platform.h b/platform/include/internal/platform.h index b48cdac..12a8ae8 100644 --- a/platform/include/internal/platform.h +++ b/platform/include/internal/platform.h @@ -59,7 +59,7 @@ struct tfe_stream_private struct tfe_proxy * proxy_ref; struct tfe_thread_ctx * thread_ref; - enum tfe_session_proto session_type; + enum tfe_stream_proto session_type; struct tfe_conn_private * conn_upstream; struct tfe_conn_private * conn_downstream; diff --git a/platform/include/internal/proxy.h b/platform/include/internal/proxy.h index 82a7083..cc1191c 100644 --- a/platform/include/internal/proxy.h +++ b/platform/include/internal/proxy.h @@ -38,7 +38,7 @@ struct tfe_proxy_accept_para /* Session Type */ bool is_set_session_type; - enum tfe_session_proto session_type; + enum tfe_stream_proto session_type; bool passthrough; }; diff --git a/platform/src/kni_acceptor.cpp b/platform/src/kni_acceptor.cpp index be87a23..2350255 100644 --- a/platform/src/kni_acceptor.cpp +++ b/platform/src/kni_acceptor.cpp @@ -126,14 +126,14 @@ void __kni_event_cb(evutil_socket_t fd, short what, void * user) assert(__tlv_info->type == KNI_TLV_TYPE_PRO); - enum tfe_session_proto __session_proto; + enum tfe_stream_proto __session_proto; if (__tlv_info->value == KNI_TLV_VALUE_HTTP) { - __session_proto = SESSION_PROTO_PLAIN; + __session_proto = STREAM_PROTO_PLAIN; } else if (__tlv_info->value == KNI_TLV_VALUE_SSL) { - __session_proto = SESSION_PROTO_SSL; + __session_proto = STREAM_PROTO_SSL; } else { diff --git a/platform/src/proxy.cpp b/platform/src/proxy.cpp index 8d13a8a..f0f9208 100644 --- a/platform/src/proxy.cpp +++ b/platform/src/proxy.cpp @@ -73,7 +73,7 @@ int tfe_proxy_fds_accept(struct tfe_proxy * ctx, const struct tfe_proxy_accept_p if (para->passthrough || ctx->tcp_all_passthrough) { bool __true = true; - enum tfe_session_proto __session_type = SESSION_PROTO_PLAIN; + enum tfe_stream_proto __session_type = STREAM_PROTO_PLAIN; tfe_stream_option_set(stream, TFE_STREAM_OPT_PASSTHROUGH, &__true, sizeof(__true)); tfe_stream_option_set(stream, TFE_STREAM_OPT_SESSION_TYPE, &__session_type, sizeof(__session_type)); diff --git a/platform/src/tcp_stream.cpp b/platform/src/tcp_stream.cpp index 514f971..55f3090 100644 --- a/platform/src/tcp_stream.cpp +++ b/platform/src/tcp_stream.cpp @@ -60,7 +60,7 @@ static inline enum tfe_conn_dir __BEV_DIR(struct tfe_stream_private * _stream, s static inline bool __IS_SSL(struct tfe_stream_private * _stream) { - return (_stream->session_type == SESSION_PROTO_SSL); + return (_stream->session_type == STREAM_PROTO_SSL); } void tfe_stream_detach(const struct tfe_stream * stream) @@ -601,7 +601,7 @@ void tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downs evutil_make_socket_nonblocking(fd_downstream); evutil_make_socket_nonblocking(fd_upstream); - if (_stream->session_type == SESSION_PROTO_PLAIN) + if (_stream->session_type == STREAM_PROTO_PLAIN) { _stream->conn_downstream = __conn_private_create(_stream, fd_downstream); _stream->conn_upstream = __conn_private_create(_stream, fd_upstream); @@ -613,7 +613,7 @@ void tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downs __conn_private_enable(_stream->conn_upstream); } - if (_stream->session_type == SESSION_PROTO_SSL) + if (_stream->session_type == STREAM_PROTO_SSL) { _stream->ssl_mgr = _stream->proxy_ref->ssl_mgr_handler; @@ -635,8 +635,8 @@ int tfe_stream_option_set(struct tfe_stream * stream, enum tfe_stream_option opt if (opt == TFE_STREAM_OPT_SESSION_TYPE) { - assert(sz_arg == sizeof(enum tfe_session_proto)); - _stream->session_type = *(enum tfe_session_proto *)arg; + assert(sz_arg == sizeof(enum tfe_stream_proto)); + _stream->session_type = *(enum tfe_stream_proto *)arg; } else if (opt == TFE_STREAM_OPT_PASSTHROUGH) {