blob: a37bb2e4d40ae684bd21760e97f12e8110b78ef1 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Muktadir R Chowdhury800833b2016-07-29 13:43:59 -05003 * Copyright (c) 2014-2016, The University of Memphis,
Vince Lehmanc2acdcb2015-04-29 11:14:35 -05004 * Regents of the University of California,
5 * Arizona Board of Regents.
akmhoque3d06e792014-05-27 16:23:20 -05006 *
7 * This file is part of NLSR (Named-data Link State Routing).
8 * See AUTHORS.md for complete list of NLSR authors and contributors.
9 *
10 * NLSR is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
akmhoque3d06e792014-05-27 16:23:20 -050020 **/
Vince Lehmanc2acdcb2015-04-29 11:14:35 -050021
akmhoque31d1d4b2014-05-05 22:08:14 -050022#ifndef NLSR_HELLO_PROTOCOL_HPP
23#define NLSR_HELLO_PROTOCOL_HPP
24
Vince Lehmanf7eec4f2015-05-08 19:02:31 -050025#include "test-access-control.hpp"
26
akmhoque31d1d4b2014-05-05 22:08:14 -050027#include <ndn-cxx/face.hpp>
Vince Lehmanc2acdcb2015-04-29 11:14:35 -050028#include <ndn-cxx/management/nfd-control-parameters.hpp>
akmhoque31d1d4b2014-05-05 22:08:14 -050029#include <ndn-cxx/util/scheduler.hpp>
30
31namespace nlsr {
32
33class Nlsr;
34
35class HelloProtocol
36{
akmhoque31d1d4b2014-05-05 22:08:14 -050037public:
Vince Lehman7c603292014-09-11 17:48:16 -050038 HelloProtocol(Nlsr& nlsr, ndn::Scheduler& scheduler)
akmhoque31d1d4b2014-05-05 22:08:14 -050039 : m_nlsr(nlsr)
Vince Lehman7c603292014-09-11 17:48:16 -050040 , m_scheduler(scheduler)
akmhoque31d1d4b2014-05-05 22:08:14 -050041 {
42 }
43
akmhoque31d1d4b2014-05-05 22:08:14 -050044 void
45 scheduleInterest(uint32_t seconds);
46
47 void
48 expressInterest(const ndn::Name& interestNamePrefix, uint32_t seconds);
49
50 void
51 sendScheduledInterest(uint32_t seconds);
52
53 void
54 processInterest(const ndn::Name& name, const ndn::Interest& interest);
55
56private:
57 void
58 processInterestTimedOut(const ndn::Interest& interest);
59
60 void
Yingdi Yu20e3a6e2014-05-26 23:16:10 -070061 onContent(const ndn::Interest& interest, const ndn::Data& data);
62
Vince Lehmanf7eec4f2015-05-08 19:02:31 -050063PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Yingdi Yu20e3a6e2014-05-26 23:16:10 -070064 void
65 onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
66
Vince Lehmanf7eec4f2015-05-08 19:02:31 -050067private:
Yingdi Yu20e3a6e2014-05-26 23:16:10 -070068 void
69 onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
70 const std::string& msg);
akmhoque31d1d4b2014-05-05 22:08:14 -050071
akmhoquec04e7272014-07-02 11:00:14 -050072 void
akmhoquedfe615f2014-07-27 14:12:21 -050073 onRegistrationFailure(uint32_t code, const std::string& error,
74 const ndn::Name& name);
akmhoquec04e7272014-07-02 11:00:14 -050075
76 void
77 onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
akmhoque102aea42014-08-04 10:22:12 -050078 const ndn::Name& neighbor, const ndn::time::milliseconds& timeout);
akmhoquec04e7272014-07-02 11:00:14 -050079
80 void
akmhoque8e0252b2014-07-07 16:04:44 -050081 registerPrefixes(const ndn::Name& adjName, const std::string& faceUri,
akmhoquebf11c5f2014-07-21 14:49:47 -050082 double linkCost, const ndn::time::milliseconds& timeout);
akmhoque31d1d4b2014-05-05 22:08:14 -050083private:
84 Nlsr& m_nlsr;
Vince Lehman7c603292014-09-11 17:48:16 -050085 ndn::Scheduler& m_scheduler;
86
akmhoque157b0a42014-05-13 00:26:37 -050087 static const std::string INFO_COMPONENT;
akmhoque93f1a072014-06-19 16:24:28 -050088 static const std::string NLSR_COMPONENT;
akmhoque31d1d4b2014-05-05 22:08:14 -050089};
90
91} //namespace nlsr
92
93#endif // NLSR_HELLO_PROTOCOL_HPP