blob: 246f9cc71204d6f18838622cb4fd3f7ade6eea2e [file] [log] [blame]
Eric Newberrya98bf932015-09-21 00:58:47 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento16916ae2019-03-29 23:53:26 -04002/*
Davide Pesaventoe422f9e2022-06-03 01:30:23 -04003 * Copyright (c) 2014-2022, Regents of the University of California,
Eric Newberrya98bf932015-09-21 00:58:47 -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 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 Shicde37ad2015-12-24 01:02:05 -070026#include "dummy-face.hpp"
Davide Pesaventoa8098582019-03-31 15:48:02 -040027#include "dummy-link-service.hpp"
Eric Newberrya98bf932015-09-21 00:58:47 -070028#include "dummy-transport.hpp"
29
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040030namespace nfd::tests {
Eric Newberrya98bf932015-09-21 00:58:47 -070031
Junxiao Shicde37ad2015-12-24 01:02:05 -070032DummyFace::DummyFace(const std::string& localUri, const std::string& remoteUri,
33 ndn::nfd::FaceScope scope, ndn::nfd::FacePersistency persistency,
34 ndn::nfd::LinkType linkType)
Davide Pesaventoa8098582019-03-31 15:48:02 -040035 : Face(make_unique<DummyLinkService>(),
Junxiao Shicde37ad2015-12-24 01:02:05 -070036 make_unique<DummyTransport>(localUri, remoteUri, scope, persistency, linkType))
Davide Pesaventoa8098582019-03-31 15:48:02 -040037 , afterSend(getDummyLinkService()->afterSend)
38 , sentInterests(getDummyLinkService()->sentInterests)
39 , sentData(getDummyLinkService()->sentData)
40 , sentNacks(getDummyLinkService()->sentNacks)
Eric Newberrya98bf932015-09-21 00:58:47 -070041{
Davide Pesaventoa8098582019-03-31 15:48:02 -040042 getDummyLinkService()->setPacketLogging(LogSentPackets);
Eric Newberrya98bf932015-09-21 00:58:47 -070043}
44
45void
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040046DummyFace::setState(face::FaceState state)
Eric Newberrya98bf932015-09-21 00:58:47 -070047{
Davide Pesaventoa8098582019-03-31 15:48:02 -040048 static_cast<DummyTransport*>(getTransport())->setState(state);
Eric Newberrya98bf932015-09-21 00:58:47 -070049}
50
51void
ashiqopu075bb7d2019-03-10 01:38:21 +000052DummyFace::receiveInterest(const Interest& interest, const EndpointId& endpointId)
Eric Newberrya98bf932015-09-21 00:58:47 -070053{
ashiqopu075bb7d2019-03-10 01:38:21 +000054 getDummyLinkService()->receiveInterest(interest, endpointId);
Eric Newberrya98bf932015-09-21 00:58:47 -070055}
56
57void
ashiqopu075bb7d2019-03-10 01:38:21 +000058DummyFace::receiveData(const Data& data, const EndpointId& endpointId)
Eric Newberrya98bf932015-09-21 00:58:47 -070059{
ashiqopu075bb7d2019-03-10 01:38:21 +000060 getDummyLinkService()->receiveData(data, endpointId);
Eric Newberrya98bf932015-09-21 00:58:47 -070061}
62
63void
ashiqopu075bb7d2019-03-10 01:38:21 +000064DummyFace::receiveNack(const lp::Nack& nack, const EndpointId& endpointId)
Eric Newberrya98bf932015-09-21 00:58:47 -070065{
ashiqopu075bb7d2019-03-10 01:38:21 +000066 getDummyLinkService()->receiveNack(nack, endpointId);
Eric Newberrya98bf932015-09-21 00:58:47 -070067}
68
Davide Pesaventoa8098582019-03-31 15:48:02 -040069DummyLinkService*
70DummyFace::getDummyLinkService() const
Eric Newberrya98bf932015-09-21 00:58:47 -070071{
Davide Pesaventoa8098582019-03-31 15:48:02 -040072 return static_cast<DummyLinkService*>(getLinkService());
Eric Newberrya98bf932015-09-21 00:58:47 -070073}
74
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040075} // namespace nfd::tests