diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/common/captureFile.h | 3 | ||||
-rwxr-xr-x | src/common/erf.h | 5 | ||||
-rwxr-xr-x | src/common/pcap.h | 6 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_general.cpp | 10 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless_port.cpp | 3 |
5 files changed, 24 insertions, 3 deletions
diff --git a/src/common/captureFile.h b/src/common/captureFile.h index 32b98272..fefa62bd 100755 --- a/src/common/captureFile.h +++ b/src/common/captureFile.h @@ -183,6 +183,9 @@ public: * open file for reading. */ virtual bool Create(char * name, int loops = 0) = 0; + + virtual capture_type_e get_type() = 0; + protected: int m_loops; uint64_t m_file_size; diff --git a/src/common/erf.h b/src/common/erf.h index 299bcdc5..2feb4fd6 100755 --- a/src/common/erf.h +++ b/src/common/erf.h @@ -248,6 +248,11 @@ public: bool Create(char *filename, int loops = 0); void Delete(); virtual bool ReadPacket(CCapPktRaw * lpPacket); + + virtual capture_type_e get_type() { + return ERF; + } + private: FILE * m_handle; }; diff --git a/src/common/pcap.h b/src/common/pcap.h index fb266e31..01c981d7 100755 --- a/src/common/pcap.h +++ b/src/common/pcap.h @@ -79,9 +79,13 @@ public: * otherwise (reached eof) */ virtual bool ReadPacket(CCapPktRaw *lpPacket); - virtual void Rewind(); + virtual void Rewind(); + virtual capture_type_e get_type() { + return LIBPCAP; + } + private: LibPCapReader(LibPCapReader &); diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index ba3c1658..85f77a7f 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -525,8 +525,18 @@ TrexRpcCmdPushRemote::_run(const Json::Value ¶ms, Json::Value &result) { if (!slave->get_owner().verify(slave_handler)) { generate_execute_err(result, "incorrect or missing slave port handler"); } + + std::stringstream ss; + CCapReaderBase *reader = CCapReaderFactory::CreateReader((char *)pcap_filename.c_str(), 0, ss); + if (!reader) { + generate_execute_err(result, ss.str()); + } + if (reader->get_type() != ERF) { + generate_execute_err(result, "dual mode is only supported on ERF format"); + } } + try { port->push_remote(pcap_filename, ipg_usec, speedup, count, duration, is_dual); } catch (const TrexException &ex) { diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index df50d3e2..5162c477 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -504,9 +504,8 @@ TrexStatelessPort::push_remote(const std::string &pcap_filename, verify_state(PORT_STATE_IDLE | PORT_STATE_STREAMS, "push_remote"); /* check that file exists */ - CCapReaderBase *reader; std::stringstream ss; - reader = CCapReaderFactory::CreateReader((char *)pcap_filename.c_str(), 0, ss); + CCapReaderBase *reader = CCapReaderFactory::CreateReader((char *)pcap_filename.c_str(), 0, ss); if (!reader) { throw TrexException(ss.str()); } |