This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
stellar-stellar/src/tcp_reassembly/tcp_reassembly.h

46 lines
1.5 KiB
C
Raw Normal View History

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__)
struct tcp_reassembly_stat
{
uint64_t packets; // current packets
uint64_t bytes; // current bytes
uint64_t tcp_segement_timout; // total tcp segment timeout
};
/*
* 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 *tcp_reassembly_new(bool enable, uint32_t max_timeout, uint32_t max_packets, uint32_t max_bytes);
void tcp_reassembly_init(struct tcp_reassembly *assembler, uint32_t c2s_init_seq, uint32_t s2c_init_seq);
void tcp_reassembly_free(struct tcp_reassembly *assembler);
void tcp_reassembly_expire(struct tcp_reassembly *assembler, uint64_t now);
// direction: 1 C2S; 2: S2C
void tcp_reassembly_update(struct tcp_reassembly *assembler, int direction, uint32_t offset, const char *payload, uint32_t len, uint64_t now);
const char *tcp_reassembly_peek(struct tcp_reassembly *assembler, int direction, uint32_t *len);
void tcp_reassembly_consume(struct tcp_reassembly *assembler, int direction, uint32_t len);
struct tcp_reassembly_stat *tcp_reassembly_get_stat(struct tcp_reassembly *assembler);
#ifdef __cpluscplus
}
#endif
#endif