2024-06-19 15:06:14 +08:00
|
|
|
#pragma once
|
2024-02-04 17:40:26 +08:00
|
|
|
|
2024-04-21 11:30:41 +08:00
|
|
|
#ifdef __cplusplus
|
2024-02-04 17:40:26 +08:00
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-03-08 14:51:21 +08:00
|
|
|
struct ip_reassembly_options
|
2024-02-04 17:40:26 +08:00
|
|
|
{
|
2024-03-29 16:32:16 +08:00
|
|
|
uint8_t enable;
|
|
|
|
|
uint32_t timeout; // range: [1, 60000]
|
2024-07-30 19:17:29 +08:00
|
|
|
uint32_t bucket_entries; // range: [1, 4294967295] (must be power of 2)
|
2024-03-29 16:32:16 +08:00
|
|
|
uint32_t bucket_num; // range: [1, 4294967295]
|
2024-02-04 17:40:26 +08:00
|
|
|
};
|
|
|
|
|
|
2024-08-27 16:19:20 +08:00
|
|
|
struct __attribute__((aligned(64))) ip_reassembly_stat
|
2024-02-23 18:19:52 +08:00
|
|
|
{
|
2024-08-19 16:15:08 +08:00
|
|
|
// IPv4 frag stat
|
|
|
|
|
uint64_t ip4_defrags_expected;
|
|
|
|
|
uint64_t ip4_defrags_succeed;
|
|
|
|
|
uint64_t ip4_defrags_failed_timeout;
|
|
|
|
|
uint64_t ip4_defrags_failed_invalid_length;
|
|
|
|
|
uint64_t ip4_defrags_failed_overlap;
|
|
|
|
|
uint64_t ip4_defrags_failed_too_many_frag;
|
|
|
|
|
|
|
|
|
|
uint64_t ip4_frags;
|
|
|
|
|
uint64_t ip4_frags_freed;
|
|
|
|
|
uint64_t ip4_frags_buffered;
|
|
|
|
|
uint64_t ip4_frags_bypass_no_buffer;
|
|
|
|
|
uint64_t ip4_frags_bypass_dup_fist_frag;
|
|
|
|
|
uint64_t ip4_frags_bypass_dup_last_frag;
|
|
|
|
|
|
|
|
|
|
// IPv6 frag stat
|
|
|
|
|
uint64_t ip6_defrags_expected;
|
|
|
|
|
uint64_t ip6_defrags_succeed;
|
|
|
|
|
uint64_t ip6_defrags_failed_timeout;
|
|
|
|
|
uint64_t ip6_defrags_failed_invalid_length;
|
|
|
|
|
uint64_t ip6_defrags_failed_overlap;
|
|
|
|
|
uint64_t ip6_defrags_failed_too_many_frag;
|
|
|
|
|
|
|
|
|
|
uint64_t ip6_frags;
|
|
|
|
|
uint64_t ip6_frags_freed;
|
|
|
|
|
uint64_t ip6_frags_buffered;
|
|
|
|
|
uint64_t ip6_frags_bypass_no_buffer;
|
|
|
|
|
uint64_t ip6_frags_bypass_dup_fist_frag;
|
|
|
|
|
uint64_t ip6_frags_bypass_dup_last_frag;
|
2024-02-23 18:19:52 +08:00
|
|
|
};
|
|
|
|
|
|
2024-03-08 14:51:21 +08:00
|
|
|
struct ip_reassembly *ip_reassembly_new(const struct ip_reassembly_options *opts);
|
2024-03-25 17:30:48 +08:00
|
|
|
void ip_reassembly_free(struct ip_reassembly *assy);
|
2024-08-15 19:03:48 +08:00
|
|
|
void ip_reassembly_expire(struct ip_reassembly *assy, uint64_t max_free, uint64_t now);
|
2024-04-18 14:20:28 +08:00
|
|
|
struct ip_reassembly_stat *ip_reassembly_stat(struct ip_reassembly *assy);
|
2024-02-04 17:40:26 +08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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-03-25 17:30:48 +08:00
|
|
|
struct packet *ip_reassembly_packet(struct ip_reassembly *assy, const struct packet *pkt, uint64_t now);
|
|
|
|
|
struct packet *ipv4_reassembly_packet(struct ip_reassembly *assy, const struct packet *pkt, uint64_t now);
|
|
|
|
|
struct packet *ipv6_reassembly_packet(struct ip_reassembly *assy, const struct packet *pkt, uint64_t now);
|
2024-02-04 17:40:26 +08:00
|
|
|
|
2024-04-21 11:30:41 +08:00
|
|
|
#ifdef __cplusplus
|
2024-02-04 17:40:26 +08:00
|
|
|
}
|
|
|
|
|
#endif
|