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/ip_reassemble/ip_reassemble.h

72 lines
2.1 KiB
C
Raw Normal View History

#ifndef _IP_REASSEMBLE_H
#define _IP_REASSEMBLE_H
#ifdef __cpluscplus
extern "C"
{
#endif
#include "packet.h"
#include "log.h"
#define IP_REASSEMBLE_DEBUG(format, ...) LOG_DEBUG("ip_reassemble", format, ##__VA_ARGS__)
#define IP_REASSEMBLE_ERROR(format, ...) LOG_ERROR("ip_reassemble", format, ##__VA_ARGS__)
struct ip_reassemble_config
{
2024-02-22 18:52:04 +08:00
bool enable;
uint32_t timeout; // seconds
uint32_t bucket_entries;
uint32_t bucket_num;
};
struct ip_reassemble_stat
{
// IPv4 flow stat
uint64_t ip4_flow_find;
uint64_t ip4_flow_add;
uint64_t ip4_flow_del;
uint64_t ip4_flow_timeout;
uint64_t ip4_flow_fail_no_space;
uint64_t ip4_flow_fail_overlap;
uint64_t ip4_flow_fail_many_frag;
uint64_t ip4_flow_fail_invalid_length;
uint64_t ip4_flow_bypass_dup_fist_frag;
uint64_t ip4_flow_bypass_dup_last_frag;
// IPv6 flow stat
uint64_t ip6_flow_find;
uint64_t ip6_flow_add;
uint64_t ip6_flow_del;
uint64_t ip6_flow_timeout;
uint64_t ip6_flow_fail_no_space;
uint64_t ip6_flow_fail_overlap;
uint64_t ip6_flow_fail_many_frag;
uint64_t ip6_flow_fail_invalid_length;
uint64_t ip6_flow_bypass_dup_fist_frag;
uint64_t ip6_flow_bypass_dup_last_frag;
};
struct ip_reassemble_manager *ip_reassemble_manager_create(const struct ip_reassemble_config *config);
void ip_reassemble_manager_destory(struct ip_reassemble_manager *mgr);
void ip_reassemble_manager_expire(struct ip_reassemble_manager *mgr);
void ip_reassemble_manager_print_stat(struct ip_reassemble_manager *mgr);
struct ip_reassemble_stat *ip_reassemble_manager_get_stat(struct ip_reassemble_manager *mgr);
/*
* Returns the reassembled packet, or NULL if the packet is not reassembled
* The returned packet should be freed by calling the packet_free() function
*/
2024-02-22 18:52:04 +08:00
struct packet *ip_reassemble_packet(struct ip_reassemble_manager *mgr, const struct packet *pkt);
struct packet *ipv4_reassemble_packet(struct ip_reassemble_manager *mgr, const struct packet *pkt);
struct packet *ipv6_reassemble_packet(struct ip_reassemble_manager *mgr, const struct packet *pkt);
#ifdef __cpluscplus
}
#endif
#endif