Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 887336c | 2017-09-19 15:25:23 -0400 | [diff] [blame^] | 2 | /* |
| 3 | * Copyright (c) 2016-2017, Regents of the University of California, |
| 4 | * Colorado State University, |
| 5 | * University Pierre & Marie Curie, Sorbonne University. |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 6 | * |
| 7 | * This file is part of ndn-tools (Named Data Networking Essential Tools). |
| 8 | * See AUTHORS.md for complete list of ndn-tools authors and contributors. |
| 9 | * |
| 10 | * ndn-tools 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 | * ndn-tools 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 | * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 22 | * |
| 23 | * @author Wentao Shang |
| 24 | * @author Steve DiBenedetto |
| 25 | * @author Andrea Tosatto |
| 26 | */ |
| 27 | |
| 28 | #include "discover-version.hpp" |
| 29 | #include "data-fetcher.hpp" |
| 30 | |
| 31 | namespace ndn { |
| 32 | namespace chunks { |
| 33 | |
| 34 | DiscoverVersion::DiscoverVersion(const Name& prefix, Face& face, const Options& options) |
| 35 | : Options(options) |
| 36 | , m_prefix(prefix) |
| 37 | , m_face(face) |
| 38 | { |
| 39 | } |
| 40 | |
Davide Pesavento | 887336c | 2017-09-19 15:25:23 -0400 | [diff] [blame^] | 41 | DiscoverVersion::~DiscoverVersion() = default; |
| 42 | |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 43 | void |
Davide Pesavento | 887336c | 2017-09-19 15:25:23 -0400 | [diff] [blame^] | 44 | DiscoverVersion::expressInterest(const Interest& interest, int maxRetriesNack, int maxRetriesTimeout) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 45 | { |
| 46 | fetcher = DataFetcher::fetch(m_face, interest, maxRetriesNack, maxRetriesTimeout, |
| 47 | bind(&DiscoverVersion::handleData, this, _1, _2), |
| 48 | bind(&DiscoverVersion::handleNack, this, _1, _2), |
| 49 | bind(&DiscoverVersion::handleTimeout, this, _1, _2), |
| 50 | isVerbose); |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | DiscoverVersion::handleData(const Interest& interest, const Data& data) |
| 55 | { |
| 56 | onDiscoverySuccess(data); |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | DiscoverVersion::handleNack(const Interest& interest, const std::string& reason) |
| 61 | { |
| 62 | onDiscoveryFailure(reason); |
| 63 | } |
| 64 | |
| 65 | void |
| 66 | DiscoverVersion::handleTimeout(const Interest& interest, const std::string& reason) |
| 67 | { |
| 68 | onDiscoveryFailure(reason); |
| 69 | } |
| 70 | |
| 71 | } // namespace chunks |
| 72 | } // namespace ndn |