✨ feat(plugin manager): integrated plugin manager, build success
This commit is contained in:
@@ -2,5 +2,7 @@ add_library(core config.cpp stat.cpp stellar.cpp inject.cpp)
|
||||
target_link_libraries(core times plugin_manager session_manager ip_reassembly packet_io pthread fieldstat4 toml)
|
||||
|
||||
add_executable(stellar main.cpp)
|
||||
target_link_libraries(stellar core plugin_manager)
|
||||
install(TARGETS stellar RUNTIME DESTINATION bin COMPONENT Program)
|
||||
target_link_libraries(stellar core)
|
||||
target_link_libraries(stellar "-rdynamic")
|
||||
install(TARGETS stellar RUNTIME DESTINATION bin COMPONENT Program)
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ static int all_stat_have_output(void)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct stellar st = {runtime};
|
||||
stellar_update_time_cache();
|
||||
|
||||
signal(SIGINT, signal_handler);
|
||||
@@ -110,8 +111,7 @@ int main(int argc, char **argv)
|
||||
STELLAR_LOG_ERROR("unable to create stellar stat");
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
runtime->plug_mgr = plugin_manager_new();
|
||||
runtime->plug_mgr = plugin_manager_init(&st, "./stellar_plugin/spec.toml");
|
||||
if (runtime->plug_mgr == NULL)
|
||||
{
|
||||
STELLAR_LOG_ERROR("unable to create plugin manager");
|
||||
@@ -160,7 +160,7 @@ error_out:
|
||||
stellar_thread_join(runtime, config);
|
||||
stellar_thread_clean(runtime, config);
|
||||
packet_io_free(runtime->packet_io);
|
||||
plugin_manager_free(runtime->plug_mgr);
|
||||
plugin_manager_exit(runtime->plug_mgr);
|
||||
stellar_stat_free(runtime->stat);
|
||||
STELLAR_LOG_STATE("stellar exit !!!\n");
|
||||
log_free();
|
||||
|
||||
@@ -51,7 +51,7 @@ static inline void free_evicted_sessions(struct session_manager *sess_mgr, uint6
|
||||
if (sess)
|
||||
{
|
||||
plugin_ctx = session_get_user_data(sess);
|
||||
plugin_manager_free_ctx(plugin_ctx);
|
||||
plugin_manager_session_runtime_free((struct plugin_manager_runtime*)plugin_ctx);
|
||||
session_manager_free_session(sess_mgr, sess);
|
||||
}
|
||||
else
|
||||
@@ -71,7 +71,7 @@ static inline void free_expired_sessions(struct session_manager *sess_mgr, uint6
|
||||
if (sess)
|
||||
{
|
||||
plugin_ctx = session_get_user_data(sess);
|
||||
plugin_manager_free_ctx(plugin_ctx);
|
||||
plugin_manager_session_runtime_free((struct plugin_manager_runtime*)plugin_ctx);
|
||||
session_manager_free_session(sess_mgr, sess);
|
||||
}
|
||||
else
|
||||
@@ -102,7 +102,7 @@ static void *work_thread(void *arg)
|
||||
struct packet packets[RX_BURST_MAX];
|
||||
struct session *sess = NULL;
|
||||
struct packet_io *packet_io = runtime->packet_io;
|
||||
struct plugin_manager *plug_mgr = runtime->plug_mgr;
|
||||
struct plugin_manager_schema *plug_mgr = runtime->plug_mgr;
|
||||
struct stellar_thread *thread = (struct stellar_thread *)arg;
|
||||
struct ip_reassembly *ip_reass = thread->ip_mgr;
|
||||
struct session_manager *sess_mgr = thread->sess_mgr;
|
||||
@@ -137,7 +137,7 @@ static void *work_thread(void *arg)
|
||||
defraged_pkt = NULL;
|
||||
pkt = &packets[i];
|
||||
|
||||
plugin_manager_dispatch_packet(plug_mgr, pkt);
|
||||
plugin_manager_on_packet(plug_mgr, pkt);
|
||||
if (packet_is_fragment(pkt))
|
||||
{
|
||||
defraged_pkt = ip_reassembly_packet(ip_reass, pkt, now);
|
||||
@@ -148,7 +148,7 @@ static void *work_thread(void *arg)
|
||||
else
|
||||
{
|
||||
pkt = defraged_pkt;
|
||||
plugin_manager_dispatch_packet(plug_mgr, pkt);
|
||||
plugin_manager_on_packet(plug_mgr, pkt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ static void *work_thread(void *arg)
|
||||
{
|
||||
goto fast_path;
|
||||
}
|
||||
plugin_ctx = plugin_manager_new_ctx(sess);
|
||||
plugin_ctx = plugin_manager_session_runtime_new(runtime->plug_mgr, sess);
|
||||
session_set_user_data(sess, plugin_ctx);
|
||||
}
|
||||
else
|
||||
@@ -174,9 +174,10 @@ static void *work_thread(void *arg)
|
||||
{
|
||||
packet_set_session_id(pkt, session_get_id(sess));
|
||||
}
|
||||
plugin_manager_dispatch_session(plug_mgr, sess, pkt);
|
||||
plugin_manager_on_session_ingress(sess, pkt);
|
||||
|
||||
fast_path:
|
||||
plugin_manager_on_session_egress(sess, pkt);
|
||||
update_session_stat(sess, pkt);
|
||||
if (packet_get_action(pkt) == PACKET_ACTION_DROP)
|
||||
{
|
||||
@@ -219,7 +220,8 @@ static void *work_thread(void *arg)
|
||||
ip_reassembly_expire(ip_reass, now);
|
||||
|
||||
// TODO
|
||||
// plugin_manager_cron();
|
||||
plugin_manager_on_polling(runtime->plug_mgr);
|
||||
// session_manager_cron();
|
||||
// poll_non_packet_events();
|
||||
|
||||
if (nr_recv == 0)
|
||||
|
||||
@@ -30,10 +30,16 @@ struct stellar_runtime
|
||||
uint64_t stat_last_output_ts;
|
||||
struct stellar_stat *stat;
|
||||
struct packet_io *packet_io;
|
||||
struct plugin_manager *plug_mgr;
|
||||
struct plugin_manager_schema *plug_mgr;
|
||||
struct stellar_thread threads[MAX_THREAD_NUM];
|
||||
};
|
||||
|
||||
//FIXME rename stellar_runtime to stellar
|
||||
struct stellar
|
||||
{
|
||||
struct stellar_runtime *st_rt;
|
||||
};
|
||||
|
||||
extern struct stellar_runtime *runtime;
|
||||
extern struct stellar_config *config;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user