summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py4
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py11
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py2
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py2
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_stream.cpp20
5 files changed, 13 insertions, 26 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
index c3fa70ec..838a49ed 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
@@ -57,7 +57,7 @@ class Port(object):
def err(self, msg):
- return RC_ERR("port {0} : {1}".format(self.port_id, msg))
+ return RC_ERR("port {0} : {1}\n".format(self.port_id, msg))
def ok(self, data = ""):
return RC_OK(data)
@@ -203,7 +203,7 @@ class Port(object):
rc = self.transmit_batch(batch)
if not rc:
- return self.err(rc.err())
+ return self.err(str(rc))
# the only valid state now
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py
index 380b7a39..907125e9 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py
@@ -27,8 +27,6 @@ from trex_stl_client import STLClient
import re
import json
-import zlib
-import struct
import argparse
@@ -218,19 +216,14 @@ class STLSim(object):
# internal run
- def __run (self, cmds_json, zipped = True):
+ def __run (self, cmds_json):
# write to temp file
f = tempfile.NamedTemporaryFile(delete = False)
msg = json.dumps(cmds_json)
- # stress the zip path
- if zipped:
- compressed = zlib.compress(msg)
- new_msg = struct.pack(">II", 0xABE85CEA, len(msg)) + compressed
-
- f.write(new_msg)
+ f.write(msg)
f.close()
# launch bp-sim
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
index 68f8f694..130beabe 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
@@ -111,7 +111,7 @@ class STLStream(object):
rx_stats = None,
next = None,
stream_id = None,
- action_count =0,
+ action_count = 0,
mac_src_override_by_pkt=None,
mac_dst_override_mode=None #see STLStreamDstMAC_xx
):
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py
index 58306c5a..84dd5090 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py
@@ -71,7 +71,7 @@ match_multiplier_help = """Multiplier should be passed in the following format:
will provide a percentage of the line rate. examples
'-m 10', '-m 10kbps', '-m 10mpps', '-m 23%%'
- '-m 23%%' : is 23% L1 bandwidth
+ '-m 23%%' : is 23%% L1 bandwidth
'-m 23mbps' : is 23mbps in L2 bandwidth (including FCS+4)
"""
diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
index 0f74e19f..8d813b7b 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
@@ -26,6 +26,7 @@ limitations under the License.
#include <trex_streams_compiler.h>
#include <common/base64.h>
#include <iostream>
+#include <memory>
using namespace std;
@@ -48,7 +49,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
string type = parse_string(mode, "type", result);
/* allocate a new stream based on the type */
- TrexStream *stream = allocate_new_stream(section, port_id, stream_id, result);
+ std::unique_ptr<TrexStream> stream( allocate_new_stream(section, port_id, stream_id, result) );
/* save this for future queries */
stream->store_stream_json(section);
@@ -57,14 +58,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
stream->m_enabled = parse_bool(section, "enabled", result);
stream->m_self_start = parse_bool(section, "self_start", result);
stream->m_flags = parse_int(section, "flags", result);
- int cnt = parse_int(section, "action_count", result);
- if (cnt<0 || cnt >= UINT16_MAX) {
- std::stringstream ss;
- ss << "bad action_count provided: should be between " << 0 << " and " << UINT16_MAX;
- delete stream;
- generate_execute_err(result, ss.str());
- }
- stream->m_action_count = (uint16_t)cnt;
+ stream->m_action_count = parse_uint16(section, "action_count", result);
/* inter stream gap */
stream->m_isg_usec = parse_double(section, "isg", result);
@@ -78,7 +72,6 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
if ( (pkt_binary.size() < TrexStream::MIN_PKT_SIZE_BYTES) || (pkt_binary.size() > TrexStream::MAX_PKT_SIZE_BYTES) ) {
std::stringstream ss;
ss << "bad packet size provided: should be between " << TrexStream::MIN_PKT_SIZE_BYTES << " and " << TrexStream::MAX_PKT_SIZE_BYTES;
- delete stream;
generate_execute_err(result, ss.str());
}
@@ -104,7 +97,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
/* parse VM */
const Json::Value &vm = parse_object(section ,"vm", result);
- parse_vm(vm, stream, result);
+ parse_vm(vm, stream.get(), result);
/* parse RX info */
const Json::Value &rx = parse_object(section, "rx_stats", result);
@@ -119,12 +112,13 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
}
/* make sure this is a valid stream to add */
- validate_stream(stream, result);
+ validate_stream(stream.get(), result);
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(stream->m_port_id);
try {
- port->add_stream(stream);
+ port->add_stream(stream.get());
+ stream.release();
} catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}