blob: 02aa4009197dcf92f450eaec5e98f25af4a926b8 [file] [log] [blame]
#ifndef NLSR_FIB_HPP
#define NLSR_FIB_HPP
#include <list>
#include <boost/cstdint.hpp>
#include <ndn-cxx/management/nfd-controller.hpp>
#include <ndn-cxx/util/time.hpp>
#include "face-map.hpp"
#include "fib-entry.hpp"
namespace nlsr {
class Nlsr;
class Fib
{
public:
Fib(Nlsr& nlsr, ndn::Face& face)
: m_nlsr(nlsr)
, m_table()
, m_refreshTime(0)
, m_controller(face)
, m_faceMap()
{
}
~Fib()
{
}
void
remove(const ndn::Name& name);
void
update(const ndn::Name& name, NexthopList& nextHopList);
void
clean();
void
setEntryRefreshTime(int32_t fert)
{
m_refreshTime = fert;
}
void
print();
private:
void
removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,
const ndn::Name& name);
int
getNumberOfFacesForName(NexthopList& nextHopList, uint32_t maxFacesPerPrefix);
ndn::EventId
scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
const ndn::time::seconds& expTime);
void
cancelScheduledExpiringEvent(ndn::EventId eid);
void
refreshEntry(const ndn::Name& name, int32_t feSeqNum);
public:
void
registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
uint64_t faceCost, uint64_t timeout);
void
registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
const ndn::Name& namePrefix, uint64_t faceCost, uint64_t timeout);
void
setStrategy(const ndn::Name& name, const std::string& strategy);
void
writeLog();
private:
void
unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri);
void
onRegistration(const ndn::nfd::ControlParameters& commandSuccessResult,
const std::string& message, const std::string& faceUri);
void
onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
const std::string& message);
void
onFailure(uint32_t code, const std::string& error, const std::string& message);
private:
Nlsr& m_nlsr;
std::list<FibEntry> m_table;
int32_t m_refreshTime;
ndn::nfd::Controller m_controller;
FaceMap m_faceMap;
};
}//namespace nlsr
#endif //NLSR_FIB_HPP