本文整理汇总了C++中TrexStatelessPort::get_stream_by_id方法的典型用法代码示例。如果您正苦于以下问题:C++ TrexStatelessPort::get_stream_by_id方法的具体用法?C++ TrexStatelessPort::get_stream_by_id怎么用?C++ TrexStatelessPort::get_stream_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrexStatelessPort
的用法示例。
在下文中一共展示了TrexStatelessPort::get_stream_by_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
/***************************
* remove stream
*
**************************/
trex_rpc_cmd_rc_e
TrexRpcCmdRemoveStream::_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);
uint32_t stream_id = parse_int(params, "stream_id", result);
TrexStream *stream = port->get_stream_by_id(stream_id);
if (!stream) {
std::stringstream ss;
ss << "stream " << stream_id << " does not exists";
generate_execute_err(result, ss.str());
}
try {
port->remove_stream(stream);
} catch (const TrexRpcException &ex) {
generate_execute_err(result, ex.what());
}
delete stream;
result["result"] = Json::objectValue;
return (TREX_RPC_CMD_OK);
}
示例2: return
/***************************
* get stream by id
* on a specific port
*
**************************/
trex_rpc_cmd_rc_e
TrexRpcCmdGetStream::_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);
bool get_pkt = parse_bool(params, "get_pkt", result);
uint32_t stream_id = parse_int(params, "stream_id", result);
TrexStream *stream = port->get_stream_by_id(stream_id);
if (!stream) {
std::stringstream ss;
ss << "stream id " << stream_id << " on port " << (int)port_id << " does not exists";
generate_execute_err(result, ss.str());
}
/* return the stored stream json (instead of decoding it all over again) */
Json::Value j = stream->get_stream_json();
if (!get_pkt) {
j.removeMember("packet");
}
result["result"]["stream"] = j;
return (TREX_RPC_CMD_OK);
}
示例3:
void
TrexRpcCmdAddStream::validate_stream(const TrexStream *stream, Json::Value &result) {
/* check packet size */
if ( (stream->m_pkt.len < TrexStream::MIN_PKT_SIZE_BYTES) || (stream->m_pkt.len > TrexStream::MAX_PKT_SIZE_BYTES) ) {
std::stringstream ss;
ss << "bad packet size provided: should be between " << TrexStream::MIN_PKT_SIZE_BYTES << " and " << TrexStream::MAX_PKT_SIZE_BYTES;
delete stream;
generate_execute_err(result, ss.str());
}
/* port id should be between 0 and count - 1 */
if (stream->m_port_id >= get_stateless_obj()->get_port_count()) {
std::stringstream ss;
ss << "invalid port id - should be between 0 and " << (int)get_stateless_obj()->get_port_count() - 1;
delete stream;
generate_execute_err(result, ss.str());
}
/* add the stream to the port's stream table */
TrexStatelessPort * port = get_stateless_obj()->get_port_by_id(stream->m_port_id);
/* does such a stream exists ? */
if (port->get_stream_by_id(stream->m_stream_id)) {
std::stringstream ss;
ss << "stream " << stream->m_stream_id << " already exists";
delete stream;
generate_execute_err(result, ss.str());
}
}