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 | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 2 | /* |
Ilya Moiseenko | 956d054 | 2012-01-02 15:26:40 -0800 | [diff] [blame] | 3 | * Copyright (c) 2011 University of California, Los Angeles |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -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 | * |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 18 | * Authors: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 19 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 20 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 21 | #ifndef NDN_FACE_H |
| 22 | #define NDN_FACE_H |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 23 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 24 | #include <ostream> |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 25 | #include <algorithm> |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 26 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 27 | #include "ns3/ptr.h" |
Alexander Afanasyev | cf6dc92 | 2012-08-10 16:55:27 -0700 | [diff] [blame] | 28 | #include "ns3/object.h" |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame] | 29 | #include "ns3/nstime.h" |
Alexander Afanasyev | 7f3e49e | 2012-04-30 00:17:07 -0700 | [diff] [blame] | 30 | #include "ns3/type-id.h" |
Alexander Afanasyev | cf6dc92 | 2012-08-10 16:55:27 -0700 | [diff] [blame] | 31 | #include "ns3/traced-callback.h" |
Alexander Afanasyev | a89bc10 | 2013-07-16 10:17:31 -0700 | [diff] [blame] | 32 | #include "ns3/ndn-name.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 33 | |
| 34 | namespace ns3 { |
| 35 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 36 | class Packet; |
| 37 | class Node; |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 38 | |
| 39 | namespace ndn { |
| 40 | |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 41 | class Interest; |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 42 | class Data; |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 43 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 44 | /** |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 45 | * \ingroup ndn |
| 46 | * \defgroup ndn-face Faces |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 47 | */ |
| 48 | /** |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 49 | * \ingroup ndn-face |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 50 | * \brief Virtual class defining NDN face |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 51 | * |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 52 | * This class defines basic functionality of NDN face. Face is core |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 53 | * component responsible for actual delivery of data packet to and |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 54 | * from NDN stack |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 55 | * |
Alexander Afanasyev | c57a877 | 2013-03-16 11:55:20 -0700 | [diff] [blame] | 56 | * \see ndn::AppFace, ndn::NetDeviceFace |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 57 | */ |
Alexander Afanasyev | cf6dc92 | 2012-08-10 16:55:27 -0700 | [diff] [blame] | 58 | class Face : |
| 59 | public Object |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 60 | { |
| 61 | public: |
Alexander Afanasyev | bdc0d98 | 2011-12-16 01:15:26 -0800 | [diff] [blame] | 62 | static TypeId |
| 63 | GetTypeId (); |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 64 | |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 65 | /** |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 66 | * \brief NDN protocol handlers |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 67 | * |
| 68 | * \param face Face from which packet has been received |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 69 | * \param packet Original packet |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 70 | */ |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 71 | typedef Callback<void, Ptr<Face>, Ptr<Interest> > InterestHandler; |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 72 | typedef Callback<void, Ptr<Face>, Ptr<Data> > DataHandler; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 73 | |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 74 | /** |
| 75 | * \brief Default constructor |
| 76 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 77 | Face (Ptr<Node> node); |
| 78 | virtual ~Face(); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 79 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 80 | /** |
| 81 | * @brief Get node to which this face is associated |
| 82 | */ |
Alexander Afanasyev | e9c9d72 | 2012-01-19 16:59:30 -0800 | [diff] [blame] | 83 | Ptr<Node> |
| 84 | GetNode () const; |
| 85 | |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 86 | //////////////////////////////////////////////////////////////////// |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 87 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 88 | /** |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 89 | * \brief Register callback to call when new packet arrives on the face |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 90 | * |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 91 | * This method should call protocol-dependent registration function |
| 92 | */ |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 93 | virtual void |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 94 | RegisterProtocolHandlers (const InterestHandler &interestHandler, const DataHandler &dataHandler); |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 95 | |
| 96 | /** |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 97 | * \brief Un-Register callback to call when new packet arrives on the face |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 98 | * |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 99 | * This method should call protocol-dependent registration function |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 100 | */ |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 101 | virtual void |
| 102 | UnRegisterProtocolHandlers (); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 103 | |
| 104 | /** |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 105 | * @brief Send out interest through the face |
| 106 | * @param interest Interest to send out |
| 107 | * @param packet "payload" that is attached to the interest (can carry some packet tags) |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 108 | * |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 109 | * @returns true if interest is considered to be send out (enqueued) |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 110 | */ |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 111 | virtual bool |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 112 | SendInterest (Ptr<const Interest> interest); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * @brief Send out Dat packet through the face |
| 116 | * @param data Data packet to send out |
| 117 | * @param packet Data packet payload, can also carry packet tags |
| 118 | * |
| 119 | * @returns true if Data packet is considered to be send out (enqueued) |
| 120 | */ |
| 121 | virtual bool |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 122 | SendData (Ptr<const Data> data); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * \brief Receive interest from application or another node and forward it up to the NDN stack |
| 126 | * |
| 127 | * By default it is called from inside Receive method, but can be used directly, if appropriate |
| 128 | */ |
| 129 | virtual bool |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 130 | ReceiveInterest (Ptr<Interest> interest); |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 131 | |
| 132 | /** |
| 133 | * \brief Receive Data packet from application or another node and forward it up to the NDN stack |
| 134 | * |
| 135 | * By default it is called from inside Receive method, but can be used directly, if appropriate |
| 136 | */ |
| 137 | virtual bool |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 138 | ReceiveData (Ptr<Data> data); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 139 | //////////////////////////////////////////////////////////////////// |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 140 | |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 141 | /** |
Alexander Afanasyev | 042b4a7 | 2012-11-09 17:47:48 -0800 | [diff] [blame] | 142 | * \brief Assign routing/forwarding metric with face |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 143 | * |
| 144 | * \param metric configured routing metric (cost) of this face |
| 145 | */ |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 146 | virtual void |
| 147 | SetMetric (uint16_t metric); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 148 | |
Alexander Afanasyev | 8e0d281 | 2012-01-19 22:38:14 -0800 | [diff] [blame] | 149 | /** |
| 150 | * \brief Get routing/forwarding metric assigned to the face |
| 151 | * |
| 152 | * \returns configured routing/forwarding metric (cost) of this face |
| 153 | */ |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 154 | virtual uint16_t |
| 155 | GetMetric (void) const; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 156 | |
| 157 | /** |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 158 | * These are face states and may be distinct from actual lower-layer |
| 159 | * device states, such as found in real implementations (where the |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 160 | * device may be down but ndn face state is still up). |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 161 | */ |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 162 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 163 | /** |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 164 | * \brief Enable or disable this face |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 165 | */ |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 166 | inline void |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 167 | SetUp (bool up = true); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 168 | |
| 169 | /** |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 170 | * \brief Returns true if this face is enabled, false otherwise. |
| 171 | */ |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 172 | inline bool |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 173 | IsUp () const; |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 174 | |
| 175 | /** |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 176 | * @brief Get face flags |
| 177 | * |
| 178 | * Face flags may indicate various properties of the face. For example, if the face is an application face, |
| 179 | * than the returned flags have Face::APPLICATION bit set. |
| 180 | * |
| 181 | * @see ndn::Face::Flags for the list of currently defined face flags |
| 182 | */ |
| 183 | inline uint32_t |
| 184 | GetFlags () const; |
| 185 | |
| 186 | /** |
| 187 | * @brief List of currently defined face flags |
| 188 | */ |
| 189 | enum Flags |
| 190 | { |
| 191 | APPLICATION = 1 ///< @brief An application face |
| 192 | }; |
Alexander Afanasyev | 5ab2bcd | 2013-07-15 18:21:19 -0700 | [diff] [blame] | 193 | |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 194 | /** |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 195 | * @brief Print information about the face into the stream |
| 196 | * @param os stream to write information to |
| 197 | */ |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 198 | virtual std::ostream& |
| 199 | Print (std::ostream &os) const; |
| 200 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 201 | /** |
Alexander Afanasyev | c57a877 | 2013-03-16 11:55:20 -0700 | [diff] [blame] | 202 | * \brief Set face Id |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 203 | * |
| 204 | * Id is purely informative and should not be used for any other purpose |
| 205 | * |
| 206 | * \param id id to set |
| 207 | */ |
| 208 | inline void |
| 209 | SetId (uint32_t id); |
| 210 | |
| 211 | /** |
Alexander Afanasyev | c57a877 | 2013-03-16 11:55:20 -0700 | [diff] [blame] | 212 | * \brief Get face Id |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 213 | * |
| 214 | * Id is purely informative and should not be used for any other purpose |
| 215 | * |
| 216 | * \returns id id to set |
| 217 | */ |
| 218 | inline uint32_t |
| 219 | GetId () const; |
| 220 | |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 221 | /** |
| 222 | * \brief Compare two faces. Only two faces on the same node could be compared. |
| 223 | * |
| 224 | * Internal index is used for comparison. |
| 225 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 226 | bool |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 227 | operator== (const Face &face) const; |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 228 | |
| 229 | /** |
| 230 | * \brief Compare two faces. Only two faces on the same node could be compared. |
| 231 | * |
| 232 | * Internal index is used for comparison. |
| 233 | */ |
Alexander Afanasyev | 0845c09 | 2012-07-13 17:45:33 -0700 | [diff] [blame] | 234 | inline bool |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 235 | operator!= (const Face &face) const; |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 236 | |
Alexander Afanasyev | 0845c09 | 2012-07-13 17:45:33 -0700 | [diff] [blame] | 237 | /** |
| 238 | * \brief Compare two faces. Only two faces on the same node could be compared. |
| 239 | * |
| 240 | * Internal index is used for comparison. |
| 241 | */ |
Alexander Afanasyev | 7fd74f9 | 2011-08-25 19:40:17 -0700 | [diff] [blame] | 242 | bool |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 243 | operator< (const Face &face) const; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 244 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 245 | protected: |
| 246 | /** |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 247 | * @brief Send packet down to the stack (towards app or network) |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 248 | */ |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 249 | virtual bool |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 250 | Send (Ptr<Packet> packet); |
Alexander Afanasyev | 5ab2bcd | 2013-07-15 18:21:19 -0700 | [diff] [blame] | 251 | |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 252 | /** |
| 253 | * @brief Send packet up to the stack (towards forwarding strategy) |
| 254 | */ |
| 255 | virtual bool |
| 256 | Receive (Ptr<const Packet> p); |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 257 | |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 258 | /** |
| 259 | * @brief Set face flags |
| 260 | */ |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 261 | void |
| 262 | SetFlags (uint32_t flags); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 263 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 264 | private: |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 265 | Face (const Face &); ///< \brief Disabled copy constructor |
| 266 | Face& operator= (const Face &); ///< \brief Disabled copy operator |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 267 | |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 268 | protected: |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 269 | Ptr<Node> m_node; ///< \brief Smart pointer to Node |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 270 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 271 | private: |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 272 | InterestHandler m_upstreamInterestHandler; |
| 273 | DataHandler m_upstreamDataHandler; |
| 274 | bool m_ifup; |
Alexander Afanasyev | c57a877 | 2013-03-16 11:55:20 -0700 | [diff] [blame] | 275 | uint32_t m_id; ///< \brief id of the interface in NDN stack (per-node uniqueness) |
Alexander Afanasyev | 52a09bd | 2013-07-29 18:49:01 -0700 | [diff] [blame] | 276 | uint16_t m_metric; ///< \brief metric of the face |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 277 | uint32_t m_flags; ///< @brief faces flags (e.g., APPLICATION) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 278 | }; |
| 279 | |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 280 | std::ostream& |
| 281 | operator<< (std::ostream& os, const Face &face); |
| 282 | |
Alexander Afanasyev | 5bee19e | 2013-07-10 14:33:57 -0700 | [diff] [blame] | 283 | inline bool |
| 284 | Face::IsUp (void) const |
| 285 | { |
| 286 | return m_ifup; |
| 287 | } |
| 288 | |
| 289 | inline void |
| 290 | Face::SetUp (bool up/* = true*/) |
| 291 | { |
| 292 | m_ifup = up; |
| 293 | } |
| 294 | |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 295 | inline uint32_t |
| 296 | Face::GetFlags () const |
| 297 | { |
| 298 | return m_flags; |
| 299 | } |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 300 | |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 301 | inline bool |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 302 | operator < (const Ptr<Face> &lhs, const Ptr<Face> &rhs) |
Alexander Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 303 | { |
| 304 | return *lhs < *rhs; |
| 305 | } |
| 306 | |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 307 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 308 | Face::SetId (uint32_t id) |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 309 | { |
| 310 | m_id = id; |
| 311 | } |
| 312 | |
| 313 | uint32_t |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 314 | Face::GetId () const |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 315 | { |
| 316 | return m_id; |
| 317 | } |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 318 | |
Alexander Afanasyev | 0845c09 | 2012-07-13 17:45:33 -0700 | [diff] [blame] | 319 | inline bool |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 320 | Face::operator!= (const Face &face) const |
Alexander Afanasyev | 0845c09 | 2012-07-13 17:45:33 -0700 | [diff] [blame] | 321 | { |
| 322 | return !(*this == face); |
| 323 | } |
| 324 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 325 | } // namespace ndn |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 326 | } // namespace ns3 |
| 327 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 328 | #endif // NDN_FACE_H |