28 #include <ndn-cxx/encoding/block-helpers.hpp> 29 #include <ndn-cxx/encoding/tlv.hpp> 30 #include <ndn-cxx/encoding/tlv-nfd.hpp> 36 namespace autoconfig_server {
44 , m_keyChain(keyChain)
45 , m_dispatcher(face, keyChain)
54 Program::enableHubData(
const FaceUri& hubFaceUri)
56 std::string uri = hubFaceUri.toString();
58 auto data = make_shared<Data>(Name(
HUB_DATA_NAME).appendVersion());
59 data->setFreshnessPeriod(1_h);
60 data->setContent(makeBinaryBlock(tlv::nfd::Uri,
61 reinterpret_cast<const uint8_t*>(uri.data()), uri.size()));
62 m_keyChain.sign(*data);
65 [
this, data] (
const Name&,
const Interest& interest) {
66 if (interest.matchesData(*data)) {
70 bind(&Program::handlePrefixRegistrationFailure,
this, _1, _2));
74 Program::enableRoutablePrefixesDataset(
const std::vector<Name>& routablePrefixes)
77 mgmt::makeAcceptAllAuthorization(),
78 [=] (
const Name&,
const Interest&, mgmt::StatusDatasetContext& context) {
79 for (
const Name& routablePrefix : routablePrefixes) {
80 context.append(routablePrefix.wireEncode());
88 bind(&Program::handlePrefixRegistrationFailure,
this, _1, _2));
92 Program::handlePrefixRegistrationFailure(
const Name& prefix,
const std::string& reason)
94 std::cerr <<
"ERROR: cannot register prefix " << prefix
95 <<
" (" << reason <<
")" << std::endl;
Copyright (c) 2014-2017, Regents of the University of California, Arizona Board of Regents...