Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
Junxiao Shi | 06d008c | 2019-02-04 08:26:59 +0000 | [diff] [blame] | 3 | * Copyright (c) 2014-2019, Regents of the University of California, |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of ndn-tools (Named Data Networking Essential Tools). |
| 12 | * See AUTHORS.md for complete list of ndn-tools authors and contributors. |
| 13 | * |
| 14 | * ndn-tools is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | * |
| 25 | * @author Jerald Paul Abraham <jeraldabraham@email.arizona.edu> |
| 26 | */ |
| 27 | |
| 28 | #ifndef NDN_TOOLS_NDNPOKE_NDNPOKE_HPP |
| 29 | #define NDN_TOOLS_NDNPOKE_NDNPOKE_HPP |
| 30 | |
| 31 | #include "core/common.hpp" |
| 32 | |
Davide Pesavento | e75861e | 2019-07-24 21:55:39 -0400 | [diff] [blame^] | 33 | #include <ndn-cxx/util/scheduler.hpp> |
| 34 | |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 35 | namespace ndn { |
| 36 | namespace peek { |
| 37 | |
| 38 | /** |
| 39 | * \brief options for NdnPoke |
| 40 | */ |
| 41 | struct PokeOptions |
| 42 | { |
Davide Pesavento | e75861e | 2019-07-24 21:55:39 -0400 | [diff] [blame^] | 43 | // Data construction options |
| 44 | Name name; |
| 45 | optional<time::milliseconds> freshnessPeriod; |
| 46 | bool wantFinalBlockId = false; |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 47 | security::SigningInfo signingInfo; |
Davide Pesavento | e75861e | 2019-07-24 21:55:39 -0400 | [diff] [blame^] | 48 | |
| 49 | // program behavior options |
| 50 | bool wantForceData = false; |
| 51 | time::milliseconds timeout = 10_s; |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | class NdnPoke : boost::noncopyable |
| 55 | { |
| 56 | public: |
Davide Pesavento | e75861e | 2019-07-24 21:55:39 -0400 | [diff] [blame^] | 57 | NdnPoke(Face& face, KeyChain& keyChain, std::istream& input, const PokeOptions& options); |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 58 | |
| 59 | void |
| 60 | start(); |
| 61 | |
| 62 | bool |
Davide Pesavento | e75861e | 2019-07-24 21:55:39 -0400 | [diff] [blame^] | 63 | didSendData() const |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 64 | { |
Davide Pesavento | e75861e | 2019-07-24 21:55:39 -0400 | [diff] [blame^] | 65 | return m_didSendData; |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 68 | private: |
| 69 | shared_ptr<Data> |
Davide Pesavento | e75861e | 2019-07-24 21:55:39 -0400 | [diff] [blame^] | 70 | createData() const; |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 71 | |
| 72 | private: |
Davide Pesavento | e75861e | 2019-07-24 21:55:39 -0400 | [diff] [blame^] | 73 | const PokeOptions m_options; |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 74 | Face& m_face; |
| 75 | KeyChain& m_keyChain; |
Davide Pesavento | e75861e | 2019-07-24 21:55:39 -0400 | [diff] [blame^] | 76 | std::istream& m_input; |
| 77 | Scheduler m_scheduler; |
| 78 | ScopedRegisteredPrefixHandle m_registeredPrefix; |
| 79 | scheduler::ScopedEventId m_timeoutEvent; |
| 80 | bool m_didSendData = false; |
Eric Newberry | 2f041d2 | 2018-06-03 18:02:31 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | } // namespace peek |
| 84 | } // namespace ndn |
| 85 | |
| 86 | #endif // NDN_TOOLS_NDNPOKE_NDNPOKE_HPP |