summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/commands/trex_rpc_cmd_general.cpp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-04-03 18:19:20 +0300
committerimarom <imarom@cisco.com>2016-04-04 09:49:54 +0300
commit4eacb570cf24927de536d23671f50609f1a9ffa5 (patch)
tree83b8dcd86994c7668a054413d0ba0449a1cf2816 /src/rpc-server/commands/trex_rpc_cmd_general.cpp
parent0eb15b2e851b5f50669633678143c5a1d3a7d95b (diff)
API classes (versions)
Diffstat (limited to 'src/rpc-server/commands/trex_rpc_cmd_general.cpp')
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index f054c0ed..f7a23188 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -38,6 +38,50 @@ limitations under the License.
using namespace std;
/**
+ * API sync
+ */
+trex_rpc_cmd_rc_e
+TrexRpcCmdAPISync::_run(const Json::Value &params, Json::Value &result) {
+ const Json::Value &api_vers = parse_array(params, "api_vers", result);
+
+ Json::Value api_ver_rc = Json::arrayValue;
+
+ /* for every element in the list - generate the appropirate API handler */
+ for (const auto api_ver : api_vers) {
+ Json::Value single_rc;
+
+ /* only those are supported */
+ const std::string type = parse_choice(api_ver, "type", {"core"}, result);
+
+ int major = parse_int(api_ver, "major", result);
+ int minor = parse_int(api_ver, "minor", result);
+ APIClass::type_e api_type;
+
+ /* decode type of API */
+ if (type == "core") {
+ api_type = APIClass::API_CLASS_TYPE_CORE;
+ }
+
+ single_rc["type"] = type;
+
+ /* this section might throw exception in case versions do not match */
+ try {
+ single_rc["api_h"] = get_stateless_obj()->verify_api(api_type, major, minor);
+
+ } catch (const TrexAPIException &e) {
+ generate_execute_err(result, e.what());
+ }
+
+ /* add to the response */
+ api_ver_rc.append(single_rc);
+ }
+
+ result["result"]["api_vers"] = api_ver_rc;
+
+ return (TREX_RPC_CMD_OK);
+}
+
+/**
* ping command
*/
trex_rpc_cmd_rc_e