blob: 9f6badd015a6567535826b313e1c8fc14b8786dd [file] [log] [blame]
akmhoquefdbddb12014-05-02 18:35:19 -05001#ifndef NLSR_SYNC_LOGIC_HANDLER_HPP
2#define NLSR_SYNC_LOGIC_HANDLER_HPP
akmhoque53353462014-04-22 08:43:45 -05003
4#include <iostream>
akmhoquefdbddb12014-05-02 18:35:19 -05005#include <boost/cstdint.hpp>
akmhoque53353462014-04-22 08:43:45 -05006
akmhoquec8a10f72014-04-25 18:42:55 -05007#include <ndn-cxx/face.hpp>
akmhoque53353462014-04-22 08:43:45 -05008#include <nsync/sync-socket.h>
akmhoquec8a10f72014-04-25 18:42:55 -05009#include <ndn-cxx/security/validator-null.hpp>
10#include <ndn-cxx/util/scheduler.hpp>
akmhoque53353462014-04-22 08:43:45 -050011
12#include "sequencing-manager.hpp"
13
Yingdi Yu0c217822014-04-24 14:22:42 -070014// class KeyManager;
akmhoque53353462014-04-22 08:43:45 -050015
16extern "C" {
17#include <unistd.h>
18}
19
20class InterestManager;
21class ConfParameter;
22
23namespace nlsr {
24
25class SyncLogicHandler
26{
27public:
akmhoquefdbddb12014-05-02 18:35:19 -050028 SyncLogicHandler(boost::asio::io_service& ioService)
akmhoque53353462014-04-22 08:43:45 -050029 : m_validator(new ndn::ValidatorNull())
30 , m_syncFace(new ndn::Face(ioService))
31 {}
32
33
34 void
35 createSyncSocket(Nlsr& pnlsr);
36
37 void
akmhoquefdbddb12014-05-02 18:35:19 -050038 nsyncUpdateCallBack(const std::vector<Sync::MissingDataInfo>& v,
akmhoque53353462014-04-22 08:43:45 -050039 Sync::SyncSocket* socket, Nlsr& pnlsr);
40
41 void
akmhoquefdbddb12014-05-02 18:35:19 -050042 nsyncRemoveCallBack(const std::string& prefix, Nlsr& pnlsr);
akmhoque53353462014-04-22 08:43:45 -050043
44 void
akmhoquefdbddb12014-05-02 18:35:19 -050045 removeRouterFromSyncing(const std::string& routerPrefix);
akmhoque53353462014-04-22 08:43:45 -050046
47 void
akmhoquefdbddb12014-05-02 18:35:19 -050048 publishRoutingUpdate(SequencingManager& sm, const std::string& updatePrefix);
akmhoque53353462014-04-22 08:43:45 -050049
Yingdi Yu0c217822014-04-24 14:22:42 -070050 // void
51 // publishKeyUpdate(KeyManager& km);
akmhoque53353462014-04-22 08:43:45 -050052
53 void
akmhoquefdbddb12014-05-02 18:35:19 -050054 publishIdentityUpdate(const std::string& identityName);
akmhoque53353462014-04-22 08:43:45 -050055
56 void
akmhoquefdbddb12014-05-02 18:35:19 -050057 setSyncPrefix(const std::string& sp)
akmhoque53353462014-04-22 08:43:45 -050058 {
59 m_syncPrefix.clear();
60 m_syncPrefix.set(sp);
61 }
62
63private:
64 void
akmhoquefdbddb12014-05-02 18:35:19 -050065 processUpdateFromSync(const std::string& updateName, uint64_t seqNo, Nlsr& pnlsr);
akmhoque53353462014-04-22 08:43:45 -050066
67 void
akmhoquefdbddb12014-05-02 18:35:19 -050068 processRoutingUpdateFromSync(const std::string& routerName, uint64_t seqNo,
akmhoque53353462014-04-22 08:43:45 -050069 Nlsr& pnlsr);
70
Yingdi Yu0c217822014-04-24 14:22:42 -070071 // void
72 // processKeysUpdateFromSync(std::string certName, uint64_t seqNo, Nlsr& pnlsr);
akmhoque53353462014-04-22 08:43:45 -050073
74 void
akmhoquefdbddb12014-05-02 18:35:19 -050075 publishSyncUpdate(const std::string& updatePrefix, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -050076
77private:
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
akmhoquefdbddb12014-05-02 18:35:19 -050086#endif //NLSR_SYNC_LOGIC_HANDLER_HPP