diff options
author | 2016-02-25 09:54:45 -0500 | |
---|---|---|
committer | 2016-02-25 09:57:23 -0500 | |
commit | aaef3f95683bfa1574537c543e4ffc86afb0480f (patch) | |
tree | 01bf5d21786fb59d13338a75b644eb0fa9a5f20d /src/rpc-server/commands | |
parent | ed7c04b5d7d5bb15aa13144e62caa786e73f7d05 (diff) |
port attributes - promiscuous and etc.
Diffstat (limited to 'src/rpc-server/commands')
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_general.cpp | 36 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmds.h | 2 |
2 files changed, 37 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 ¶ms, 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 ¶ms, 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 ¶ms, 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 |