summaryrefslogtreecommitdiffstats
path: root/src/rpc-server
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-01-26 16:57:41 -0500
committerimarom <imarom@cisco.com>2016-01-26 16:57:41 -0500
commitea3f39cd42ea667d1928564a25bffca19275cfeb (patch)
treee66c13220f660857f5adc69f36d5241c2ed1e80a /src/rpc-server
parentdb6254e3c59ef887ff41ff2aff44349010bd6bad (diff)
1. fixed failing regression test
2. enabled STL nose tests 3. fixed packet size padding to 60
Diffstat (limited to 'src/rpc-server')
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_stream.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
index dc8a9ccd..69e5dd18 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
@@ -65,17 +65,27 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
const Json::Value &pkt = parse_object(section, "packet", result);
std::string pkt_binary = base64_decode(parse_string(pkt, "binary", result));
+ /* check packet size */
+ if ( (pkt_binary.size() < TrexStream::MIN_PKT_SIZE_BYTES) || (pkt_binary.size() > 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());
+ }
+
/* fetch the packet from the message */
- stream->m_pkt.len = pkt_binary.size();
- stream->m_pkt.binary = new uint8_t[pkt_binary.size()];
+ stream->m_pkt.len = std::max(pkt_binary.size(), 60UL);
+
+ /* allocate and init to zero ( with () ) */
+ stream->m_pkt.binary = new uint8_t[pkt_binary.size()]();
if (!stream->m_pkt.binary) {
generate_internal_err(result, "unable to allocate memory");
}
- /* copy the packet */
const char *pkt_buffer = pkt_binary.c_str();
+ /* copy the packet - if less than 60 it will remain zeroes */
for (int i = 0; i < pkt_binary.size(); i++) {
stream->m_pkt.binary[i] = pkt_buffer[i];
}
@@ -306,14 +316,6 @@ TrexRpcCmdAddStream::parse_vm(const Json::Value &vm, TrexStream *stream, Json::V
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());
- }
-
/* add the stream to the port's stream table */
TrexStatelessPort * port = get_stateless_obj()->get_port_by_id(stream->m_port_id);