blob: 739f90b34994db515d15d172a65e7720d288df13 [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>
akmhoque53353462014-04-22 08:43:45 -050010
11#include "sequencing-manager.hpp"
12
akmhoque53353462014-04-22 08:43:45 -050013extern "C" {
14#include <unistd.h>
15}
16
17class InterestManager;
18class ConfParameter;
19
20namespace nlsr {
21
22class SyncLogicHandler
23{
24public:
akmhoquefdbddb12014-05-02 18:35:19 -050025 SyncLogicHandler(boost::asio::io_service& ioService)
akmhoque53353462014-04-22 08:43:45 -050026 : m_validator(new ndn::ValidatorNull())
27 , m_syncFace(new ndn::Face(ioService))
akmhoque157b0a42014-05-13 00:26:37 -050028 {
29 }
akmhoque53353462014-04-22 08:43:45 -050030
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