Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
Ilya Moiseenko | 956d054 | 2012-01-02 15:26:40 -0800 | [diff] [blame] | 3 | * Copyright (c) 2011 University of California, Los Angeles |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Authors: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 21 | #ifndef NDN_NET_DEVICE_FACE_H |
| 22 | #define NDN_NET_DEVICE_FACE_H |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 23 | |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 24 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 25 | #include "ns3/ndnSIM/model/ndn-face.hpp" |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame] | 26 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 27 | #include "ns3/net-device.h" |
| 28 | |
| 29 | namespace ns3 { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 30 | namespace ndn { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 31 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 32 | /** |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 33 | * \ingroup ndn-face |
| 34 | * \brief Implementation of layer-2 (Ethernet) Ndn face |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 35 | * |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 36 | * This class defines basic functionality of Ndn face. Face is core |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 37 | * component responsible for actual delivery of data packet to and |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 38 | * from Ndn stack |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 39 | * |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 40 | * NdnNetDevice face is permanently associated with one NetDevice |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 41 | * object and this object cannot be changed for the lifetime of the |
| 42 | * face |
| 43 | * |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 44 | * \see NdnAppFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 45 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 46 | class NetDeviceFace : public Face { |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 47 | public: |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 48 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 49 | * \brief Constructor |
| 50 | * |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 51 | * @param node Node associated with the face |
| 52 | * @param netDevice a smart pointer to NetDevice object to which |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 53 | * this face will be associate |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 54 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 55 | NetDeviceFace(Ptr<Node> node, const Ptr<NetDevice>& netDevice); |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 56 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 57 | virtual ~NetDeviceFace(); |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 58 | |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 59 | public: // from nfd::Face |
| 60 | virtual void |
| 61 | sendInterest(const Interest& interest); |
| 62 | |
| 63 | virtual void |
| 64 | sendData(const Data& data); |
| 65 | |
| 66 | virtual void |
| 67 | close(); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 68 | |
| 69 | public: |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 70 | /** |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 71 | * \brief Get NetDevice associated with the face |
| 72 | * |
| 73 | * \returns smart pointer to NetDevice associated with the face |
| 74 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 75 | Ptr<NetDevice> |
| 76 | GetNetDevice() const; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 77 | |
| 78 | private: |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 79 | void |
| 80 | send(Ptr<Packet> packet); |
| 81 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 82 | /// \brief callback from lower layers |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 83 | void |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 84 | receiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 85 | const Address& from, const Address& to, NetDevice::PacketType packetType); |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 86 | |
| 87 | private: |
Alexander Afanasyev | 82d5ffe | 2014-12-30 23:55:38 -0800 | [diff] [blame] | 88 | Ptr<Node> m_node; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 89 | Ptr<NetDevice> m_netDevice; ///< \brief Smart pointer to NetDevice |
| 90 | }; |
| 91 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 92 | } // namespace ndn |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 93 | } // namespace ns3 |
| 94 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 95 | #endif // NDN_NET_DEVICE_FACE_H |