tools: add mtu option to 'nfdc face create'
refs #4789
Change-Id: I9e31c5fb460ee99199332ffb6fadc9f0f33125e9
diff --git a/tools/nfdc/face-module.cpp b/tools/nfdc/face-module.cpp
index 23a03db..ae6ba16 100644
--- a/tools/nfdc/face-module.cpp
+++ b/tools/nfdc/face-module.cpp
@@ -57,7 +57,8 @@
.addArg("reliability", ArgValueType::BOOLEAN, Required::NO, Positional::NO)
.addArg("congestion-marking", ArgValueType::BOOLEAN, Required::NO, Positional::NO)
.addArg("congestion-marking-interval", ArgValueType::UNSIGNED, Required::NO, Positional::NO)
- .addArg("default-congestion-threshold", ArgValueType::UNSIGNED, Required::NO, Positional::NO);
+ .addArg("default-congestion-threshold", ArgValueType::UNSIGNED, Required::NO, Positional::NO)
+ .addArg("mtu", ArgValueType::UNSIGNED, Required::NO, Positional::NO);
parser.addCommand(defFaceCreate, &FaceModule::create);
CommandDefinition defFaceDestroy("face", "destroy");
@@ -159,6 +160,7 @@
auto congestionMarking = ctx.args.getTribool("congestion-marking");
auto baseCongestionMarkingIntervalMs = ctx.args.getOptional<uint64_t>("congestion-marking-interval");
auto defaultCongestionThreshold = ctx.args.getOptional<uint64_t>("default-congestion-threshold");
+ auto mtu = ctx.args.getOptional<uint64_t>("mtu");
FaceUri canonicalRemote;
optional<FaceUri> canonicalLocal;
@@ -192,7 +194,11 @@
return false;
}
- if (persistencyLessThan(respParams.getFacePersistency(), persistency)) {
+ if (mtu && (!respParams.hasMtu() || respParams.getMtu() != *mtu)) {
+ // Mtu cannot be changed with faces/update
+ return false;
+ }
+ else if (persistencyLessThan(respParams.getFacePersistency(), persistency)) {
// need to upgrade persistency
ControlParameters params;
params.setFaceId(respParams.getFaceId()).setFacePersistency(persistency);
@@ -263,6 +269,9 @@
if (defaultCongestionThreshold) {
params.setDefaultCongestionThreshold(*defaultCongestionThreshold);
}
+ if (mtu) {
+ params.setMtu(*mtu);
+ }
ctx.controller.start<ndn::nfd::FaceCreateCommand>(
params,
@@ -400,6 +409,10 @@
os << "</congestion>";
}
+ if (item.hasMtu()) {
+ os << "<mtu>" << item.getMtu() << "</mtu>";
+ }
+
if (item.getFlags() == 0) {
os << "<flags/>";
}
@@ -469,6 +482,10 @@
os << "}";
}
+ if (item.hasMtu()) {
+ os << ia("mtu") << item.getMtu();
+ }
+
os << ia("counters")
<< "{in={"
<< item.getNInInterests() << "i "
@@ -512,6 +529,9 @@
if (resp.hasDefaultCongestionThreshold()) {
os << ia("default-congestion-threshold") << resp.getDefaultCongestionThreshold() << "B";
}
+ if (resp.hasMtu()) {
+ os << ia("mtu") << resp.getMtu();
+ }
os << '\n';
}