blob: 5432ee1f68786bdcb8a2dbf8eb319f9e2e52817b [file] [log] [blame]
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
Ilya Moiseenko956d0542012-01-02 15:26:40 -08003 * Copyright (c) 2011 University of California, Los Angeles
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -07004 *
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 Afanasyev4aac5572012-08-09 10:49:55 -070021#ifndef NDN_NET_DEVICE_FACE_H
22#define NDN_NET_DEVICE_FACE_H
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070023
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070024#include "ns3/ndnSIM/model/ndn-common.hpp"
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080025#include "ns3/ndnSIM/model/ndn-face.hpp"
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070026
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070027#include "ns3/net-device.h"
28
29namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070030namespace ndn {
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080031
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070032/**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070033 * \ingroup ndn-face
34 * \brief Implementation of layer-2 (Ethernet) Ndn face
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070035 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070036 * This class defines basic functionality of Ndn face. Face is core
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070037 * component responsible for actual delivery of data packet to and
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070038 * from Ndn stack
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070039 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070040 * NdnNetDevice face is permanently associated with one NetDevice
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070041 * object and this object cannot be changed for the lifetime of the
42 * face
43 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070044 * \see NdnAppFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070045 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080046class NetDeviceFace : public Face {
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070047public:
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070048 /**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070049 * \brief Constructor
50 *
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070051 * @param node Node associated with the face
52 * @param netDevice a smart pointer to NetDevice object to which
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070053 * this face will be associate
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070054 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055 NetDeviceFace(Ptr<Node> node, const Ptr<NetDevice>& netDevice);
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080056
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070057 virtual ~NetDeviceFace();
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070058
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080059public: // 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 Afanasyev09c7deb2011-11-23 14:50:10 -080068
69public:
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070070 /**
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070071 * \brief Get NetDevice associated with the face
72 *
73 * \returns smart pointer to NetDevice associated with the face
74 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080075 Ptr<NetDevice>
76 GetNetDevice() const;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070077
78private:
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080079 void
80 send(Ptr<Packet> packet);
81
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070082 /// \brief callback from lower layers
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080083 void
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080084 receiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080085 const Address& from, const Address& to, NetDevice::PacketType packetType);
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070086
87private:
Alexander Afanasyev82d5ffe2014-12-30 23:55:38 -080088 Ptr<Node> m_node;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070089 Ptr<NetDevice> m_netDevice; ///< \brief Smart pointer to NetDevice
90};
91
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070092} // namespace ndn
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070093} // namespace ns3
94
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080095#endif // NDN_NET_DEVICE_FACE_H