summaryrefslogtreecommitdiffstats
path: root/src/rpc-server
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-02-25 09:54:45 -0500
committerimarom <imarom@cisco.com>2016-02-25 09:57:23 -0500
commitaaef3f95683bfa1574537c543e4ffc86afb0480f (patch)
tree01bf5d21786fb59d13338a75b644eb0fa9a5f20d /src/rpc-server
parented7c04b5d7d5bb15aa13144e62caa786e73f7d05 (diff)
port attributes - promiscuous and etc.
Diffstat (limited to 'src/rpc-server')
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp36
-rw-r--r--src/rpc-server/commands/trex_rpc_cmds.h2
-rw-r--r--src/rpc-server/trex_rpc_cmds_table.cpp1
3 files changed, 38 insertions, 1 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index 9b3b59a7..05565179 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -208,6 +208,39 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
}
/**
+ * set port commands
+ *
+ * @author imarom (24-Feb-16)
+ *
+ * @param params
+ * @param result
+ *
+ * @return trex_rpc_cmd_rc_e
+ */
+trex_rpc_cmd_rc_e
+TrexRpcCmdSetPortAttr::_run(const Json::Value &params, Json::Value &result) {
+
+ uint8_t port_id = parse_port(params, result);
+ TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
+
+ const Json::Value &attr = parse_object(params, "attr", result);
+
+ /* iterate over all attributes in the dict */
+ for (const std::string &name : attr.getMemberNames()) {
+
+ /* handle promiscuous */
+ if (name == "promiscuous") {
+ bool enabled = parse_bool(attr[name], "enabled", result);
+ port->set_promiscuous(enabled);
+ }
+ }
+
+ result["result"] = Json::objectValue;
+ return (TREX_RPC_CMD_OK);
+}
+
+
+/**
* returns the current owner of the device
*
* @author imarom (08-Sep-15)
@@ -318,6 +351,9 @@ TrexRpcCmdGetPortStatus::_run(const Json::Value &params, Json::Value &result) {
result["result"]["state"] = port->get_state_as_string();
result["result"]["max_stream_id"] = port->get_max_stream_id();
+ /* attributes */
+ result["result"]["attr"]["promiscuous"]["enabled"] = port->get_promiscuous();
+
return (TREX_RPC_CMD_OK);
}
diff --git a/src/rpc-server/commands/trex_rpc_cmds.h b/src/rpc-server/commands/trex_rpc_cmds.h
index 9545e585..ac63e39d 100644
--- a/src/rpc-server/commands/trex_rpc_cmds.h
+++ b/src/rpc-server/commands/trex_rpc_cmds.h
@@ -81,7 +81,7 @@ TREX_RPC_CMD_DEFINE(TrexRpcCmdRelease, "release", 1, true);
*/
TREX_RPC_CMD_DEFINE(TrexRpcCmdGetPortStats, "get_port_stats", 1, false);
TREX_RPC_CMD_DEFINE(TrexRpcCmdGetPortStatus, "get_port_status", 1, false);
-
+TREX_RPC_CMD_DEFINE(TrexRpcCmdSetPortAttr, "set_port_attr", 3, false);
/**
* stream cmds
diff --git a/src/rpc-server/trex_rpc_cmds_table.cpp b/src/rpc-server/trex_rpc_cmds_table.cpp
index 5218cd0a..7b8dfdfc 100644
--- a/src/rpc-server/trex_rpc_cmds_table.cpp
+++ b/src/rpc-server/trex_rpc_cmds_table.cpp
@@ -43,6 +43,7 @@ TrexRpcCommandsTable::TrexRpcCommandsTable() {
register_command(new TrexRpcCmdRelease());
register_command(new TrexRpcCmdGetPortStats());
register_command(new TrexRpcCmdGetPortStatus());
+ register_command(new TrexRpcCmdSetPortAttr());
/* stream commands */