refactor: packet dump utils

This commit is contained in:
luwenpeng
2024-08-13 10:24:26 +08:00
parent ff8630e436
commit 03468d55be
13 changed files with 200 additions and 186 deletions

View File

@@ -12,7 +12,6 @@
#include "hexdump.h"
#include "session_utils.h"
#include "packet_dump.h"
#include "packet_parse.h"
#include "stellar/packet.h"
#include "stellar/stellar_mq.h"
@@ -104,7 +103,7 @@ static void on_sess_udp_msg(struct session *sess, int topic_id, const void *msg,
log_print(ctx->fd, "debug plugin", "on UDP msg: %s", buff);
memset(buff, 0, sizeof(buff));
packet_to_str(pkt, buff, sizeof(buff) - 1);
packet_dump_str(pkt, buff, sizeof(buff) - 1);
log_print(ctx->fd, "debug plugin", "rx UDP packet: \n%s", buff);
pthread_spin_lock(&ctx->lock);
@@ -128,7 +127,7 @@ static void on_sess_tcp_msg(struct session *sess, int topic_id, const void *msg,
log_print(ctx->fd, "debug plugin", "on TCP msg: %s", buff);
memset(buff, 0, sizeof(buff));
packet_to_str(pkt, buff, sizeof(buff) - 1);
packet_dump_str(pkt, buff, sizeof(buff) - 1);
log_print(ctx->fd, "debug plugin", "rx TCP packet: \n%s", buff);
pthread_spin_lock(&ctx->lock);

View File

@@ -256,7 +256,7 @@ static void packet_handler(u_char *user, const struct pcap_pkthdr *h, const u_ch
if (rte->print_verbose)
{
PRINT_GREEN("frame=%lu len=%u", rte->pcap_count, h->caplen);
packet_print(&pkt);
packet_dump_stdio(&pkt);
}
if (rte->tshark_format)