summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/trex_rpc_cmd_api.h
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2015-09-17 21:46:17 +0300
committerHanoh Haim <hhaim@cisco.com>2015-09-17 21:46:17 +0300
commita78680a896f65dd6733d27d99e9cd8440eb185e9 (patch)
treed7b9e514b413847944e39eb1dcc874b4c9044c42 /src/rpc-server/trex_rpc_cmd_api.h
parentf885ac59cebcf1e87b97b0e6ef6e9eb032f9f733 (diff)
parentf61bbcca4ab21100068887b1a08bf9bdf250f14d (diff)
Merge branch 'master' of csi-sceasr-b45:/auto/proj-pcube-b/apps/PL-b/tools/repo//trex-corev1.76
Diffstat (limited to 'src/rpc-server/trex_rpc_cmd_api.h')
-rw-r--r--src/rpc-server/trex_rpc_cmd_api.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/rpc-server/trex_rpc_cmd_api.h b/src/rpc-server/trex_rpc_cmd_api.h
index def52fca..3c718eaa 100644
--- a/src/rpc-server/trex_rpc_cmd_api.h
+++ b/src/rpc-server/trex_rpc_cmd_api.h
@@ -68,8 +68,15 @@ public:
/**
* method name and params
*/
- TrexRpcCommand(const std::string &method_name, int param_count) : m_name(method_name), m_param_count(param_count) {
-
+ TrexRpcCommand(const std::string &method_name, int param_count, bool needs_ownership) :
+ m_name(method_name),
+ m_param_count(param_count),
+ m_needs_ownership(needs_ownership) {
+
+ /* if needs ownership - another field is needed (handler) */
+ if (m_needs_ownership) {
+ m_param_count++;
+ }
}
/**
@@ -112,6 +119,18 @@ protected:
void check_param_count(const Json::Value &params, int expected, Json::Value &result);
/**
+ * verify ownership
+ *
+ */
+ void verify_ownership(const Json::Value &params, Json::Value &result);
+
+ /**
+ * validate port id
+ *
+ */
+ void validate_port_id(uint8_t port_id, Json::Value &result);
+
+ /**
* parse functions
*
*/
@@ -133,6 +152,9 @@ protected:
const Json::Value & parse_object(const Json::Value &parent, int index, Json::Value &result);
const Json::Value & parse_array(const Json::Value &parent, int index, Json::Value &result);
+ /* shortcut for parsing port id */
+ uint8_t parse_port(const Json::Value &params, Json::Value &result);
+
/**
* parse a field from choices
*
@@ -164,6 +186,9 @@ protected:
s.pop_back();
s += "]";
generate_parse_err(result, s);
+
+ /* dummy return value - does not matter, the above will throw exception */
+ return (*choices.begin());
}
/**
@@ -209,6 +234,7 @@ protected:
/* RPC command name */
std::string m_name;
int m_param_count;
+ bool m_needs_ownership;
};
#endif /* __TREX_RPC_CMD_API_H__ */