refactor: packet module (split to parse/build/layer/tunnel/utils)

This commit is contained in:
luwenpeng
2024-06-24 17:07:05 +08:00
parent d8963af5f8
commit 71422ebb36
36 changed files with 796 additions and 724 deletions

View File

@@ -9,12 +9,19 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "log.h"
#include "tuple.h"
#include "macro.h"
#include "dumpfile_io.h"
#include "packet_priv.h"
#include "packet_def.h"
#include "packet_ldbc.h"
#include "packet_utils.h"
#include "packet_parse.h"
#include "lock_free_queue.h"
#define PACKET_IO_LOG_STATE(format, ...) LOG_STATE("dumpfile io", format, ##__VA_ARGS__)
#define PACKET_IO_LOG_ERROR(format, ...) LOG_ERROR("dumpfile io", format, ##__VA_ARGS__)
#define MAX_PACKET_QUEUE_SIZE (4096 * 1000)
struct dumpfile_io
@@ -203,7 +210,7 @@ static void pcap_packet_handler(u_char *user, const struct pcap_pkthdr *h, const
struct packet pkt;
memset(&pkt, 0, sizeof(struct packet));
packet_parse(&pkt, pcap_pkt->data, pcap_pkt->len);
uint64_t hash = packet_get_hash(&pkt, LDBC_METHOD_HASH_INT_IP_AND_EXT_IP, PACKET_DIRECTION_OUTGOING);
uint64_t hash = packet_ldbc_hash(&pkt, LDBC_HASH_OUTERMOST_INT_EXT_IP, PACKET_DIRECTION_OUTGOING);
// push packet to queue
struct lock_free_queue *queue = handle->queue[hash % handle->nr_threads];