lp: add CongestionMark field and tag
refs #3797
Change-Id: I6ac6663c874abde1df2102af81fc03567ad87029
diff --git a/src/face.cpp b/src/face.cpp
index d20f57c..430f65e 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -240,10 +240,22 @@
{
Block wire = data.wireEncode();
+ lp::Packet packet;
+ bool hasLpFields = false;
+
shared_ptr<lp::CachePolicyTag> cachePolicyTag = data.getTag<lp::CachePolicyTag>();
if (cachePolicyTag != nullptr) {
- lp::Packet packet;
packet.add<lp::CachePolicyField>(*cachePolicyTag);
+ hasLpFields = true;
+ }
+
+ shared_ptr<lp::CongestionMarkTag> congestionMarkTag = data.getTag<lp::CongestionMarkTag>();
+ if (congestionMarkTag != nullptr) {
+ packet.add<lp::CongestionMarkField>(*congestionMarkTag);
+ hasLpFields = true;
+ }
+
+ if (hasLpFields) {
packet.add<lp::FragmentField>(std::make_pair(wire.begin(), wire.end()));
wire = packet.wireEncode();
}
@@ -264,6 +276,11 @@
const Block& interestWire = nack.getInterest().wireEncode();
packet.add<lp::FragmentField>(std::make_pair(interestWire.begin(), interestWire.end()));
+ shared_ptr<lp::CongestionMarkTag> congestionMarkTag = nack.getTag<lp::CongestionMarkTag>();
+ if (congestionMarkTag != nullptr) {
+ packet.add<lp::CongestionMarkField>(*congestionMarkTag);
+ }
+
Block wire = packet.wireEncode();
if (wire.size() > MAX_NDN_PACKET_SIZE)
@@ -500,13 +517,17 @@
/**
* @brief extract local fields from NDNLPv2 packet and tag onto a network layer packet
*/
-template<typename NETPKT>
+template<typename NetPkt>
static void
-extractLpLocalFields(NETPKT& netPacket, const lp::Packet& lpPacket)
+extractLpLocalFields(NetPkt& netPacket, const lp::Packet& lpPacket)
{
if (lpPacket.has<lp::IncomingFaceIdField>()) {
netPacket.setTag(make_shared<lp::IncomingFaceIdTag>(lpPacket.get<lp::IncomingFaceIdField>()));
}
+
+ if (lpPacket.has<lp::CongestionMarkField>()) {
+ netPacket.setTag(make_shared<lp::CongestionMarkTag>(lpPacket.get<lp::CongestionMarkField>()));
+ }
}
void