Removed the ambiguous session_get0_current_payload() API. It is unclear whether the original packet payload or TCP reassembled payload is obtained.

It is recommended to:
* Use packet_get_payload() to obtain the original packet payload
* Use tcp_segment_get_data() to obtain the reassembled data
This commit is contained in:
luwenpeng
2024-08-01 15:14:47 +08:00
parent 776090331e
commit 12975e2da7
9 changed files with 40 additions and 21 deletions

View File

@@ -9,13 +9,11 @@
#include <pthread.h>
#include <arpa/inet.h>
#include "log.h"
#include "hexdump.h"
#include "session_utils.h"
#include "tcp_reassembly.h"
#include "packet_dump.h"
#include "packet_parse.h"
#include "packet_utils.h"
#include "stellar/packet.h"
#include "stellar/session_mq.h"
// NOTE: packet hexdump or tcp segment hexdump may be too long, so we need direct output to fd, instead of using log_print
@@ -131,15 +129,17 @@ static void on_sess_tcp_stream_msg(struct session *sess, int topic_id, const voi
char buff[4096];
struct tcp_segment *seg = (struct tcp_segment *)msg;
struct plugin_ctx *ctx = (struct plugin_ctx *)plugin_ctx;
const char *data = tcp_segment_get_data(seg);
uint16_t len = tcp_segment_get_len(seg);
memset(buff, 0, sizeof(buff));
session_to_str(sess, 1, buff, sizeof(buff) - 1);
log_print(ctx->fd, "debug plugin", "on TCP stream msg: %s", buff);
log_print(ctx->fd, "debug plugin", "rx TCP segment: len: %d, data: %p\n", seg->len, seg->data);
log_print(ctx->fd, "debug plugin", "rx TCP segment: len: %d, data: %p\n", len, data);
pthread_spin_lock(&ctx->lock);
hexdump_to_fd(ctx->fd, (const char *)seg->data, seg->len);
hexdump_to_fd(ctx->fd, data, len);
pthread_spin_unlock(&ctx->lock);
}