Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2011-2015 Regents of the University of California. |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 8 | * 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 Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 12 | * 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 Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 16 | * 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 Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 19 | |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 20 | #ifndef NDN_NET_DEVICE_LINK_SERVICE_HPP |
| 21 | #define NDN_NET_DEVICE_LINK_SERVICE_HPP |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 22 | |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 24 | #include "ns3/ndnSIM/NFD/daemon/face/link-service.hpp" |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 25 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 26 | #include "ns3/net-device.h" |
| 27 | |
| 28 | namespace ns3 { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 29 | namespace ndn { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 30 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 31 | /** |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 32 | * \ingroup ndn-face |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 33 | * \brief Implementation of layer-2 (Ethernet) LinkService (current hack, to be changed eventually) |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 34 | * |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 35 | * NetDeviceLinkService is permanently associated with one NetDevice |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 36 | * object and this object cannot be changed for the lifetime of the |
| 37 | * face |
| 38 | * |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 39 | * \see AppLinkService |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 40 | */ |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 41 | class NetDeviceLinkService : public nfd::face::LinkService |
| 42 | { |
| 43 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 44 | public: |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 45 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 46 | * \brief Constructor |
| 47 | * |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 48 | * @param node Node associated with the face |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 49 | * @param netDevice a smart pointer to NetDevice object to which this NetDeviceLinkService will be associate |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 50 | */ |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 51 | NetDeviceLinkService(Ptr<Node> node, const Ptr<NetDevice>& netDevice); |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 52 | |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 53 | virtual |
| 54 | ~NetDeviceLinkService(); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 55 | |
| 56 | public: |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 57 | /** |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 58 | * \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 Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 65 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 66 | Ptr<NetDevice> |
| 67 | GetNetDevice() const; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 68 | |
| 69 | private: |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 70 | 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 | |
| 86 | private: |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 87 | void |
| 88 | send(Ptr<Packet> packet); |
| 89 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 90 | /// \brief callback from lower layers |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 91 | void |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 92 | receiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 93 | const Address& from, const Address& to, NetDevice::PacketType packetType); |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 94 | |
| 95 | private: |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 96 | Ptr<Node> m_node; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 97 | Ptr<NetDevice> m_netDevice; ///< \brief Smart pointer to NetDevice |
| 98 | }; |
| 99 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 100 | } // namespace ndn |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 101 | } // namespace ns3 |
| 102 | |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 103 | #endif // NDN_NET_DEVICE_LINK_SERVICE_HPP |