Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2005,2006,2007 INRIA |
| 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 | * |
Ilya Moiseenko | 1cf6b0a | 2011-08-29 13:02:34 -0700 | [diff] [blame] | 18 | * Authors: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | Ilya Moiseenko <iliamo@cs.ucla.edu> |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 20 | */ |
Ilya Moiseenko | 1cf6b0a | 2011-08-29 13:02:34 -0700 | [diff] [blame] | 21 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 22 | #ifndef CCNX_LOCAL_FACE_H |
| 23 | #define CCNX_LOCAL_FACE_H |
| 24 | |
| 25 | #include "ccnx-face.h" |
| 26 | |
Ilya Moiseenko | 1cf6b0a | 2011-08-29 13:02:34 -0700 | [diff] [blame] | 27 | namespace ns3 |
| 28 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 29 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 30 | class CcnxInterestHeader; |
| 31 | class CcnxContentObjectHeader; |
| 32 | class Packet; |
| 33 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 34 | /** |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 35 | * \ingroup ccnx-face |
| 36 | * \brief Implementation of application CCNx face |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 37 | * |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 38 | * This class defines basic functionality of CCNx face. Face is core |
| 39 | * component responsible for actual delivery of data packet to and |
| 40 | * from CCNx stack |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 41 | * |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 42 | * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxIpv4Face, CcnxUdpFace |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 43 | */ |
| 44 | class CcnxLocalFace : public CcnxFace |
| 45 | { |
| 46 | public: |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 47 | typedef Callback<void,const Ptr<const CcnxInterestHeader> &> InterestHandler; |
| 48 | typedef Callback<void,const Ptr<const CcnxContentObjectHeader> &, |
| 49 | const Ptr<const Packet> &> ContentObjectHandler; |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 50 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 51 | /** |
| 52 | * \brief Default constructor |
| 53 | */ |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 54 | CcnxLocalFace (); |
| 55 | virtual ~CcnxLocalFace(); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 56 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 57 | //////////////////////////////////////////////////////////////////// |
| 58 | // methods overloaded from CcnxFace |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 59 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 60 | /** |
| 61 | * \brief This method should be called to establish link with lower layers |
| 62 | */ |
| 63 | virtual void |
| 64 | RegisterProtocolHandler (ProtocolHandler handler); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 65 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 66 | /** |
| 67 | * \brief This method will be called by lower layers to send data to *application* |
| 68 | */ |
| 69 | virtual void |
| 70 | Send (Ptr<Packet> p); |
Ilya Moiseenko | acac1ea | 2011-10-28 13:16:53 -0700 | [diff] [blame] | 71 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 72 | virtual std::ostream& |
| 73 | Print (std::ostream &os) const; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 74 | //////////////////////////////////////////////////////////////////// |
| 75 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 76 | /** |
| 77 | * \brief This method will be called by higher layers to send data to *ccnx stack* |
| 78 | */ |
| 79 | void ReceiveFromApplication (Ptr<Packet> p); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 80 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 81 | /** |
| 82 | * \brief Set callback to application |
| 83 | * |
| 84 | * \param onInterest InterestHandler to be called when interest arrives on the face. Will be disabled if 0 |
| 85 | */ |
| 86 | void SetInterestHandler (InterestHandler onInterest); |
| 87 | |
| 88 | /** |
| 89 | * \brief Set callback to application |
| 90 | * |
| 91 | * \param onContentObject ContentObjectHandler to be called when data arrives. Will be disabled if 0 |
| 92 | */ |
| 93 | void SetContentObjectHandler (ContentObjectHandler onContentObject); |
| 94 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 95 | private: |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 96 | CcnxLocalFace (const CcnxLocalFace &); ///< \brief Disabled copy constructor |
| 97 | CcnxLocalFace& operator= (const CcnxLocalFace &); ///< \brief Disabled copy operator |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 98 | |
| 99 | private: |
| 100 | InterestHandler m_onInterest; |
| 101 | ContentObjectHandler m_onContentObject; |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 104 | std::ostream& operator<< (std::ostream& os, const CcnxLocalFace &localFace); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 105 | |
| 106 | } // namespace ns3 |
| 107 | |
| 108 | #endif |