akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 1 | #ifndef NLSR_SYNC_LOGIC_HANDLER_HPP |
| 2 | #define NLSR_SYNC_LOGIC_HANDLER_HPP |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 3 | |
| 4 | #include <iostream> |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 5 | #include <boost/cstdint.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 6 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 7 | #include <ndn-cxx/face.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 8 | #include <nsync/sync-socket.h> |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 9 | #include <ndn-cxx/security/validator-null.hpp> |
| 10 | #include <ndn-cxx/util/scheduler.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 11 | |
| 12 | #include "sequencing-manager.hpp" |
| 13 | |
Yingdi Yu | 0c21782 | 2014-04-24 14:22:42 -0700 | [diff] [blame] | 14 | // class KeyManager; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 15 | |
| 16 | extern "C" { |
| 17 | #include <unistd.h> |
| 18 | } |
| 19 | |
| 20 | class InterestManager; |
| 21 | class ConfParameter; |
| 22 | |
| 23 | namespace nlsr { |
| 24 | |
| 25 | class SyncLogicHandler |
| 26 | { |
| 27 | public: |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 28 | SyncLogicHandler(boost::asio::io_service& ioService) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 29 | : m_validator(new ndn::ValidatorNull()) |
| 30 | , m_syncFace(new ndn::Face(ioService)) |
| 31 | {} |
| 32 | |
| 33 | |
| 34 | void |
| 35 | createSyncSocket(Nlsr& pnlsr); |
| 36 | |
| 37 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 38 | nsyncUpdateCallBack(const std::vector<Sync::MissingDataInfo>& v, |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 39 | Sync::SyncSocket* socket, Nlsr& pnlsr); |
| 40 | |
| 41 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 42 | nsyncRemoveCallBack(const std::string& prefix, Nlsr& pnlsr); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 43 | |
| 44 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 45 | removeRouterFromSyncing(const std::string& routerPrefix); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 46 | |
| 47 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 48 | publishRoutingUpdate(SequencingManager& sm, const std::string& updatePrefix); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 49 | |
Yingdi Yu | 0c21782 | 2014-04-24 14:22:42 -0700 | [diff] [blame] | 50 | // void |
| 51 | // publishKeyUpdate(KeyManager& km); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 52 | |
| 53 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 54 | publishIdentityUpdate(const std::string& identityName); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 55 | |
| 56 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 57 | setSyncPrefix(const std::string& sp) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 58 | { |
| 59 | m_syncPrefix.clear(); |
| 60 | m_syncPrefix.set(sp); |
| 61 | } |
| 62 | |
| 63 | private: |
| 64 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 65 | processUpdateFromSync(const std::string& updateName, uint64_t seqNo, Nlsr& pnlsr); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 66 | |
| 67 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 68 | processRoutingUpdateFromSync(const std::string& routerName, uint64_t seqNo, |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 69 | Nlsr& pnlsr); |
| 70 | |
Yingdi Yu | 0c21782 | 2014-04-24 14:22:42 -0700 | [diff] [blame] | 71 | // void |
| 72 | // processKeysUpdateFromSync(std::string certName, uint64_t seqNo, Nlsr& pnlsr); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 73 | |
| 74 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 75 | publishSyncUpdate(const std::string& updatePrefix, uint64_t seqNo); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 76 | |
| 77 | private: |
| 78 | ndn::shared_ptr<ndn::ValidatorNull> m_validator; |
| 79 | ndn::shared_ptr<ndn::Face> m_syncFace; |
| 80 | ndn::shared_ptr<Sync::SyncSocket> m_syncSocket; |
| 81 | ndn::Name m_syncPrefix; |
| 82 | }; |
| 83 | |
| 84 | } //namespace nlsr |
| 85 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 86 | #endif //NLSR_SYNC_LOGIC_HANDLER_HPP |