1515#pragma once
1616
1717#include < cstdint>
18-
19- #include " packet.hpp"
2018#include " fieldManager.hpp"
2119#include " ../api.hpp"
2220
@@ -163,21 +161,28 @@ class IPXP_API ProcessPlugin {
163161 = 0 ;
164162
165163 /* *
166- * @brief Called to update plugin state for a constructed flow.
164+ * @brief Called before the main per-packet update.
165+ *
166+ * This method is invoked for each packet of a flow **before** the standard
167+ * update phase (`onUpdate()`) is executed. It allows the plugin to perform
168+ * early decisions or actions that must happen prior to flow statistics being
169+ * updated or other plugins being called.
170+ *
171+ * Typical use cases include:
172+ * - Requesting flow export and immediate re-insertion
173+ * (e.g., splitting a stream into multiple flows such as individual HTTP
174+ * requests or SIP sessions).
175+ * - Forcing a flow flush before normal packet processing.
167176 *
168- * This method is called for each packet of a flow after the plugin has been constructed
169- * (onInit returned ConstructionState::Constructed and RequiresUpdate). It allows the plugin
170- * to process packets and update its internal state. If the plugin no longer requires updates,
171- * it should return UpdateRequirement::NoUpdateNeeded. The method can also request actions such
172- * as flushing or removing the plugin from the flow.
173177 *
174178 * @param flowContext Context containing references to the flow and packet.
175179 * @param pluginContext Pointer to plugin-specific context memory.
176180 * @return PluginUpdateResult describing update requirements and actions.
177181 */
178182 [[nodiscard]] virtual PluginUpdateResult
179- onUpdate (const FlowContext& flowContext, void * pluginContext)
183+ beforeUpdate (const FlowContext& flowContext, void * pluginContext)
180184 {
185+ // TODO
181186 (void ) flowContext;
182187 (void ) pluginContext;
183188 return {
@@ -186,6 +191,29 @@ class IPXP_API ProcessPlugin {
186191 };
187192 }
188193
194+ /* *
195+ * @brief Called to update plugin state for a constructed flow.
196+ *
197+ * This method is called for each subsequent packet of a flow after the plugin has been
198+ * constructed. Importantly, onUpdate() is **not called for the same packet** that triggered
199+ * onInit(). Instead, the first invocation of onUpdate() happens with the *next* packet of the
200+ * flow. This ensures that initialization and the first update are clearly separated.
201+ *
202+ * The plugin can use this method to process packets and update its internal state. If the
203+ * plugin no longer requires updates, it should return UpdateRequirement::NoUpdateNeeded. The
204+ * method can also request actions such as flushing or removing the plugin from the flow.
205+ *
206+ * @param flowContext Context containing references to the flow and packet.
207+ * @param pluginContext Pointer to plugin-specific context memory.
208+ * @return PluginUpdateResult describing update requirements and actions.
209+ */
210+ [[nodiscard]] virtual PluginUpdateResult
211+ onUpdate (const FlowContext& flowContext, void * pluginContext)
212+ {
213+ throw std::logic_error (
214+ " Unexpected call to Base::onUpdate(). Override this method in your plugin." );
215+ }
216+
189217 /* *
190218 * @brief Called to export the flow record processed by the plugin.
191219 *
0 commit comments