Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame^] | 3 | * Copyright (c) 2012-2024 University of California, Los Angeles |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 4 | * |
| 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 Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 20 | #include <ndn-cxx/data.hpp> |
Davide Pesavento | 48dbab6 | 2023-08-12 16:06:52 -0400 | [diff] [blame] | 21 | #include <ndn-cxx/interest.hpp> |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 22 | #include <ndn-cxx/lp/nack.hpp> |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 23 | #include <ndn-cxx/security/key-chain.hpp> |
Davide Pesavento | 48dbab6 | 2023-08-12 16:06:52 -0400 | [diff] [blame] | 24 | #include <ndn-cxx/util/dummy-client-face.hpp> |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 25 | |
| 26 | #ifndef NDN_CHRONOSYNC_UNIT_TESTS_DUMMY_FORWARDER_HPP |
| 27 | #define NDN_CHRONOSYNC_UNIT_TESTS_DUMMY_FORWARDER_HPP |
| 28 | |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame^] | 29 | namespace chronosync::tests { |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 30 | |
| 31 | /** |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame^] | 32 | * @brief Very basic implementation of a dummy forwarder. |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 33 | * |
| 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 | */ |
| 37 | class DummyForwarder |
| 38 | { |
| 39 | public: |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame^] | 40 | DummyForwarder(boost::asio::io_context& io, ndn::KeyChain& keyChain); |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 41 | |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame^] | 42 | ndn::Face& |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 43 | addFace(); |
| 44 | |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame^] | 45 | ndn::Face& |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 46 | getFace(size_t nFace) |
| 47 | { |
| 48 | return *m_faces.at(nFace); |
| 49 | } |
| 50 | |
Nick Gordon | 0b3beab | 2018-03-02 13:03:28 -0600 | [diff] [blame] | 51 | void |
| 52 | removeFaces(); |
| 53 | |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 54 | private: |
Davide Pesavento | 1af7949 | 2023-09-22 15:45:21 -0400 | [diff] [blame] | 55 | boost::asio::io_context& m_io; |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame^] | 56 | ndn::KeyChain& m_keyChain; |
| 57 | std::vector<std::shared_ptr<ndn::DummyClientFace>> m_faces; |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 58 | }; |
| 59 | |
Davide Pesavento | 30c41ec | 2024-02-12 17:36:35 -0500 | [diff] [blame^] | 60 | } // namespace chronosync::tests |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 61 | |
| 62 | #endif // NDN_CHRONOSYNC_UNIT_TESTS_DUMMY_FORWARDER_HPP |