blob: 9e7e0b6b67384e1dafa90d56204a19b1a1a12fe2 [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/*
3 * Copyright (c) 2014-2019, 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
30namespace nfd {
31namespace face {
32namespace tests {
33
Junxiao Shicde37ad2015-12-24 01:02:05 -070034DummyFace::DummyFace(const std::string& localUri, const std::string& remoteUri,
35 ndn::nfd::FaceScope scope, ndn::nfd::FacePersistency persistency,
36 ndn::nfd::LinkType linkType)
Davide Pesaventoa8098582019-03-31 15:48:02 -040037 : Face(make_unique<DummyLinkService>(),
Junxiao Shicde37ad2015-12-24 01:02:05 -070038 make_unique<DummyTransport>(localUri, remoteUri, scope, persistency, linkType))
Davide Pesaventoa8098582019-03-31 15:48:02 -040039 , afterSend(getDummyLinkService()->afterSend)
40 , sentInterests(getDummyLinkService()->sentInterests)
41 , sentData(getDummyLinkService()->sentData)
42 , sentNacks(getDummyLinkService()->sentNacks)
Eric Newberrya98bf932015-09-21 00:58:47 -070043{
Davide Pesaventoa8098582019-03-31 15:48:02 -040044 getDummyLinkService()->setPacketLogging(LogSentPackets);
Eric Newberrya98bf932015-09-21 00:58:47 -070045}
46
47void
Junxiao Shicde37ad2015-12-24 01:02:05 -070048DummyFace::setState(FaceState state)
Eric Newberrya98bf932015-09-21 00:58:47 -070049{
Davide Pesaventoa8098582019-03-31 15:48:02 -040050 static_cast<DummyTransport*>(getTransport())->setState(state);
Eric Newberrya98bf932015-09-21 00:58:47 -070051}
52
53void
Junxiao Shicde37ad2015-12-24 01:02:05 -070054DummyFace::receiveInterest(const Interest& interest)
Eric Newberrya98bf932015-09-21 00:58:47 -070055{
Davide Pesaventoa8098582019-03-31 15:48:02 -040056 getDummyLinkService()->receiveInterest(interest);
Eric Newberrya98bf932015-09-21 00:58:47 -070057}
58
59void
Junxiao Shicde37ad2015-12-24 01:02:05 -070060DummyFace::receiveData(const Data& data)
Eric Newberrya98bf932015-09-21 00:58:47 -070061{
Davide Pesaventoa8098582019-03-31 15:48:02 -040062 getDummyLinkService()->receiveData(data);
Eric Newberrya98bf932015-09-21 00:58:47 -070063}
64
65void
Junxiao Shicde37ad2015-12-24 01:02:05 -070066DummyFace::receiveNack(const lp::Nack& nack)
Eric Newberrya98bf932015-09-21 00:58:47 -070067{
Davide Pesaventoa8098582019-03-31 15:48:02 -040068 getDummyLinkService()->receiveNack(nack);
Eric Newberrya98bf932015-09-21 00:58:47 -070069}
70
Davide Pesaventoa8098582019-03-31 15:48:02 -040071DummyLinkService*
72DummyFace::getDummyLinkService() const
Eric Newberrya98bf932015-09-21 00:58:47 -070073{
Davide Pesaventoa8098582019-03-31 15:48:02 -040074 return static_cast<DummyLinkService*>(getLinkService());
Eric Newberrya98bf932015-09-21 00:58:47 -070075}
76
Eric Newberrya98bf932015-09-21 00:58:47 -070077} // namespace tests
78} // namespace face
79} // namespace nfd