Add ip_reassemble & ip_fragment function define
This commit is contained in:
32
src/ip_fragment/ip_fragment.cpp
Normal file
32
src/ip_fragment/ip_fragment.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "ip_fragment.h"
|
||||
|
||||
/*
|
||||
* Return the number of fragmented packets, stored in the pkts_out array
|
||||
* Packets in the pkts_out array should be freed by calling the packet_free() function
|
||||
*/
|
||||
|
||||
uint16_t ipv4_fragment_packet(struct packet *pkt_in, struct packet **pkts_out, uint16_t nb_pkts_out, uint16_t mtu_size)
|
||||
{
|
||||
if (pkt_in == NULL || pkts_out == NULL || nb_pkts_out == 0)
|
||||
{
|
||||
IP_FRAGMENT_LOG_ERROR("invalid input parameters");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t ipv6_fragment_packet(struct packet *pkt_in, struct packet **pkts_out, uint16_t nb_pkts_out, uint16_t mtu_size)
|
||||
{
|
||||
if (pkt_in == NULL || pkts_out == NULL || nb_pkts_out == 0)
|
||||
{
|
||||
IP_FRAGMENT_LOG_ERROR("invalid input parameters");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
return 0;
|
||||
}
|
||||
26
src/ip_fragment/ip_fragment.h
Normal file
26
src/ip_fragment/ip_fragment.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef _IP_FRAGMENT_H
|
||||
#define _IP_FRAGMENT_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "packet.h"
|
||||
#include "log.h"
|
||||
|
||||
#define IP_FRAGMENT_LOG_DEBUG(format, ...) LOG_DEBUG("ip_fragment", format, ##__VA_ARGS__)
|
||||
#define IP_FRAGMENT_LOG_ERROR(format, ...) LOG_ERROR("ip_fragment", format, ##__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Return the number of fragmented packets, stored in the pkts_out array
|
||||
* Packets in the pkts_out array should be freed by calling the packet_free() function
|
||||
*/
|
||||
uint16_t ipv4_fragment_packet(struct packet *pkt_in, struct packet **pkts_out, uint16_t nb_pkts_out, uint16_t mtu_size);
|
||||
uint16_t ipv6_fragment_packet(struct packet *pkt_in, struct packet **pkts_out, uint16_t nb_pkts_out, uint16_t mtu_size);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
31
src/ip_reassemble/ip_reassemble.cpp
Normal file
31
src/ip_reassemble/ip_reassemble.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "ip_reassemble.h"
|
||||
|
||||
struct ip_reassemble_manager *ip_reassemble_manager_create(const struct ip_reassemble_config *config)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void ip_reassemble_manager_destory(struct ip_reassemble_manager *mgr)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void ip_reassemble_manager_stat(struct ip_reassemble_manager *mgr)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the reassembled packet, or NULL if the packet is not reassembled
|
||||
* The returned packet should be freed by calling the packet_free() function
|
||||
*/
|
||||
|
||||
struct packet *ipv4_reassemble_packet(struct ip_reassemble_manager *mgr, const struct packet *pkt)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
struct packet *ipv6_reassemble_packet(struct ip_reassemble_manager *mgr, const struct packet *pkt)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
40
src/ip_reassemble/ip_reassemble.h
Normal file
40
src/ip_reassemble/ip_reassemble.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#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
|
||||
{
|
||||
bool enable_reassemble;
|
||||
|
||||
uint32_t max_cycles;
|
||||
uint32_t max_entries;
|
||||
uint32_t bucket_entries;
|
||||
uint32_t bucket_num;
|
||||
};
|
||||
|
||||
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_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
|
||||
*/
|
||||
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
|
||||
Reference in New Issue
Block a user