[ndnSIM] face: Add GeoTag processing in the generic link service
Change-Id: I6d679b85758bd6a105bd72ac50df7e61fae9b1eb
diff --git a/daemon/face/generic-link-service.cpp b/daemon/face/generic-link-service.cpp
index bdb6906..239de43 100644
--- a/daemon/face/generic-link-service.cpp
+++ b/daemon/face/generic-link-service.cpp
@@ -162,6 +162,13 @@
else {
lpPacket.add<lp::HopCountTagField>(0);
}
+
+ if (m_options.enableGeoTags) {
+ auto geoTag = m_options.enableGeoTags();
+ if (geoTag != nullptr) {
+ lpPacket.add<lp::GeoTagField>(*geoTag);
+ }
+ }
}
void
@@ -357,6 +364,10 @@
interest->setTag(make_shared<lp::HopCountTag>(firstPkt.get<lp::HopCountTagField>() + 1));
}
+ if (m_options.enableGeoTags && firstPkt.has<lp::GeoTagField>()) {
+ interest->setTag(make_shared<lp::GeoTag>(firstPkt.get<lp::GeoTagField>()));
+ }
+
if (firstPkt.has<lp::NextHopFaceIdField>()) {
if (m_options.allowLocalFields) {
interest->setTag(make_shared<lp::NextHopFaceIdTag>(firstPkt.get<lp::NextHopFaceIdField>()));
@@ -416,6 +427,10 @@
data->setTag(make_shared<lp::HopCountTag>(firstPkt.get<lp::HopCountTagField>() + 1));
}
+ if (m_options.enableGeoTags && firstPkt.has<lp::GeoTagField>()) {
+ data->setTag(make_shared<lp::GeoTag>(firstPkt.get<lp::GeoTagField>()));
+ }
+
if (firstPkt.has<lp::NackField>()) {
++this->nInNetInvalid;
NFD_LOG_FACE_WARN("received Nack with Data: DROP");
diff --git a/daemon/face/generic-link-service.hpp b/daemon/face/generic-link-service.hpp
index 3137555..64a2d3c 100644
--- a/daemon/face/generic-link-service.hpp
+++ b/daemon/face/generic-link-service.hpp
@@ -31,6 +31,8 @@
#include "lp-reassembler.hpp"
#include "lp-reliability.hpp"
+#include <ndn-cxx/lp/tags.hpp>
+
namespace nfd {
namespace face {
@@ -98,7 +100,6 @@
class Options
{
public:
- constexpr
Options() noexcept
{
}
@@ -151,6 +152,12 @@
/** \brief enables self-learning forwarding support
*/
bool allowSelfLearning = true;
+
+ /** \brief Enable encoding and decoding of GeoTags
+ *
+ * To enable, set value of enableGeoTags option to a function that generates `shared_ptr<GeoTag>`
+ */
+ std::function<std::shared_ptr<ndn::lp::GeoTag>()> enableGeoTags;
};
/** \brief counters provided by GenericLinkService