diff options
Diffstat (limited to 'src/stateless/cp/trex_stream.cpp')
-rw-r--r-- | src/stateless/cp/trex_stream.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/stateless/cp/trex_stream.cpp b/src/stateless/cp/trex_stream.cpp index 182036f1..2fd91560 100644 --- a/src/stateless/cp/trex_stream.cpp +++ b/src/stateless/cp/trex_stream.cpp @@ -20,6 +20,7 @@ limitations under the License. */ #include <trex_stream.h> #include <cstddef> +#include <string.h> /************************************** * stream @@ -57,6 +58,29 @@ TrexStream::get_stream_json() { } /************************************** + * stream compiled object + *************************************/ +TrexStreamsCompiledObj::~TrexStreamsCompiledObj() { + for (auto &obj : m_objs) { + delete obj.m_pkt; + } + m_objs.clear(); +} + +void +TrexStreamsCompiledObj::add_compiled_stream(double pps, uint8_t *pkt, uint16_t pkt_len) { + obj_st obj; + + obj.m_pps = pps; + obj.m_pkt_len = pkt_len; + + obj.m_pkt = new uint8_t[pkt_len]; + memcpy(obj.m_pkt, pkt, pkt_len); + + m_objs.push_back(obj); +} + +/************************************** * stream table *************************************/ TrexStreamTable::TrexStreamTable() { @@ -114,3 +138,31 @@ void TrexStreamTable::get_stream_list(std::vector<uint32_t> &stream_list) { int TrexStreamTable::size() { return m_stream_table.size(); } + + +bool +TrexStreamTable::compile(TrexStreamsCompiledObj &obj) { + + /* for now we do something trivial, */ + for (auto it = m_stream_table.begin(); it != m_stream_table.end(); it++ ) { + TrexStream *stream = (*it).second; + + if (!stream->m_enabled) { + continue; + } + if (!stream->m_self_start) { + continue; + } + + /* support only continous for now ... */ + TrexStreamContinuous *cont_stream = dynamic_cast<TrexStreamContinuous *>(stream); + if (!cont_stream) { + continue; + } + + obj.add_compiled_stream(cont_stream->get_pps(), cont_stream->m_pkt.binary, cont_stream->m_pkt.len); + } + + return true; +} + |