void RibManager::unregisterEntry(const shared_ptr<const Interest>& request, ControlParameters& params) { ndn::nfd::RibUnregisterCommand command; // Passing all parameters gives error in validation, // so passing only the required arguments. ControlParameters parameters; parameters.setName(params.getName()); if (params.hasFaceId()) { parameters.setFaceId(params.getFaceId()); } if (params.hasOrigin()) { parameters.setOrigin(params.getOrigin()); } if (!validateParameters(command, parameters)) { NFD_LOG_DEBUG("unregister result: FAIL reason: malformed"); if (static_cast<bool>(request)) { sendResponse(request->getName(), 400, "Malformed command"); } return; } bool isSelfRegistration = (!parameters.hasFaceId() || parameters.getFaceId() == 0); if (isSelfRegistration) { shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag = request->getTag<lp::IncomingFaceIdTag>(); if (incomingFaceIdTag == nullptr) { sendResponse(request->getName(), 503, "requested self-registration, but IncomingFaceId is unavailable"); return; } parameters.setFaceId(*incomingFaceIdTag); } // Respond since command is valid and authorized sendSuccessResponse(request, parameters); Route route; route.faceId = parameters.getFaceId(); route.origin = parameters.getOrigin(); NFD_LOG_INFO("Removing route " << parameters.getName() << " nexthop=" << route.faceId << " origin=" << route.origin); RibUpdate update; update.setAction(RibUpdate::UNREGISTER) .setName(parameters.getName()) .setRoute(route); m_managedRib.beginApplyUpdate(update, bind(&RibManager::onRibUpdateSuccess, this, update), bind(&RibManager::onRibUpdateFailure, this, update, _1, _2)); }
void RibUnregisterCommand::applyDefaultsToRequest(ControlParameters& parameters) const { if (!parameters.hasFaceId()) { parameters.setFaceId(0); } if (!parameters.hasOrigin()) { parameters.setOrigin(ROUTE_ORIGIN_APP); } }
virtual void applyDefaultsToRequest(ControlParameters& parameters) const { if (!parameters.hasFaceId()) { parameters.setFaceId(0); } if (!parameters.hasOrigin()) { parameters.setOrigin(ROUTE_ORIGIN_APP); } }
void RibRegisterCommand::applyDefaultsToRequest(ControlParameters& parameters) const { if (!parameters.hasFaceId()) { parameters.setFaceId(0); } if (!parameters.hasOrigin()) { parameters.setOrigin(ROUTE_ORIGIN_APP); } if (!parameters.hasCost()) { parameters.setCost(0); } if (!parameters.hasFlags()) { parameters.setFlags(ROUTE_FLAG_CHILD_INHERIT); } }
virtual void applyDefaultsToRequest(ControlParameters& parameters) const { if (!parameters.hasFaceId()) { parameters.setFaceId(0); } if (!parameters.hasOrigin()) { parameters.setOrigin(ROUTE_ORIGIN_APP); } if (!parameters.hasCost()) { parameters.setCost(0); } if (!parameters.hasFlags()) { parameters.setFlags(ROUTE_FLAG_CHILD_INHERIT); } if (!parameters.hasExpirationPeriod()) { if (parameters.getFaceId() == 0) { parameters.setExpirationPeriod(time::milliseconds::max()); } else { parameters.setExpirationPeriod(time::hours(1)); } } }