summaryrefslogtreecommitdiffstats
path: root/src/flow_stat.cpp
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-06-20 16:45:21 +0300
committerIdo Barnea <ibarnea@cisco.com>2016-06-20 16:45:39 +0300
commit1b1567ac6c2cfcb1625dded30f497339c1519f91 (patch)
treede5a82c3daafb9d6b38df46265c344b75986cbe2 /src/flow_stat.cpp
parent88486da4a095bd7fa7094d4bd9ab54eeafd24a26 (diff)
Adding verify_stream in flow_stat.cpp
Diffstat (limited to 'src/flow_stat.cpp')
-rw-r--r--src/flow_stat.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp
index 71d3a74a..366c3aa8 100644
--- a/src/flow_stat.cpp
+++ b/src/flow_stat.cpp
@@ -539,7 +539,20 @@ void CFlowStatRuleMgr::init_stream(TrexStream * stream) {
stream->m_rx_check.m_hw_id = HW_ID_INIT;
}
+int CFlowStatRuleMgr::verify_stream(TrexStream * stream) {
+ return add_stream_internal(stream, false);
+}
+
int CFlowStatRuleMgr::add_stream(TrexStream * stream) {
+ return add_stream_internal(stream, true);
+}
+
+/*
+ * Helper function for adding/verifying streams
+ * stream - stream to act on
+ * do_action - if false, just verify. Do not change any state, or add to database.
+ */
+int CFlowStatRuleMgr::add_stream_internal(TrexStream * stream, bool do_action) {
#ifdef __DEBUG_FUNC_ENTRY__
std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << std::endl;
stream_dump(stream);
@@ -572,7 +585,9 @@ int CFlowStatRuleMgr::add_stream(TrexStream * stream) {
}
// throws exception if there is error
- m_user_id_map.add_stream(stream->m_rx_check.m_pg_id, l4_proto);
+ if (do_action) {
+ m_user_id_map.add_stream(stream->m_rx_check.m_pg_id, l4_proto);
+ }
break;
case TrexPlatformApi::IF_STAT_PAYLOAD:
uint16_t payload_len;
@@ -584,14 +599,17 @@ int CFlowStatRuleMgr::add_stream(TrexStream * stream) {
+ " payload bytes for payload rules. Packet only has " + std::to_string(payload_len) + " bytes"
, TrexException::T_FLOW_STAT_PAYLOAD_TOO_SHORT);
}
- m_user_id_map.add_stream(stream->m_rx_check.m_pg_id, PAYLOAD_RULE_PROTO);
+ if (do_action) {
+ m_user_id_map.add_stream(stream->m_rx_check.m_pg_id, PAYLOAD_RULE_PROTO);
+ }
break;
default:
throw TrexFStatEx("Wrong rule_type", TrexException::T_FLOW_STAT_BAD_RULE_TYPE);
break;
}
-
- stream->m_rx_check.m_hw_id = HW_ID_FREE;
+ if (do_action) {
+ stream->m_rx_check.m_hw_id = HW_ID_FREE;
+ }
return 0;
}