blob: 2908b9bb6723ec9f12c7d89761c6c1b90d9c9090 [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
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070020#ifndef NDN_NET_DEVICE_FACE_H
21#define NDN_NET_DEVICE_FACE_H
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070022
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070023#include "ns3/ndnSIM/model/ndn-common.hpp"
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080024#include "ns3/ndnSIM/model/ndn-face.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
33 * \brief Implementation of layer-2 (Ethernet) Ndn face
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070034 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070035 * This class defines basic functionality of Ndn face. Face is core
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070036 * component responsible for actual delivery of data packet to and
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070037 * from Ndn stack
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070038 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070039 * NdnNetDevice face is permanently associated with one NetDevice
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070040 * object and this object cannot be changed for the lifetime of the
41 * face
42 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070043 * \see NdnAppFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070044 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045class NetDeviceFace : public Face {
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070046public:
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070047 /**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070048 * \brief Constructor
49 *
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070050 * @param node Node associated with the face
51 * @param netDevice a smart pointer to NetDevice object to which
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070052 * this face will be associate
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070053 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080054 NetDeviceFace(Ptr<Node> node, const Ptr<NetDevice>& netDevice);
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080055
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070056 virtual ~NetDeviceFace();
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070057
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080058public: // from nfd::Face
59 virtual void
60 sendInterest(const Interest& interest);
61
62 virtual void
63 sendData(const Data& data);
64
65 virtual void
66 close();
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080067
68public:
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070069 /**
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070070 * \brief Get NetDevice associated with the face
71 *
72 * \returns smart pointer to NetDevice associated with the face
73 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080074 Ptr<NetDevice>
75 GetNetDevice() const;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070076
77private:
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080078 void
79 send(Ptr<Packet> packet);
80
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070081 /// \brief callback from lower layers
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080082 void
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080083 receiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080084 const Address& from, const Address& to, NetDevice::PacketType packetType);
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070085
86private:
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080087 Ptr<Node> m_node;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070088 Ptr<NetDevice> m_netDevice; ///< \brief Smart pointer to NetDevice
89};
90
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070091} // namespace ndn
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070092} // namespace ns3
93
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080094#endif // NDN_NET_DEVICE_FACE_H