blob: 1f625542e88b0d57851bdb033fa70e74ec6c7b09 [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
akmhoque53353462014-04-22 08:43:45 -050014extern "C" {
15#include <unistd.h>
16}
17
18class InterestManager;
19class ConfParameter;
20
21namespace nlsr {
22
23class SyncLogicHandler
24{
25public:
akmhoquefdbddb12014-05-02 18:35:19 -050026 SyncLogicHandler(boost::asio::io_service& ioService)
akmhoque53353462014-04-22 08:43:45 -050027 : m_validator(new ndn::ValidatorNull())
28 , m_syncFace(new ndn::Face(ioService))
29 {}
30
31
32 void
33 createSyncSocket(Nlsr& pnlsr);
34
35 void
akmhoquefdbddb12014-05-02 18:35:19 -050036 nsyncUpdateCallBack(const std::vector<Sync::MissingDataInfo>& v,
akmhoque53353462014-04-22 08:43:45 -050037 Sync::SyncSocket* socket, Nlsr& pnlsr);
38
39 void
akmhoquefdbddb12014-05-02 18:35:19 -050040 nsyncRemoveCallBack(const std::string& prefix, Nlsr& pnlsr);
akmhoque53353462014-04-22 08:43:45 -050041
42 void
akmhoque31d1d4b2014-05-05 22:08:14 -050043 removeRouterFromSyncing(const ndn::Name& routerPrefix);
akmhoque53353462014-04-22 08:43:45 -050044
45 void
akmhoque31d1d4b2014-05-05 22:08:14 -050046 publishRoutingUpdate(SequencingManager& sm, const ndn::Name& updatePrefix);
akmhoque53353462014-04-22 08:43:45 -050047
48 void
akmhoquefdbddb12014-05-02 18:35:19 -050049 setSyncPrefix(const std::string& sp)
akmhoque53353462014-04-22 08:43:45 -050050 {
51 m_syncPrefix.clear();
52 m_syncPrefix.set(sp);
53 }
54
55private:
56 void
akmhoque31d1d4b2014-05-05 22:08:14 -050057 processUpdateFromSync(const ndn::Name& updateName, uint64_t seqNo,
58 Nlsr& pnlsr);
akmhoque53353462014-04-22 08:43:45 -050059
60 void
akmhoque31d1d4b2014-05-05 22:08:14 -050061 processRoutingUpdateFromSync(const ndn::Name& routerName, uint64_t seqNo,
akmhoque53353462014-04-22 08:43:45 -050062 Nlsr& pnlsr);
63
akmhoque53353462014-04-22 08:43:45 -050064 void
akmhoque31d1d4b2014-05-05 22:08:14 -050065 publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -050066
67private:
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
akmhoquefdbddb12014-05-02 18:35:19 -050076#endif //NLSR_SYNC_LOGIC_HANDLER_HPP