![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
PCAPNG capture hook for dfx message traffic. More...
#include <dfx-pcapng/Capture.hpp>
Public Member Functions | |
| Capture (bool getHwAndOsInfo=true) | |
| Construct a capture hook. | |
| ~Capture () | |
| Destroy the capture hook and stop background capture work. | |
| template<typename ... Args> | |
| void | setFileSink (Args &&... args) |
| Enable file output using a FileSink. | |
| void | unsetFileSink () |
| Disable the file sink if enabled. | |
| template<typename ... Args> | |
| void | setPipeSink (Args &&... args) |
| Enable pipe output using a PipeSink. | |
| void | unsetPipeSink () |
| Disable the pipe sink if enabled. | |
| template<typename ... Args> | |
| void | setTcpSink (Args &&... args) |
| Enable TCP output using a TcpSink. | |
| void | unsetTcpSink () |
| Disable the TCP sink if enabled. | |
| void | setUserAppInfo (std::string info) |
| Set application-specific information to embed in the capture. | |
| void | onMessageSent (Core::OutputPort const &port, Core::Message const &message) override |
| Port hook: called when a message is sent from an output port. | |
| void | onMessageReceived (Core::InputPort const &port, Core::Message const &message) override |
| Port hook: called when a message is received by an input port. | |
| void | onNodeCreated (Core::NodePtr node) override |
| Graph hook: called when a node is created. | |
| void | onNodeRemoved (Core::NodePtr node) override |
| Graph hook: called when a node is removed. | |
| void | onChannelCreated (Core::ChannelPtr) override |
| Graph hook: channel creation is currently ignored for capture. | |
| void | onChannelRemoved (Core::ChannelPtr) override |
| Graph hook: channel removal is currently ignored for capture. | |
PCAPNG capture hook for dfx message traffic.
Capture is a runtime hook object that can be attached to a dfx graph to export message activity to PCAPNG (Wireshark-readable) output streams.
It combines two hook roles:
Internally, Capture delegates actual encoding and I/O to a dedicated Worker, and can be connected to one or more output "sinks" (file, pipe, TCP).
Sinks can be enabled/disabled at runtime with the set*Sink() / unset*Sink() APIs. The worker is responsible for orchestrating emission to the active sinks.
Capture keeps weak references to nodes it has seen via graph callbacks. These are used to emit node-related metadata consistently even if nodes are later destroyed.
| dfx::Pcapng::Capture::Capture | ( | bool | getHwAndOsInfo = true | ) |
Construct a capture hook.
| getHwAndOsInfo | If true, the capture will include host metadata such as hardware and OS information. Similar to the uname -srvm command. |
| dfx::Pcapng::Capture::~Capture | ( | ) |
Destroy the capture hook and stop background capture work.
The destructor is responsible for stopping the internal worker and flushing/closing any active sinks, so that the capture output is finalized properly. It also deregisters it-self from all nodes that are still alive.
|
inlineoverridevirtual |
Graph hook: channel creation is currently ignored for capture.
Implements dfx::Hooks::Graph.
|
inlineoverridevirtual |
Graph hook: channel removal is currently ignored for capture.
Implements dfx::Hooks::Graph.
|
overridevirtual |
Port hook: called when a message is received by an input port.
The capture records the message reception event and forwards the relevant data to the internal worker for serialization into PCAPNG blocks.
| port | Input port that received the message. |
| message | Message being received. |
Implements dfx::Hooks::Port.
|
overridevirtual |
Port hook: called when a message is sent from an output port.
The capture records the message emission event and forwards the relevant data to the internal worker for serialization into PCAPNG blocks.
| port | Output port that emitted the message. |
| message | Message being sent. |
Implements dfx::Hooks::Port.
|
overridevirtual |
Graph hook: called when a node is created.
Register this as Hooks::Port for every input and output port of the created node.
| node | Newly created node. |
Implements dfx::Hooks::Graph.
|
overridevirtual |
Graph hook: called when a node is removed.
Remove the internal weak pointer from the watch list.
| node | Removed node. |
Implements dfx::Hooks::Graph.
|
inline |
|
inline |
|
inline |
| void dfx::Pcapng::Capture::setUserAppInfo | ( | std::string | info | ) |
Set application-specific information to embed in the capture.
This information is intended to help identify the capture in tooling (e.g. Wireshark) and can include things like scenario name, version, build ID, test case, etc. The default value is "dfx-pcapng"
| info | Free-form string describing the user application / scenario. |
| void dfx::Pcapng::Capture::unsetFileSink | ( | ) |
Disable the file sink if enabled.
| void dfx::Pcapng::Capture::unsetPipeSink | ( | ) |
Disable the pipe sink if enabled.
| void dfx::Pcapng::Capture::unsetTcpSink | ( | ) |
Disable the TCP sink if enabled.