本文整理汇总了C++中ControlParameters::wireEncode方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlParameters::wireEncode方法的具体用法?C++ ControlParameters::wireEncode怎么用?C++ ControlParameters::wireEncode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlParameters
的用法示例。
在下文中一共展示了ControlParameters::wireEncode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setResponse
void
StrategyChoiceManager::unsetStrategy(ControlParameters& parameters,
ControlResponse& response)
{
ndn::nfd::StrategyChoiceUnsetCommand command;
if (!validateParameters(command, parameters))
{
static const Name ROOT_PREFIX;
if (parameters.hasName() && parameters.getName() == ROOT_PREFIX)
{
NFD_LOG_DEBUG("strategy-choice result: FAIL reason: unset-root");
setResponse(response, 403, "Cannot unset root prefix strategy");
}
else
{
NFD_LOG_DEBUG("strategy-choice result: FAIL reason: malformed");
setResponse(response, 400, "Malformed command");
}
return;
}
m_strategyChoice.erase(parameters.getName());
NFD_LOG_DEBUG("strategy-choice result: SUCCESS");
setResponse(response, 200, "Success", parameters.wireEncode());
}
示例2: encodedParameters
BOOST_FIXTURE_TEST_CASE(DestroyFace, AuthorizedCommandFixture<FaceFixture>)
{
shared_ptr<DummyFace> dummy(make_shared<DummyFace>());
FaceTableFixture::m_faceTable.add(dummy);
ControlParameters parameters;
parameters.setFaceId(dummy->getId());
Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("destroy");
commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
ndn::nfd::FaceEventNotification expectedFaceEvent;
expectedFaceEvent.setKind(ndn::nfd::FACE_EVENT_DESTROYED)
.setFaceId(dummy->getId())
.setRemoteUri(dummy->getRemoteUri().toString())
.setLocalUri(dummy->getLocalUri().toString())
.setFlags(0);
getFace()->onReceiveData +=
bind(&FaceFixture::callbackDispatch, this, _1, command->getName(),
200, "Success", ref(encodedParameters), expectedFaceEvent);
destroyFace(*command, parameters);
BOOST_REQUIRE(didCallbackFire());
BOOST_REQUIRE(didReceiveNotication());
}
示例3: 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()));
}
示例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"));
}
}
示例5: encodedParameters
BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceId,
AuthorizedCommandFixture<LocalControlFixture>)
{
shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
BOOST_REQUIRE(dummy->isLocal());
FaceTableFixture::m_faceTable.add(dummy);
ControlParameters parameters;
parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID);
Block encodedParameters(parameters.wireEncode());
Name enable("/localhost/nfd/faces/enable-local-control");
enable.append(encodedParameters);
shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
enableCommand->setIncomingFaceId(dummy->getId());
generateCommand(*enableCommand);
TestFaceManagerCommon::m_face->onReceiveData +=
[this, enableCommand, encodedParameters] (const Data& response) {
this->validateControlResponse(response, enableCommand->getName(),
200, "Success", encodedParameters);
};
onValidatedFaceRequest(enableCommand);
BOOST_REQUIRE(didCallbackFire());
BOOST_REQUIRE(dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
TestFaceManagerCommon::m_face->onReceiveData.clear();
resetCallbackFired();
Name disable("/localhost/nfd/faces/disable-local-control");
disable.append(encodedParameters);
shared_ptr<Interest> disableCommand(make_shared<Interest>(disable));
disableCommand->setIncomingFaceId(dummy->getId());
generateCommand(*disableCommand);
TestFaceManagerCommon::m_face->onReceiveData +=
[this, disableCommand, encodedParameters] (const Data& response) {
this->validateControlResponse(response, disableCommand->getName(),
200, "Success", encodedParameters);
};
onValidatedFaceRequest(disableCommand);
BOOST_REQUIRE(didCallbackFire());
BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
}
示例6: addCreatedFaceToForwarder
void
FaceManager::onCreated(const Name& requestName,
ControlParameters& parameters,
const shared_ptr<Face>& newFace)
{
addCreatedFaceToForwarder(newFace);
parameters.setFaceId(newFace->getId());
parameters.setUri(newFace->getRemoteUri().toString());
sendResponse(requestName, 200, "Success", parameters.wireEncode());
}
示例7: 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()));
}
示例8:
Name
ControlCommand::getRequestName(const Name& commandPrefix,
const ControlParameters& parameters) const
{
this->validateRequest(parameters);
Name name = commandPrefix;
name.append(m_module).append(m_verb);
name.append(parameters.wireEncode());
return name;
}
示例9: commandInterest
/** \brief make a Command Interest from parameters
*/
Interest
makeCommandInterest(const ControlParameters& parameters,
const Sign& sign) const
{
this->validateRequest(parameters);
Name name = m_prefix;
name.append(parameters.wireEncode());
Interest commandInterest(name);
sign(commandInterest);
return commandInterest;
}
示例10: sendResponse
void
FaceManager::disableLocalControl(const Interest& request,
ControlParameters& parameters)
{
ndn::nfd::FaceDisableLocalControlCommand command;
shared_ptr<LocalFace> face;
LocalControlFeature feature;
if (extractLocalControlParameters(request, parameters, command, face, feature))
{
face->setLocalControlHeaderFeature(feature, false);
sendResponse(request.getName(), 200, "Success", parameters.wireEncode());
}
}
示例11: makeCreateFaceResponse
void
FaceManager::afterCreateFaceSuccess(const shared_ptr<Face>& face,
const ControlParameters& parameters,
const ndn::mgmt::CommandContinuation& done)
{
if (face->getId() != face::INVALID_FACEID) { // Face already exists
NFD_LOG_TRACE("Attempted to create duplicate face of " << face->getId());
ControlParameters response = makeCreateFaceResponse(*face);
done(ControlResponse(409, "Face with remote URI already exists").setBody(response.wireEncode()));
return;
}
// If scope non-local and flags set to enable local fields, request shouldn't
// have made it this far
BOOST_ASSERT(face->getScope() == ndn::nfd::FACE_SCOPE_LOCAL ||
!parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) ||
(parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) &&
!parameters.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED)));
m_faceTable.add(face);
ControlParameters response = makeCreateFaceResponse(*face);
done(ControlResponse(200, "OK").setBody(response.wireEncode()));
}
示例12: encodedParameters
void
StrategyChoiceHelper::sendCommand(const ControlParameters& parameters, Ptr<Node> node)
{
NS_LOG_DEBUG("Strategy choice command was initialized");
Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/strategy-choice");
commandName.append("set");
commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
StackHelper::getKeyChain().sign(*command);
Ptr<L3Protocol> l3protocol = node->GetObject<L3Protocol>();
l3protocol->injectInterest(*command);
}
示例13: encodedParameters
void
FibHelper::RemoveNextHop(const ControlParameters& parameters, Ptr<Node> node)
{
Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("remove-nexthop");
commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
command->setCanBePrefix(false);
StackHelper::getKeyChain().sign(*command);
Ptr<L3Protocol> l3protocol = node->GetObject<L3Protocol>();
l3protocol->injectInterest(*command);
}
示例14: sendResponse
void
RibManager::onUnRegSuccess(const shared_ptr<const Interest>& request,
const ControlParameters& parameters,
const Route& route)
{
ControlResponse response;
response.setCode(200);
response.setText("Success");
response.setBody(parameters.wireEncode());
NFD_LOG_TRACE("onUnRegSuccess: unregistered " << route);
if (static_cast<bool>(request)) {
sendResponse(request->getName(), response);
}
}
示例15: encodedParameters
void
FibHelper::AddNextHop(const ControlParameters& parameters, Ptr<Node> node)
{
NS_LOG_DEBUG("Add Next Hop command was initialized");
Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("add-nexthop");
commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
StackHelper::getKeyChain().sign(*command);
Ptr<L3Protocol> l3protocol = node->GetObject<L3Protocol>();
shared_ptr<nfd::FibManager> fibManager = l3protocol->getFibManager();
fibManager->onFibRequest(*command);
}