Add packet IO module
* support marsio
* support dumpfile ( 1 thread read dumpfile & N thread handle packet)
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#include "checksum.h"
|
||||
#include "ipv4_utils.h"
|
||||
#include "ipv6_utils.h"
|
||||
#include "packet_helpers.h"
|
||||
#include "packet_utils.h"
|
||||
#include "ip_reassemble.h"
|
||||
|
||||
#define IPV4_KEYLEN 1
|
||||
@@ -636,15 +636,15 @@ static struct packet *ip_frag_reassemble(struct ip_reassemble_manager *mgr, stru
|
||||
|
||||
// calculate the length of the reassembled packet
|
||||
uint32_t packet_len = flow->expected_total_size + flow->hdr.hdr_len;
|
||||
char *buff = (char *)calloc(1, packet_len + sizeof(struct packet));
|
||||
if (buff == NULL)
|
||||
struct packet *pkt = packet_new(packet_len);
|
||||
if (pkt == NULL)
|
||||
{
|
||||
IP_REASSEMBLE_ERROR("unable to allocate memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *ptr = buff + sizeof(struct packet);
|
||||
char *end = ptr + packet_len;
|
||||
char *ptr = (char *)packet_get_data(pkt);
|
||||
char *end = ptr + packet_get_len(pkt);
|
||||
|
||||
// copy last frag
|
||||
if (last->len > end - ptr)
|
||||
@@ -732,17 +732,19 @@ static struct packet *ip_frag_reassemble(struct ip_reassemble_manager *mgr, stru
|
||||
}
|
||||
|
||||
// create a new packet
|
||||
packet_parse((struct packet *)buff, buff + sizeof(struct packet), packet_len);
|
||||
return (struct packet *)buff;
|
||||
packet_parse(pkt, ptr, packet_len);
|
||||
packet_set_action(pkt, PACKET_ACTION_DROP);
|
||||
|
||||
return pkt;
|
||||
|
||||
error_out_invalid_length:
|
||||
ip_reassemble_stat_inc(mgr, fail_invalid_length, &flow->key);
|
||||
free(buff);
|
||||
packet_free(pkt);
|
||||
return NULL;
|
||||
|
||||
error_out_overlap:
|
||||
ip_reassemble_stat_inc(mgr, fail_overlap, &flow->key);
|
||||
free(buff);
|
||||
packet_free(pkt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user