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 | |
| 23 | class interestManager; |
| 24 | class ConfParameter; |
| 25 | |
| 26 | namespace nlsr |
| 27 | { |
| 28 | class SyncLogicHandler |
| 29 | { |
| 30 | public: |
| 31 | SyncLogicHandler(ndn::shared_ptr<boost::asio::io_service> ioService) |
| 32 | : validator(new ndn::ValidatorNull()) |
| 33 | , syncFace(new ndn::Face(ioService)) |
| 34 | {} |
| 35 | |
| 36 | |
| 37 | void createSyncSocket(Nlsr& pnlsr); |
| 38 | void nsyncUpdateCallBack(const vector<MissingDataInfo> &v, |
| 39 | SyncSocket *socket, Nlsr& pnlsr ); |
| 40 | void nsyncRemoveCallBack(const string& prefix, Nlsr &pnlsr); |
| 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) |
| 46 | { |
| 47 | syncPrefix.clear(); |
| 48 | syncPrefix.set(sp); |
| 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, |
| 56 | Nlsr& pnlsr); |
| 57 | void publishSyncUpdate(string updatePrefix, uint64_t seqNo); |
| 58 | private: |
| 59 | ndn::shared_ptr<ndn::ValidatorNull> validator; |
| 60 | ndn::shared_ptr<ndn::Face> syncFace; |
| 61 | ndn::shared_ptr<SyncSocket> syncSocket; |
| 62 | ndn::Name syncPrefix; |
| 63 | }; |
| 64 | } |
| 65 | #endif |