blob: af5ad34d4648b79673698044566eb9dcaeee68ba [file] [log] [blame]
Eric Newberry2f041d22018-06-03 18:02:31 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
Junxiao Shi06d008c2019-02-04 08:26:59 +00003 * Copyright (c) 2014-2019, Regents of the University of California,
Eric Newberry2f041d22018-06-03 18:02:31 -07004 * 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 Pesaventoe75861e2019-07-24 21:55:39 -040033#include <ndn-cxx/util/scheduler.hpp>
34
Eric Newberry2f041d22018-06-03 18:02:31 -070035namespace ndn {
36namespace peek {
37
38/**
39 * \brief options for NdnPoke
40 */
41struct PokeOptions
42{
Davide Pesaventoe75861e2019-07-24 21:55:39 -040043 // Data construction options
44 Name name;
45 optional<time::milliseconds> freshnessPeriod;
46 bool wantFinalBlockId = false;
Eric Newberry2f041d22018-06-03 18:02:31 -070047 security::SigningInfo signingInfo;
Davide Pesaventoe75861e2019-07-24 21:55:39 -040048
49 // program behavior options
50 bool wantForceData = false;
51 time::milliseconds timeout = 10_s;
Eric Newberry2f041d22018-06-03 18:02:31 -070052};
53
54class NdnPoke : boost::noncopyable
55{
56public:
Davide Pesaventoe75861e2019-07-24 21:55:39 -040057 NdnPoke(Face& face, KeyChain& keyChain, std::istream& input, const PokeOptions& options);
Eric Newberry2f041d22018-06-03 18:02:31 -070058
59 void
60 start();
61
62 bool
Davide Pesaventoe75861e2019-07-24 21:55:39 -040063 didSendData() const
Eric Newberry2f041d22018-06-03 18:02:31 -070064 {
Davide Pesaventoe75861e2019-07-24 21:55:39 -040065 return m_didSendData;
Eric Newberry2f041d22018-06-03 18:02:31 -070066 }
67
Eric Newberry2f041d22018-06-03 18:02:31 -070068private:
69 shared_ptr<Data>
Davide Pesaventoe75861e2019-07-24 21:55:39 -040070 createData() const;
Eric Newberry2f041d22018-06-03 18:02:31 -070071
72private:
Davide Pesaventoe75861e2019-07-24 21:55:39 -040073 const PokeOptions m_options;
Eric Newberry2f041d22018-06-03 18:02:31 -070074 Face& m_face;
75 KeyChain& m_keyChain;
Davide Pesaventoe75861e2019-07-24 21:55:39 -040076 std::istream& m_input;
77 Scheduler m_scheduler;
78 ScopedRegisteredPrefixHandle m_registeredPrefix;
79 scheduler::ScopedEventId m_timeoutEvent;
80 bool m_didSendData = false;
Eric Newberry2f041d22018-06-03 18:02:31 -070081};
82
83} // namespace peek
84} // namespace ndn
85
86#endif // NDN_TOOLS_NDNPOKE_NDNPOKE_HPP