enhance: imitate_tcp_packet() support setting tcp options

This commit is contained in:
luwenpeng
2024-07-02 17:55:55 +08:00
parent 5591227b9a
commit 2c0ec4072f
8 changed files with 73 additions and 16 deletions

View File

@@ -390,7 +390,6 @@ int dumpfile_io_inject(struct dumpfile_io *handle, uint16_t thr_idx, struct pack
struct packet_io_stat *stat = &handle->stat[thr_idx];
struct tuple6 tuple;
const char *data;
char file[1024] = {0};
char src_addr[INET6_ADDRSTRLEN] = {0};
char dst_addr[INET6_ADDRSTRLEN] = {0};
@@ -399,7 +398,6 @@ int dumpfile_io_inject(struct dumpfile_io *handle, uint16_t thr_idx, struct pack
{
pkt = &pkts[i];
len = packet_get_raw_len(pkt);
data = packet_get_raw_data(pkt);
stat->inject_pkts++;
stat->inject_bytes += len;
@@ -425,7 +423,7 @@ int dumpfile_io_inject(struct dumpfile_io *handle, uint16_t thr_idx, struct pack
}
snprintf(file, sizeof(file), "%s/inject-%s:%u-%s:%u-%lu.pcap", handle->work_dir, src_addr, ntohs(tuple.src_port), dst_addr, ntohs(tuple.dst_port), stat->inject_pkts);
if (packet_dump(file, data, len) == -1)
if (packet_dump_pcap(pkt, file) == -1)
{
PACKET_IO_LOG_ERROR("unable to dump pcap file: %s", file);
}