22 #include <hal_posix/file_io.h>
26 #ifndef SATCAT5_PCAP_BUFFSIZE
27 #define SATCAT5_PCAP_BUFFSIZE 1600
46 explicit ReadPcap(
const char* filename = 0);
50 void open(
const char* filename);
51 inline void open(
const std::string& filename)
52 {
open(filename.c_str()); }
56 inline void close() {m_file.close();}
73 inline u16 file_rd16()
74 {
return m_mode_be ? m_file.read_u16() : m_file.read_u16l(); }
75 inline u32 file_rd32()
76 {
return m_mode_be ? m_file.read_u32() : m_file.read_u32l(); }
84 u8 m_buff[SATCAT5_PCAP_BUFFSIZE];
98 inline void open(
const std::string& filename, u16 type = LINKTYPE_ETHERNET)
99 {
open(filename.c_str(), type); }
110 u32
add_interface(
const char* name, u16 type = LINKTYPE_ETHERNET);
115 { m_interface_next = id; }
130 const bool m_mode_ng;
131 u32 m_interface_count, m_interface_next;
132 u8 m_buff[SATCAT5_PCAP_BUFFSIZE];
Real-time clock for tracking date/time.
Ephemeral Readable interface for a simple array.
Ephemeral Writeable interface for a simple array.
Read bytes or packets from a file.
Write bytes or packets to a file.
Read packet stream from a file.
void open(const char *filename)
Open the specified file.
void close()
Close the current file, if any.
void open(const std::string &filename)
Open the specified file.
ReadPcap(const char *filename=0)
Open the input file and autodetect format.
void read_finalize() override
Override end-of-packet handling.
Store packet stream to a file.
u32 add_interface(const char *name, u16 type=LINKTYPE_ETHERNET)
Write a new interface description block (PCAPNG only).
void close()
Close the current file, if any.
void set_passthrough(satcat5::io::Writeable *wr)
Passthrough mode carbon-copies each packet to another Writeable object, using the internal working bu...
void open(const char *filename, u16 type=LINKTYPE_ETHERNET)
Open the specified file, and optionally specify LinkType.
void open(const std::string &filename, u16 type=LINKTYPE_ETHERNET)
Open the specified file, and optionally specify LinkType.
void set_interface(u32 id)
Set interface ID number for the next call to write_finalize.
WritePcap(bool pcapng=true)
Create the capture object and set PCAP or PCAPNG mode.
bool write_finalize() override
Override end-of-packet handling.
Helper object for writing capture files with multiple sources.
WritePcapInterface(satcat5::io::WritePcap *pcap, const char *label, u16 type=LINKTYPE_ETHERNET)
Constructor adds a new interface to a packet-capture.
bool write_finalize() override
Override end-of-packet handling.
Abstract API for writing byte-streams and packets.
Wrapper class for forwarding writes to another object.
Real-time clock conversion functions.
constexpr u16 LINKTYPE_AOS
Define selected LinkType codes from the official registry: https://www.tcpdump.org/linktypes....
constexpr u16 LINKTYPE_USER(u16 x)
Define selected LinkType codes from the official registry: https://www.tcpdump.org/linktypes....
constexpr u16 LINKTYPE_ETHERNET
Define selected LinkType codes from the official registry: https://www.tcpdump.org/linktypes....
constexpr u16 LINKTYPE_USER0
Define selected LinkType codes from the official registry: https://www.tcpdump.org/linktypes....