summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/trex_rpc_cmd.cpp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-09-09 18:06:12 +0300
committerimarom <imarom@cisco.com>2015-09-09 18:56:11 +0300
commit54f8323b3938bf4ab672cde01a06711bfc522a2e (patch)
tree3454351e53499c2051715641e1b87b3e32f9a333 /src/rpc-server/trex_rpc_cmd.cpp
parente33befcf222fd2108d589dede11069d4256bb21a (diff)
added ownership to RPC server
Diffstat (limited to 'src/rpc-server/trex_rpc_cmd.cpp')
-rw-r--r--src/rpc-server/trex_rpc_cmd.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/rpc-server/trex_rpc_cmd.cpp b/src/rpc-server/trex_rpc_cmd.cpp
index 3fc77f71..437e8b1a 100644
--- a/src/rpc-server/trex_rpc_cmd.cpp
+++ b/src/rpc-server/trex_rpc_cmd.cpp
@@ -19,6 +19,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
#include <trex_rpc_cmd_api.h>
+#include <trex_rpc_server_api.h>
trex_rpc_cmd_rc_e
TrexRpcCommand::run(const Json::Value &params, Json::Value &result) {
@@ -26,8 +27,16 @@ TrexRpcCommand::run(const Json::Value &params, Json::Value &result) {
/* the internal run can throw a parser error / other error */
try {
+
check_param_count(params, m_param_count, result);
+
+ if (m_needs_ownership) {
+ verify_ownership(params, result);
+ }
+
+ /* run the command itself*/
rc = _run(params, result);
+
} catch (TrexRpcCommandException &e) {
return e.get_rc();
}
@@ -45,6 +54,15 @@ TrexRpcCommand::check_param_count(const Json::Value &params, int expected, Json:
}
}
+void
+TrexRpcCommand::verify_ownership(const Json::Value &params, Json::Value &result) {
+ std::string handler = parse_string(params, "handler", result);
+
+ if (!TrexRpcServer::verify_owner_handler(handler)) {
+ generate_execute_err(result, "invalid handler provided. please pass the handler given when calling 'acquire' or take ownership");
+ }
+}
+
const char *
TrexRpcCommand::type_to_str(field_type_e type) {
switch (type) {