当前位置: 首页>>代码示例>>C++>>正文


C++ ControlParameters::getFaceId方法代码示例

本文整理汇总了C++中ControlParameters::getFaceId方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlParameters::getFaceId方法的具体用法?C++ ControlParameters::getFaceId怎么用?C++ ControlParameters::getFaceId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ControlParameters的用法示例。


在下文中一共展示了ControlParameters::getFaceId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setFaceForSelfRegistration

void
FibManager::removeNextHop(const Name& topPrefix, const Interest& interest,
                          ControlParameters parameters,
                          const ndn::mgmt::CommandContinuation& done)
{
  setFaceForSelfRegistration(interest, parameters);

  NFD_LOG_TRACE("remove-nexthop prefix: " << parameters.getName()
                << " faceid: " << parameters.getFaceId());

  auto face = m_getFace(parameters.getFaceId());
  if (static_cast<bool>(face)) {
    auto entry = m_fib.findExactMatch(parameters.getName());
    if (static_cast<bool>(entry)) {
      entry->removeNextHop(face);
      NFD_LOG_DEBUG("remove-nexthop result: OK prefix: " << parameters.getName()
                    << " faceid: " << parameters.getFaceId());

      if (!entry->hasNextHops()) {
        m_fib.erase(*entry);
      }
    }
    else {
      NFD_LOG_DEBUG("remove-nexthop result: OK");
    }
  }
  else {
    NFD_LOG_DEBUG("remove-nexthop result: OK");
  }

  done(ControlResponse(200, "Success").setBody(parameters.wireEncode()));
}
开发者ID:MobinRanjbar,项目名称:NFD,代码行数:32,代码来源:fib-manager.cpp

示例2: sendResponse

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));
}
开发者ID:MobinRanjbar,项目名称:NFD,代码行数:59,代码来源:rib-manager.cpp

示例3: sendResponse

void
FibManager::onValidatedFibRequest(const shared_ptr<const Interest>& request)
{
  const Name& command = request->getName();
  const Name::Component& verb = command[COMMAND_PREFIX.size()];
  const Name::Component& parameterComponent = command[COMMAND_PREFIX.size() + 1];

  SignedVerbDispatchTable::const_iterator verbProcessor = m_signedVerbDispatch.find(verb);
  if (verbProcessor != m_signedVerbDispatch.end())
    {
      ControlParameters parameters;
      if (!extractParameters(parameterComponent, parameters) || !parameters.hasFaceId())
        {
          NFD_LOG_DEBUG("command result: malformed verb: " << verb);
          sendResponse(command, 400, "Malformed command");
          return;
        }

      if (parameters.getFaceId() == 0)
        {
          parameters.setFaceId(request->getIncomingFaceId());
        }

      NFD_LOG_DEBUG("command result: processing verb: " << verb);
      ControlResponse response;
      (verbProcessor->second)(this, parameters, response);
      sendResponse(command, response);
    }
  else
    {
      NFD_LOG_DEBUG("command result: unsupported verb: " << verb);
      sendResponse(command, 501, "Unsupported command");
    }
}
开发者ID:akmhoque,项目名称:NFD,代码行数:34,代码来源:fib-manager.cpp

示例4: done

void
FibManager::addNextHop(const Name& topPrefix, const Interest& interest,
                       ControlParameters parameters,
                       const ndn::mgmt::CommandContinuation& done)
{
  setFaceForSelfRegistration(interest, parameters);

  const Name& prefix = parameters.getName();
  FaceId faceId = parameters.getFaceId();
  uint64_t cost = parameters.getCost();

  NFD_LOG_TRACE("add-nexthop prefix: " << prefix
                << " faceid: " << faceId
                << " cost: " << cost);

  auto face = m_getFace(faceId);
  if (static_cast<bool>(face)) {
    auto entry = m_fib.insert(prefix).first;

    entry->addNextHop(face, cost);

    NFD_LOG_DEBUG("add-nexthop result: OK"
                  << " prefix:" << prefix
                  << " faceid: " << faceId
                  << " cost: " << cost);

    return done(ControlResponse(200, "Success").setBody(parameters.wireEncode()));
  }
  else {
    NFD_LOG_INFO("add-nexthop result: FAIL reason: unknown-faceid: " << faceId);
    return done(ControlResponse(410, "Face not found"));
  }
}
开发者ID:MobinRanjbar,项目名称:NFD,代码行数:33,代码来源:fib-manager.cpp

示例5:

void
FaceDestroyCommand::validateRequest(const ControlParameters& parameters) const
{
  this->ControlCommand::validateRequest(parameters);

  if (parameters.getFaceId() == 0) {
    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must not be zero"));
  }
}
开发者ID:YuanKQ,项目名称:NFD_for_android,代码行数:9,代码来源:nfd-control-command.cpp

示例6:

void
RibRegisterCommand::validateResponse(const ControlParameters& parameters) const
{
  this->ControlCommand::validateResponse(parameters);

  if (parameters.getFaceId() == INVALID_FACE_ID) {
    BOOST_THROW_EXCEPTION(ArgumentError("FaceId must be valid"));
  }
}
开发者ID:cawka,项目名称:ndn-cxx,代码行数:9,代码来源:control-command.cpp

示例7: ArgumentError

  virtual void
  validateResponse(const ControlParameters& parameters) const
  {
    this->ControlCommand::validateResponse(parameters);

    if (parameters.getFaceId() == 0) {
      throw ArgumentError("FaceId must not be zero");
    }
  }
开发者ID:PatrickGuo,项目名称:ndn-cxx-master,代码行数:9,代码来源:nfd-control-command.hpp

示例8: setResponse

void
FibManager::removeNextHop(ControlParameters& parameters,
                          ControlResponse& response)
{
  ndn::nfd::FibRemoveNextHopCommand command;
  if (!validateParameters(command, parameters))
    {
      NFD_LOG_DEBUG("remove-nexthop result: FAIL reason: malformed");
      setResponse(response, 400, "Malformed command");
      return;
    }

  NFD_LOG_TRACE("remove-nexthop prefix: " << parameters.getName()
                << " faceid: " << parameters.getFaceId());

  shared_ptr<Face> faceToRemove = m_getFace(parameters.getFaceId());
  if (static_cast<bool>(faceToRemove))
    {
      shared_ptr<fib::Entry> entry = m_managedFib.findExactMatch(parameters.getName());
      if (static_cast<bool>(entry))
        {
          entry->removeNextHop(faceToRemove);
          NFD_LOG_DEBUG("remove-nexthop result: OK prefix: " << parameters.getName()
                        << " faceid: " << parameters.getFaceId());

          if (!entry->hasNextHops())
            {
              m_managedFib.erase(*entry);
            }
        }
      else
        {
          NFD_LOG_DEBUG("remove-nexthop result: OK, but entry for face id "
                        << parameters.getFaceId() << " not found");
        }
    }
  else
    {
      NFD_LOG_DEBUG("remove-nexthop result: OK, but face id "
                    << parameters.getFaceId() << " not found");
    }

  setResponse(response, 200, "Success", parameters.wireEncode());
}
开发者ID:akmhoque,项目名称:NFD,代码行数:44,代码来源:fib-manager.cpp

示例9: done

void
FaceManager::destroyFace(const ControlParameters& parameters,
                         const ndn::mgmt::CommandContinuation& done)
{
  Face* face = m_faceTable.get(parameters.getFaceId());
  if (face != nullptr) {
    face->close();
  }

  done(ControlResponse(200, "OK").setBody(parameters.wireEncode()));
}
开发者ID:named-data,项目名称:NFD,代码行数:11,代码来源:face-manager.cpp

示例10: bind

void
Nfdc::faceDestroy(const ControlParameters& faceCreateResult)
{
  ControlParameters faceParameters;
  faceParameters.setFaceId(faceCreateResult.getFaceId());

  m_controller.start<FaceDestroyCommand>(faceParameters,
                                         bind(&Nfdc::onSuccess, this, _1,
                                              "Face destroy succeeded"),
                                         bind(&Nfdc::onError, this, _1, _2,
                                              "Face destroy failed"));
}
开发者ID:PhilipsIII,项目名称:NFD,代码行数:12,代码来源:nfdc.cpp

示例11:

void
FibManager::setFaceForSelfRegistration(const Interest& request, ControlParameters& parameters)
{
  bool isSelfRegistration = (parameters.getFaceId() == 0);
  if (isSelfRegistration) {
    shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag = request.getTag<lp::IncomingFaceIdTag>();
    // NDNLPv2 says "application MUST be prepared to receive a packet without IncomingFaceId field",
    // but it's fine to assert IncomingFaceId is available, because InternalFace lives inside NFD
    // and is initialized synchronously with IncomingFaceId field enabled.
    BOOST_ASSERT(incomingFaceIdTag != nullptr);
    parameters.setFaceId(*incomingFaceIdTag);
  }
}
开发者ID:MobinRanjbar,项目名称:NFD,代码行数:13,代码来源:fib-manager.cpp

示例12: sendResponse

void
FaceManager::destroyFace(const Interest& request,
                         ControlParameters& parameters)
{
  const Name& requestName = request.getName();
  ndn::nfd::FaceDestroyCommand command;

  if (!validateParameters(command, parameters))
    {
      sendResponse(requestName, 400, "Malformed command");
      return;
    }

  shared_ptr<Face> target = m_faceTable.get(parameters.getFaceId());
  if (static_cast<bool>(target))
    {
      target->close();
    }

  sendResponse(requestName, 200, "Success", parameters.wireEncode());

}
开发者ID:Estoque86,项目名称:Comparison_New_Simulators,代码行数:22,代码来源:face-manager.cpp

示例13: applyDefaultsToRequest

 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));
     }
   }
 }
开发者ID:PatrickGuo,项目名称:ndn-cxx-master,代码行数:24,代码来源:nfd-control-command.hpp


注:本文中的ControlParameters::getFaceId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。