use crate::filecontainer::*;
/// Opaque C types.
-pub enum Flow {}
pub enum DetectEngineState {}
pub enum AppLayerDecoderEvents {}
}
}
}
+
+/// Opaque flow type (defined in C)
+pub enum Flow {}
+
+/// Extern functions operating on Flow.
+extern {
+ pub fn FlowGetLastTimeAsParts(flow: &Flow, secs: *mut u64, usecs: *mut u64);
+}
+
+/// Rust implementation of Flow.
+impl Flow {
+
+ /// Return the time of the last flow update as a `Duration`
+ /// since the epoch.
+ pub fn get_last_time(&mut self) -> std::time::Duration {
+ unsafe {
+ let mut secs: u64 = 0;
+ let mut usecs: u64 = 0;
+ FlowGetLastTimeAsParts(self, &mut secs, &mut usecs);
+ std::time::Duration::new(secs, usecs as u32 * 1000)
+ }
+ }
+}
\ No newline at end of file
}
}
+/**
+ * \brief Get flow last time as individual values.
+ *
+ * Instead of returning a pointer to the timeval copy the timeval
+ * parts into output pointers to make it simpler to call from Rust
+ * over FFI using only basic data types.
+ */
+void FlowGetLastTimeAsParts(Flow *flow, uint64_t *secs, uint64_t *usecs)
+{
+ *secs = (uint64_t)flow->lastts.tv_sec;
+ *usecs = (uint64_t)flow->lastts.tv_usec;
+}
+
/************************************Unittests*******************************/
#ifdef UNITTESTS
int GetFlowBypassInfoID(void);
void RegisterFlowBypassInfo(void);
+void FlowGetLastTimeAsParts(Flow *flow, uint64_t *secs, uint64_t *usecs);
+
/** ----- Inline functions ----- */
/** \brief Set the No Packet Inspection Flag without locking the flow.