blob: 27e02d66371dede5b426ed1667c5741ac909597b [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 Afanasyev56f79ea2011-08-17 23:54:27 -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 Afanasyev56f79ea2011-08-17 23:54:27 -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 Afanasyev56f79ea2011-08-17 23:54:27 -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 Afanasyev56f79ea2011-08-17 23:54:27 -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 **/
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070019
Xuxiang Tian91018732016-08-17 16:24:47 -070020#ifndef NDN_NET_DEVICE_LINK_SERVICE_HPP
21#define NDN_NET_DEVICE_LINK_SERVICE_HPP
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070022
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070023#include "ns3/ndnSIM/model/ndn-common.hpp"
Xuxiang Tian91018732016-08-17 16:24:47 -070024#include "ns3/ndnSIM/NFD/daemon/face/link-service.hpp"
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070025
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070026#include "ns3/net-device.h"
27
28namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070029namespace ndn {
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080030
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070031/**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070032 * \ingroup ndn-face
Xuxiang Tian91018732016-08-17 16:24:47 -070033 * \brief Implementation of layer-2 (Ethernet) LinkService (current hack, to be changed eventually)
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070034 *
Xuxiang Tian91018732016-08-17 16:24:47 -070035 * NetDeviceLinkService is permanently associated with one NetDevice
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070036 * object and this object cannot be changed for the lifetime of the
37 * face
38 *
Xuxiang Tian91018732016-08-17 16:24:47 -070039 * \see AppLinkService
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070040 */
Xuxiang Tian91018732016-08-17 16:24:47 -070041class NetDeviceLinkService : public nfd::face::LinkService
42{
43
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070044public:
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070045 /**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070046 * \brief Constructor
47 *
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070048 * @param node Node associated with the face
Xuxiang Tian91018732016-08-17 16:24:47 -070049 * @param netDevice a smart pointer to NetDevice object to which this NetDeviceLinkService will be associate
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070050 */
Xuxiang Tian91018732016-08-17 16:24:47 -070051 NetDeviceLinkService(Ptr<Node> node, const Ptr<NetDevice>& netDevice);
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080052
Xuxiang Tian91018732016-08-17 16:24:47 -070053 virtual
54 ~NetDeviceLinkService();
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080055
56public:
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070057 /**
Xuxiang Tian91018732016-08-17 16:24:47 -070058 * \brief Get Node associated with the LinkService
59 */
60 Ptr<Node>
61 GetNode() const;
62
63 /**
64 * \brief Get NetDevice associated with the LinkService
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070065 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080066 Ptr<NetDevice>
67 GetNetDevice() const;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070068
69private:
Xuxiang Tian91018732016-08-17 16:24:47 -070070 virtual void
71 doSendInterest(const ::ndn::Interest& interest) override;
72
73 virtual void
74 doSendData(const ::ndn::Data& data) override;
75
76 virtual void
77 doSendNack(const ::ndn::lp::Nack& nack) override;
78
79 virtual void
80 doReceivePacket(nfd::face::Transport::Packet&& packet) override
81 {
82 // not used now
83 BOOST_ASSERT(false);
84 }
85
86private:
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080087 void
88 send(Ptr<Packet> packet);
89
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070090 /// \brief callback from lower layers
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080091 void
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080092 receiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093 const Address& from, const Address& to, NetDevice::PacketType packetType);
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070094
95private:
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080096 Ptr<Node> m_node;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070097 Ptr<NetDevice> m_netDevice; ///< \brief Smart pointer to NetDevice
98};
99
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700100} // namespace ndn
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700101} // namespace ns3
102
Xuxiang Tian91018732016-08-17 16:24:47 -0700103#endif // NDN_NET_DEVICE_LINK_SERVICE_HPP