| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| /** |
| * Copyright (c) 2014-2016, The University of Memphis, |
| * Regents of the University of California, |
| * Arizona Board of Regents. |
| * |
| * This file is part of NLSR (Named-data Link State Routing). |
| * See AUTHORS.md for complete list of NLSR authors and contributors. |
| * |
| * NLSR is free software: you can redistribute it and/or modify it under the terms |
| * of the GNU General Public License as published by the Free Software Foundation, |
| * either version 3 of the License, or (at your option) any later version. |
| * |
| * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| * PURPOSE. See the GNU General Public License for more details. |
| * |
| * You should have received a copy of the GNU General Public License along with |
| * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| * |
| **/ |
| #ifndef NLSR_FIB_HPP |
| #define NLSR_FIB_HPP |
| |
| #include <map> |
| |
| #include <boost/cstdint.hpp> |
| |
| #include <ndn-cxx/mgmt/nfd/controller.hpp> |
| #include <ndn-cxx/util/time.hpp> |
| #include "face-map.hpp" |
| #include "fib-entry.hpp" |
| #include "test-access-control.hpp" |
| #include "utility/face-controller.hpp" |
| |
| namespace nlsr { |
| |
| typedef ndn::nfd::Controller::CommandSucceedCallback CommandSucceedCallback; |
| typedef ndn::nfd::Controller::CommandFailCallback CommandFailCallback; |
| |
| class AdjacencyList; |
| class ConfParameter; |
| |
| class Fib |
| { |
| public: |
| Fib(ndn::Face& face, ndn::Scheduler& scheduler, AdjacencyList& adjacencyList, ConfParameter& conf, |
| ndn::KeyChain& keyChain) |
| : m_scheduler(scheduler) |
| , m_table() |
| , m_refreshTime(0) |
| , m_controller(face, keyChain) |
| , m_faceController(face.getIoService(), m_controller) |
| , m_faceMap() |
| , m_adjacencyList(adjacencyList) |
| , m_confParameter(conf) |
| { |
| } |
| |
| ~Fib() |
| { |
| } |
| |
| void |
| remove(const ndn::Name& name); |
| |
| void |
| update(const ndn::Name& name, NexthopList& allHops); |
| |
| void |
| clean(); |
| |
| void |
| setEntryRefreshTime(int32_t fert) |
| { |
| m_refreshTime = fert; |
| } |
| |
| private: |
| bool |
| isPrefixUpdatable(const ndn::Name& name); |
| |
| void |
| addNextHopsToFibEntryAndNfd(FibEntry& entry, NexthopList& hopsToAdd); |
| |
| void |
| removeOldNextHopsFromFibEntryAndNfd(FibEntry& entry, const NexthopList& installedHops); |
| |
| void |
| removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri, |
| const ndn::Name& name); |
| |
| unsigned int |
| getNumberOfFacesForName(NexthopList& nextHopList); |
| |
| ndn::EventId |
| scheduleEntryExpiration(const ndn::Name& name, int32_t feSeqNum, |
| const ndn::time::seconds& expTime); |
| |
| void |
| cancelScheduledExpiringEvent(ndn::EventId eid); |
| |
| public: |
| void |
| registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri, |
| uint64_t faceCost, |
| const ndn::time::milliseconds& timeout, |
| uint64_t flags, uint8_t times); |
| |
| void |
| registerPrefix(const ndn::Name& namePrefix, |
| const std::string& faceUri, |
| uint64_t faceCost, |
| const ndn::time::milliseconds& timeout, |
| uint64_t flags, |
| uint8_t times, |
| const CommandSucceedCallback& onSuccess, |
| const CommandFailCallback& onFailure); |
| |
| void |
| setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t count); |
| |
| void |
| writeLog(); |
| |
| void |
| destroyFace(const std::string& faceUri, |
| const CommandSucceedCallback& onSuccess, |
| const CommandFailCallback& onFailure); |
| |
| private: |
| void |
| createFace(const std::string& faceUri, |
| const CommandSucceedCallback& onSuccess, |
| const CommandFailCallback& onFailure); |
| |
| void |
| registerPrefixInNfd(ndn::nfd::ControlParameters& parameters, |
| const std::string& faceUri, |
| uint8_t times); |
| |
| void |
| registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult, |
| const ndn::nfd::ControlParameters& parameters, |
| uint8_t times, |
| const CommandSucceedCallback& onSuccess, |
| const CommandFailCallback& onFailure); |
| |
| void |
| destroyFaceInNfd(const ndn::nfd::ControlParameters& faceDestroyResult, |
| const CommandSucceedCallback& onSuccess, |
| const CommandFailCallback& onFailure); |
| |
| 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 |
| onUnregistration(const ndn::nfd::ControlParameters& commandSuccessResult, |
| const std::string& message); |
| |
| void |
| onRegistrationFailure(const ndn::nfd::ControlResponse& response, |
| const std::string& message, |
| const ndn::nfd::ControlParameters& parameters, |
| const std::string& faceUri, |
| uint8_t times); |
| |
| void |
| onUnregistrationFailure(const ndn::nfd::ControlResponse& response, |
| const std::string& message); |
| |
| void |
| onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult, |
| const std::string& message); |
| |
| void |
| onSetStrategyFailure(const ndn::nfd::ControlResponse& response, |
| const ndn::nfd::ControlParameters& parameters, |
| uint32_t count, |
| const std::string& message); |
| |
| private: |
| ndn::Scheduler& m_scheduler; |
| std::map<ndn::Name, FibEntry> m_table; |
| int32_t m_refreshTime; |
| ndn::nfd::Controller m_controller; |
| util::FaceController m_faceController; |
| |
| PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| FaceMap m_faceMap; |
| |
| private: |
| AdjacencyList& m_adjacencyList; |
| ConfParameter& m_confParameter; |
| |
| static const uint64_t GRACE_PERIOD; |
| }; |
| |
| } // namespace nlsr |
| #endif //NLSR_FIB_HPP |