2024-02-04 17:40:26 +08:00
|
|
|
#ifndef _IP_REASSEMBLE_H
|
|
|
|
|
#define _IP_REASSEMBLE_H
|
|
|
|
|
|
2024-04-21 11:30:41 +08:00
|
|
|
#ifdef __cplusplus
|
2024-02-04 17:40:26 +08:00
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-04-22 20:01:15 +08:00
|
|
|
#include "packet_priv.h"
|
2024-02-04 17:40:26 +08:00
|
|
|
#include "log.h"
|
|
|
|
|
|
2024-03-08 13:55:17 +08:00
|
|
|
#define IP_REASSEMBLE_DEBUG(format, ...) LOG_DEBUG("ip_reassembly", format, ##__VA_ARGS__)
|
|
|
|
|
#define IP_REASSEMBLE_ERROR(format, ...) LOG_ERROR("ip_reassembly", format, ##__VA_ARGS__)
|
2024-02-04 17:40:26 +08:00
|
|
|
|
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]
|
|
|
|
|
uint32_t bucket_entries; // range: [1, 256] (must be power of 2)
|
|
|
|
|
uint32_t bucket_num; // range: [1, 4294967295]
|
2024-02-04 17:40:26 +08:00
|
|
|
};
|
|
|
|
|
|
2024-03-08 13:55:17 +08:00
|
|
|
struct ip_reassembly_stat
|
2024-02-23 18:19:52 +08:00
|
|
|
{
|
|
|
|
|
// 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;
|
|
|
|
|
};
|
|
|
|
|
|
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);
|
|
|
|
|
void ip_reassembly_expire(struct ip_reassembly *assy, 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
|
|
|
|
|
|
|
|
|
|
#endif
|