akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 1 | #ifndef NLSR_SLH_HPP |
| 2 | #define NLSR_SLH_HPP |
| 3 | |
| 4 | #include <iostream> |
| 5 | |
| 6 | #include <ndn-cpp-dev/face.hpp> |
| 7 | #include <nsync/sync-socket.h> |
| 8 | #include <ndn-cpp-dev/security/validator-null.hpp> |
| 9 | #include <ndn-cpp-dev/util/scheduler.hpp> |
| 10 | |
| 11 | #include "nlsr_sm.hpp" |
| 12 | |
| 13 | class KeyManager; |
| 14 | |
| 15 | extern "C" { |
| 16 | #include <unistd.h> |
| 17 | } |
| 18 | |
| 19 | using namespace ndn; |
| 20 | using namespace Sync; |
| 21 | using namespace std; |
| 22 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame^] | 23 | class InterestManager; |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 24 | class ConfParameter; |
| 25 | |
| 26 | namespace nlsr |
| 27 | { |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 28 | class SyncLogicHandler |
| 29 | { |
| 30 | public: |
| 31 | SyncLogicHandler(ndn::shared_ptr<boost::asio::io_service> ioService) |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame^] | 32 | : m_validator(new ndn::ValidatorNull()) |
| 33 | , m_syncFace(new ndn::Face(ioService)) |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 34 | {} |
| 35 | |
| 36 | |
| 37 | void createSyncSocket(Nlsr& pnlsr); |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame^] | 38 | void nsyncUpdateCallBack(const vector<MissingDataInfo>& v, |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 39 | SyncSocket *socket, Nlsr& pnlsr ); |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame^] | 40 | void nsyncRemoveCallBack(const string& prefix, Nlsr& pnlsr); |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 41 | void removeRouterFromSyncing(string& routerPrefix); |
| 42 | void publishRoutingUpdate(SequencingManager& sm, string updatePrefix); |
| 43 | void publishKeyUpdate(KeyManager& km); |
| 44 | void publishIdentityUpdate(string identityName); |
| 45 | void setSyncPrefix(string sp) |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 46 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame^] | 47 | m_syncPrefix.clear(); |
| 48 | m_syncPrefix.set(sp); |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 49 | } |
| 50 | private: |
| 51 | void processUpdateFromSync(std::string updateName, uint64_t seqNo, |
| 52 | Nlsr& pnlsr); |
| 53 | void processRoutingUpdateFromSync(std::string routerName, uint64_t seqNo, |
| 54 | Nlsr& pnlsr); |
| 55 | void processKeysUpdateFromSync(std::string certName, uint64_t seqNo, |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 56 | Nlsr& pnlsr); |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 57 | void publishSyncUpdate(string updatePrefix, uint64_t seqNo); |
| 58 | private: |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame^] | 59 | ndn::shared_ptr<ndn::ValidatorNull> m_validator; |
| 60 | ndn::shared_ptr<ndn::Face> m_syncFace; |
| 61 | ndn::shared_ptr<SyncSocket> m_syncSocket; |
| 62 | ndn::Name m_syncPrefix; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 63 | }; |
akmhoque | ba09474 | 2014-02-28 11:47:21 -0600 | [diff] [blame] | 64 | } |
| 65 | #endif |