akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Muktadir R Chowdhury | 800833b | 2016-07-29 13:43:59 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, The University of Memphis, |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 6 | * |
| 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/>. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 20 | **/ |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 21 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 22 | #ifndef NLSR_HELLO_PROTOCOL_HPP |
| 23 | #define NLSR_HELLO_PROTOCOL_HPP |
| 24 | |
Vince Lehman | f7eec4f | 2015-05-08 19:02:31 -0500 | [diff] [blame] | 25 | #include "test-access-control.hpp" |
| 26 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 27 | #include <ndn-cxx/face.hpp> |
Vince Lehman | c2acdcb | 2015-04-29 11:14:35 -0500 | [diff] [blame] | 28 | #include <ndn-cxx/management/nfd-control-parameters.hpp> |
Junxiao Shi | 63bd034 | 2016-08-17 16:57:14 +0000 | [diff] [blame^] | 29 | #include <ndn-cxx/management/nfd-control-response.hpp> |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 30 | #include <ndn-cxx/util/scheduler.hpp> |
| 31 | |
| 32 | namespace nlsr { |
| 33 | |
| 34 | class Nlsr; |
| 35 | |
| 36 | class HelloProtocol |
| 37 | { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 38 | public: |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 39 | HelloProtocol(Nlsr& nlsr, ndn::Scheduler& scheduler) |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 40 | : m_nlsr(nlsr) |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 41 | , m_scheduler(scheduler) |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 42 | { |
| 43 | } |
| 44 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 45 | void |
| 46 | scheduleInterest(uint32_t seconds); |
| 47 | |
| 48 | void |
| 49 | expressInterest(const ndn::Name& interestNamePrefix, uint32_t seconds); |
| 50 | |
| 51 | void |
| 52 | sendScheduledInterest(uint32_t seconds); |
| 53 | |
| 54 | void |
| 55 | processInterest(const ndn::Name& name, const ndn::Interest& interest); |
| 56 | |
| 57 | private: |
| 58 | void |
| 59 | processInterestTimedOut(const ndn::Interest& interest); |
| 60 | |
| 61 | void |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 62 | onContent(const ndn::Interest& interest, const ndn::Data& data); |
| 63 | |
Vince Lehman | f7eec4f | 2015-05-08 19:02:31 -0500 | [diff] [blame] | 64 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 65 | void |
| 66 | onContentValidated(const ndn::shared_ptr<const ndn::Data>& data); |
| 67 | |
Vince Lehman | f7eec4f | 2015-05-08 19:02:31 -0500 | [diff] [blame] | 68 | private: |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 69 | void |
| 70 | onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, |
| 71 | const std::string& msg); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 72 | |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 73 | void |
Junxiao Shi | 63bd034 | 2016-08-17 16:57:14 +0000 | [diff] [blame^] | 74 | onRegistrationFailure(const ndn::nfd::ControlResponse& response, |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame] | 75 | const ndn::Name& name); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 76 | |
| 77 | void |
| 78 | onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult, |
akmhoque | 102aea4 | 2014-08-04 10:22:12 -0500 | [diff] [blame] | 79 | const ndn::Name& neighbor, const ndn::time::milliseconds& timeout); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 80 | |
| 81 | void |
akmhoque | 8e0252b | 2014-07-07 16:04:44 -0500 | [diff] [blame] | 82 | registerPrefixes(const ndn::Name& adjName, const std::string& faceUri, |
akmhoque | bf11c5f | 2014-07-21 14:49:47 -0500 | [diff] [blame] | 83 | double linkCost, const ndn::time::milliseconds& timeout); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 84 | private: |
| 85 | Nlsr& m_nlsr; |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 86 | ndn::Scheduler& m_scheduler; |
| 87 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 88 | static const std::string INFO_COMPONENT; |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 89 | static const std::string NLSR_COMPONENT; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 90 | }; |
| 91 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame] | 92 | } // namespace nlsr |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 93 | |
| 94 | #endif // NLSR_HELLO_PROTOCOL_HPP |