blob: 5bc8e3ab7bb676be3e2fa4020cb2842410aa902c [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
Alexander Afanasyev0c395372014-12-20 15:54:02 -080024#include "ndn-face.hpp"
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070025#include "ns3/net-device.h"
26
27namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070028namespace ndn {
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080029
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070030/**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070031 * \ingroup ndn-face
32 * \brief Implementation of layer-2 (Ethernet) Ndn face
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070033 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070034 * This class defines basic functionality of Ndn face. Face is core
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070035 * component responsible for actual delivery of data packet to and
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070036 * from Ndn stack
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070037 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070038 * NdnNetDevice face is permanently associated with one NetDevice
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070039 * object and this object cannot be changed for the lifetime of the
40 * face
41 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070042 * \see NdnAppFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070043 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080044class NetDeviceFace : public Face {
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070045public:
Alexander Afanasyevcbe92ae2011-12-16 13:06:18 -080046 static TypeId
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080047 GetTypeId();
Alexander Afanasyevcbe92ae2011-12-16 13:06:18 -080048
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070049 /**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070050 * \brief Constructor
51 *
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070052 * @param node Node associated with the face
53 * @param netDevice a smart pointer to NetDevice object to which
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070054 * this face will be associate
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070055 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080056 NetDeviceFace(Ptr<Node> node, const Ptr<NetDevice>& netDevice);
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070057 virtual ~NetDeviceFace();
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070058
59 ////////////////////////////////////////////////////////////////////
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070060 // methods overloaded from NdnFace
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070061 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080062 RegisterProtocolHandlers(const InterestHandler& interestHandler, const DataHandler& dataHandler);
Alexander Afanasyev5bee19e2013-07-10 14:33:57 -070063
64 virtual void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080065 UnRegisterProtocolHandlers();
66
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080067protected:
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070068 virtual bool
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069 Send(Ptr<Packet> p);
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080070
71public:
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070072 /**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070073 * @brief Print out name of the NdnFace to the stream
Alexander Afanasyevb4fee8b2012-06-06 12:54:26 -070074 */
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070075 virtual std::ostream&
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080076 Print(std::ostream& os) const;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070077 ////////////////////////////////////////////////////////////////////
78
79 /**
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070080 * \brief Get NetDevice associated with the face
81 *
82 * \returns smart pointer to NetDevice associated with the face
83 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080084 Ptr<NetDevice>
85 GetNetDevice() const;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070086
87private:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080088 NetDeviceFace(const NetDeviceFace&); ///< \brief Disabled copy constructor
89 NetDeviceFace&
90 operator=(const NetDeviceFace&); ///< \brief Disabled copy operator
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070091
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070092 /// \brief callback from lower layers
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093 void
94 ReceiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
95 const Address& from, const Address& to, NetDevice::PacketType packetType);
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070096
97private:
98 Ptr<NetDevice> m_netDevice; ///< \brief Smart pointer to NetDevice
99};
100
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700101} // namespace ndn
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700102} // namespace ns3
103
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800104#endif // NDN_NET_DEVICE_FACE_H