blob: 45ce00df2b7bf458060f0e820eb013eccf494dd1 [file] [log] [blame]
Davide Pesavento35120ea2015-11-17 21:13:18 +01001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi0d82d042017-07-07 06:15:27 +00002/*
Davide Pesaventod7083a52023-10-19 17:51:16 -04003 * Copyright (c) 2014-2023, Regents of the University of California,
Davide Pesavento35120ea2015-11-17 21:13:18 +01004 * 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 NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD 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 * NFD 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 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
Junxiao Shi7003c602017-01-10 13:35:28 +000026#ifndef NFD_TESTS_DAEMON_FACE_ETHERNET_FIXTURE_HPP
27#define NFD_TESTS_DAEMON_FACE_ETHERNET_FIXTURE_HPP
Davide Pesavento35120ea2015-11-17 21:13:18 +010028
Davide Pesavento6bd6d0b2017-03-25 15:16:40 -040029#include "face/multicast-ethernet-transport.hpp"
Davide Pesavento35120ea2015-11-17 21:13:18 +010030
Davide Pesaventod7083a52023-10-19 17:51:16 -040031#include "tests/daemon/global-io-fixture.hpp"
Davide Pesavento22fba352017-10-17 15:53:51 -040032#include "test-netif.hpp"
Davide Pesavento35120ea2015-11-17 21:13:18 +010033
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040034namespace nfd::tests {
Davide Pesavento35120ea2015-11-17 21:13:18 +010035
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040036/**
37 * \brief Fixture providing a list of EthernetTransport-capable network interfaces.
Junxiao Shi84d62cb2017-07-12 16:15:18 +000038 */
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040039class EthernetFixture : public virtual GlobalIoFixture
Davide Pesavento35120ea2015-11-17 21:13:18 +010040{
41protected:
Junxiao Shi7003c602017-01-10 13:35:28 +000042 EthernetFixture()
Davide Pesavento35120ea2015-11-17 21:13:18 +010043 {
Junxiao Shi84d62cb2017-07-12 16:15:18 +000044 for (const auto& netif : collectNetworkInterfaces()) {
Davide Pesaventod7083a52023-10-19 17:51:16 -040045 // similar filtering logic to EthernetFactory::applyMcastConfigToNetif()
46 if (netif->isUp() && !netif->isLoopback() && netif->canMulticast()) {
Davide Pesavento35120ea2015-11-17 21:13:18 +010047 try {
Davide Pesaventod7083a52023-10-19 17:51:16 -040048 face::MulticastEthernetTransport t(*netif, ethernet::getBroadcastAddress(),
49 ndn::nfd::LINK_TYPE_MULTI_ACCESS);
Junxiao Shi7003c602017-01-10 13:35:28 +000050 netifs.push_back(netif);
Davide Pesavento35120ea2015-11-17 21:13:18 +010051 }
Davide Pesaventod7083a52023-10-19 17:51:16 -040052 catch (const face::EthernetTransport::Error&) {
Junxiao Shi7003c602017-01-10 13:35:28 +000053 // ignore
Davide Pesavento35120ea2015-11-17 21:13:18 +010054 }
55 }
56 }
Davide Pesavento6bd6d0b2017-03-25 15:16:40 -040057 }
58
Davide Pesavento35120ea2015-11-17 21:13:18 +010059protected:
Davide Pesaventod7083a52023-10-19 17:51:16 -040060 /**
61 * \brief EthernetTransport-capable network interfaces.
Junxiao Shi7003c602017-01-10 13:35:28 +000062 */
Junxiao Shi84d62cb2017-07-12 16:15:18 +000063 std::vector<shared_ptr<const ndn::net::NetworkInterface>> netifs;
Davide Pesavento35120ea2015-11-17 21:13:18 +010064};
65
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040066} // namespace nfd::tests
67
Junxiao Shi7003c602017-01-10 13:35:28 +000068#define SKIP_IF_ETHERNET_NETIF_COUNT_LT(n) \
69 do { \
70 if (this->netifs.size() < (n)) { \
71 BOOST_WARN_MESSAGE(false, "skipping assertions that require " #n \
72 " or more EthernetTransport-capable network interfaces"); \
73 return; \
74 } \
Davide Pesavento35120ea2015-11-17 21:13:18 +010075 } while (false)
76
Junxiao Shi7003c602017-01-10 13:35:28 +000077#endif // NFD_TESTS_DAEMON_FACE_ETHERNET_FIXTURE_HPP