Class PcapWriter
Defined in File pcap.h
Class Documentation
-
class PcapWriter
Class for dealing with writing udp pcap files.
Public Types
Public Functions
-
PcapWriter(const std::string &file, PacketEncapsulation encap, uint16_t frag_size)
- Parameters:
file[in] – The file path to write the pcap to
encap[in] – The encapsulation to use for the pcap
frag_size[in] – The fragmentation size to use (Currently broken)
-
PcapWriter(const PcapWriter &other) = delete
-
PcapWriter(PcapWriter &&other)
Move construct from one PcapWriter to a new PcapWriter.
- Parameters:
other[in] – The other PcapWriter to move from.
-
PcapWriter &operator=(PcapWriter &other) = delete
-
PcapWriter &operator=(PcapWriter &&other)
Assign move resources from one PcapWriter to another.
- Parameters:
other[in] – The other PcapWriter to move from.
-
virtual ~PcapWriter()
Destructor for cleaning up after PcapWriter.
-
void write_packet(const uint8_t *buf, size_t buf_size, const std::string &src_ip, const std::string &dst_ip, uint16_t src_port, uint16_t dst_port, PacketInfo::ts timestamp)
Write a packet using a buffer to the pcap.
Note
The timestamp parameter does not affect the order of packets being recorded, it is strictly recorded FIFO.
- Parameters:
buf[in] – The buffer to write
buf_size[in] – The size of the buffer to write
src_ip[in] – The source ip address to use for the packet
dst_ip[in] – The destination ip address to use for the packet
src_port[in] – The source port number to use for the packet
dst_port[in] – The destination port number to use for the packet
timestamp[in] – The timestamp of the packet to record
-
void write_packet(const uint8_t *buf, size_t buf_size, const PacketInfo &info)
Write a packet using a buffer to the pcap.
Note
The timestamp parameter in info does not affect the order of packets being recorded, it is strictly recorded FIFO.
- Parameters:
buf[in] – The buffer to write
buf_size[in] – The size of the buffer to write
info[in] – The packet info object to use for the recording parameters
-
void flush()
Write all pending data to the pcap file.
-
void close()
Flushes and cleans up all memory in use by the pap writer.
-
PcapWriter(const std::string &file, PacketEncapsulation encap, uint16_t frag_size)