本文整理汇总了C++中TrexStatelessPort::get_owner方法的典型用法代码示例。如果您正苦于以下问题:C++ TrexStatelessPort::get_owner方法的具体用法?C++ TrexStatelessPort::get_owner怎么用?C++ TrexStatelessPort::get_owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrexStatelessPort
的用法示例。
在下文中一共展示了TrexStatelessPort::get_owner方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
/**
* fetch the port status
*
* @author imarom (09-Dec-15)
*
* @param params
* @param result
*
* @return trex_rpc_cmd_rc_e
*/
trex_rpc_cmd_rc_e
TrexRpcCmdGetPortStatus::_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);
result["result"]["owner"] = (port->get_owner().is_free() ? "" : port->get_owner().get_name());
result["result"]["state"] = port->get_state_as_string();
result["result"]["max_stream_id"] = port->get_max_stream_id();
return (TREX_RPC_CMD_OK);
}
示例2:
void
TrexRpcCommand::verify_ownership(const Json::Value ¶ms, Json::Value &result) {
std::string handler = parse_string(params, "handler", result);
uint8_t port_id = parse_port(params, result);
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
if (port->get_owner().is_free()) {
generate_execute_err(result, "please acquire the port before modifying port state");
}
if (!port->get_owner().verify(handler)) {
generate_execute_err(result, "port is not owned by you or your current executing session");
}
}
示例3: catch
/**
* push a remote PCAP on a port
*
*/
trex_rpc_cmd_rc_e
TrexRpcCmdPushRemote::_run(const Json::Value ¶ms, Json::Value &result) {
uint8_t port_id = parse_port(params, result);
std::string pcap_filename = parse_string(params, "pcap_filename", result);
double ipg_usec = parse_double(params, "ipg_usec", result);
double speedup = parse_double(params, "speedup", result);
uint32_t count = parse_uint32(params, "count", result);
double duration = parse_double(params, "duration", result);
bool is_dual = parse_bool(params, "is_dual", result, false);
std::string slave_handler = parse_string(params, "slave_handler", result, "");
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
/* for dual mode - make sure slave_handler matches */
if (is_dual) {
TrexStatelessPort *slave = get_stateless_obj()->get_port_by_id(port_id ^ 0x1);
if (!slave->get_owner().verify(slave_handler)) {
generate_execute_err(result, "incorrect or missing slave port handler");
}
}
try {
port->push_remote(pcap_filename, ipg_usec, speedup, count, duration, is_dual);
} catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
result["result"] = Json::objectValue;
return (TREX_RPC_CMD_OK);
}
示例4: return
/**
* returns the current owner of the device
*
* @author imarom (08-Sep-15)
*
* @param params
* @param result
*
* @return trex_rpc_cmd_rc_e
*/
trex_rpc_cmd_rc_e
TrexRpcCmdGetOwner::_run(const Json::Value ¶ms, Json::Value &result) {
Json::Value §ion = result["result"];
uint8_t port_id = parse_port(params, result);
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
section["owner"] = port->get_owner().get_name();
return (TREX_RPC_CMD_OK);
}
示例5: catch
/**
* acquire device
*
*/
trex_rpc_cmd_rc_e
TrexRpcCmdAcquire::_run(const Json::Value ¶ms, Json::Value &result) {
uint8_t port_id = parse_port(params, result);
const string &new_owner = parse_string(params, "user", result);
bool force = parse_bool(params, "force", result);
uint32_t session_id = parse_uint32(params, "session_id", result);
/* if not free and not you and not force - fail */
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
try {
port->acquire(new_owner, session_id, force);
} catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
result["result"] = port->get_owner().get_handler();
return (TREX_RPC_CMD_OK);
}