30 namespace autoconfig {
34 , m_keyChain(keyChain)
35 , m_controller(face, keyChain)
36 , m_nextStageOnFailure(nextStageOnFailure)
43 util::FaceUri faceUri(uri);
45 faceUri.canonize(bind(&Base::onCanonizeSuccess,
this, _1),
46 bind(&Base::onCanonizeFailure,
this, _1),
47 m_face.getIoService(), time::seconds(4));
53 Base::onCanonizeSuccess(
const util::FaceUri& canonicalUri)
55 std::cerr <<
"About to connect to: " << canonicalUri.toString() << std::endl;
57 m_controller.start<nfd::FaceCreateCommand>(nfd::ControlParameters()
58 .setUri(canonicalUri.toString()),
59 bind(&Base::onHubConnectSuccess,
this, _1),
60 bind(&Base::onHubConnectError,
this, _1));
64 Base::onCanonizeFailure(
const std::string& reason)
66 std::ostringstream os;
67 os <<
"FaceUri canonization failed: " << reason;
68 BOOST_THROW_EXCEPTION(Error(os.str()));
72 Base::onHubConnectSuccess(
const nfd::ControlParameters& resp)
74 std::cerr <<
"Successfully created face: " << resp << std::endl;
76 static const Name TESTBED_PREFIX =
"/ndn";
77 registerPrefix(TESTBED_PREFIX, resp.getFaceId());
79 static const Name LOCALHOP_NFD_PREFIX =
"/localhop/nfd";
80 registerPrefix(LOCALHOP_NFD_PREFIX, resp.getFaceId());
84 Base::onHubConnectError(
const nfd::ControlResponse& response)
86 std::ostringstream os;
87 os <<
"Failed to create face: " << response.getText() <<
" (code: " << response.getCode() <<
")";
88 BOOST_THROW_EXCEPTION(Error(os.str()));
92 Base::registerPrefix(
const Name& prefix, uint64_t faceId)
95 m_controller.start<nfd::RibRegisterCommand>(nfd::ControlParameters()
98 .setOrigin(nfd::ROUTE_ORIGIN_AUTOCONF)
100 .setExpirationPeriod(time::milliseconds::max()),
101 bind(&Base::onPrefixRegistrationSuccess,
this, _1),
102 bind(&Base::onPrefixRegistrationError,
this, _1));
106 Base::onPrefixRegistrationSuccess(
const nfd::ControlParameters& commandSuccessResult)
108 std::cerr <<
"Successful in name registration: " << commandSuccessResult << std::endl;
112 Base::onPrefixRegistrationError(
const nfd::ControlResponse& response)
114 std::ostringstream os;
115 os <<
"Failed in name registration, " << response.getText() <<
" (code: " << response.getCode() <<
")";
116 BOOST_THROW_EXCEPTION(Error(os.str()));
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...