Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014, Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | **/ |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 25 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 26 | #ifndef NFD_DAEMON_FACE_DATAGRAM_FACE_HPP |
| 27 | #define NFD_DAEMON_FACE_DATAGRAM_FACE_HPP |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 28 | |
| 29 | #include "face.hpp" |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 30 | #include "core/logger.hpp" |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 31 | |
| 32 | namespace nfd { |
| 33 | |
Davide Pesavento | d8d4d98 | 2014-03-21 18:47:58 +0100 | [diff] [blame] | 34 | template <class Protocol> |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 35 | class DatagramFace : public Face |
| 36 | { |
| 37 | public: |
Davide Pesavento | d8d4d98 | 2014-03-21 18:47:58 +0100 | [diff] [blame] | 38 | typedef Protocol protocol; |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 39 | |
| 40 | /** \brief Construct datagram face |
| 41 | * |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 42 | * \param socket Protocol-specific socket for the created face |
| 43 | * \param isOnDemand If true, the face can be closed after it remains |
Davide Pesavento | d8d4d98 | 2014-03-21 18:47:58 +0100 | [diff] [blame] | 44 | * unused for a certain amount of time |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 45 | */ |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 46 | DatagramFace(const FaceUri& remoteUri, const FaceUri& localUri, |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 47 | const shared_ptr<typename protocol::socket>& socket, |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 48 | bool isOnDemand); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 49 | |
| 50 | virtual |
| 51 | ~DatagramFace(); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 52 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 53 | // from Face |
| 54 | virtual void |
| 55 | sendInterest(const Interest& interest); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 56 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 57 | virtual void |
| 58 | sendData(const Data& data); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 59 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 60 | virtual void |
| 61 | close(); |
| 62 | |
| 63 | void |
| 64 | handleSend(const boost::system::error_code& error, |
| 65 | const Block& wire); |
| 66 | |
| 67 | void |
| 68 | handleReceive(const boost::system::error_code& error, |
| 69 | size_t nBytesReceived); |
| 70 | |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 71 | /** |
| 72 | * \brief Set m_hasBeenUsedRecently to false |
| 73 | */ |
| 74 | void |
| 75 | resetRecentUsage(); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 76 | |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 77 | bool |
| 78 | hasBeenUsedRecently() const; |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 79 | |
| 80 | void |
| 81 | setOnDemand(bool isOnDemand); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 82 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 83 | protected: |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 84 | void |
| 85 | receiveDatagram(const uint8_t* buffer, |
| 86 | size_t nBytesReceived, |
| 87 | const boost::system::error_code& error); |
| 88 | |
| 89 | void |
| 90 | keepFaceAliveUntilAllHandlersExecuted(const shared_ptr<Face>& face); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 91 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 92 | void |
| 93 | closeSocket(); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 94 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 95 | protected: |
| 96 | shared_ptr<typename protocol::socket> m_socket; |
| 97 | uint8_t m_inputBuffer[MAX_NDN_PACKET_SIZE]; |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 98 | bool m_hasBeenUsedRecently; |
| 99 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 100 | NFD_LOG_INCLASS_DECLARE(); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 101 | }; |
| 102 | |
Davide Pesavento | 1bdef28 | 2014-04-08 20:59:50 +0200 | [diff] [blame] | 103 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 104 | template <class T> |
| 105 | inline |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 106 | DatagramFace<T>::DatagramFace(const FaceUri& remoteUri, const FaceUri& localUri, |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 107 | const shared_ptr<typename DatagramFace::protocol::socket>& socket, |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 108 | bool isOnDemand) |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 109 | : Face(remoteUri, localUri) |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 110 | , m_socket(socket) |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 111 | { |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 112 | setOnDemand(isOnDemand); |
| 113 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 114 | m_socket->async_receive(boost::asio::buffer(m_inputBuffer, MAX_NDN_PACKET_SIZE), 0, |
| 115 | bind(&DatagramFace<T>::handleReceive, this, _1, _2)); |
| 116 | } |
| 117 | |
| 118 | template <class T> |
| 119 | inline |
| 120 | DatagramFace<T>::~DatagramFace() |
| 121 | { |
| 122 | } |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 123 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 124 | template <class T> |
| 125 | inline void |
| 126 | DatagramFace<T>::sendInterest(const Interest& interest) |
| 127 | { |
Alexander Afanasyev | 7e698e6 | 2014-03-07 16:48:35 +0000 | [diff] [blame] | 128 | this->onSendInterest(interest); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 129 | m_socket->async_send(boost::asio::buffer(interest.wireEncode().wire(), |
| 130 | interest.wireEncode().size()), |
| 131 | bind(&DatagramFace<T>::handleSend, this, _1, interest.wireEncode())); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 132 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 133 | // anything else should be done here? |
| 134 | } |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 135 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 136 | template <class T> |
| 137 | inline void |
| 138 | DatagramFace<T>::sendData(const Data& data) |
| 139 | { |
Alexander Afanasyev | 7e698e6 | 2014-03-07 16:48:35 +0000 | [diff] [blame] | 140 | this->onSendData(data); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 141 | m_socket->async_send(boost::asio::buffer(data.wireEncode().wire(), |
| 142 | data.wireEncode().size()), |
| 143 | bind(&DatagramFace<T>::handleSend, this, _1, data.wireEncode())); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 144 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 145 | // anything else should be done here? |
| 146 | } |
| 147 | |
| 148 | template <class T> |
| 149 | inline void |
| 150 | DatagramFace<T>::handleSend(const boost::system::error_code& error, |
| 151 | const Block& wire) |
| 152 | { |
| 153 | if (error != 0) { |
| 154 | if (error == boost::system::errc::operation_canceled) // when socket is closed by someone |
| 155 | return; |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 156 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 157 | if (!m_socket->is_open()) |
| 158 | { |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 159 | fail("Tunnel closed"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 160 | return; |
| 161 | } |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 162 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 163 | NFD_LOG_WARN("[id:" << this->getId() |
| 164 | << ",endpoint:" << m_socket->local_endpoint() |
| 165 | << "] Send operation failed, closing socket: " |
| 166 | << error.category().message(error.value())); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 167 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 168 | closeSocket(); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 169 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 170 | if (error == boost::asio::error::eof) |
| 171 | { |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 172 | fail("Tunnel closed"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 173 | } |
| 174 | else |
| 175 | { |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 176 | fail("Send operation failed, closing socket: " + |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 177 | error.category().message(error.value())); |
| 178 | } |
| 179 | return; |
| 180 | } |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 181 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 182 | NFD_LOG_TRACE("[id:" << this->getId() |
| 183 | << ",endpoint:" << m_socket->local_endpoint() |
| 184 | << "] Successfully sent: " << wire.size() << " bytes"); |
| 185 | // do nothing (needed to retain validity of wire memory block |
| 186 | } |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 187 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 188 | template <class T> |
| 189 | inline void |
| 190 | DatagramFace<T>::close() |
| 191 | { |
| 192 | if (!m_socket->is_open()) |
| 193 | return; |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 194 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 195 | NFD_LOG_INFO("[id:" << this->getId() |
| 196 | << ",endpoint:" << m_socket->local_endpoint() |
| 197 | << "] Close tunnel"); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 198 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 199 | closeSocket(); |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 200 | fail("Close tunnel"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | template <class T> |
| 204 | inline void |
| 205 | DatagramFace<T>::handleReceive(const boost::system::error_code& error, |
| 206 | size_t nBytesReceived) |
| 207 | { |
Alexander Afanasyev | 7e698e6 | 2014-03-07 16:48:35 +0000 | [diff] [blame] | 208 | NFD_LOG_DEBUG("handleReceive: " << nBytesReceived); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 209 | receiveDatagram(m_inputBuffer, nBytesReceived, error); |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 210 | if (m_socket->is_open()) |
| 211 | m_socket->async_receive(boost::asio::buffer(m_inputBuffer, MAX_NDN_PACKET_SIZE), 0, |
| 212 | bind(&DatagramFace<T>::handleReceive, this, _1, _2)); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | template <class T> |
| 216 | inline void |
| 217 | DatagramFace<T>::receiveDatagram(const uint8_t* buffer, |
| 218 | size_t nBytesReceived, |
| 219 | const boost::system::error_code& error) |
| 220 | { |
| 221 | if (error != 0 || nBytesReceived == 0) { |
| 222 | if (error == boost::system::errc::operation_canceled) // when socket is closed by someone |
| 223 | return; |
| 224 | |
| 225 | // this should be unnecessary, but just in case |
| 226 | if (!m_socket->is_open()) |
| 227 | { |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 228 | fail("Tunnel closed"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 229 | return; |
| 230 | } |
| 231 | |
| 232 | NFD_LOG_WARN("[id:" << this->getId() |
| 233 | << ",endpoint:" << m_socket->local_endpoint() |
| 234 | << "] Receive operation failed: " |
| 235 | << error.category().message(error.value())); |
| 236 | |
| 237 | closeSocket(); |
| 238 | |
| 239 | if (error == boost::asio::error::eof) |
| 240 | { |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 241 | fail("Tunnel closed"); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 242 | } |
| 243 | else |
| 244 | { |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 245 | fail("Receive operation failed, closing socket: " + |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 246 | error.category().message(error.value())); |
| 247 | } |
| 248 | return; |
| 249 | } |
| 250 | |
| 251 | NFD_LOG_TRACE("[id:" << this->getId() |
| 252 | << ",endpoint:" << m_socket->local_endpoint() |
| 253 | << "] Received: " << nBytesReceived << " bytes"); |
| 254 | |
Alexander Afanasyev | 5a8d8d8 | 2014-03-21 14:08:41 -0700 | [diff] [blame] | 255 | Block element; |
| 256 | bool isOk = Block::fromBuffer(buffer, nBytesReceived, element); |
| 257 | if (!isOk) |
| 258 | { |
| 259 | NFD_LOG_WARN("[id:" << this->getId() |
| 260 | << ",endpoint:" << m_socket->local_endpoint() |
| 261 | << "] Failed to parse incoming packet"); |
| 262 | // This message won't extend the face lifetime |
| 263 | return; |
| 264 | } |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 265 | |
Alexander Afanasyev | 5a8d8d8 | 2014-03-21 14:08:41 -0700 | [diff] [blame] | 266 | if (element.size() != nBytesReceived) |
| 267 | { |
| 268 | NFD_LOG_WARN("[id:" << this->getId() |
| 269 | << ",endpoint:" << m_socket->local_endpoint() |
| 270 | << "] Received datagram size and decoded " |
| 271 | << "element size don't match"); |
| 272 | // This message won't extend the face lifetime |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | if (!this->decodeAndDispatchInput(element)) |
| 277 | { |
| 278 | NFD_LOG_WARN("[id:" << this->getId() |
| 279 | << ",endpoint:" << m_socket->local_endpoint() |
| 280 | << "] Received unrecognized block of type [" |
| 281 | << element.type() << "]"); |
| 282 | // This message won't extend the face lifetime |
| 283 | return; |
| 284 | } |
| 285 | |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 286 | m_hasBeenUsedRecently = true; |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | |
| 290 | template <class T> |
| 291 | inline void |
| 292 | DatagramFace<T>::keepFaceAliveUntilAllHandlersExecuted(const shared_ptr<Face>& face) |
| 293 | { |
| 294 | } |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 295 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 296 | template <class T> |
| 297 | inline void |
| 298 | DatagramFace<T>::closeSocket() |
| 299 | { |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 300 | NFD_LOG_DEBUG("closeSocket " << m_socket->local_endpoint()); |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 301 | boost::asio::io_service& io = m_socket->get_io_service(); |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 302 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 303 | // use the non-throwing variants and ignore errors, if any |
| 304 | boost::system::error_code error; |
| 305 | m_socket->shutdown(protocol::socket::shutdown_both, error); |
| 306 | m_socket->close(error); |
| 307 | // after this, handlers will be called with an error code |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 308 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 309 | // ensure that the Face object is alive at least until all pending |
| 310 | // handlers are dispatched |
| 311 | io.post(bind(&DatagramFace<T>::keepFaceAliveUntilAllHandlersExecuted, |
| 312 | this, this->shared_from_this())); |
| 313 | } |
| 314 | |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 315 | template <class T> |
| 316 | inline void |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 317 | DatagramFace<T>::setOnDemand(bool isOnDemand) |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 318 | { |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 319 | Face::setOnDemand(isOnDemand); |
Giulio Grassi | 69871f0 | 2014-03-09 16:14:44 +0100 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | template <class T> |
| 323 | inline void |
| 324 | DatagramFace<T>::resetRecentUsage() |
| 325 | { |
| 326 | m_hasBeenUsedRecently = false; |
| 327 | } |
| 328 | |
| 329 | template <class T> |
| 330 | inline bool |
| 331 | DatagramFace<T>::hasBeenUsedRecently() const |
| 332 | { |
| 333 | return m_hasBeenUsedRecently; |
| 334 | } |
| 335 | |
Giulio Grassi | 624f6c6 | 2014-02-18 19:42:14 +0100 | [diff] [blame] | 336 | } // namespace nfd |
| 337 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 338 | #endif // NFD_DAEMON_FACE_DATAGRAM_FACE_HPP |