dual mode - check for ERF only
authorimarom <[email protected]>
Sun, 4 Sep 2016 14:42:48 +0000 (17:42 +0300)
committerimarom <[email protected]>
Wed, 7 Sep 2016 11:02:56 +0000 (14:02 +0300)
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py
src/common/captureFile.h
src/common/erf.h
src/common/pcap.h
src/rpc-server/commands/trex_rpc_cmd_general.cpp
src/stateless/cp/trex_stateless_port.cpp

index 2c1fa5e..b4a7b4c 100755 (executable)
@@ -2234,6 +2234,9 @@ class STLClient(object):
 
         # for dual mode check that all are masters
         if is_dual:
+            if not pcap_filename.endswith('erf'):
+                raise STLError("dual mode: only ERF format is supported for dual mode")
+
             for port in ports:
                 master = port
                 slave = port ^ 0x1
index 4e57aae..779f35d 100755 (executable)
@@ -317,7 +317,7 @@ OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'],
               DUAL: ArgumentPack(['--dual'],
                                  {"action": "store_true",
                                   'default': False,
-                                  'help': "Transmit in a dual mode - requires a slave attached to the port"}),
+                                  'help': "Transmit in a dual mode - requires ownership on the adjacent port"}),
 
               FILE_PATH: ArgumentPack(['-f'],
                                       {'metavar': 'FILE',
index 32b9827..fefa62b 100755 (executable)
@@ -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;
index 299bcdc..2feb4fd 100755 (executable)
@@ -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;
 };
index fb266e3..01c981d 100755 (executable)
@@ -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 &);
        
index ba3c165..85f77a7 100644 (file)
@@ -525,8 +525,18 @@ TrexRpcCmdPushRemote::_run(const Json::Value &params, 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) {
index df50d3e..5162c47 100644 (file)
@@ -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());
     }