fix: cppcheck
This commit is contained in:
@@ -995,7 +995,7 @@ int packet_to_str(const struct packet *pkt, char *buff, int size)
|
|||||||
|
|
||||||
int used = 0;
|
int used = 0;
|
||||||
memset(buff, 0, size);
|
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, pkt->data_ptr, pkt->data_len, pkt->trim_len,
|
||||||
pkt->layers_used, pkt->layers_size);
|
pkt->layers_used, pkt->layers_size);
|
||||||
for (uint8_t i = 0; i < pkt->layers_used; i++)
|
for (uint8_t i = 0; i < pkt->layers_used; i++)
|
||||||
|
|||||||
@@ -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)
|
set(LIBRARY times session_manager plugin_manager ip_reassembly packet_io packet pthread fieldstat4 toml)
|
||||||
|
|
||||||
add_library(stellar_core STATIC ${SOURCE})
|
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})
|
add_library(stellar_devel SHARED ${SOURCE})
|
||||||
#target_link_libraries(stellar_devel ${LIBRARY})
|
#target_link_libraries(stellar_devel ${LIBRARY})
|
||||||
|
|||||||
@@ -14,7 +14,9 @@
|
|||||||
#include "packet_dump.h"
|
#include "packet_dump.h"
|
||||||
#include "packet_parse.h"
|
#include "packet_parse.h"
|
||||||
#include "stellar/packet.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
|
// 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, ...)
|
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)
|
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];
|
char buff[4096];
|
||||||
struct packet *pkt = (struct packet *)msg;
|
struct packet *pkt = (struct packet *)msg;
|
||||||
struct plugin_ctx *ctx = (struct plugin_ctx *)plugin_ctx;
|
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)
|
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];
|
char buff[4096];
|
||||||
struct packet *pkt = (struct packet *)msg;
|
struct packet *pkt = (struct packet *)msg;
|
||||||
struct plugin_ctx *ctx = (struct plugin_ctx *)plugin_ctx;
|
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)
|
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];
|
char buff[4096];
|
||||||
struct tcp_segment *seg = (struct tcp_segment *)msg;
|
struct tcp_segment *seg = (struct tcp_segment *)msg;
|
||||||
struct plugin_ctx *ctx = (struct plugin_ctx *)plugin_ctx;
|
struct plugin_ctx *ctx = (struct plugin_ctx *)plugin_ctx;
|
||||||
@@ -166,9 +183,9 @@ extern "C"
|
|||||||
|
|
||||||
ctx->st = st;
|
ctx->st = st;
|
||||||
ctx->sess_plug_id = stellar_session_plugin_register(st, on_sess_new, on_sess_free, ctx);
|
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->udp_topic_id = stellar_mq_get_topic_id(st, TOPIC_UDP);
|
||||||
ctx->tcp_topic_id = stellar_session_mq_get_topic_id(st, TOPIC_TCP);
|
ctx->tcp_topic_id = stellar_mq_get_topic_id(st, TOPIC_TCP);
|
||||||
ctx->tcp_stream_topic_id = stellar_session_mq_get_topic_id(st, TOPIC_TCP_STREAM);
|
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->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);
|
stellar_session_mq_subscribe(st, ctx->tcp_topic_id, on_sess_tcp_msg, ctx->sess_plug_id);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include "toml.h"
|
#include "toml.h"
|
||||||
@@ -10,7 +11,6 @@
|
|||||||
#include "stellar/session.h"
|
#include "stellar/session.h"
|
||||||
#include "stellar/stellar_mq.h"
|
#include "stellar/stellar_mq.h"
|
||||||
|
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||||
|
|
||||||
#define LOG_ERR(fmt, ...) printf("ERROR [packet inject] " fmt, ##__VA_ARGS__)
|
#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)
|
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};
|
char buffer[1024] = {0};
|
||||||
struct packet *pkt = (struct packet *)msg;
|
struct packet *pkt = (struct packet *)msg;
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ static void usage(char *cmd)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int opt = 0;
|
int opt = 0;
|
||||||
struct runtime rte = {0};
|
struct runtime rte = {};
|
||||||
while ((opt = getopt(argc, argv, "f:tvh")) != -1)
|
while ((opt = getopt(argc, argv, "f:tvh")) != -1)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
|
|||||||
Reference in New Issue
Block a user