blob: 4f90fd6d916d08a2d4b2cf630cc689aa652ec3b1 [file] [log] [blame]
akmhoqueba094742014-02-28 11:47:21 -06001#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
13class KeyManager;
14
15extern "C" {
16#include <unistd.h>
17}
18
19using namespace ndn;
20using namespace Sync;
21using namespace std;
22
akmhoque05d5fcf2014-04-15 14:58:45 -050023class InterestManager;
akmhoqueba094742014-02-28 11:47:21 -060024class ConfParameter;
25
26namespace nlsr
27{
akmhoque5a44dd42014-03-12 18:11:32 -050028 class SyncLogicHandler
29 {
30 public:
31 SyncLogicHandler(ndn::shared_ptr<boost::asio::io_service> ioService)
akmhoque05d5fcf2014-04-15 14:58:45 -050032 : m_validator(new ndn::ValidatorNull())
33 , m_syncFace(new ndn::Face(ioService))
akmhoque5a44dd42014-03-12 18:11:32 -050034 {}
35
36
37 void createSyncSocket(Nlsr& pnlsr);
akmhoque05d5fcf2014-04-15 14:58:45 -050038 void nsyncUpdateCallBack(const vector<MissingDataInfo>& v,
akmhoque5a44dd42014-03-12 18:11:32 -050039 SyncSocket *socket, Nlsr& pnlsr );
akmhoque05d5fcf2014-04-15 14:58:45 -050040 void nsyncRemoveCallBack(const string& prefix, Nlsr& pnlsr);
akmhoque5a44dd42014-03-12 18:11:32 -050041 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)
akmhoqueba094742014-02-28 11:47:21 -060046 {
akmhoque05d5fcf2014-04-15 14:58:45 -050047 m_syncPrefix.clear();
48 m_syncPrefix.set(sp);
akmhoque5a44dd42014-03-12 18:11:32 -050049 }
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,
akmhoqueba094742014-02-28 11:47:21 -060056 Nlsr& pnlsr);
akmhoque5a44dd42014-03-12 18:11:32 -050057 void publishSyncUpdate(string updatePrefix, uint64_t seqNo);
58 private:
akmhoque05d5fcf2014-04-15 14:58:45 -050059 ndn::shared_ptr<ndn::ValidatorNull> m_validator;
60 ndn::shared_ptr<ndn::Face> m_syncFace;
61 ndn::shared_ptr<SyncSocket> m_syncSocket;
62 ndn::Name m_syncPrefix;
akmhoque5a44dd42014-03-12 18:11:32 -050063 };
akmhoqueba094742014-02-28 11:47:21 -060064}
65#endif