本文整理汇总了C++中TrexStatelessPort::add_stream方法的典型用法代码示例。如果您正苦于以下问题:C++ TrexStatelessPort::add_stream方法的具体用法?C++ TrexStatelessPort::add_stream怎么用?C++ TrexStatelessPort::add_stream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrexStatelessPort
的用法示例。
在下文中一共展示了TrexStatelessPort::add_stream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
/***************************
* add new stream
*
**************************/
trex_rpc_cmd_rc_e
TrexRpcCmdAddStream::_run(const Json::Value ¶ms, Json::Value &result) {
uint8_t port_id = parse_port(params, result);
uint32_t stream_id = parse_int(params, "stream_id", 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, port_id, stream_id, result);
/* save this for future queries */
stream->store_stream_json(section);
/* 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, "isg", result);
stream->m_next_stream_id = parse_int(section, "next_stream_id", result);
const Json::Value &pkt = parse_object(section, "packet", result);
const Json::Value &pkt_binary = parse_array(pkt, "binary", result);
/* fetch the packet from the message */
stream->m_pkt.len = pkt_binary.size();
stream->m_pkt.binary = new uint8_t[pkt_binary.size()];
if (!stream->m_pkt.binary) {
generate_internal_err(result, "unable to allocate memory");
}
/* parse the packet */
for (int i = 0; i < pkt_binary.size(); i++) {
stream->m_pkt.binary[i] = parse_byte(pkt_binary, i, result);
}
/* meta data */
stream->m_pkt.meta = parse_string(pkt, "meta", result);
/* parse VM */
const Json::Value &vm = parse_object(section ,"vm", result);
parse_vm(vm, stream, 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_enabled", result);
}
/* make sure this is a valid stream to add */
validate_stream(stream, result);
TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(stream->m_port_id);
try {
port->add_stream(stream);
} catch (const TrexRpcException &ex) {
generate_execute_err(result, ex.what());
}
result["result"] = Json::objectValue;
return (TREX_RPC_CMD_OK);
}