/// Extern functions operating on Flow.
extern {
pub fn FlowGetLastTimeAsParts(flow: &Flow, secs: *mut u64, usecs: *mut u64);
+ pub fn FlowGetFlags(flow: &Flow) -> u32;
+ pub fn FlowGetSourcePort(flow: &Flow) -> u16;
+ pub fn FlowGetDestinationPort(flow: &Flow) -> u16;
}
/// Rust implementation of Flow.
std::time::Duration::new(secs, usecs as u32 * 1000)
}
}
+
+ /// Return the flow flags.
+ pub fn get_flags(&self) -> u32 {
+ unsafe { FlowGetFlags(self) }
+ }
+
+ /// Return flow ports
+ pub fn get_ports(&self) -> (u16, u16) {
+ unsafe { (FlowGetSourcePort(self), FlowGetDestinationPort(self)) }
+ }
}
*usecs = (uint64_t)flow->lastts.tv_usec;
}
+/**
+ * \brief Get flow source port.
+ *
+ * A function to get the flow sport useful when the caller only has an
+ * opaque pointer to the flow structure.
+ */
+uint16_t FlowGetSourcePort(Flow *flow)
+{
+ return flow->sp;
+}
+
+/**
+ * \brief Get flow destination port.
+ *
+ * A function to get the flow dport useful when the caller only has an
+ * opaque pointer to the flow structure.
+ */
+
+uint16_t FlowGetDestinationPort(Flow *flow)
+{
+ return flow->dp;
+}
+/**
+ * \brief Get flow flags.
+ *
+ * A function to get the flow flags useful when the caller only has an
+ * opaque pointer to the flow structure.
+ */
+
+uint32_t FlowGetFlags(Flow *flow)
+{
+ return flow->flags;
+}
/************************************Unittests*******************************/
#ifdef UNITTESTS
void RegisterFlowBypassInfo(void);
void FlowGetLastTimeAsParts(Flow *flow, uint64_t *secs, uint64_t *usecs);
+uint32_t FlowGetFlags(Flow *flow);
+uint16_t FlowGetSourcePort(Flow *flow);
+uint16_t FlowGetDestinationPort(Flow *flow);
/** ----- Inline functions ----- */