* 增加HTTP解析层目录结构,集成CMakeLists.txt编译文件; * 调整编译顺序,先编译插件再编译平台; * 增加TFE_PLUGIN_REGISTER宏,在TFE启动时自注册插件; * 修改了stream_open接口,在插件流初始化接口不传入数据。
58 lines
1.6 KiB
C
58 lines
1.6 KiB
C
#pragma once
|
|
|
|
#include <tfe_stream.h>
|
|
|
|
struct tfe_proxy;
|
|
struct tfe_thread_ctx;
|
|
|
|
typedef int plugin_init_cb_t(struct tfe_proxy * proxy);
|
|
typedef void plugin_deinit_cb_t(struct tfe_proxy * proxy);
|
|
|
|
//Return 1 for identify as its traffic;
|
|
//Return 0 for unknown traffic;
|
|
typedef int stream_open_cb_t(const struct tfe_stream * stream, unsigned int thread_id,
|
|
enum tfe_conn_dir dir, void ** pme);
|
|
|
|
typedef 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,
|
|
enum tfe_stream_close_reason reason, void ** pme);
|
|
|
|
enum tfe_plugin_type
|
|
{
|
|
TFE_PLUGIN_TYPE_PLATFORM,
|
|
TFE_PLUGIN_TYPE_PROTOCOL,
|
|
TFE_PLUGIN_TYPE_BUSINESS
|
|
};
|
|
|
|
struct tfe_plugin
|
|
{
|
|
/* SYMBOL & PROTOCOL */
|
|
const char * symbol;
|
|
enum tfe_plugin_type type;
|
|
enum tfe_app_proto proto;
|
|
|
|
/* PLUGIN INIT & DEINIT */
|
|
plugin_init_cb_t * on_init;
|
|
plugin_deinit_cb_t * on_deinit;
|
|
|
|
/* PLUGIN STREAM ENTRIES */
|
|
stream_open_cb_t * on_open;
|
|
stream_data_cb_t * on_data;
|
|
stream_close_cb_t * on_close;
|
|
};
|
|
|
|
/* Register plugin */
|
|
int tfe_plugin_register(struct tfe_plugin * plugin);
|
|
/* Unregister plugin */
|
|
void tfe_plugin_unregister(struct tfe_plugin * plugin);
|
|
|
|
#define TFE_PLUGIN_REGISTER(_symbol, _plugin) \
|
|
static void __attribute__((constructor, used)) __plugin_loader_##_symbol(); \
|
|
static void __plugin_loader_##_symbol() \
|
|
{ \
|
|
_plugin.symbol = #_symbol; \
|
|
tfe_plugin_register(&_plugin); \
|
|
}
|