blob: d790a0437fb4b02529eaae8ae61afafae3f6c096 [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 *
20 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
21 *
22 **/
akmhoquefdbddb12014-05-02 18:35:19 -050023#ifndef NLSR_SYNC_LOGIC_HANDLER_HPP
24#define NLSR_SYNC_LOGIC_HANDLER_HPP
akmhoque53353462014-04-22 08:43:45 -050025
26#include <iostream>
akmhoquefdbddb12014-05-02 18:35:19 -050027#include <boost/cstdint.hpp>
akmhoque53353462014-04-22 08:43:45 -050028
akmhoquec8a10f72014-04-25 18:42:55 -050029#include <ndn-cxx/face.hpp>
akmhoque53353462014-04-22 08:43:45 -050030#include <nsync/sync-socket.h>
akmhoquec8a10f72014-04-25 18:42:55 -050031#include <ndn-cxx/security/validator-null.hpp>
akmhoque53353462014-04-22 08:43:45 -050032
33#include "sequencing-manager.hpp"
34
akmhoque53353462014-04-22 08:43:45 -050035extern "C" {
36#include <unistd.h>
37}
38
39class InterestManager;
40class ConfParameter;
41
42namespace nlsr {
43
44class SyncLogicHandler
45{
46public:
akmhoquefdbddb12014-05-02 18:35:19 -050047 SyncLogicHandler(boost::asio::io_service& ioService)
akmhoque53353462014-04-22 08:43:45 -050048 : m_validator(new ndn::ValidatorNull())
49 , m_syncFace(new ndn::Face(ioService))
akmhoque157b0a42014-05-13 00:26:37 -050050 {
51 }
akmhoque53353462014-04-22 08:43:45 -050052
53
54 void
55 createSyncSocket(Nlsr& pnlsr);
56
57 void
akmhoquefdbddb12014-05-02 18:35:19 -050058 nsyncUpdateCallBack(const std::vector<Sync::MissingDataInfo>& v,
akmhoque53353462014-04-22 08:43:45 -050059 Sync::SyncSocket* socket, Nlsr& pnlsr);
60
61 void
akmhoquefdbddb12014-05-02 18:35:19 -050062 nsyncRemoveCallBack(const std::string& prefix, Nlsr& pnlsr);
akmhoque53353462014-04-22 08:43:45 -050063
64 void
akmhoque31d1d4b2014-05-05 22:08:14 -050065 removeRouterFromSyncing(const ndn::Name& routerPrefix);
akmhoque53353462014-04-22 08:43:45 -050066
67 void
akmhoque31d1d4b2014-05-05 22:08:14 -050068 publishRoutingUpdate(SequencingManager& sm, const ndn::Name& updatePrefix);
akmhoque53353462014-04-22 08:43:45 -050069
70 void
akmhoquefdbddb12014-05-02 18:35:19 -050071 setSyncPrefix(const std::string& sp)
akmhoque53353462014-04-22 08:43:45 -050072 {
73 m_syncPrefix.clear();
74 m_syncPrefix.set(sp);
75 }
76
77private:
78 void
akmhoque31d1d4b2014-05-05 22:08:14 -050079 processUpdateFromSync(const ndn::Name& updateName, uint64_t seqNo,
80 Nlsr& pnlsr);
akmhoque53353462014-04-22 08:43:45 -050081
82 void
akmhoque31d1d4b2014-05-05 22:08:14 -050083 processRoutingUpdateFromSync(const ndn::Name& routerName, uint64_t seqNo,
akmhoque53353462014-04-22 08:43:45 -050084 Nlsr& pnlsr);
85
akmhoque53353462014-04-22 08:43:45 -050086 void
akmhoque31d1d4b2014-05-05 22:08:14 -050087 publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -050088
89private:
90 ndn::shared_ptr<ndn::ValidatorNull> m_validator;
91 ndn::shared_ptr<ndn::Face> m_syncFace;
92 ndn::shared_ptr<Sync::SyncSocket> m_syncSocket;
93 ndn::Name m_syncPrefix;
94};
95
96} //namespace nlsr
97
akmhoquefdbddb12014-05-02 18:35:19 -050098#endif //NLSR_SYNC_LOGIC_HANDLER_HPP