diff --git a/daemon/face/null-face.cpp b/daemon/face/null-face.cpp index 5d556932..2c409a74 100644 --- a/daemon/face/null-face.cpp +++ b/daemon/face/null-face.cpp @@ -1,12 +1,12 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /** - * Copyright (c) 2014, Regents of the University of California, - * Arizona Board of Regents, - * Colorado State University, - * University Pierre & Marie Curie, Sorbonne University, - * Washington University in St. Louis, - * Beijing Institute of Technology, - * The University of Memphis + * Copyright (c) 2014-2015, Regents of the University of California, + * Arizona Board of Regents, + * Colorado State University, + * University Pierre & Marie Curie, Sorbonne University, + * Washington University in St. Louis, + * Beijing Institute of Technology, + * The University of Memphis. * * This file is part of NFD (Named Data Networking Forwarding Daemon). * See AUTHORS.md for complete list of NFD authors and contributors. @@ -24,31 +24,26 @@ */ #include "null-face.hpp" +#include "lp-face-wrapper.hpp" +#include "generic-link-service.hpp" +#include "internal-transport.hpp" namespace nfd { +namespace face { -// FIB might restrict creating a nexthop record toward non-local face in /localhost namespace. -// NullFace has isLocal=true to enable creating a "blackhole" FIB entry under /localhost. +// FIB could restrict creating a nexthop record toward non-local face in /localhost namespace. +// NullFace has scope=local to enable creating a "blackhole" FIB entry under /localhost. -NullFace::NullFace(const FaceUri& uri) - : Face(uri, uri, true) +shared_ptr +makeNullFace(const FaceUri& uri) { + auto face = make_unique(make_unique(), + make_unique(uri, uri, ndn::nfd::FACE_SCOPE_LOCAL)); + auto faceW = make_shared(std::move(face)); + // TODO#3172 eliminate wrapper + + return faceW; } -void -NullFace::sendInterest(const Interest& interest) -{ -} - -void -NullFace::sendData(const Data& data) -{ -} - -void -NullFace::close() -{ - this->fail("close"); -} - +} // namespace face } // namespace nfd diff --git a/daemon/face/null-face.hpp b/daemon/face/null-face.hpp index a4e39777..a07b26cb 100644 --- a/daemon/face/null-face.hpp +++ b/daemon/face/null-face.hpp @@ -1,12 +1,12 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /** - * Copyright (c) 2014, Regents of the University of California, - * Arizona Board of Regents, - * Colorado State University, - * University Pierre & Marie Curie, Sorbonne University, - * Washington University in St. Louis, - * Beijing Institute of Technology, - * The University of Memphis + * Copyright (c) 2014-2015, Regents of the University of California, + * Arizona Board of Regents, + * Colorado State University, + * University Pierre & Marie Curie, Sorbonne University, + * Washington University in St. Louis, + * Beijing Institute of Technology, + * The University of Memphis. * * This file is part of NFD (Named Data Networking Forwarding Daemon). * See AUTHORS.md for complete list of NFD authors and contributors. @@ -29,26 +29,14 @@ #include "face.hpp" namespace nfd { +namespace face { -/** - * \brief a Face that has no underlying transport and drops every packet +/** \return a Face that has no underlying transport and drops every packet */ -class NullFace : public Face -{ -public: - explicit - NullFace(const FaceUri& uri = FaceUri("null://")); - - void - sendInterest(const Interest& interest) DECL_OVERRIDE; - - void - sendData(const Data& data) DECL_OVERRIDE; - - void - close() DECL_OVERRIDE; -}; +shared_ptr +makeNullFace(const FaceUri& uri = FaceUri("null://")); +} // namespace face } // namespace nfd #endif // NFD_DAEMON_FACE_NULL_FACE_HPP diff --git a/daemon/nfd.cpp b/daemon/nfd.cpp index 2676a3a6..bcc59262 100644 --- a/daemon/nfd.cpp +++ b/daemon/nfd.cpp @@ -90,9 +90,9 @@ Nfd::initialize() initializeManagement(); - m_forwarder->getFaceTable().addReserved(make_shared(), FACEID_NULL); - m_forwarder->getFaceTable().addReserved(make_shared(FaceUri("contentstore://")), - FACEID_CONTENT_STORE); + FaceTable& faceTable = m_forwarder->getFaceTable(); + faceTable.addReserved(face::makeNullFace(), FACEID_NULL); + faceTable.addReserved(face::makeNullFace(FaceUri("contentstore://")), FACEID_CONTENT_STORE); PrivilegeHelper::drop(); diff --git a/tests/daemon/face/null-face.t.cpp b/tests/daemon/face/null-face.t.cpp index 83dfbf4a..fbc53124 100644 --- a/tests/daemon/face/null-face.t.cpp +++ b/tests/daemon/face/null-face.t.cpp @@ -24,17 +24,36 @@ */ #include "face/null-face.hpp" +#include "face/lp-face-wrapper.hpp" +#include "transport-properties.hpp" #include "tests/test-common.hpp" namespace nfd { +namespace face { namespace tests { -BOOST_FIXTURE_TEST_SUITE(FaceNullFace, BaseFixture) +using namespace nfd::tests; + +BOOST_AUTO_TEST_SUITE(Face) +BOOST_FIXTURE_TEST_SUITE(TestNullFace, BaseFixture) + +using nfd::Face; + +BOOST_AUTO_TEST_CASE(StaticProperties) +{ + shared_ptr faceW = makeNullFace(FaceUri("testnull://hhppt12sy")); + LpFace* face = static_pointer_cast(faceW)->getLpFace(); + checkStaticPropertiesInitialized(*face->getTransport()); + + BOOST_CHECK_EQUAL(face->getLocalUri(), FaceUri("testnull://hhppt12sy")); + BOOST_CHECK_EQUAL(face->getRemoteUri(), FaceUri("testnull://hhppt12sy")); + BOOST_CHECK_EQUAL(face->getScope(), ndn::nfd::FACE_SCOPE_LOCAL); +} BOOST_AUTO_TEST_CASE(Send) { - shared_ptr face = make_shared(); + shared_ptr face = makeNullFace(); shared_ptr interest = makeInterest("/A"); BOOST_CHECK_NO_THROW(face->sendInterest(*interest)); @@ -45,7 +64,9 @@ BOOST_AUTO_TEST_CASE(Send) BOOST_CHECK_NO_THROW(face->close()); } -BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() // TestNullFace +BOOST_AUTO_TEST_SUITE_END() // Face } // namespace tests +} // namespace face } // namespace nfd