本文整理汇总了C++中TrexStatelessPort::get_stream_table方法的典型用法代码示例。如果您正苦于以下问题:C++ TrexStatelessPort::get_stream_table方法的具体用法?C++ TrexStatelessPort::get_stream_table怎么用?C++ TrexStatelessPort::get_stream_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrexStatelessPort
的用法示例。
在下文中一共展示了TrexStatelessPort::get_stream_table方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
/***************************
* remove stream
*
**************************/
trex_rpc_cmd_rc_e
TrexRpcCmdRemoveStream::_run(const Json::Value ¶ms, Json::Value &result) {
uint8_t port_id = parse_byte(params, "port_id", result);
uint32_t stream_id = parse_int(params, "stream_id", result);
if (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;
generate_execute_err(result, ss.str());
}
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
TrexStream *stream = port->get_stream_table()->get_stream_by_id(stream_id);
if (!stream) {
std::stringstream ss;
ss << "stream " << stream_id << " does not exists";
generate_execute_err(result, ss.str());
}
port->get_stream_table()->remove_stream(stream);
delete stream;
result["result"] = "ACK";
return (TREX_RPC_CMD_OK);
}
示例2:
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_table()->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());
}
}
示例3: return
/***************************
* add new stream
*
**************************/
trex_rpc_cmd_rc_e
TrexRpcCmdAddStream::_run(const Json::Value ¶ms, Json::Value &result) {
const Json::Value §ion = parse_object(params, "stream", result);
/* get the type of the stream */
const Json::Value &mode = parse_object(section, "mode", result);
string type = parse_string(mode, "type", result);
/* allocate a new stream based on the type */
TrexStream *stream = allocate_new_stream(section, result);
/* some fields */
stream->m_enabled = parse_bool(section, "enabled", result);
stream->m_self_start = parse_bool(section, "self_start", result);
/* inter stream gap */
stream->m_isg_usec = parse_double(section, "Is", result);
stream->m_next_stream_id = parse_int(section, "next_stream_id", result);
const Json::Value &pkt = parse_array(section, "packet", result);
/* fetch the packet from the message */
stream->m_pkt_len = pkt.size();
stream->m_pkt = new uint8_t[pkt.size()];
if (!stream->m_pkt) {
generate_internal_err(result, "unable to allocate memory");
}
/* parse the packet */
for (int i = 0; i < pkt.size(); i++) {
stream->m_pkt[i] = parse_byte(pkt, i, result);
}
/* parse RX info */
const Json::Value &rx = parse_object(section, "rx_stats", result);
stream->m_rx_check.m_enable = parse_bool(rx, "enabled", result);
/* if it is enabled - we need more fields */
if (stream->m_rx_check.m_enable) {
stream->m_rx_check.m_stream_id = parse_int(rx, "stream_id", result);
stream->m_rx_check.m_seq_enabled = parse_bool(rx, "seq_enabled", result);
stream->m_rx_check.m_latency = parse_bool(rx, "latency", result);
}
/* make sure this is a valid stream to add */
validate_stream(stream, result);
TrexStatelessPort *port = get_trex_stateless()->get_port_by_id(stream->m_port_id);
port->get_stream_table()->add_stream(stream);
result["result"] = "ACK";
return (TREX_RPC_CMD_OK);
}
示例4:
/***************************
* remove all streams
* for a port
*
**************************/
trex_rpc_cmd_rc_e
TrexRpcCmdRemoveAllStreams::_run(const Json::Value ¶ms, Json::Value &result) {
uint8_t port_id = parse_byte(params, "port_id", result);
if (port_id >= get_trex_stateless()->get_port_count()) {
std::stringstream ss;
ss << "invalid port id - should be between 0 and " << (int)get_trex_stateless()->get_port_count() - 1;
generate_execute_err(result, ss.str());
}
TrexStatelessPort *port = get_trex_stateless()->get_port_by_id(port_id);
port->get_stream_table()->remove_and_delete_all_streams();
result["result"] = "ACK";
}