blob: 70fd07ec0852ef44c96afe2b570c225d5e1ffdbd [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014 University of Memphis,
4 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>
19 *
akmhoque3d06e792014-05-27 16:23:20 -050020 **/
akmhoquefdbddb12014-05-02 18:35:19 -050021#ifndef NLSR_SYNC_LOGIC_HANDLER_HPP
22#define NLSR_SYNC_LOGIC_HANDLER_HPP
akmhoque53353462014-04-22 08:43:45 -050023
Vince Lehman904c2412014-09-23 19:36:11 -050024#include <ndn-cxx/face.hpp>
25#include <ndn-cxx/security/validator-null.hpp>
26#include <nsync/sync-socket.h>
27
akmhoque53353462014-04-22 08:43:45 -050028#include <iostream>
Vince Lehman904c2412014-09-23 19:36:11 -050029#include <unistd.h>
akmhoquefdbddb12014-05-02 18:35:19 -050030#include <boost/cstdint.hpp>
akmhoque53353462014-04-22 08:43:45 -050031
akmhoque53353462014-04-22 08:43:45 -050032class InterestManager;
akmhoque53353462014-04-22 08:43:45 -050033
34namespace nlsr {
35
Vince Lehman904c2412014-09-23 19:36:11 -050036class ConfParameter;
37class Lsdb;
38class SequencingManager;
39class SyncUpdate;
40
akmhoque53353462014-04-22 08:43:45 -050041class SyncLogicHandler
42{
43public:
Vince Lehman904c2412014-09-23 19:36:11 -050044 SyncLogicHandler(ndn::Face& face, Lsdb& lsdb, ConfParameter& conf)
akmhoque53353462014-04-22 08:43:45 -050045 : m_validator(new ndn::ValidatorNull())
Vince Lehman904c2412014-09-23 19:36:11 -050046 , m_syncFace(face)
47 , m_lsdb(lsdb)
48 , m_confParam(conf)
akmhoque157b0a42014-05-13 00:26:37 -050049 {
50 }
akmhoque53353462014-04-22 08:43:45 -050051
Vince Lehman904c2412014-09-23 19:36:11 -050052 void
53 createSyncSocket();
akmhoque53353462014-04-22 08:43:45 -050054
55 void
Vince Lehman904c2412014-09-23 19:36:11 -050056 onNsyncUpdate(const std::vector<Sync::MissingDataInfo>& v, Sync::SyncSocket* socket);
akmhoque53353462014-04-22 08:43:45 -050057
58 void
Vince Lehman904c2412014-09-23 19:36:11 -050059 onNsyncRemoval(const std::string& prefix);
akmhoque53353462014-04-22 08:43:45 -050060
61 void
Vince Lehman904c2412014-09-23 19:36:11 -050062 publishRoutingUpdate(SequencingManager& manager, const ndn::Name& updatePrefix);
akmhoque53353462014-04-22 08:43:45 -050063
64 void
akmhoquefdbddb12014-05-02 18:35:19 -050065 setSyncPrefix(const std::string& sp)
akmhoque53353462014-04-22 08:43:45 -050066 {
67 m_syncPrefix.clear();
68 m_syncPrefix.set(sp);
69 }
70
71private:
72 void
Vince Lehman904c2412014-09-23 19:36:11 -050073 processUpdateFromSync(const SyncUpdate& updateName);
74
75 bool
76 isLsaNew(const ndn::Name& originRouter, const std::string& lsaType, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -050077
78 void
Vince Lehman904c2412014-09-23 19:36:11 -050079 expressInterestForLsa(const SyncUpdate& updateName, std::string lsaType, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -050080
akmhoque53353462014-04-22 08:43:45 -050081 void
akmhoque31d1d4b2014-05-05 22:08:14 -050082 publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -050083
84private:
85 ndn::shared_ptr<ndn::ValidatorNull> m_validator;
Vince Lehman904c2412014-09-23 19:36:11 -050086 ndn::Face& m_syncFace;
akmhoque53353462014-04-22 08:43:45 -050087 ndn::shared_ptr<Sync::SyncSocket> m_syncSocket;
88 ndn::Name m_syncPrefix;
Vince Lehman904c2412014-09-23 19:36:11 -050089
90 Lsdb& m_lsdb;
91 ConfParameter& m_confParam;
92
93 static const std::string NLSR_COMPONENT;
94 static const std::string LSA_COMPONENT;
95 static const std::string NAME_COMPONENT;
96 static const std::string ADJACENCY_COMPONENT;
97 static const std::string COORDINATE_COMPONENT;
98
akmhoque53353462014-04-22 08:43:45 -050099};
100
101} //namespace nlsr
102
akmhoquefdbddb12014-05-02 18:35:19 -0500103#endif //NLSR_SYNC_LOGIC_HANDLER_HPP