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