blob: a307a9472129d3f7589094f69bc83b376820cef9 [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 **/
akmhoque31d1d4b2014-05-05 22:08:14 -050023#ifndef NLSR_HELLO_PROTOCOL_HPP
24#define NLSR_HELLO_PROTOCOL_HPP
25
26#include <boost/cstdint.hpp>
27#include <ndn-cxx/face.hpp>
28#include <ndn-cxx/util/scheduler.hpp>
29
30namespace nlsr {
31
32class Nlsr;
33
34class HelloProtocol
35{
akmhoque31d1d4b2014-05-05 22:08:14 -050036public:
Vince Lehman7c603292014-09-11 17:48:16 -050037 HelloProtocol(Nlsr& nlsr, ndn::Scheduler& scheduler)
akmhoque31d1d4b2014-05-05 22:08:14 -050038 : m_nlsr(nlsr)
Vince Lehman7c603292014-09-11 17:48:16 -050039 , m_scheduler(scheduler)
akmhoque31d1d4b2014-05-05 22:08:14 -050040 {
41 }
42
akmhoque31d1d4b2014-05-05 22:08:14 -050043 void
44 scheduleInterest(uint32_t seconds);
45
46 void
47 expressInterest(const ndn::Name& interestNamePrefix, uint32_t seconds);
48
49 void
50 sendScheduledInterest(uint32_t seconds);
51
52 void
53 processInterest(const ndn::Name& name, const ndn::Interest& interest);
54
55private:
56 void
57 processInterestTimedOut(const ndn::Interest& interest);
58
59 void
Yingdi Yu20e3a6e2014-05-26 23:16:10 -070060 onContent(const ndn::Interest& interest, const ndn::Data& data);
61
62 void
63 onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
64
65 void
66 onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
67 const std::string& msg);
akmhoque31d1d4b2014-05-05 22:08:14 -050068
akmhoquec04e7272014-07-02 11:00:14 -050069 void
akmhoquedfe615f2014-07-27 14:12:21 -050070 onRegistrationFailure(uint32_t code, const std::string& error,
71 const ndn::Name& name);
akmhoquec04e7272014-07-02 11:00:14 -050072
73 void
74 onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
akmhoque102aea42014-08-04 10:22:12 -050075 const ndn::Name& neighbor, const ndn::time::milliseconds& timeout);
akmhoquec04e7272014-07-02 11:00:14 -050076
77 void
akmhoque8e0252b2014-07-07 16:04:44 -050078 registerPrefixes(const ndn::Name& adjName, const std::string& faceUri,
akmhoquebf11c5f2014-07-21 14:49:47 -050079 double linkCost, const ndn::time::milliseconds& timeout);
akmhoque31d1d4b2014-05-05 22:08:14 -050080private:
81 Nlsr& m_nlsr;
Vince Lehman7c603292014-09-11 17:48:16 -050082 ndn::Scheduler& m_scheduler;
83
akmhoque157b0a42014-05-13 00:26:37 -050084 static const std::string INFO_COMPONENT;
akmhoque93f1a072014-06-19 16:24:28 -050085 static const std::string NLSR_COMPONENT;
akmhoque31d1d4b2014-05-05 22:08:14 -050086};
87
88} //namespace nlsr
89
90#endif // NLSR_HELLO_PROTOCOL_HPP