management: replace FaceFlags with individual fields
refs #1992
Change-Id: I2b8e999fcf27444b8f3805f23da9f8ef9bcb5624
diff --git a/src/encoding/tlv-nfd.hpp b/src/encoding/tlv-nfd.hpp
index 3cde88b..9f7d5f8 100644
--- a/src/encoding/tlv-nfd.hpp
+++ b/src/encoding/tlv-nfd.hpp
@@ -61,7 +61,9 @@
FaceStatus = 128,
LocalUri = 129,
ChannelStatus = 130,
- FaceFlags = 194,
+ FaceScope = 132,
+ FacePersistency = 133,
+ LinkType = 134,
FaceEventNotification = 192,
FaceEventKind = 193,
diff --git a/src/management/nfd-face-event-notification.cpp b/src/management/nfd-face-event-notification.cpp
new file mode 100644
index 0000000..d459de4
--- /dev/null
+++ b/src/management/nfd-face-event-notification.cpp
@@ -0,0 +1,186 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "nfd-face-event-notification.hpp"
+
+namespace ndn {
+namespace nfd {
+FaceEventNotification::FaceEventNotification()
+ : FaceTraits()
+ , m_kind(static_cast<FaceEventKind>(0))
+{
+}
+
+FaceEventNotification::FaceEventNotification(const Block& block)
+{
+ this->wireDecode(block);
+}
+
+template<bool T>
+size_t
+FaceEventNotification::wireEncode(EncodingImpl<T>& encoder) const
+{
+ size_t totalLength = 0;
+
+ totalLength += prependNonNegativeIntegerBlock(encoder,
+ tlv::nfd::LinkType, m_linkType);
+ totalLength += prependNonNegativeIntegerBlock(encoder,
+ tlv::nfd::FacePersistency, m_facePersistency);
+ totalLength += prependNonNegativeIntegerBlock(encoder,
+ tlv::nfd::FaceScope, m_faceScope);
+ totalLength += prependByteArrayBlock(encoder, tlv::nfd::LocalUri,
+ reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size());
+ totalLength += prependByteArrayBlock(encoder, tlv::nfd::Uri,
+ reinterpret_cast<const uint8_t*>(m_remoteUri.c_str()), m_remoteUri.size());
+ totalLength += prependNonNegativeIntegerBlock(encoder,
+ tlv::nfd::FaceId, m_faceId);
+ totalLength += prependNonNegativeIntegerBlock(encoder,
+ tlv::nfd::FaceEventKind, m_kind);
+
+ totalLength += encoder.prependVarNumber(totalLength);
+ totalLength += encoder.prependVarNumber(tlv::nfd::FaceEventNotification);
+ return totalLength;
+}
+
+const Block&
+FaceEventNotification::wireEncode() const
+{
+ if (m_wire.hasWire())
+ return m_wire;
+
+ EncodingEstimator estimator;
+ size_t estimatedSize = wireEncode(estimator);
+
+ EncodingBuffer buffer(estimatedSize, 0);
+ wireEncode(buffer);
+
+ m_wire = buffer.block();
+ return m_wire;
+}
+
+void
+FaceEventNotification::wireDecode(const Block& block)
+{
+ if (block.type() != tlv::nfd::FaceEventNotification) {
+ throw Error("expecting FaceEventNotification block");
+ }
+ m_wire = block;
+ m_wire.parse();
+ Block::element_const_iterator val = m_wire.elements_begin();
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceEventKind) {
+ m_kind = static_cast<FaceEventKind>(readNonNegativeInteger(*val));
+ ++val;
+ }
+ else {
+ throw Error("missing required FaceEventKind field");
+ }
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceId) {
+ m_faceId = readNonNegativeInteger(*val);
+ ++val;
+ }
+ else {
+ throw Error("missing required FaceId field");
+ }
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::Uri) {
+ m_remoteUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
+ ++val;
+ }
+ else {
+ throw Error("missing required Uri field");
+ }
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::LocalUri) {
+ m_localUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
+ ++val;
+ }
+ else {
+ throw Error("missing required LocalUri field");
+ }
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceScope) {
+ m_faceScope = static_cast<FaceScope>(readNonNegativeInteger(*val));
+ ++val;
+ }
+ else {
+ throw Error("missing required FaceScope field");
+ }
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::FacePersistency) {
+ m_facePersistency = static_cast<FacePersistency>(readNonNegativeInteger(*val));
+ ++val;
+ }
+ else {
+ throw Error("missing required FacePersistency field");
+ }
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::LinkType) {
+ m_linkType = static_cast<LinkType>(readNonNegativeInteger(*val));
+ ++val;
+ }
+ else {
+ throw Error("missing required LinkType field");
+ }
+}
+
+FaceEventNotification&
+FaceEventNotification::setKind(FaceEventKind kind)
+{
+ m_wire.reset();
+ m_kind = kind;
+ return *this;
+}
+
+void
+FaceEventNotification::wireReset() const
+{
+ m_wire.reset();
+}
+
+std::ostream&
+operator<<(std::ostream& os, const FaceEventNotification& notification)
+{
+ os << "FaceEventNotification(";
+
+ switch (notification.getKind())
+ {
+ case FACE_EVENT_CREATED:
+ os << "Kind: created, ";
+ break;
+ case FACE_EVENT_DESTROYED:
+ os << "Kind: destroyed, ";
+ break;
+ }
+
+ os << "FaceID: " << notification.getFaceId() << ", "
+ << "RemoteUri: " << notification.getRemoteUri() << ", "
+ << "LocalUri: " << notification.getLocalUri() << ", "
+ << "FaceScope: " << notification.getFaceScope() << ", "
+ << "FacePersistency: " << notification.getFacePersistency() << ", "
+ << "LinkType: " << notification.getLinkType()
+ << ")";
+ return os;
+}
+
+} // namespace nfd
+} // namespace ndn
diff --git a/src/management/nfd-face-event-notification.hpp b/src/management/nfd-face-event-notification.hpp
index a455e57..94870d9 100644
--- a/src/management/nfd-face-event-notification.hpp
+++ b/src/management/nfd-face-event-notification.hpp
@@ -23,11 +23,7 @@
#define NDN_MANAGEMENT_NFD_FACE_EVENT_NOTIFICATION_HPP
// This include must be kept as the first one, to ensure nfd-face-flags.hpp compiles on its own.
-#include "nfd-face-flags.hpp"
-
-#include "../encoding/tlv-nfd.hpp"
-#include "../encoding/encoding-buffer.hpp"
-#include "../encoding/block-helpers.hpp"
+#include "nfd-face-traits.hpp"
namespace ndn {
namespace nfd {
@@ -45,26 +41,13 @@
* \brief represents a Face status change notification
* \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Status-Change-Notification
*/
-class FaceEventNotification : public FaceFlagsTraits<FaceEventNotification>
+class FaceEventNotification : public FaceTraits<FaceEventNotification>
{
public:
- class Error : public tlv::Error
- {
- public:
- explicit
- Error(const std::string& what)
- : tlv::Error(what)
- {
- }
- };
-
FaceEventNotification();
explicit
- FaceEventNotification(const Block& block)
- {
- this->wireDecode(block);
- }
+ FaceEventNotification(const Block& block);
/** \brief prepend FaceEventNotification to the encoder
*/
@@ -90,198 +73,20 @@
}
FaceEventNotification&
- setKind(FaceEventKind kind)
- {
- m_wire.reset();
- m_kind = kind;
- return *this;
- }
+ setKind(FaceEventKind kind);
- uint64_t
- getFaceId() const
- {
- return m_faceId;
- }
-
- FaceEventNotification&
- setFaceId(uint64_t faceId)
- {
- m_wire.reset();
- m_faceId = faceId;
- return *this;
- }
-
- const std::string&
- getRemoteUri() const
- {
- return m_remoteUri;
- }
-
- FaceEventNotification&
- setRemoteUri(const std::string& remoteUri)
- {
- m_wire.reset();
- m_remoteUri = remoteUri;
- return *this;
- }
-
- const std::string&
- getLocalUri() const
- {
- return m_localUri;
- }
-
- FaceEventNotification&
- setLocalUri(const std::string& localUri)
- {
- m_wire.reset();
- m_localUri = localUri;
- return *this;
- }
-
- uint64_t
- getFlags() const
- {
- return m_flags;
- }
-
- FaceEventNotification&
- setFlags(uint64_t flags)
- {
- m_wire.reset();
- m_flags = flags;
- return *this;
- }
+protected:
+ void
+ wireReset() const;
private:
FaceEventKind m_kind;
- uint64_t m_faceId;
- std::string m_remoteUri;
- std::string m_localUri;
- uint64_t m_flags;
mutable Block m_wire;
};
-inline
-FaceEventNotification::FaceEventNotification()
- : m_kind(static_cast<FaceEventKind>(0))
- , m_faceId(0)
- , m_flags(0)
-{
-}
-
-template<bool T>
-inline size_t
-FaceEventNotification::wireEncode(EncodingImpl<T>& encoder) const
-{
- size_t totalLength = 0;
-
- totalLength += prependNonNegativeIntegerBlock(encoder,
- tlv::nfd::FaceFlags, m_flags);
- totalLength += prependByteArrayBlock(encoder, tlv::nfd::LocalUri,
- reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size());
- totalLength += prependByteArrayBlock(encoder, tlv::nfd::Uri,
- reinterpret_cast<const uint8_t*>(m_remoteUri.c_str()), m_remoteUri.size());
- totalLength += prependNonNegativeIntegerBlock(encoder,
- tlv::nfd::FaceId, m_faceId);
- totalLength += prependNonNegativeIntegerBlock(encoder,
- tlv::nfd::FaceEventKind, m_kind);
-
- totalLength += encoder.prependVarNumber(totalLength);
- totalLength += encoder.prependVarNumber(tlv::nfd::FaceEventNotification);
- return totalLength;
-}
-
-inline const Block&
-FaceEventNotification::wireEncode() const
-{
- if (m_wire.hasWire())
- return m_wire;
-
- EncodingEstimator estimator;
- size_t estimatedSize = wireEncode(estimator);
-
- EncodingBuffer buffer(estimatedSize, 0);
- wireEncode(buffer);
-
- m_wire = buffer.block();
- return m_wire;
-}
-
-inline void
-FaceEventNotification::wireDecode(const Block& block)
-{
- if (block.type() != tlv::nfd::FaceEventNotification) {
- throw Error("expecting FaceEventNotification block");
- }
- m_wire = block;
- m_wire.parse();
- Block::element_const_iterator val = m_wire.elements_begin();
-
- if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceEventKind) {
- m_kind = static_cast<FaceEventKind>(readNonNegativeInteger(*val));
- ++val;
- }
- else {
- throw Error("missing required FaceEventKind field");
- }
-
- if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceId) {
- m_faceId = static_cast<uint64_t>(readNonNegativeInteger(*val));
- ++val;
- }
- else {
- throw Error("missing required FaceId field");
- }
-
- if (val != m_wire.elements_end() && val->type() == tlv::nfd::Uri) {
- m_remoteUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
- ++val;
- }
- else {
- throw Error("missing required Uri field");
- }
-
- if (val != m_wire.elements_end() && val->type() == tlv::nfd::LocalUri) {
- m_localUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
- ++val;
- }
- else {
- throw Error("missing required LocalUri field");
- }
-
- if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceFlags) {
- m_flags = static_cast<uint64_t>(readNonNegativeInteger(*val));
- ++val;
- }
- else {
- throw Error("missing required FaceFlags field");
- }
-}
-
-inline std::ostream&
-operator<<(std::ostream& os, const FaceEventNotification& notification)
-{
- os << "FaceEventNotification(";
-
- switch (notification.getKind())
- {
- case FACE_EVENT_CREATED:
- os << "Kind: created, ";
- break;
- case FACE_EVENT_DESTROYED:
- os << "Kind: destroyed, ";
- break;
- }
-
- os << "FaceID: " << notification.getFaceId() << ", "
- << "RemoteUri: " << notification.getRemoteUri() << ", "
- << "LocalUri: " << notification.getLocalUri() << ", "
- << "Flags: " << notification.getFlags()
- << ")";
- return os;
-}
+std::ostream&
+operator<<(std::ostream& os, const FaceEventNotification& notification);
} // namespace nfd
} // namespace ndn
diff --git a/src/management/nfd-face-flags.hpp b/src/management/nfd-face-flags.hpp
deleted file mode 100644
index 39c85cb..0000000
--- a/src/management/nfd-face-flags.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2014 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#ifndef NDN_MANAGEMENT_NFD_FACE_FLAGS_HPP
-#define NDN_MANAGEMENT_NFD_FACE_FLAGS_HPP
-
-namespace ndn {
-namespace nfd {
-
-/**
- * \ingroup management
- * \brief provides additional information about a face
- */
-enum FaceFlags {
- /** \brief face is local (for scope control purpose)
- */
- FACE_IS_LOCAL = 1,
- /** \brief face is created on demand (accepted incoming connection,
- * not initiated outgoing connection)
- */
- FACE_IS_ON_DEMAND = 2
- // FACE_? = 4
- // FACE_? = 8
-};
-
-/**
- * \ingroup management
- * \brief implements getters to each face flag
- *
- * \tparam T class containing a FaceFlags field and implements
- * `FaceFlags getFlags() const` method
- */
-template<typename T>
-class FaceFlagsTraits
-{
-public:
- bool
- isLocal() const
- {
- return static_cast<const T*>(this)->getFlags() & FACE_IS_LOCAL;
- }
-
- bool
- isOnDemand() const
- {
- return static_cast<const T*>(this)->getFlags() & FACE_IS_ON_DEMAND;
- }
-};
-
-} // namespace nfd
-} // namespace ndn
-
-#endif // NDN_MANAGEMENT_NFD_FACE_FLAGS_HPP
diff --git a/src/management/nfd-face-status.cpp b/src/management/nfd-face-status.cpp
index adf29c2..17145bd 100644
--- a/src/management/nfd-face-status.cpp
+++ b/src/management/nfd-face-status.cpp
@@ -25,9 +25,8 @@
namespace nfd {
FaceStatus::FaceStatus()
- : m_faceId(0)
+ : FaceTraits()
, m_hasExpirationPeriod(false)
- , m_flags(0)
, m_nInInterests(0)
, m_nInDatas(0)
, m_nOutInterests(0)
@@ -37,6 +36,11 @@
{
}
+FaceStatus::FaceStatus(const Block& block)
+{
+ this->wireDecode(block);
+}
+
template<bool T>
size_t
FaceStatus::wireEncode(EncodingImpl<T>& encoder) const
@@ -56,7 +60,11 @@
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::NInInterests, m_nInInterests);
totalLength += prependNonNegativeIntegerBlock(encoder,
- tlv::nfd::FaceFlags, m_flags);
+ tlv::nfd::LinkType, m_linkType);
+ totalLength += prependNonNegativeIntegerBlock(encoder,
+ tlv::nfd::FacePersistency, m_facePersistency);
+ totalLength += prependNonNegativeIntegerBlock(encoder,
+ tlv::nfd::FaceScope, m_faceScope);
if (m_hasExpirationPeriod) {
totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::ExpirationPeriod, m_expirationPeriod.count());
@@ -139,12 +147,28 @@
// ExpirationPeriod is optional
}
- if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceFlags) {
- m_flags = readNonNegativeInteger(*val);
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceScope) {
+ m_faceScope = static_cast<FaceScope>(readNonNegativeInteger(*val));
++val;
}
else {
- throw Error("missing required FaceFlags field");
+ throw Error("missing required FaceScope field");
+ }
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::FacePersistency) {
+ m_facePersistency = static_cast<FacePersistency>(readNonNegativeInteger(*val));
+ ++val;
+ }
+ else {
+ throw Error("missing required FacePersistency field");
+ }
+
+ if (val != m_wire.elements_end() && val->type() == tlv::nfd::LinkType) {
+ m_linkType = static_cast<LinkType>(readNonNegativeInteger(*val));
+ ++val;
+ }
+ else {
+ throw Error("missing required LinkType field");
}
if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInInterests) {
@@ -196,6 +220,69 @@
}
}
+FaceStatus&
+FaceStatus::setExpirationPeriod(const time::milliseconds& expirationPeriod)
+{
+ m_wire.reset();
+ m_expirationPeriod = expirationPeriod;
+ m_hasExpirationPeriod = true;
+ return *this;
+}
+
+FaceStatus&
+FaceStatus::setNInInterests(uint64_t nInInterests)
+{
+ m_wire.reset();
+ m_nInInterests = nInInterests;
+ return *this;
+}
+
+FaceStatus&
+FaceStatus::setNInDatas(uint64_t nInDatas)
+{
+ m_wire.reset();
+ m_nInDatas = nInDatas;
+ return *this;
+}
+
+FaceStatus&
+FaceStatus::setNOutInterests(uint64_t nOutInterests)
+{
+ m_wire.reset();
+ m_nOutInterests = nOutInterests;
+ return *this;
+}
+
+FaceStatus&
+FaceStatus::setNOutDatas(uint64_t nOutDatas)
+{
+ m_wire.reset();
+ m_nOutDatas = nOutDatas;
+ return *this;
+}
+
+FaceStatus&
+FaceStatus::setNInBytes(uint64_t nInBytes)
+{
+ m_wire.reset();
+ m_nInBytes = nInBytes;
+ return *this;
+}
+
+FaceStatus&
+FaceStatus::setNOutBytes(uint64_t nOutBytes)
+{
+ m_wire.reset();
+ m_nOutBytes = nOutBytes;
+ return *this;
+}
+
+void
+FaceStatus::wireReset() const
+{
+ m_wire.reset();
+}
+
std::ostream&
operator<<(std::ostream& os, const FaceStatus& status)
{
@@ -211,7 +298,9 @@
os << "ExpirationPeriod: infinite,\n";
}
- os << "Flags: " << status.getFlags() << ",\n"
+ os << "FaceScope: " << status.getFaceScope() << ",\n"
+ << "FacePersistency: " << status.getFacePersistency() << ",\n"
+ << "LinkType: " << status.getLinkType() << ",\n"
<< "Counters: { Interests: {in: " << status.getNInInterests() << ", "
<< "out: " << status.getNOutInterests() << "},\n"
<< " Data: {in: " << status.getNInDatas() << ", "
diff --git a/src/management/nfd-face-status.hpp b/src/management/nfd-face-status.hpp
index eff9c83..237b3f1 100644
--- a/src/management/nfd-face-status.hpp
+++ b/src/management/nfd-face-status.hpp
@@ -23,11 +23,8 @@
#define NDN_MANAGEMENT_NFD_FACE_STATUS_HPP
// This include must be kept as the first one, to ensure nfd-face-flags.hpp compiles on its own.
-#include "nfd-face-flags.hpp"
+#include "nfd-face-traits.hpp"
-#include "../encoding/tlv-nfd.hpp"
-#include "../encoding/encoding-buffer.hpp"
-#include "../encoding/block-helpers.hpp"
#include "../util/time.hpp"
namespace ndn {
@@ -38,26 +35,13 @@
* \brief represents Face status
* \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
*/
-class FaceStatus : public FaceFlagsTraits<FaceStatus>
+class FaceStatus : public FaceTraits<FaceStatus>
{
public:
- class Error : public tlv::Error
- {
- public:
- explicit
- Error(const std::string& what)
- : tlv::Error(what)
- {
- }
- };
-
FaceStatus();
explicit
- FaceStatus(const Block& block)
- {
- this->wireDecode(block);
- }
+ FaceStatus(const Block& block);
/** \brief prepend FaceStatus to the encoder
*/
@@ -76,48 +60,6 @@
wireDecode(const Block& wire);
public: // getters & setters
- uint64_t
- getFaceId() const
- {
- return m_faceId;
- }
-
- FaceStatus&
- setFaceId(uint64_t faceId)
- {
- m_wire.reset();
- m_faceId = faceId;
- return *this;
- }
-
- const std::string&
- getRemoteUri() const
- {
- return m_remoteUri;
- }
-
- FaceStatus&
- setRemoteUri(const std::string& remoteUri)
- {
- m_wire.reset();
- m_remoteUri = remoteUri;
- return *this;
- }
-
- const std::string&
- getLocalUri() const
- {
- return m_localUri;
- }
-
- FaceStatus&
- setLocalUri(const std::string& localUri)
- {
- m_wire.reset();
- m_localUri = localUri;
- return *this;
- }
-
bool
hasExpirationPeriod() const
{
@@ -132,26 +74,7 @@
}
FaceStatus&
- setExpirationPeriod(const time::milliseconds& expirationPeriod)
- {
- m_expirationPeriod = expirationPeriod;
- m_hasExpirationPeriod = true;
- return *this;
- }
-
- uint64_t
- getFlags() const
- {
- return m_flags;
- }
-
- FaceStatus&
- setFlags(uint64_t flags)
- {
- m_wire.reset();
- m_flags = flags;
- return *this;
- }
+ setExpirationPeriod(const time::milliseconds& expirationPeriod);
uint64_t
getNInInterests() const
@@ -160,12 +83,7 @@
}
FaceStatus&
- setNInInterests(uint64_t nInInterests)
- {
- m_wire.reset();
- m_nInInterests = nInInterests;
- return *this;
- }
+ setNInInterests(uint64_t nInInterests);
uint64_t
getNInDatas() const
@@ -174,12 +92,7 @@
}
FaceStatus&
- setNInDatas(uint64_t nInDatas)
- {
- m_wire.reset();
- m_nInDatas = nInDatas;
- return *this;
- }
+ setNInDatas(uint64_t nInDatas);
uint64_t
getNOutInterests() const
@@ -188,12 +101,7 @@
}
FaceStatus&
- setNOutInterests(uint64_t nOutInterests)
- {
- m_wire.reset();
- m_nOutInterests = nOutInterests;
- return *this;
- }
+ setNOutInterests(uint64_t nOutInterests);
uint64_t
getNOutDatas() const
@@ -202,12 +110,7 @@
}
FaceStatus&
- setNOutDatas(uint64_t nOutDatas)
- {
- m_wire.reset();
- m_nOutDatas = nOutDatas;
- return *this;
- }
+ setNOutDatas(uint64_t nOutDatas);
uint64_t
getNInBytes() const
@@ -216,12 +119,7 @@
}
FaceStatus&
- setNInBytes(uint64_t nInBytes)
- {
- m_wire.reset();
- m_nInBytes = nInBytes;
- return *this;
- }
+ setNInBytes(uint64_t nInBytes);
uint64_t
getNOutBytes() const
@@ -230,20 +128,15 @@
}
FaceStatus&
- setNOutBytes(uint64_t nOutBytes)
- {
- m_wire.reset();
- m_nOutBytes = nOutBytes;
- return *this;
- }
+ setNOutBytes(uint64_t nOutBytes);
+
+protected:
+ void
+ wireReset() const;
private:
- uint64_t m_faceId;
- std::string m_remoteUri;
- std::string m_localUri;
time::milliseconds m_expirationPeriod;
bool m_hasExpirationPeriod;
- uint64_t m_flags;
uint64_t m_nInInterests;
uint64_t m_nInDatas;
uint64_t m_nOutInterests;
diff --git a/src/management/nfd-face-traits.cpp b/src/management/nfd-face-traits.cpp
new file mode 100644
index 0000000..5556046
--- /dev/null
+++ b/src/management/nfd-face-traits.cpp
@@ -0,0 +1,82 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "nfd-face-traits.hpp"
+
+namespace ndn {
+namespace nfd {
+
+std::ostream&
+operator<<(std::ostream& os, FaceScope faceScope)
+{
+ switch (faceScope) {
+ case FACE_SCOPE_NON_LOCAL:
+ os << "non-local";
+ break;
+ case FACE_SCOPE_LOCAL:
+ os << "local";
+ break;
+ default:
+ os << "unknown";
+ break;
+ }
+ return os;
+}
+
+std::ostream&
+operator<<(std::ostream& os, FacePersistency facePersistency)
+{
+ switch (facePersistency) {
+ case FACE_PERSISTENCY_PERSISTENT:
+ os << "persistent";
+ break;
+ case FACE_PERSISTENCY_ON_DEMAND:
+ os << "on-demand";
+ break;
+ case FACE_PERSISTENCY_PERMANENT:
+ os << "permanent";
+ break;
+ default:
+ os << "unknown";
+ break;
+ }
+ return os;
+}
+
+std::ostream&
+operator<<(std::ostream& os, LinkType linkType)
+{
+ switch (linkType) {
+ case LINK_TYPE_POINT_TO_POINT:
+ os << "point-to-point";
+ break;
+ case LINK_TYPE_MULTI_ACCESS:
+ os << "multi-access";
+ break;
+ default:
+ os << "unknown";
+ break;
+ }
+ return os;
+}
+
+} // namespace nfd
+} // namespace ndn
diff --git a/src/management/nfd-face-traits.hpp b/src/management/nfd-face-traits.hpp
new file mode 100644
index 0000000..db4aef4
--- /dev/null
+++ b/src/management/nfd-face-traits.hpp
@@ -0,0 +1,274 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#ifndef NDN_MANAGEMENT_NFD_FACE_TRAITS_HPP
+#define NDN_MANAGEMENT_NFD_FACE_TRAITS_HPP
+
+#include "../encoding/tlv-nfd.hpp"
+#include "../encoding/encoding-buffer.hpp"
+#include "../encoding/block-helpers.hpp"
+
+namespace ndn {
+namespace nfd {
+
+/**
+ * \ingroup management
+ * \deprecated provides additional information about a face
+ */
+enum FaceFlags {
+ /** \deprecated face is local (for scope control purpose)
+ */
+ FACE_IS_LOCAL = 1,
+ /** \deprecated face is created on demand (accepted incoming connection,
+ * not initiated outgoing connection)
+ */
+ FACE_IS_ON_DEMAND = 2
+};
+
+/**
+ * \ingroup management
+ * \brief provides additional information about a faceScope
+ */
+enum FaceScope {
+ /** \brief face is non-local
+ */
+ FACE_SCOPE_NON_LOCAL = 0,
+ /** \brief face is local
+ */
+ FACE_SCOPE_LOCAL = 1
+};
+
+std::ostream&
+operator<<(std::ostream& os, FaceScope faceScope);
+
+/**
+ * \ingroup management
+ * \brief provides additional information about a facePersistency
+ */
+enum FacePersistency {
+ /** \brief face is persistent
+ */
+ FACE_PERSISTENCY_PERSISTENT = 0,
+ /** \brief face is on-demand
+ */
+ FACE_PERSISTENCY_ON_DEMAND = 1,
+ /** \brief face is permanent
+ */
+ FACE_PERSISTENCY_PERMANENT = 2
+};
+
+std::ostream&
+operator<<(std::ostream& os, FacePersistency facePersistency);
+
+/**
+ * \ingroup management
+ * \brief provides additional information about a linkType
+ */
+enum LinkType {
+ /** \brief link is point-to-point
+ */
+ LINK_TYPE_POINT_TO_POINT = 0,
+ /** \brief link is multi-access
+ */
+ LINK_TYPE_MULTI_ACCESS = 1
+};
+
+std::ostream&
+operator<<(std::ostream& os, LinkType linkType);
+
+/** \ingroup management
+ * \brief providers getters and setters of face information fields
+ * \tparam C the concrete class; it must provide .wireReset() method
+ to clear wire encoding when a field changes
+ */
+template<class C>
+class FaceTraits
+{
+public:
+ class Error : public tlv::Error
+ {
+ public:
+ explicit
+ Error(const std::string& what)
+ : tlv::Error(what)
+ {
+ }
+ };
+
+ FaceTraits()
+ : m_faceId(0)
+ , m_faceScope(FACE_SCOPE_NON_LOCAL)
+ , m_facePersistency(FACE_PERSISTENCY_PERSISTENT)
+ , m_linkType(LINK_TYPE_POINT_TO_POINT)
+ {
+ }
+
+ uint64_t
+ getFaceId() const
+ {
+ return m_faceId;
+ }
+
+ C&
+ setFaceId(uint64_t faceId)
+ {
+ wireReset();
+ m_faceId = faceId;
+ return static_cast<C&>(*this);
+ }
+
+ const std::string&
+ getRemoteUri() const
+ {
+ return m_remoteUri;
+ }
+
+ C&
+ setRemoteUri(const std::string& remoteUri)
+ {
+ wireReset();
+ m_remoteUri = remoteUri;
+ return static_cast<C&>(*this);
+ }
+
+ const std::string&
+ getLocalUri() const
+ {
+ return m_localUri;
+ }
+
+ C&
+ setLocalUri(const std::string& localUri)
+ {
+ wireReset();
+ m_localUri = localUri;
+ return static_cast<C&>(*this);
+ }
+
+ FaceScope
+ getFaceScope() const
+ {
+ return m_faceScope;
+ }
+
+ C&
+ setFaceScope(FaceScope faceScope)
+ {
+ wireReset();
+ m_faceScope = faceScope;
+ return static_cast<C&>(*this);
+ }
+
+ FacePersistency
+ getFacePersistency() const
+ {
+ return m_facePersistency;
+ }
+
+ C&
+ setFacePersistency(FacePersistency facePersistency)
+ {
+ wireReset();
+ m_facePersistency = facePersistency;
+ return static_cast<C&>(*this);
+ }
+
+ LinkType
+ getLinkType() const
+ {
+ return m_linkType;
+ }
+
+ C&
+ setLinkType(LinkType linkType)
+ {
+ wireReset();
+ m_linkType = linkType;
+ return static_cast<C&>(*this);
+ }
+
+ /**
+ * \deprecated Use getFaceScope instead
+ */
+ bool
+ isLocal() const
+ {
+ return getFlags() & FACE_IS_LOCAL;
+ }
+
+ /**
+ * \deprecated Use getFacePersistency instead
+ */
+ bool
+ isOnDemand() const
+ {
+ return getFlags() & FACE_IS_ON_DEMAND;
+ }
+
+ /**
+ * \deprecated Use getFaceScope, and getFacePersistency instead
+ */
+ uint64_t
+ getFlags() const
+ {
+ uint64_t flags = 0;
+ if (m_faceScope == FACE_SCOPE_LOCAL)
+ flags |= FACE_IS_LOCAL;
+ if (m_facePersistency == FACE_PERSISTENCY_ON_DEMAND)
+ flags |= FACE_IS_ON_DEMAND;
+ return flags;
+ }
+
+ /**
+ * \deprecated Use setFaceScope, and setFacePersistency instead
+ */
+ C&
+ setFlags(uint64_t flags)
+ {
+ wireReset();
+ if ((flags & FACE_IS_LOCAL) != 0)
+ m_faceScope = FACE_SCOPE_LOCAL;
+ else
+ m_faceScope = FACE_SCOPE_NON_LOCAL;
+ if ((flags & FACE_IS_ON_DEMAND) != 0)
+ m_facePersistency = FACE_PERSISTENCY_ON_DEMAND;
+ else
+ m_facePersistency = FACE_PERSISTENCY_PERSISTENT;
+ return static_cast<C&>(*this);
+ }
+
+protected:
+ virtual void
+ wireReset() const = 0;
+
+protected:
+ uint64_t m_faceId;
+ std::string m_remoteUri;
+ std::string m_localUri;
+ FaceScope m_faceScope;
+ FacePersistency m_facePersistency;
+ LinkType m_linkType;
+};
+
+} // namespace nfd
+} // namespace ndn
+
+#endif // NDN_MANAGEMENT_NFD_FACE_TRAITS_HPP
diff --git a/tests/unit-tests/management/test-nfd-face-event-notification.cpp b/tests/unit-tests/management/test-nfd-face-event-notification.cpp
index c042bf4..5d014d8 100644
--- a/tests/unit-tests/management/test-nfd-face-event-notification.cpp
+++ b/tests/unit-tests/management/test-nfd-face-event-notification.cpp
@@ -28,25 +28,33 @@
BOOST_AUTO_TEST_SUITE(ManagementTestNfdFaceEventNotification)
-BOOST_AUTO_TEST_CASE(Flags)
+BOOST_AUTO_TEST_CASE(Traits)
{
FaceEventNotification notification;
- notification.setFlags(0);
- BOOST_CHECK_EQUAL(notification.isLocal(), false);
- BOOST_CHECK_EQUAL(notification.isOnDemand(), false);
+ BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_NON_LOCAL);
+ BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERSISTENT);
+ BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT);
- notification.setFlags(FACE_IS_LOCAL);
- BOOST_CHECK_EQUAL(notification.isLocal(), true);
- BOOST_CHECK_EQUAL(notification.isOnDemand(), false);
+ notification.setFaceScope(FACE_SCOPE_LOCAL);
+ BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL);
+ BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERSISTENT);
+ BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT);
- notification.setFlags(FACE_IS_ON_DEMAND);
- BOOST_CHECK_EQUAL(notification.isLocal(), false);
- BOOST_CHECK_EQUAL(notification.isOnDemand(), true);
+ notification.setFacePersistency(FACE_PERSISTENCY_ON_DEMAND);
+ BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL);
+ BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_ON_DEMAND);
+ BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT);
- notification.setFlags(FACE_IS_LOCAL | FACE_IS_ON_DEMAND);
- BOOST_CHECK_EQUAL(notification.isLocal(), true);
- BOOST_CHECK_EQUAL(notification.isOnDemand(), true);
+ notification.setFacePersistency(FACE_PERSISTENCY_PERMANENT);
+ BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL);
+ BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERMANENT);
+ BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_POINT_TO_POINT);
+
+ notification.setLinkType(LINK_TYPE_MULTI_ACCESS);
+ BOOST_CHECK_EQUAL(notification.getFaceScope(), FACE_SCOPE_LOCAL);
+ BOOST_CHECK_EQUAL(notification.getFacePersistency(), FACE_PERSISTENCY_PERMANENT);
+ BOOST_CHECK_EQUAL(notification.getLinkType(), LINK_TYPE_MULTI_ACCESS);
}
BOOST_AUTO_TEST_CASE(EncodeCreated)
@@ -56,21 +64,25 @@
.setFaceId(20)
.setRemoteUri("tcp4://192.0.2.1:55555")
.setLocalUri("tcp4://192.0.2.2:6363")
- .setFlags(FACE_IS_ON_DEMAND);
+ .setFaceScope(FACE_SCOPE_LOCAL)
+ .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND)
+ .setLinkType(LINK_TYPE_MULTI_ACCESS);
Block wire;
BOOST_REQUIRE_NO_THROW(wire = notification1.wireEncode());
// These octets are obtained by the snippet below.
// This check is intended to detect unexpected encoding change in the future.
- //for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
- // printf("0x%02x, ", *it);
- //}
+ // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+ // printf("0x%02x, ", *it);
+ // }
static const uint8_t expected[] = {
- 0xc0, 0x38, 0xc1, 0x01, 0x01, 0x69, 0x01, 0x14, 0x72, 0x16, 0x74, 0x63,
- 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32,
- 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35, 0x35, 0x35, 0x81, 0x15, 0x74, 0x63,
- 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32,
- 0x2e, 0x32, 0x3a, 0x36, 0x33, 0x36, 0x33, 0xc2, 0x01, 0x02,
+ 0xc0, 0x3e, 0xc1, 0x01, 0x01, 0x69, 0x01, 0x14, 0x72, 0x16,
+ 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32,
+ 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35,
+ 0x35, 0x35, 0x81, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f,
+ 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32,
+ 0x3a, 0x36, 0x33, 0x36, 0x33, 0x84, 0x01, 0x01, 0x85, 0x01,
+ 0x01, 0x86, 0x01, 0x01,
};
BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected),
wire.begin(), wire.end());
@@ -81,7 +93,9 @@
BOOST_CHECK_EQUAL(notification1.getFaceId(), notification2.getFaceId());
BOOST_CHECK_EQUAL(notification1.getRemoteUri(), notification2.getRemoteUri());
BOOST_CHECK_EQUAL(notification1.getLocalUri(), notification2.getLocalUri());
- BOOST_CHECK_EQUAL(notification1.getFlags(), notification2.getFlags());
+ BOOST_CHECK_EQUAL(notification1.getFaceScope(), notification2.getFaceScope());
+ BOOST_CHECK_EQUAL(notification1.getFacePersistency(), notification2.getFacePersistency());
+ BOOST_CHECK_EQUAL(notification1.getLinkType(), notification2.getLinkType());
std::ostringstream os;
os << notification2;
@@ -90,7 +104,9 @@
"FaceID: 20, "
"RemoteUri: tcp4://192.0.2.1:55555, "
"LocalUri: tcp4://192.0.2.2:6363, "
- "Flags: 2)");
+ "FaceScope: local, "
+ "FacePersistency: on-demand, "
+ "LinkType: multi-access)");
}
BOOST_AUTO_TEST_CASE(EncodeDestroyed)
@@ -100,21 +116,25 @@
.setFaceId(20)
.setRemoteUri("tcp4://192.0.2.1:55555")
.setLocalUri("tcp4://192.0.2.2:6363")
- .setFlags(FACE_IS_ON_DEMAND);
+ .setFaceScope(FACE_SCOPE_LOCAL)
+ .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND)
+ .setLinkType(LINK_TYPE_MULTI_ACCESS);
Block wire;
BOOST_REQUIRE_NO_THROW(wire = notification1.wireEncode());
// These octets are obtained by the snippet below.
// This check is intended to detect unexpected encoding change in the future.
- //for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
- // printf("0x%02x, ", *it);
- //}
+ // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+ // printf("0x%02x, ", *it);
+ // }
static const uint8_t expected[] = {
- 0xc0, 0x38, 0xc1, 0x01, 0x02, 0x69, 0x01, 0x14, 0x72, 0x16, 0x74, 0x63,
- 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32,
- 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35, 0x35, 0x35, 0x81, 0x15, 0x74, 0x63,
- 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32,
- 0x2e, 0x32, 0x3a, 0x36, 0x33, 0x36, 0x33, 0xc2, 0x01, 0x02,
+ 0xc0, 0x3e, 0xc1, 0x01, 0x02, 0x69, 0x01, 0x14, 0x72, 0x16,
+ 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32,
+ 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a, 0x35, 0x35, 0x35,
+ 0x35, 0x35, 0x81, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f,
+ 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32,
+ 0x3a, 0x36, 0x33, 0x36, 0x33, 0x84, 0x01, 0x01, 0x85, 0x01,
+ 0x01, 0x86, 0x01, 0x01,
};
BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected),
wire.begin(), wire.end());
@@ -125,7 +145,9 @@
BOOST_CHECK_EQUAL(notification1.getFaceId(), notification2.getFaceId());
BOOST_CHECK_EQUAL(notification1.getRemoteUri(), notification2.getRemoteUri());
BOOST_CHECK_EQUAL(notification1.getLocalUri(), notification2.getLocalUri());
- BOOST_CHECK_EQUAL(notification1.getFlags(), notification2.getFlags());
+ BOOST_CHECK_EQUAL(notification1.getFaceScope(), notification2.getFaceScope());
+ BOOST_CHECK_EQUAL(notification1.getFacePersistency(), notification2.getFacePersistency());
+ BOOST_CHECK_EQUAL(notification1.getLinkType(), notification2.getLinkType());
std::ostringstream os;
os << notification2;
@@ -134,7 +156,9 @@
"FaceID: 20, "
"RemoteUri: tcp4://192.0.2.1:55555, "
"LocalUri: tcp4://192.0.2.2:6363, "
- "Flags: 2)");
+ "FaceScope: local, "
+ "FacePersistency: on-demand, "
+ "LinkType: multi-access)");
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/unit-tests/management/test-nfd-face-status.cpp b/tests/unit-tests/management/test-nfd-face-status.cpp
index 22c7264..4c1a7fa 100644
--- a/tests/unit-tests/management/test-nfd-face-status.cpp
+++ b/tests/unit-tests/management/test-nfd-face-status.cpp
@@ -34,7 +34,9 @@
status1.setFaceId(100)
.setRemoteUri("tcp4://192.0.2.1:6363")
.setLocalUri("tcp4://192.0.2.2:55555")
- .setFlags(FACE_IS_ON_DEMAND)
+ .setFaceScope(FACE_SCOPE_LOCAL)
+ .setFacePersistency(FACE_PERSISTENCY_ON_DEMAND)
+ .setLinkType(LINK_TYPE_MULTI_ACCESS)
.setExpirationPeriod(time::seconds(10))
.setNInInterests(10)
.setNInDatas(200)
@@ -52,13 +54,15 @@
// printf("0x%02x, ", *it);
// }
static const uint8_t expected[] = {
- 0x80, 0x52, 0x69, 0x01, 0x64, 0x72, 0x15, 0x74, 0x63, 0x70, 0x34, 0x3a,
- 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x31, 0x3a,
- 0x36, 0x33, 0x36, 0x33, 0x81, 0x16, 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f,
- 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, 0x3a, 0x35,
- 0x35, 0x35, 0x35, 0x35, 0x6d, 0x02, 0x27, 0x10, 0xc2, 0x01, 0x02, 0x90,
- 0x01, 0x0a, 0x91, 0x01, 0xc8, 0x92, 0x02, 0x0b, 0xb8, 0x93, 0x01, 0x04,
- 0x94, 0x04, 0x4f, 0x41, 0xe7, 0x7b, 0x95, 0x04, 0x3b, 0x8d, 0x37, 0x30
+ 0x80, 0x58, 0x69, 0x01, 0x64, 0x72, 0x15, 0x74, 0x63, 0x70,
+ 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e,
+ 0x32, 0x2e, 0x31, 0x3a, 0x36, 0x33, 0x36, 0x33, 0x81, 0x16,
+ 0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32,
+ 0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, 0x3a, 0x35, 0x35, 0x35,
+ 0x35, 0x35, 0x6d, 0x02, 0x27, 0x10, 0x84, 0x01, 0x01, 0x85,
+ 0x01, 0x01, 0x86, 0x01, 0x01, 0x90, 0x01, 0x0a, 0x91, 0x01,
+ 0xc8, 0x92, 0x02, 0x0b, 0xb8, 0x93, 0x01, 0x04, 0x94, 0x04,
+ 0x4f, 0x41, 0xe7, 0x7b, 0x95, 0x04, 0x3b, 0x8d, 0x37, 0x30,
};
BOOST_CHECK_EQUAL_COLLECTIONS(expected, expected + sizeof(expected),
wire.begin(), wire.end());
@@ -68,7 +72,9 @@
BOOST_CHECK_EQUAL(status1.getFaceId(), status2.getFaceId());
BOOST_CHECK_EQUAL(status1.getRemoteUri(), status2.getRemoteUri());
BOOST_CHECK_EQUAL(status1.getLocalUri(), status2.getLocalUri());
- BOOST_CHECK_EQUAL(status1.getFlags(), status2.getFlags());
+ BOOST_CHECK_EQUAL(status1.getFaceScope(), status2.getFaceScope());
+ BOOST_CHECK_EQUAL(status1.getFacePersistency(), status2.getFacePersistency());
+ BOOST_CHECK_EQUAL(status1.getLinkType(), status2.getLinkType());
BOOST_CHECK_EQUAL(status1.getNInInterests(), status2.getNInInterests());
BOOST_CHECK_EQUAL(status1.getNInDatas(), status2.getNInDatas());
BOOST_CHECK_EQUAL(status1.getNOutInterests(), status2.getNOutInterests());
@@ -82,7 +88,9 @@
"RemoteUri: tcp4://192.0.2.1:6363,\n"
"LocalUri: tcp4://192.0.2.2:55555,\n"
"ExpirationPeriod: 10000 milliseconds,\n"
- "Flags: 2,\n"
+ "FaceScope: local,\n"
+ "FacePersistency: on-demand,\n"
+ "LinkType: multi-access,\n"
"Counters: { Interests: {in: 10, out: 3000},\n"
" Data: {in: 200, out: 4},\n"
" bytes: {in: 1329719163, out: 999110448} }\n"