diff --git a/src/packet/packet_parse.cpp b/src/packet/packet_parse.cpp index 7139c8a..1bc18f5 100644 --- a/src/packet/packet_parse.cpp +++ b/src/packet/packet_parse.cpp @@ -995,7 +995,7 @@ int packet_to_str(const struct packet *pkt, char *buff, int size) int used = 0; memset(buff, 0, size); - used += snprintf(buff + used, size - used, "packet: %p, data_ptr: %p, data_len: %u, trim_len: %u, layers_used: %u, layers_size: %u\n", + used += snprintf(buff + used, size - used, "packet: %p, data_ptr: %p, data_len: %u, trim_len: %u, layers_used: %d, layers_size: %d\n", pkt, pkt->data_ptr, pkt->data_len, pkt->trim_len, pkt->layers_used, pkt->layers_size); for (uint8_t i = 0; i < pkt->layers_used; i++) diff --git a/src/stellar/CMakeLists.txt b/src/stellar/CMakeLists.txt index bfd8f65..5a81601 100644 --- a/src/stellar/CMakeLists.txt +++ b/src/stellar/CMakeLists.txt @@ -2,7 +2,7 @@ set(SOURCE stellar_config.cpp stellar_stat.cpp stellar_core.cpp) set(LIBRARY times session_manager plugin_manager ip_reassembly packet_io packet pthread fieldstat4 toml) add_library(stellar_core STATIC ${SOURCE}) -target_link_libraries(stellar_core PRIVATE ${LIBRARY}) +target_link_libraries(stellar_core PUBLIC ${LIBRARY}) add_library(stellar_devel SHARED ${SOURCE}) #target_link_libraries(stellar_devel ${LIBRARY}) diff --git a/test/debug_plugin/debug_plugin.cpp b/test/debug_plugin/debug_plugin.cpp index fb9a081..6ab8de9 100644 --- a/test/debug_plugin/debug_plugin.cpp +++ b/test/debug_plugin/debug_plugin.cpp @@ -14,7 +14,9 @@ #include "packet_dump.h" #include "packet_parse.h" #include "stellar/packet.h" -#include "stellar/session_mq.h" +#include "stellar/stellar_mq.h" + +#pragma GCC diagnostic ignored "-Wunused-parameter" // NOTE: packet hexdump or tcp segment hexdump may be too long, so we need direct output to fd, instead of using log_print static void log_print(int fd, const char *module, const char *fmt, ...) @@ -88,6 +90,11 @@ static void on_sess_free(struct session *sess, void *sess_ctx, void *plugin_ctx) static void on_sess_udp_msg(struct session *sess, int topic_id, const void *msg, void *sess_ctx, void *plugin_ctx) { + if (msg == NULL) + { + return; + } + char buff[4096]; struct packet *pkt = (struct packet *)msg; struct plugin_ctx *ctx = (struct plugin_ctx *)plugin_ctx; @@ -107,6 +114,11 @@ static void on_sess_udp_msg(struct session *sess, int topic_id, const void *msg, static void on_sess_tcp_msg(struct session *sess, int topic_id, const void *msg, void *sess_ctx, void *plugin_ctx) { + if (msg == NULL) + { + return; + } + char buff[4096]; struct packet *pkt = (struct packet *)msg; struct plugin_ctx *ctx = (struct plugin_ctx *)plugin_ctx; @@ -126,6 +138,11 @@ static void on_sess_tcp_msg(struct session *sess, int topic_id, const void *msg, static void on_sess_tcp_stream_msg(struct session *sess, int topic_id, const void *msg, void *sess_ctx, void *plugin_ctx) { + if (msg == NULL) + { + return; + } + char buff[4096]; struct tcp_segment *seg = (struct tcp_segment *)msg; struct plugin_ctx *ctx = (struct plugin_ctx *)plugin_ctx; @@ -166,9 +183,9 @@ extern "C" ctx->st = st; ctx->sess_plug_id = stellar_session_plugin_register(st, on_sess_new, on_sess_free, ctx); - ctx->udp_topic_id = stellar_session_mq_get_topic_id(st, TOPIC_UDP); - ctx->tcp_topic_id = stellar_session_mq_get_topic_id(st, TOPIC_TCP); - ctx->tcp_stream_topic_id = stellar_session_mq_get_topic_id(st, TOPIC_TCP_STREAM); + ctx->udp_topic_id = stellar_mq_get_topic_id(st, TOPIC_UDP); + ctx->tcp_topic_id = stellar_mq_get_topic_id(st, TOPIC_TCP); + ctx->tcp_stream_topic_id = stellar_mq_get_topic_id(st, TOPIC_TCP_STREAM); stellar_session_mq_subscribe(st, ctx->udp_topic_id, on_sess_udp_msg, ctx->sess_plug_id); stellar_session_mq_subscribe(st, ctx->tcp_topic_id, on_sess_tcp_msg, ctx->sess_plug_id); diff --git a/test/packet_inject/packet_inject.cpp b/test/packet_inject/packet_inject.cpp index f9bc08c..6087cae 100644 --- a/test/packet_inject/packet_inject.cpp +++ b/test/packet_inject/packet_inject.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "toml.h" @@ -10,7 +11,6 @@ #include "stellar/session.h" #include "stellar/stellar_mq.h" - #pragma GCC diagnostic ignored "-Wunused-parameter" #define LOG_ERR(fmt, ...) printf("ERROR [packet inject] " fmt, ##__VA_ARGS__) @@ -431,7 +431,10 @@ static void on_sess_free(struct session *sess, void *sess_ctx, void *plugin_ctx) static void on_sess_msg(struct session *sess, int topic_id, const void *msg, void *sess_ctx, void *plugin_ctx) { - if(msg==NULL)return;// session closing, return directly + if (msg == NULL) + { + return; + } char buffer[1024] = {0}; struct packet *pkt = (struct packet *)msg; diff --git a/test/packet_tool/packet_tool.cpp b/test/packet_tool/packet_tool.cpp index cd5af41..3946be1 100644 --- a/test/packet_tool/packet_tool.cpp +++ b/test/packet_tool/packet_tool.cpp @@ -279,7 +279,7 @@ static void usage(char *cmd) int main(int argc, char **argv) { int opt = 0; - struct runtime rte = {0}; + struct runtime rte = {}; while ((opt = getopt(argc, argv, "f:tvh")) != -1) { switch (opt)