feature: packet IO support IP reassembly
This commit is contained in:
@@ -1,18 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "log_internal.h"
|
||||
#include "packet_dump.h"
|
||||
#include "packet_parser.h"
|
||||
#include "packet_helper.h"
|
||||
#include "packet_internal.h"
|
||||
|
||||
#define PACKET_DUMP_LOG_ERROR(format, ...) STELLAR_LOG_ERROR(__thread_local_logger, "packet dump", format, ##__VA_ARGS__)
|
||||
|
||||
struct pcap_pkt_hdr
|
||||
{
|
||||
unsigned int tv_sec; // time stamp
|
||||
@@ -32,8 +23,6 @@ struct pcap_file_hdr
|
||||
unsigned int linktype; // data link type (LINKTYPE_*)
|
||||
};
|
||||
|
||||
// return 0: success
|
||||
// return -1: failed
|
||||
int packet_dump_pcap(const struct packet *pkt, const char *file)
|
||||
{
|
||||
const char *data = packet_get_raw_data(pkt);
|
||||
@@ -49,16 +38,9 @@ int packet_dump_pcap(const struct packet *pkt, const char *file)
|
||||
.snaplen = 0xFFFF,
|
||||
.linktype = 1};
|
||||
|
||||
if (file == NULL || data == NULL || len == 0)
|
||||
{
|
||||
PACKET_DUMP_LOG_ERROR("invalid parameter, file: %p, data: %p, len: %d", file, data, len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE *fp = fopen(file, "w+");
|
||||
if (fp == NULL)
|
||||
{
|
||||
PACKET_DUMP_LOG_ERROR("fopen %s failed, %s", file, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user