diff options
Diffstat (limited to 'src/rpc-server/commands/trex_rpc_cmd_stream.cpp')
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_stream.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp index 8d813b7b..508967b9 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp @@ -249,13 +249,47 @@ TrexRpcCmdAddStream::parse_vm_instr_flow_var(const Json::Value &inst, TrexStream uint64_t init_value = parse_uint64(inst, "init_value", result); uint64_t min_value = parse_uint64(inst, "min_value", result); uint64_t max_value = parse_uint64(inst, "max_value", result); + uint64_t step = parse_uint64(inst, "step", result); + + if (max_value < min_value ) { + std::stringstream ss; + ss << "VM: request flow var variable '" << max_value << "' is smaller than " << min_value; + generate_parse_err(result, ss.str()); + } + + if (flow_var_size == 1 ) { + if ( (init_value > UINT8_MAX) || (min_value > UINT8_MAX) || (max_value > UINT8_MAX) || (step >UINT8_MAX) ) { + std::stringstream ss; + ss << "VM: request val is bigger than " << UINT8_MAX; + generate_parse_err(result, ss.str()); + } + } + + if (flow_var_size == 2 ) { + if ( (init_value > UINT16_MAX) || (min_value > UINT16_MAX) || (max_value > UINT16_MAX) || (step > UINT16_MAX) ) { + std::stringstream ss; + ss << "VM: request val is bigger than " << UINT16_MAX; + generate_parse_err(result, ss.str()); + } + } + + if (flow_var_size == 4 ) { + if ( (init_value > UINT32_MAX) || (min_value > UINT32_MAX) || (max_value > UINT32_MAX) || (step > UINT32_MAX) ) { + std::stringstream ss; + ss << "VM: request val is bigger than " << UINT32_MAX; + generate_parse_err(result, ss.str()); + } + } + stream->m_vm.add_instruction(new StreamVmInstructionFlowMan(flow_var_name, flow_var_size, op_type, init_value, min_value, - max_value)); + max_value, + step) + ); } void |