blob: 798ac1aecdeaf56aae20b9b55251ae3cf81d8343 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyev98256102011-08-14 01:00:02 -07004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyev98256102011-08-14 01:00:02 -07007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM 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,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyev98256102011-08-14 01:00:02 -070011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM 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.
Alexander Afanasyev98256102011-08-14 01:00:02 -070015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Ilya Moiseenko1cf6b0a2011-08-29 13:02:34 -070019
Alexander Afanasyevc018a562016-09-08 16:27:31 -070020#ifndef NDN_APP_LINK_SERVICE_HPP
21#define NDN_APP_LINK_SERVICE_HPP
Alexander Afanasyev98256102011-08-14 01:00:02 -070022
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070023#include "ns3/ndnSIM/model/ndn-common.hpp"
Alexander Afanasyevc018a562016-09-08 16:27:31 -070024#include "ns3/ndnSIM/NFD/daemon/face/link-service.hpp"
Alexander Afanasyev98256102011-08-14 01:00:02 -070025
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070026namespace ns3 {
Alexander Afanasyev98256102011-08-14 01:00:02 -070027
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070028class Packet;
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080029class Node;
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070030
31namespace ndn {
32
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070033class App;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070034
Alexander Afanasyev98256102011-08-14 01:00:02 -070035/**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070036 * \ingroup ndn-face
Alexander Afanasyevc018a562016-09-08 16:27:31 -070037 * \brief Implementation of LinkService for ndnSIM application
Alexander Afanasyev98256102011-08-14 01:00:02 -070038 *
Alexander Afanasyevc018a562016-09-08 16:27:31 -070039 * \see NetDeviceLinkService
Alexander Afanasyev98256102011-08-14 01:00:02 -070040 */
Alexander Afanasyevc018a562016-09-08 16:27:31 -070041class AppLinkService : public nfd::face::LinkService
42{
Alexander Afanasyev98256102011-08-14 01:00:02 -070043public:
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070044 /**
45 * \brief Default constructor
46 */
Alexander Afanasyevc018a562016-09-08 16:27:31 -070047 AppLinkService(Ptr<App> app);
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080048
Alexander Afanasyevc018a562016-09-08 16:27:31 -070049 virtual ~AppLinkService();
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050
Alexander Afanasyevc018a562016-09-08 16:27:31 -070051public:
Alexander Afanasyevc3c7f042015-08-21 11:38:00 -070052 void
53 onReceiveInterest(const Interest& interest);
54
Alexander Afanasyevc3c7f042015-08-21 11:38:00 -070055 void
56 onReceiveData(const Data& data);
57
Alexander Afanasyevc018a562016-09-08 16:27:31 -070058 void
59 onReceiveNack(const lp::Nack& nack);
60
61private:
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080062 virtual void
Alexander Afanasyevc018a562016-09-08 16:27:31 -070063 doSendInterest(const Interest& interest) override;
64
65 virtual void
66 doSendData(const Data& data) override;
67
68 virtual void
69 doSendNack(const lp::Nack& nack) override;
70
71 virtual void
72 doReceivePacket(nfd::face::Transport::Packet&& packet) override
73 {
74 // does nothing (all operations for now handled by LinkService)
75 BOOST_ASSERT(false);
76 }
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080077
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070078private:
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080079 Ptr<Node> m_node;
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070080 Ptr<App> m_app;
Alexander Afanasyev98256102011-08-14 01:00:02 -070081};
82
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070083} // namespace ndn
Alexander Afanasyev98256102011-08-14 01:00:02 -070084} // namespace ns3
85
Alexander Afanasyevc018a562016-09-08 16:27:31 -070086#endif // NDN_APP_LINK_SERVICE_HPP