【修改】修改example,从pluginmanage的样例中摘出其中一部分
This commit is contained in:
@@ -11,8 +11,15 @@
|
||||
#define PLUGIN_CONFIG_PATH "./conf/plugin_manage.toml"
|
||||
#define LUA_CONFIG_PATH "./conf/lua_plugin_manage.toml"
|
||||
|
||||
// #define DEBUG_PLUGIN_SCHEMA
|
||||
|
||||
static struct lua_config_specific *config_load(const char *config_file_name, int *specific_num);
|
||||
#ifdef DEBUG_PLUGIN_SCHEMA
|
||||
static void debug_plugin_manage_schema(struct plugin_manager_schema *schema);
|
||||
#endif
|
||||
|
||||
#define PACKET_COUNT 10
|
||||
#define SESSION_COUNT 10
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -22,10 +29,45 @@ int main()
|
||||
int num = 0;
|
||||
struct lua_config_specific *specific = config_load(LUA_CONFIG_PATH, &num);
|
||||
struct plugin_manager_schema *plug_mgr = plugin_manager_init(&st, PLUGIN_CONFIG_PATH);
|
||||
/* 初始化lua插件 */
|
||||
struct lua_plugin_manage_schema *lua_schema = lua_plugin_manage_init(&st, num, specific);
|
||||
st.lua_plug_mgr = lua_schema;
|
||||
#ifdef DEBUG_PLUGIN_SCHEMA
|
||||
debug_plugin_manage_schema(plug_mgr);
|
||||
#endif
|
||||
|
||||
unsigned char ip_proto=6;
|
||||
struct packet pkt={&st, TCP, ip_proto};
|
||||
struct session sess[SESSION_COUNT];
|
||||
memset(&sess, 0, sizeof(sess));
|
||||
|
||||
for(int i=0; i < SESSION_COUNT; i++)
|
||||
{
|
||||
sess[i].plug_mgr_rt=plugin_manager_session_runtime_new(plug_mgr, &sess[i]);
|
||||
sess[i].type=SESSION_TYPE_TCP;
|
||||
}
|
||||
|
||||
for (int j = 0; j < PACKET_COUNT; j++)
|
||||
{
|
||||
// plugin_manager_on_packet_ingress(plug_mgr, &pkt);
|
||||
|
||||
for (int i = 0; i < SESSION_COUNT; i++)
|
||||
{
|
||||
sess[i].sess_pkt_cnt+=1;
|
||||
plugin_manager_on_session_ingress(&sess[i], &pkt);
|
||||
plugin_manager_on_session_egress(&sess[i], &pkt);
|
||||
}
|
||||
|
||||
// plugin_manager_on_packet_egress(plug_mgr, &pkt);
|
||||
}
|
||||
|
||||
for(int i=0; i < SESSION_COUNT; i++)
|
||||
{
|
||||
plugin_manager_on_session_closing(&sess[i]);
|
||||
plugin_manager_session_runtime_free(sess[i].plug_mgr_rt);
|
||||
}
|
||||
|
||||
plugin_manager_exit(plug_mgr);
|
||||
lua_plugin_manage_exit(lua_schema);
|
||||
return 0;
|
||||
}
|
||||
@@ -83,6 +125,7 @@ static struct lua_config_specific *config_load(const char *config_file_name, int
|
||||
return new_spec;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PLUGIN_SCHEMA
|
||||
static void debug_plugin_manage_schema(struct plugin_manager_schema *schema)
|
||||
{
|
||||
struct registered_session_plugin_schema * plugin = NULL;
|
||||
@@ -92,4 +135,5 @@ static void debug_plugin_manage_schema(struct plugin_manager_schema *schema)
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user