diff options
Diffstat (limited to 'src/rpc-server/trex_rpc_cmd.cpp')
-rw-r--r-- | src/rpc-server/trex_rpc_cmd.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/rpc-server/trex_rpc_cmd.cpp b/src/rpc-server/trex_rpc_cmd.cpp index af0db3f4..d4eef1f7 100644 --- a/src/rpc-server/trex_rpc_cmd.cpp +++ b/src/rpc-server/trex_rpc_cmd.cpp @@ -63,8 +63,12 @@ TrexRpcCommand::verify_ownership(const Json::Value ¶ms, Json::Value &result) TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id); - if (!port->verify_owner_handler(handler)) { - generate_execute_err(result, "invalid handler provided. please pass the handler given when calling 'acquire' or take ownership"); + if (port->get_owner().is_free()) { + generate_execute_err(result, "please acquire the port before modifying port state"); + } + + if (!port->get_owner().verify(handler)) { + generate_execute_err(result, "port is not owned by you or your current executing session"); } } @@ -92,6 +96,8 @@ TrexRpcCommand::type_to_str(field_type_e type) { return "byte"; case FIELD_TYPE_UINT16: return "uint16"; + case FIELD_TYPE_UINT32: + return "uint32"; case FIELD_TYPE_BOOL: return "bool"; case FIELD_TYPE_INT: @@ -161,6 +167,18 @@ TrexRpcCommand::parse_uint16(const Json::Value &parent, int index, Json::Value & return parent[index].asUInt(); } +uint32_t +TrexRpcCommand::parse_uint32(const Json::Value &parent, const std::string &name, Json::Value &result) { + check_field_type(parent, name, FIELD_TYPE_UINT32, result); + return parent[name].asUInt(); +} + +uint32_t +TrexRpcCommand::parse_uint32(const Json::Value &parent, int index, Json::Value &result) { + check_field_type(parent, index, FIELD_TYPE_UINT32, result); + return parent[index].asUInt(); +} + int TrexRpcCommand::parse_int(const Json::Value &parent, const std::string &name, Json::Value &result) { check_field_type(parent, name, FIELD_TYPE_INT, result); @@ -250,6 +268,12 @@ TrexRpcCommand::check_field_type_common(const Json::Value &field, const std::str } break; + case FIELD_TYPE_UINT32: + if ( (!field.isUInt()) || (field.asUInt() > 0xFFFFFFFF)) { + rc = false; + } + break; + case FIELD_TYPE_BOOL: if (!field.isBool()) { rc = false; |