blob: 3fef612bba2771d9ec1be227c7779142bc6c5a95 [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
23class interestManager;
24class ConfParameter;
25
26namespace 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