diff options
author | imarom <imarom@cisco.com> | 2016-11-22 15:48:40 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-11-22 15:48:40 +0200 |
commit | 6c18d6a2173ff2f3ecd031046077cd65d3ed8785 (patch) | |
tree | 8b0ad6ef47bf755a39f53d1b3012cac358bb28ec /src/stateless/rx | |
parent | c14a58893ba5d24057b72e4bc2381541f4558fcc (diff) |
RX features - added timestamp to RX packets
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'src/stateless/rx')
-rw-r--r-- | src/stateless/rx/trex_stateless_rx_port_mngr.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/stateless/rx/trex_stateless_rx_port_mngr.h b/src/stateless/rx/trex_stateless_rx_port_mngr.h index aa8ba8e9..fd023ea9 100644 --- a/src/stateless/rx/trex_stateless_rx_port_mngr.h +++ b/src/stateless/rx/trex_stateless_rx_port_mngr.h @@ -99,11 +99,17 @@ public: m_raw = (uint8_t *)malloc(m_size); memcpy(m_raw, p, m_size); + + /* save the packet timestamp */ + m_timestamp = now_sec(); } - /* RVO here - no performance impact */ - const std::string to_base64_str() const { - return base64_encode(m_raw, m_size); + /* slow path and also RVO - pass by value is ok */ + Json::Value to_json() { + Json::Value output; + output["ts"] = m_timestamp; + output["binary"] = base64_encode(m_raw, m_size); + return output; } ~RxPacket() { @@ -114,8 +120,9 @@ public: private: - uint8_t *m_raw; - uint16_t m_size; + uint8_t *m_raw; + uint16_t m_size; + dsec_t m_timestamp; }; /** @@ -194,7 +201,7 @@ public: int tmp = m_tail; while (tmp != m_head) { RxPacket *pkt = m_buffer[tmp]; - output.append(pkt->to_base64_str()); + output.append(pkt->to_json()); tmp = next(tmp); } |