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 | |
| 21 | #ifndef CCNX_NET_DEVICE_FACE_H |
| 22 | #define CCNX_NET_DEVICE_FACE_H |
| 23 | |
| 24 | #include "ccnx-face.h" |
| 25 | #include "ns3/net-device.h" |
| 26 | |
| 27 | namespace ns3 { |
| 28 | |
| 29 | class Address; |
| 30 | |
| 31 | /** |
| 32 | * \ingroup ccnx-face |
| 33 | * \brief Implementation of layer-2 (Ethernet) CCNx face |
| 34 | * |
| 35 | * This class defines basic functionality of CCNx face. Face is core |
| 36 | * component responsible for actual delivery of data packet to and |
| 37 | * from CCNx stack |
| 38 | * |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 39 | * CcnxNetDevice face is permanently associated with one NetDevice |
| 40 | * object and this object cannot be changed for the lifetime of the |
| 41 | * face |
| 42 | * |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 43 | * \see CcnxAppFace, CcnxNetDeviceFace, CcnxIpv4Face, CcnxUdpFace |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 44 | */ |
| 45 | class CcnxNetDeviceFace : public CcnxFace |
| 46 | { |
| 47 | public: |
Alexander Afanasyev | cbe92ae | 2011-12-16 13:06:18 -0800 | [diff] [blame] | 48 | static TypeId |
| 49 | GetTypeId (); |
| 50 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 51 | /** |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 52 | * \brief Constructor |
| 53 | * |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 54 | * @param node Node associated with the face |
| 55 | * @param netDevice a smart pointer to NetDevice object to which |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 56 | * this face will be associate |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 57 | */ |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 58 | CcnxNetDeviceFace (Ptr<Node> node, const Ptr<NetDevice> &netDevice); |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 59 | virtual ~CcnxNetDeviceFace(); |
| 60 | |
| 61 | //////////////////////////////////////////////////////////////////// |
| 62 | // methods overloaded from CcnxFace |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 63 | virtual void |
| 64 | RegisterProtocolHandler (ProtocolHandler handler); |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 65 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 66 | protected: |
| 67 | // also from CcnxFace |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 68 | virtual bool |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 69 | SendImpl (Ptr<Packet> p); |
| 70 | |
| 71 | public: |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 72 | /** |
| 73 | * @brief Print out name of the CcnxFace to the stream |
| 74 | */ |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 75 | virtual std::ostream& |
| 76 | Print (std::ostream &os) const; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 77 | //////////////////////////////////////////////////////////////////// |
| 78 | |
| 79 | /** |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 80 | * \brief Get NetDevice associated with the face |
| 81 | * |
| 82 | * \returns smart pointer to NetDevice associated with the face |
| 83 | */ |
| 84 | Ptr<NetDevice> GetNetDevice () const; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 85 | |
| 86 | private: |
| 87 | CcnxNetDeviceFace (const CcnxNetDeviceFace &); ///< \brief Disabled copy constructor |
| 88 | CcnxNetDeviceFace& operator= (const CcnxNetDeviceFace &); ///< \brief Disabled copy operator |
| 89 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 90 | /// \brief callback from lower layers |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 91 | void ReceiveFromNetDevice (Ptr<NetDevice> device, |
| 92 | Ptr<const Packet> p, |
| 93 | uint16_t protocol, |
| 94 | const Address &from, |
| 95 | const Address &to, |
| 96 | NetDevice::PacketType packetType); |
| 97 | |
| 98 | private: |
| 99 | Ptr<NetDevice> m_netDevice; ///< \brief Smart pointer to NetDevice |
| 100 | }; |
| 101 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 102 | } // namespace ns3 |
| 103 | |
| 104 | #endif //CCNX_NET_DEVICE_FACE_H |