diff options
author | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-12-18 20:11:31 +0200 |
---|---|---|
committer | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-12-19 11:23:48 +0200 |
commit | 5cfeb192a3ff47c5cacc21abe20db2f61a66dd2b (patch) | |
tree | 57a455e70d9ac9c453495f4929ac9fac5b9fb011 /src/rpc-server/commands | |
parent | cc4bd93b660505a7c9d8e370a1220377907fa6d2 (diff) |
changes from code review
Change-Id: I628608643d902bd6310b04b8036fc5f1fcc42309
Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'src/rpc-server/commands')
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_general.cpp | 7 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_stream.cpp | 29 |
2 files changed, 14 insertions, 22 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index b3b1b3b4..d4854a79 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -631,11 +631,8 @@ TrexRpcCmdPushRemote::_run(const Json::Value ¶ms, Json::Value &result) { uint8_t port_id = parse_port(params, result); std::string pcap_filename = parse_string(params, "pcap_filename", result); double ipg_usec = parse_double(params, "ipg_usec", result); - double min_ipg_sec = 0; - if (params.isMember("min_ipg_usec")) { - min_ipg_sec = usec_to_sec(parse_double(params, "min_ipg_usec", result)); - } - double speedup = parse_double(params, "speedup", result); + double min_ipg_sec = usec_to_sec(parse_udouble(params, "min_ipg_usec", result, 0)); + double speedup = parse_udouble(params, "speedup", result); uint32_t count = parse_uint32(params, "count", result); double duration = parse_double(params, "duration", result); bool is_dual = parse_bool(params, "is_dual", result, false); diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp index 9a57c5f9..3f73a5d7 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp @@ -40,7 +40,7 @@ TrexRpcCmdAddStream::_run(const Json::Value ¶ms, Json::Value &result) { uint8_t port_id = parse_port(params, result); - uint32_t stream_id = parse_int(params, "stream_id", result); + uint32_t stream_id = parse_uint32(params, "stream_id", result); const Json::Value §ion = parse_object(params, "stream", result); @@ -62,7 +62,7 @@ TrexRpcCmdAddStream::_run(const Json::Value ¶ms, Json::Value &result) { stream->m_random_seed = parse_uint32(section, "random_seed", result,0); /* default is zero */ /* inter stream gap */ - stream->m_isg_usec = parse_double(section, "isg", result); + stream->m_isg_usec = parse_udouble(section, "isg", result); stream->m_next_stream_id = parse_int(section, "next_stream_id", result); @@ -114,7 +114,7 @@ TrexRpcCmdAddStream::_run(const Json::Value ¶ms, Json::Value &result) { generate_parse_err(result, "RX stats is not supported on this interface"); } - stream->m_rx_check.m_pg_id = parse_int(rx, "stream_id", result); + stream->m_rx_check.m_pg_id = parse_uint32(rx, "stream_id", result); std::string type = parse_string(rx, "rule_type", result); if (type == "latency") { stream->m_rx_check.m_rule_type = TrexPlatformApi::IF_STAT_PAYLOAD; @@ -155,7 +155,7 @@ TrexRpcCmdAddStream::allocate_new_stream(const Json::Value §ion, uint8_t por } else if (type == "single_burst") { - uint32_t total_pkts = parse_int(mode, "total_pkts", result); + uint32_t total_pkts = parse_uint32(mode, "total_pkts", result); stream.reset(new TrexStream(TrexStream::stSINGLE_BURST, port_id, stream_id)); stream->set_single_burst(total_pkts); @@ -163,9 +163,9 @@ TrexRpcCmdAddStream::allocate_new_stream(const Json::Value §ion, uint8_t por } else if (type == "multi_burst") { - double ibg_usec = parse_double(mode, "ibg", result); - uint32_t num_bursts = parse_int(mode, "count", result); - uint32_t pkts_per_burst = parse_int(mode, "pkts_per_burst", result); + double ibg_usec = parse_udouble(mode, "ibg", result); + uint32_t num_bursts = parse_uint32(mode, "count", result); + uint32_t pkts_per_burst = parse_uint32(mode, "pkts_per_burst", result); stream.reset(new TrexStream(TrexStream::stMULTI_BURST,port_id, stream_id )); stream->set_multi_burst(pkts_per_burst,num_bursts,ibg_usec); @@ -186,12 +186,7 @@ TrexRpcCmdAddStream::allocate_new_stream(const Json::Value §ion, uint8_t por void TrexRpcCmdAddStream::parse_rate(const Json::Value &rate, std::unique_ptr<TrexStream> &stream, Json::Value &result) { - double value = parse_double(rate, "value", result); - if (value <= 0) { - std::stringstream ss; - ss << "rate value must be a positive number - got: '" << value << "'"; - generate_parse_err(result, ss.str()); - } + double value = parse_udouble(rate, "value", result); auto rate_types = {"pps", "bps_L1", "bps_L2", "percentage"}; std::string rate_type = parse_choice(rate, "type", rate_types, result); @@ -533,7 +528,7 @@ TrexRpcCmdRemoveStream::_run(const Json::Value ¶ms, Json::Value &result) { uint8_t port_id = parse_port(params, result); TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id); - uint32_t stream_id = parse_int(params, "stream_id", result); + uint32_t stream_id = parse_uint32(params, "stream_id", result); TrexStream *stream = port->get_stream_by_id(stream_id); if (!stream) { @@ -615,7 +610,7 @@ TrexRpcCmdGetStream::_run(const Json::Value ¶ms, Json::Value &result) { TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id); bool get_pkt = parse_bool(params, "get_pkt", result); - uint32_t stream_id = parse_int(params, "stream_id", result); + uint32_t stream_id = parse_uint32(params, "stream_id", result); TrexStream *stream = port->get_stream_by_id(stream_id); @@ -660,9 +655,9 @@ TrexRpcCmdStartTraffic::_run(const Json::Value ¶ms, Json::Value &result) { std::string type = parse_choice(mul_obj, "type", TrexPortMultiplier::g_types, result); std::string op = parse_string(mul_obj, "op", result); - double value = parse_double(mul_obj, "value", result); + double value = parse_udouble(mul_obj, "value", result); - if ( value <=0 ){ + if ( value == 0 ){ generate_parse_err(result, "multiplier can't be zero"); } |