mgmt: Added skeleton for InternalFace

refs: #1137

Change-Id: I5aab5a9cac8da5f31603fb755b934347b63045eb
This commit is contained in:
Steve DiBenedetto authored and Alexander Afanasyev committed 2014-01-29 22:22:46 -08:00
1 parent 71929b35da
commit 5b433984c1
4 files changed
+171

No files matched your search

+32
View File
@@ -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<void(const Name&, const Interest&)> 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
+56
View File
@@ -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
+52
View File
@@ -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<Name, OnInterest> m_interestFilters;
};
} // namespace nfd
#endif //NFD_MGMT_INTERNAL_FACE_HPP
+31
View File
@@ -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 <boost/test/unit_test.hpp>
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