blob: 379d3cead163e27d3fe9b94b47246b7ef09dc0cd [file] [log] [blame]
Ashlesh Gawande08784d42017-09-06 23:40:21 -05001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
Davide Pesavento30c41ec2024-02-12 17:36:35 -05003 * Copyright (c) 2012-2024 University of California, Los Angeles
Ashlesh Gawande08784d42017-09-06 23:40:21 -05004 *
5 * This file is part of ChronoSync, synchronization library for distributed realtime
6 * applications for NDN.
7 *
8 * ChronoSync is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation, either
10 * version 3 of the License, or (at your option) any later version.
11 *
12 * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ChronoSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
Ashlesh Gawande08784d42017-09-06 23:40:21 -050020#include <ndn-cxx/data.hpp>
Davide Pesavento48dbab62023-08-12 16:06:52 -040021#include <ndn-cxx/interest.hpp>
Ashlesh Gawande08784d42017-09-06 23:40:21 -050022#include <ndn-cxx/lp/nack.hpp>
Ashlesh Gawande08784d42017-09-06 23:40:21 -050023#include <ndn-cxx/security/key-chain.hpp>
Davide Pesavento48dbab62023-08-12 16:06:52 -040024#include <ndn-cxx/util/dummy-client-face.hpp>
Ashlesh Gawande08784d42017-09-06 23:40:21 -050025
26#ifndef NDN_CHRONOSYNC_UNIT_TESTS_DUMMY_FORWARDER_HPP
27#define NDN_CHRONOSYNC_UNIT_TESTS_DUMMY_FORWARDER_HPP
28
Davide Pesavento30c41ec2024-02-12 17:36:35 -050029namespace chronosync::tests {
Ashlesh Gawande08784d42017-09-06 23:40:21 -050030
31/**
Davide Pesavento30c41ec2024-02-12 17:36:35 -050032 * @brief Very basic implementation of a dummy forwarder.
Ashlesh Gawande08784d42017-09-06 23:40:21 -050033 *
34 * Interests expressed by any added face, will be forwarded to all other faces.
35 * Similarly, any pushed data, will be pushed to all other faces.
36 */
37class DummyForwarder
38{
39public:
Davide Pesavento30c41ec2024-02-12 17:36:35 -050040 DummyForwarder(boost::asio::io_context& io, ndn::KeyChain& keyChain);
Ashlesh Gawande08784d42017-09-06 23:40:21 -050041
Davide Pesavento30c41ec2024-02-12 17:36:35 -050042 ndn::Face&
Ashlesh Gawande08784d42017-09-06 23:40:21 -050043 addFace();
44
Davide Pesavento30c41ec2024-02-12 17:36:35 -050045 ndn::Face&
Ashlesh Gawande08784d42017-09-06 23:40:21 -050046 getFace(size_t nFace)
47 {
48 return *m_faces.at(nFace);
49 }
50
Nick Gordon0b3beab2018-03-02 13:03:28 -060051 void
52 removeFaces();
53
Ashlesh Gawande08784d42017-09-06 23:40:21 -050054private:
Davide Pesavento1af79492023-09-22 15:45:21 -040055 boost::asio::io_context& m_io;
Davide Pesavento30c41ec2024-02-12 17:36:35 -050056 ndn::KeyChain& m_keyChain;
57 std::vector<std::shared_ptr<ndn::DummyClientFace>> m_faces;
Ashlesh Gawande08784d42017-09-06 23:40:21 -050058};
59
Davide Pesavento30c41ec2024-02-12 17:36:35 -050060} // namespace chronosync::tests
Ashlesh Gawande08784d42017-09-06 23:40:21 -050061
62#endif // NDN_CHRONOSYNC_UNIT_TESTS_DUMMY_FORWARDER_HPP