[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 35e78b1..1ab78fe 100644
--- a/daemon/face/generic-link-service.cpp
+++ b/daemon/face/generic-link-service.cpp
@@ -190,6 +190,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
@@ -378,6 +385,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>()));
@@ -437,6 +448,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>()) {
++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 7a86b09..b2faea3 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 {
@@ -164,6 +166,12 @@
* being set with canOverrideMtuTo().
*/
ssize_t overrideMtu = std::numeric_limits<ssize_t>::max();
+
+ /** \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