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 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 14 | extern "C" { |
| 15 | #include <unistd.h> |
| 16 | } |
| 17 | |
| 18 | class InterestManager; |
| 19 | class ConfParameter; |
| 20 | |
| 21 | namespace nlsr { |
| 22 | |
| 23 | class SyncLogicHandler |
| 24 | { |
| 25 | public: |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 26 | SyncLogicHandler(boost::asio::io_service& ioService) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 27 | : m_validator(new ndn::ValidatorNull()) |
| 28 | , m_syncFace(new ndn::Face(ioService)) |
| 29 | {} |
| 30 | |
| 31 | |
| 32 | void |
| 33 | createSyncSocket(Nlsr& pnlsr); |
| 34 | |
| 35 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 36 | nsyncUpdateCallBack(const std::vector<Sync::MissingDataInfo>& v, |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 37 | Sync::SyncSocket* socket, Nlsr& pnlsr); |
| 38 | |
| 39 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 40 | nsyncRemoveCallBack(const std::string& prefix, Nlsr& pnlsr); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 41 | |
| 42 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame^] | 43 | removeRouterFromSyncing(const ndn::Name& routerPrefix); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 44 | |
| 45 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame^] | 46 | publishRoutingUpdate(SequencingManager& sm, const ndn::Name& updatePrefix); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 47 | |
| 48 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 49 | setSyncPrefix(const std::string& sp) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 50 | { |
| 51 | m_syncPrefix.clear(); |
| 52 | m_syncPrefix.set(sp); |
| 53 | } |
| 54 | |
| 55 | private: |
| 56 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame^] | 57 | processUpdateFromSync(const ndn::Name& updateName, uint64_t seqNo, |
| 58 | Nlsr& pnlsr); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 59 | |
| 60 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame^] | 61 | processRoutingUpdateFromSync(const ndn::Name& routerName, uint64_t seqNo, |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 62 | Nlsr& pnlsr); |
| 63 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 64 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame^] | 65 | publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 66 | |
| 67 | private: |
| 68 | ndn::shared_ptr<ndn::ValidatorNull> m_validator; |
| 69 | ndn::shared_ptr<ndn::Face> m_syncFace; |
| 70 | ndn::shared_ptr<Sync::SyncSocket> m_syncSocket; |
| 71 | ndn::Name m_syncPrefix; |
| 72 | }; |
| 73 | |
| 74 | } //namespace nlsr |
| 75 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 76 | #endif //NLSR_SYNC_LOGIC_HANDLER_HPP |