2024-03-21 19:27:41 +08:00
|
|
|
#ifndef _TCP_REASSEMBLY_H
|
|
|
|
|
#define _TCP_REASSEMBLY_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#define TCP_REASSEMBLE_DEBUG(format, ...) LOG_DEBUG("tcp_reassembly", format, ##__VA_ARGS__)
|
|
|
|
|
#define TCP_REASSEMBLE_ERROR(format, ...) LOG_ERROR("tcp_reassembly", format, ##__VA_ARGS__)
|
|
|
|
|
|
2024-03-25 17:30:48 +08:00
|
|
|
/*
|
|
|
|
|
* If retransmission or overlap occurs, the old data packet may have been consumed by the upper-layer plug-in,
|
|
|
|
|
* so the old data packet takes priority and the new data packet will be bypassed.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct tcp_reassembly_options
|
|
|
|
|
{
|
|
|
|
|
bool enable;
|
|
|
|
|
uint32_t max_timeout;
|
|
|
|
|
uint32_t max_segments;
|
|
|
|
|
uint32_t max_bytes;
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-21 19:27:41 +08:00
|
|
|
struct tcp_reassembly_stat
|
|
|
|
|
{
|
2024-03-25 17:30:48 +08:00
|
|
|
uint64_t curr_segments;
|
|
|
|
|
uint64_t curr_bytes;
|
|
|
|
|
|
|
|
|
|
uint64_t insert_segments;
|
|
|
|
|
uint64_t insert_bytes;
|
2024-03-21 19:27:41 +08:00
|
|
|
|
2024-03-25 17:30:48 +08:00
|
|
|
uint64_t remove_segments;
|
|
|
|
|
uint64_t remove_bytes;
|
|
|
|
|
|
|
|
|
|
uint64_t consume_segments;
|
|
|
|
|
uint64_t consume_bytes;
|
|
|
|
|
|
|
|
|
|
uint64_t retrans_bypass_segments;
|
|
|
|
|
uint64_t retrans_bypass_bytes;
|
|
|
|
|
|
|
|
|
|
uint64_t overload_bypass_segments;
|
|
|
|
|
uint64_t overload_bypass_bytes;
|
|
|
|
|
|
|
|
|
|
uint64_t timeout_discard_segments;
|
|
|
|
|
uint64_t timeout_discard_bytes;
|
2024-03-21 19:27:41 +08:00
|
|
|
};
|
|
|
|
|
|
2024-03-25 17:30:48 +08:00
|
|
|
struct tcp_reassembly *tcp_reassembly_new(struct tcp_reassembly_options *opts);
|
|
|
|
|
void tcp_reassembly_free(struct tcp_reassembly *assy);
|
2024-03-21 19:27:41 +08:00
|
|
|
|
2024-03-25 17:30:48 +08:00
|
|
|
void tcp_reassembly_init(struct tcp_reassembly *assy, uint32_t syn_seq);
|
|
|
|
|
void tcp_reassembly_expire(struct tcp_reassembly *assy, uint64_t now);
|
2024-03-21 19:27:41 +08:00
|
|
|
|
2024-03-25 17:30:48 +08:00
|
|
|
void tcp_reassembly_insert(struct tcp_reassembly *assy, uint32_t seq, const char *payload, uint32_t len, uint64_t now);
|
|
|
|
|
const char *tcp_reassembly_peek(struct tcp_reassembly *assy, uint32_t *len);
|
|
|
|
|
void tcp_reassembly_consume(struct tcp_reassembly *assy, uint32_t len);
|
2024-03-21 19:27:41 +08:00
|
|
|
|
2024-03-25 17:30:48 +08:00
|
|
|
struct tcp_reassembly_stat *tcp_reassembly_get_stat(struct tcp_reassembly *assy);
|
|
|
|
|
void tcp_reassembly_print_stat(struct tcp_reassembly *assy);
|
2024-03-21 19:27:41 +08:00
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|