diff --git a/daemon/mgmt/app-face.hpp b/daemon/mgmt/app-face.hpp new file mode 100644 index 00000000..af58cdf7 --- /dev/null +++ b/daemon/mgmt/app-face.hpp @@ -0,0 +1,32 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/** + * Copyright (C) 2014 Named Data Networking Project + * See COPYING for copyright and distribution information. + */ + +#ifndef NFD_MGMT_APP_FACE_HPP +#define NFD_MGMT_APP_FACE_HPP + +#include "common.hpp" + +namespace nfd { + +typedef ndn::func_lib::function OnInterest; + +class AppFace +{ +public: + virtual void + setInterestFilter(const Name& filter, + OnInterest onInterest) = 0; + + virtual void + put(const Data& data) = 0; + + virtual + ~AppFace() { } +}; + +} // namespace nfd + +#endif //NFD_MGMT_APP_FACE_HPP diff --git a/daemon/mgmt/internal-face.cpp b/daemon/mgmt/internal-face.cpp new file mode 100644 index 00000000..cd66b4af --- /dev/null +++ b/daemon/mgmt/internal-face.cpp @@ -0,0 +1,56 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/** + * Copyright (C) 2014 Named Data Networking Project + * See COPYING for copyright and distribution information. + */ + +#include "internal-face.hpp" + +namespace nfd { + +const FaceId INTERNAL_FACE_FACEID = 0; + +InternalFace::InternalFace() + : Face(INTERNAL_FACE_FACEID) +{ + +} + +void +InternalFace::sendInterest(const Interest& interest) +{ + static const Name prefixRegPrefix("/localhost/nfd/prefixreg"); + const Name& interestName = interest.getName(); + + if (prefixRegPrefix.isPrefixOf(interestName)) + { + //invoke FibManager + } + //Drop Interest +} + +void +InternalFace::sendData(const Data& data) +{ + +} + +void +InternalFace::setInterestFilter(const Name& filter, + OnInterest onInterest) +{ + +} + +void +InternalFace::put(const Data& data) +{ + onReceiveData(data); +} + +InternalFace::~InternalFace() +{ + +} + +} // namespace nfd diff --git a/daemon/mgmt/internal-face.hpp b/daemon/mgmt/internal-face.hpp new file mode 100644 index 00000000..77981434 --- /dev/null +++ b/daemon/mgmt/internal-face.hpp @@ -0,0 +1,52 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/** + * Copyright (C) 2014 Named Data Networking Project + * See COPYING for copyright and distribution information. + */ + +#ifndef NFD_MGMT_INTERNAL_FACE_HPP +#define NFD_MGMT_INTERNAL_FACE_HPP + +#include "face/face.hpp" +#include "app-face.hpp" + +namespace nfd { + +class InternalFace : public Face, public AppFace +{ +public: + + InternalFace(); + + // Overridden Face methods for forwarder + + virtual void + sendInterest(const Interest& interest); + + virtual void + sendData(const Data& data); + + // Methods implementing AppFace interface. Do not invoke from forwarder. + + virtual void + setInterestFilter(const Name& filter, + OnInterest onInterest); + + virtual void + put(const Data& data); + + virtual + ~InternalFace(); + +private: + + // void + // onConfig(ConfigFile::Node section, bool isDryRun); + + std::map m_interestFilters; + +}; + +} // namespace nfd + +#endif //NFD_MGMT_INTERNAL_FACE_HPP diff --git a/tests/mgmt/internal-face.cpp b/tests/mgmt/internal-face.cpp new file mode 100644 index 00000000..0ece5b67 --- /dev/null +++ b/tests/mgmt/internal-face.cpp @@ -0,0 +1,31 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/** + * Copyright (C) 2014 Named Data Networking Project + * See COPYING for copyright and distribution information. + */ + +#include "mgmt/internal-face.hpp" + +#include + +namespace nfd { + +BOOST_AUTO_TEST_SUITE(MgmtInternalFace) + +BOOST_AUTO_TEST_CASE(ValidPrefixRegistration) +{ + InternalFace internal; + Interest regInterest("/localhost/nfd/prefixreg/hello/world"); + internal.sendInterest(regInterest); +} + +BOOST_AUTO_TEST_CASE(InvalidPrefixRegistration) +{ + InternalFace internal; + Interest nonRegInterest("/hello/world"); + internal.sendInterest(nonRegInterest); +} + +BOOST_AUTO_TEST_SUITE_END() + +} // namespace nfd