blob: f297f9da4fcf1def107b982df8a2738b9c4a6b82 [file] [log] [blame]
Eric Newberry2f041d22018-06-03 18:02:31 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014-2018, Regents of the University of California,
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
33namespace ndn {
34namespace peek {
35
36/**
37 * \brief options for NdnPoke
38 */
39struct PokeOptions
40{
41 Name prefixName;
42 bool wantForceData = false;
43 security::SigningInfo signingInfo;
44 bool wantLastAsFinalBlockId = false;
45 optional<time::milliseconds> freshnessPeriod = {};
46};
47
48class NdnPoke : boost::noncopyable
49{
50public:
51 NdnPoke(Face& face, KeyChain& keyChain, std::istream& inStream, const PokeOptions& options);
52
53 void
54 start();
55
56 bool
57 wasDataSent() const
58 {
59 return m_wasDataSent;
60 }
61
Eric Newberry2f041d22018-06-03 18:02:31 -070062private:
63 shared_ptr<Data>
64 createDataPacket();
65
66 void
67 onInterest(const Name& name, const Interest& interest, const shared_ptr<Data>& data);
68
69 void
70 onRegisterFailed(const Name& prefix, const std::string& reason);
71
72private:
73 Face& m_face;
74 KeyChain& m_keyChain;
75 std::istream& m_inStream;
76 const PokeOptions& m_options;
77
Eric Newberry468dbdf2018-06-20 23:58:55 -070078 const RegisteredPrefixId* m_registeredPrefix;
Eric Newberry2f041d22018-06-03 18:02:31 -070079 bool m_wasDataSent;
80};
81
82} // namespace peek
83} // namespace ndn
84
85#endif // NDN_TOOLS_NDNPOKE_NDNPOKE_HPP