face/rib/tools: avoid deprecate Block::fromBuffer overloads
refs #2553
Change-Id: I32ea424ab7547f59fea2fca70ad6f41cd90bab58
diff --git a/daemon/face/datagram-face.hpp b/daemon/face/datagram-face.hpp
index 886a8b3..adbf9e6 100644
--- a/daemon/face/datagram-face.hpp
+++ b/daemon/face/datagram-face.hpp
@@ -215,8 +215,9 @@
NFD_LOG_FACE_TRACE("Received: " << nBytesReceived << " bytes");
this->getMutableCounters().getNInBytes() += nBytesReceived;
+ bool isOk = false;
Block element;
- bool isOk = Block::fromBuffer(buffer, nBytesReceived, element);
+ std::tie(isOk, element) = Block::fromBuffer(buffer, nBytesReceived);
if (!isOk)
{
NFD_LOG_FACE_WARN("Failed to parse incoming packet");
diff --git a/daemon/face/ethernet-face.cpp b/daemon/face/ethernet-face.cpp
index 8bd2c7b..d2cd9a1 100644
--- a/daemon/face/ethernet-face.cpp
+++ b/daemon/face/ethernet-face.cpp
@@ -381,8 +381,9 @@
length -= ethernet::HDR_LEN;
/// \todo Reserve space in front and at the back of the underlying buffer
+ bool isOk = false;
Block fragment;
- bool isOk = Block::fromBuffer(packet, length, fragment);
+ std::tie(isOk, fragment) = Block::fromBuffer(packet, length);
if (!isOk)
{
NFD_LOG_FACE_WARN("Block received from " << sourceAddress.toString()
diff --git a/daemon/face/stream-face.hpp b/daemon/face/stream-face.hpp
index fb51afd..fa743de 100644
--- a/daemon/face/stream-face.hpp
+++ b/daemon/face/stream-face.hpp
@@ -268,22 +268,21 @@
bool isOk = true;
Block element;
- while (m_inputBufferSize - offset > 0)
- {
- isOk = Block::fromBuffer(m_inputBuffer + offset, m_inputBufferSize - offset, element);
- if (!isOk)
- break;
+ while (m_inputBufferSize - offset > 0) {
+ std::tie(isOk, element) = Block::fromBuffer(m_inputBuffer + offset, m_inputBufferSize - offset);
+ if (!isOk)
+ break;
- offset += element.size();
+ offset += element.size();
- BOOST_ASSERT(offset <= m_inputBufferSize);
+ BOOST_ASSERT(offset <= m_inputBufferSize);
- if (!this->decodeAndDispatchInput(element))
- {
- NFD_LOG_FACE_WARN("Received unrecognized TLV block of type " << element.type());
- // ignore unknown packet and proceed
- }
+ if (!this->decodeAndDispatchInput(element)) {
+ NFD_LOG_FACE_WARN("Received unrecognized TLV block of type " << element.type());
+ // ignore unknown packet and proceed
}
+ }
+
if (!isOk && m_inputBufferSize == ndn::MAX_NDN_PACKET_SIZE && offset == 0)
{
NFD_LOG_FACE_WARN("Failed to parse incoming packet or packet too large to process");
diff --git a/daemon/face/websocket-face.cpp b/daemon/face/websocket-face.cpp
index 27a8f57..007e800 100644
--- a/daemon/face/websocket-face.cpp
+++ b/daemon/face/websocket-face.cpp
@@ -115,9 +115,10 @@
this->getMutableCounters().getNInBytes() += msg.size();
// Try to parse message data
+ bool isOk = false;
Block element;
- bool isOk = Block::fromBuffer(reinterpret_cast<const uint8_t*>(msg.c_str()),
- msg.size(), element);
+ std::tie(isOk, element) = Block::fromBuffer(reinterpret_cast<const uint8_t*>(msg.c_str()),
+ msg.size());
if (!isOk)
{
NFD_LOG_FACE_WARN("Received block is invalid or too large to process");