using namespace std;
-/**
+/***************************
* add new stream
*
- */
+ **************************/
trex_rpc_cmd_rc_e
TrexRpcCmdAddStream::_run(const Json::Value ¶ms, Json::Value &result) {
generate_internal_err(result, "unable to allocate memory");
}
+ /* parse the packet */
for (int i = 0; i < pkt.size(); i++) {
stream->m_pkt[i] = parse_byte(pkt, i, result);
}
+ /* parse RX info */
+ const Json::Value &rx = parse_object(section, "rx_stats", result);
+
+ stream->m_rx_check.m_enable = parse_bool(rx, "enabled", result);
+
+ /* if it is enabled - we need more fields */
+ if (stream->m_rx_check.m_enable) {
+ stream->m_rx_check.m_stream_id = parse_int(rx, "stream_id", result);
+ stream->m_rx_check.m_seq_enabled = parse_bool(rx, "seq_enabled", result);
+ stream->m_rx_check.m_latency = parse_bool(rx, "latency", result);
+ }
+
/* make sure this is a valid stream to add */
validate_stream(stream, result);
generate_parse_err(result, "bad stream type provided: '" + type + "'");
}
+ /* make sure we were able to allocate the memory */
if (!stream) {
generate_internal_err(result, "unable to allocate memory");
}
}
+/***************************
+ * remove stream
+ *
+ **************************/
trex_rpc_cmd_rc_e
TrexRpcCmdRemoveStream::_run(const Json::Value ¶ms, Json::Value &result) {
uint8_t port_id = parse_byte(params, "port_id", result);
}
TrexStatelessPort *port = get_trex_stateless()->get_port_by_id(port_id);
- TrexStream *stream = port->get_stream_table()->get_stream_by_id(stream_id);
+ TrexStream *stream = port->get_stream_table()->get_stream_by_id(stream_id);
if (!stream) {
std::stringstream ss;
result["result"] = "ACK";
}
+/***************************
+ * remove all streams
+ * for a port
+ *
+ **************************/
+trex_rpc_cmd_rc_e
+TrexRpcCmdRemoveAllStreams::_run(const Json::Value ¶ms, Json::Value &result) {
+ uint8_t port_id = parse_byte(params, "port_id", result);
+
+ if (port_id >= get_trex_stateless()->get_port_count()) {
+ std::stringstream ss;
+ ss << "invalid port id - should be between 0 and " << (int)get_trex_stateless()->get_port_count() - 1;
+ generate_execute_err(result, ss.str());
+ }
+
+ TrexStatelessPort *port = get_trex_stateless()->get_port_by_id(port_id);
+ port->get_stream_table()->remove_and_delete_all_streams();
+
+ result["result"] = "ACK";
+}
+
trex_rpc_cmd_rc_e
TrexRpcCmdTestAdd::_run(const Json::Value ¶ms, Json::Value &result) {
- const Json::Value &x = params["x"];
- const Json::Value &y = params["y"];
-
result["result"] = parse_int(params, "x", result) + parse_int(params, "y", result);
-
+
return (TREX_RPC_CMD_OK);
}
trex_rpc_cmd_rc_e
TrexRpcCmdTestSub::_run(const Json::Value ¶ms, Json::Value &result) {
- const Json::Value &x = params["x"];
- const Json::Value &y = params["y"];
-
result["result"] = parse_int(params, "x", result) - parse_int(params, "y", result);
return (TREX_RPC_CMD_OK);