summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/trex_rpc_cmd.cpp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-09-07 16:27:12 +0300
committerimarom <imarom@cisco.com>2015-09-07 16:27:12 +0300
commite33befcf222fd2108d589dede11069d4256bb21a (patch)
tree839e07e84cd658df6e0465558e80e27cec3288dc /src/rpc-server/trex_rpc_cmd.cpp
parent3adfe9c3c8a6e2ce1cdc5bd1a673e428c18fa64b (diff)
added VM support to the streams and RPC parser
Diffstat (limited to 'src/rpc-server/trex_rpc_cmd.cpp')
-rw-r--r--src/rpc-server/trex_rpc_cmd.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/rpc-server/trex_rpc_cmd.cpp b/src/rpc-server/trex_rpc_cmd.cpp
index 6988cba7..3fc77f71 100644
--- a/src/rpc-server/trex_rpc_cmd.cpp
+++ b/src/rpc-server/trex_rpc_cmd.cpp
@@ -50,6 +50,8 @@ TrexRpcCommand::type_to_str(field_type_e type) {
switch (type) {
case FIELD_TYPE_BYTE:
return "byte";
+ case FIELD_TYPE_UINT16:
+ return "uint16";
case FIELD_TYPE_BOOL:
return "bool";
case FIELD_TYPE_INT:
@@ -107,6 +109,18 @@ TrexRpcCommand::parse_byte(const Json::Value &parent, int index, Json::Value &re
return parent[index].asUInt();
}
+uint16_t
+TrexRpcCommand::parse_uint16(const Json::Value &parent, const std::string &name, Json::Value &result) {
+ check_field_type(parent, name, FIELD_TYPE_UINT16, result);
+ return parent[name].asUInt();
+}
+
+uint16_t
+TrexRpcCommand::parse_uint16(const Json::Value &parent, int index, Json::Value &result) {
+ check_field_type(parent, index, FIELD_TYPE_UINT16, 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);
@@ -190,6 +204,12 @@ TrexRpcCommand::check_field_type_common(const Json::Value &field, const std::str
}
break;
+ case FIELD_TYPE_UINT16:
+ if ( (!field.isUInt()) || (field.asInt() > 0xFFFF)) {
+ rc = false;
+ }
+ break;
+
case FIELD_TYPE_BOOL:
if (!field.isBool()) {
rc = false;