face: change Transport static properties initialization
Transport constructor now initializes static properties to invalid values.
Subclass constructor must explicitly set every static property.
refs #3259
Change-Id: I7ac3819694e0772c33a8a5d573e260f0eb944bff
diff --git a/daemon/face/internal-transport.cpp b/daemon/face/internal-transport.cpp
index d9dc238..070a4b5 100644
--- a/daemon/face/internal-transport.cpp
+++ b/daemon/face/internal-transport.cpp
@@ -40,6 +40,7 @@
this->setScope(scope);
this->setPersistency(ndn::nfd::FACE_PERSISTENCY_PERMANENT);
this->setLinkType(linkType);
+ this->setMtu(MTU_UNLIMITED);
NFD_LOG_FACE_INFO("Creating transport");
}
diff --git a/daemon/face/transport.cpp b/daemon/face/transport.cpp
index d6008f7..0c4f4ee 100644
--- a/daemon/face/transport.cpp
+++ b/daemon/face/transport.cpp
@@ -60,15 +60,13 @@
Transport::Transport()
: m_face(nullptr)
, m_service(nullptr)
- , m_scope(ndn::nfd::FACE_SCOPE_NON_LOCAL)
- , m_persistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
- , m_linkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT)
- , m_mtu(MTU_UNLIMITED)
+ , m_scope(ndn::nfd::FACE_SCOPE_NONE)
+ , m_persistency(ndn::nfd::FACE_PERSISTENCY_NONE)
+ , m_linkType(ndn::nfd::LINK_TYPE_NONE)
+ , m_mtu(MTU_INVALID)
, m_state(TransportState::UP)
, m_counters(nullptr)
{
- // warning: Subclass constructor must explicitly initialize all static properties
- // using setters, and should not rely on the defaults here.
}
Transport::~Transport()
diff --git a/daemon/face/transport.hpp b/daemon/face/transport.hpp
index b7f1c30..55efe3b 100644
--- a/daemon/face/transport.hpp
+++ b/daemon/face/transport.hpp
@@ -55,6 +55,10 @@
*/
const ssize_t MTU_UNLIMITED = -1;
+/** \brief (for internal use) indicates MTU field is unset
+ */
+const ssize_t MTU_INVALID = -2;
+
/** \brief the lower part of an LpFace
* \sa LpFace
*/
@@ -89,6 +93,14 @@
EndpointId remoteEndpoint;
};
+ /** \brief constructor
+ *
+ * Transport constructor initializes static properties to invalid values.
+ * Subclass constructor must explicitly set every static property.
+ *
+ * This constructor initializes TransportState to UP;
+ * subclass constructor can rely on this default value.
+ */
Transport();
virtual