Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 2 | /* |
Eric Newberry | f3ee808 | 2020-01-28 13:44:18 -0800 | [diff] [blame] | 3 | * Copyright (c) 2014-2020, Regents of the University of California, |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 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. |
| 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 | */ |
| 25 | |
| 26 | #ifndef NFD_DAEMON_FACE_TRANSPORT_HPP |
| 27 | #define NFD_DAEMON_FACE_TRANSPORT_HPP |
| 28 | |
Davide Pesavento | cb425e8 | 2019-07-14 21:48:22 -0400 | [diff] [blame] | 29 | #include "face-common.hpp" |
Davide Pesavento | 2cae8ca | 2019-04-18 20:48:05 -0400 | [diff] [blame] | 30 | #include "common/counter.hpp" |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 31 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 32 | namespace nfd { |
| 33 | namespace face { |
| 34 | |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 35 | /** \brief Indicates the state of a transport. |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 36 | */ |
| 37 | enum class TransportState { |
| 38 | NONE, |
Davide Pesavento | 68ab43d | 2017-07-02 13:37:35 -0400 | [diff] [blame] | 39 | UP, ///< the transport is up and can transmit packets |
| 40 | DOWN, ///< the transport is temporarily down, and is being recovered |
| 41 | CLOSING, ///< the transport is being closed gracefully, either by the peer or by a call to close() |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 42 | FAILED, ///< the transport is being closed due to a failure |
| 43 | CLOSED ///< the transport is closed, and can be safely deallocated |
| 44 | }; |
| 45 | |
| 46 | std::ostream& |
| 47 | operator<<(std::ostream& os, TransportState state); |
| 48 | |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 49 | /** \brief Counters provided by a transport. |
| 50 | * \note The type name TransportCounters is an implementation detail. |
| 51 | * Use Transport::Counters in public API. |
Junxiao Shi | 57df288 | 2015-11-11 06:12:35 -0700 | [diff] [blame] | 52 | */ |
| 53 | class TransportCounters |
| 54 | { |
| 55 | public: |
| 56 | /** \brief count of incoming packets |
| 57 | * |
| 58 | * A 'packet' typically means a top-level TLV block. |
| 59 | * For a datagram-based transport, an incoming packet that cannot be parsed as TLV |
| 60 | * would not be counted. |
| 61 | */ |
| 62 | PacketCounter nInPackets; |
| 63 | |
| 64 | /** \brief count of outgoing packets |
| 65 | * |
| 66 | * A 'packet' typically means a top-level TLV block. |
| 67 | * This counter is incremented only if transport is UP. |
| 68 | */ |
| 69 | PacketCounter nOutPackets; |
| 70 | |
| 71 | /** \brief total incoming bytes |
| 72 | * |
| 73 | * This counter includes headers imposed by NFD (such as NDNLP), |
| 74 | * but excludes overhead of underlying protocol (such as IP header). |
| 75 | * For a datagram-based transport, an incoming packet that cannot be parsed as TLV |
| 76 | * would not be counted. |
| 77 | */ |
| 78 | ByteCounter nInBytes; |
| 79 | |
| 80 | /** \brief total outgoing bytes |
| 81 | * |
| 82 | * This counter includes headers imposed by NFD (such as NDNLP), |
| 83 | * but excludes overhead of underlying protocol (such as IP header). |
| 84 | * This counter is increased only if transport is UP. |
| 85 | */ |
| 86 | ByteCounter nOutBytes; |
| 87 | }; |
| 88 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 89 | /** \brief indicates the transport has no limit on payload size |
| 90 | */ |
| 91 | const ssize_t MTU_UNLIMITED = -1; |
| 92 | |
Junxiao Shi | 5b8a2b2 | 2015-10-22 17:20:44 -0700 | [diff] [blame] | 93 | /** \brief (for internal use) indicates MTU field is unset |
| 94 | */ |
| 95 | const ssize_t MTU_INVALID = -2; |
| 96 | |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 97 | /** \brief indicates that the transport does not support reading the queue capacity/length |
| 98 | */ |
| 99 | const ssize_t QUEUE_UNSUPPORTED = -1; |
| 100 | |
| 101 | /** \brief indicates that the transport was unable to retrieve the queue capacity/length |
| 102 | */ |
| 103 | const ssize_t QUEUE_ERROR = -2; |
| 104 | |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 105 | /** \brief The lower half of a Face. |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 106 | * \sa Face |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 107 | */ |
Junxiao Shi | 57df288 | 2015-11-11 06:12:35 -0700 | [diff] [blame] | 108 | class Transport : protected virtual TransportCounters, noncopyable |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 109 | { |
| 110 | public: |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 111 | /** \brief Counters provided by a transport. |
| 112 | * \sa TransportCounters |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 113 | */ |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 114 | using Counters = TransportCounters; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 115 | |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 116 | /** \brief Default constructor. |
Junxiao Shi | 5b8a2b2 | 2015-10-22 17:20:44 -0700 | [diff] [blame] | 117 | * |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 118 | * This constructor initializes static properties to invalid values. |
Junxiao Shi | 5b8a2b2 | 2015-10-22 17:20:44 -0700 | [diff] [blame] | 119 | * Subclass constructor must explicitly set every static property. |
| 120 | * |
| 121 | * This constructor initializes TransportState to UP; |
| 122 | * subclass constructor can rely on this default value. |
| 123 | */ |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 124 | Transport(); |
| 125 | |
| 126 | virtual |
| 127 | ~Transport(); |
| 128 | |
| 129 | public: |
| 130 | /** \brief set Face and LinkService for Transport |
| 131 | * \pre setFaceAndLinkService has not been called |
| 132 | */ |
| 133 | void |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 134 | setFaceAndLinkService(Face& face, LinkService& service); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 135 | |
| 136 | /** \return Face to which this Transport is attached |
| 137 | */ |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 138 | const Face* |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 139 | getFace() const; |
| 140 | |
| 141 | /** \return LinkService to which this Transport is attached |
| 142 | */ |
| 143 | const LinkService* |
| 144 | getLinkService() const; |
| 145 | |
| 146 | /** \return LinkService to which this Transport is attached |
| 147 | */ |
| 148 | LinkService* |
| 149 | getLinkService(); |
| 150 | |
Junxiao Shi | 57df288 | 2015-11-11 06:12:35 -0700 | [diff] [blame] | 151 | virtual const Counters& |
| 152 | getCounters() const; |
| 153 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 154 | public: // upper interface |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 155 | /** \brief Request the transport to be closed |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 156 | * |
| 157 | * This operation is effective only if transport is in UP or DOWN state, |
| 158 | * otherwise it has no effect. |
| 159 | * The transport changes state to CLOSING, and performs cleanup procedure. |
| 160 | * The state will be changed to CLOSED when cleanup is complete, which may |
| 161 | * happen synchronously or asynchronously. |
| 162 | */ |
| 163 | void |
| 164 | close(); |
| 165 | |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 166 | /** \brief Send a link-layer packet |
| 167 | * \param packet the packet to be sent, must be a valid and well-formed TLV block |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 168 | * \note This operation has no effect if getState() is neither UP nor DOWN |
| 169 | * \warning Behavior is undefined if packet size exceeds the MTU limit |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 170 | */ |
| 171 | void |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame^] | 172 | send(const Block& packet); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 173 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 174 | public: // static properties |
| 175 | /** \return a FaceUri representing local endpoint |
| 176 | */ |
| 177 | FaceUri |
| 178 | getLocalUri() const; |
| 179 | |
| 180 | /** \return a FaceUri representing remote endpoint |
| 181 | */ |
| 182 | FaceUri |
| 183 | getRemoteUri() const; |
| 184 | |
| 185 | /** \return whether face is local or non-local for scope control purpose |
| 186 | */ |
| 187 | ndn::nfd::FaceScope |
| 188 | getScope() const; |
| 189 | |
| 190 | /** \return face persistency setting |
| 191 | */ |
| 192 | ndn::nfd::FacePersistency |
| 193 | getPersistency() const; |
| 194 | |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 195 | /** \brief check whether the face persistency can be changed to \p newPersistency |
Yanbiao Li | 32dab97 | 2016-11-27 12:26:09 +0800 | [diff] [blame] | 196 | * |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 197 | * This function serves as the external API, and invokes the protected function |
| 198 | * canChangePersistencyToImpl to perform further checks if \p newPersistency differs |
| 199 | * from the current persistency. |
Yanbiao Li | 32dab97 | 2016-11-27 12:26:09 +0800 | [diff] [blame] | 200 | * |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 201 | * \return true if the change can be performed, false otherwise |
Yanbiao Li | 32dab97 | 2016-11-27 12:26:09 +0800 | [diff] [blame] | 202 | */ |
| 203 | bool |
| 204 | canChangePersistencyTo(ndn::nfd::FacePersistency newPersistency) const; |
| 205 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 206 | /** \brief changes face persistency setting |
| 207 | */ |
| 208 | void |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 209 | setPersistency(ndn::nfd::FacePersistency newPersistency); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 210 | |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 211 | /** \return the link type of the transport |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 212 | */ |
| 213 | ndn::nfd::LinkType |
| 214 | getLinkType() const; |
| 215 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 216 | /** \return maximum payload size |
| 217 | * \retval MTU_UNLIMITED transport has no limit on payload size |
| 218 | * |
| 219 | * This size is the maximum packet size that can be sent or received through this transport. |
| 220 | * |
| 221 | * For a datagram-based transport, this is typically the Maximum Transmission Unit (MTU), |
| 222 | * after the overhead of headers introduced by the transport has been accounted for. |
| 223 | * For a stream-based transport, this is typically unlimited (MTU_UNLIMITED). |
| 224 | */ |
| 225 | ssize_t |
| 226 | getMtu() const; |
| 227 | |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 228 | /** \return capacity of the send queue (in bytes) |
| 229 | * \retval QUEUE_UNSUPPORTED transport does not support queue capacity retrieval |
| 230 | * \retval QUEUE_ERROR transport was unable to retrieve the queue capacity |
| 231 | */ |
| 232 | ssize_t |
| 233 | getSendQueueCapacity() const; |
| 234 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 235 | public: // dynamic properties |
| 236 | /** \return transport state |
| 237 | */ |
| 238 | TransportState |
| 239 | getState() const; |
| 240 | |
| 241 | /** \brief signals when transport state changes |
| 242 | */ |
| 243 | signal::Signal<Transport, TransportState/*old*/, TransportState/*new*/> afterStateChange; |
| 244 | |
Eric Newberry | c64d30a | 2015-12-26 11:07:27 -0700 | [diff] [blame] | 245 | /** \return expiration time of the transport |
| 246 | * \retval time::steady_clock::TimePoint::max() the transport has indefinite lifetime |
| 247 | */ |
| 248 | time::steady_clock::TimePoint |
| 249 | getExpirationTime() const; |
| 250 | |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 251 | /** \return current send queue length of the transport (in octets) |
| 252 | * \retval QUEUE_UNSUPPORTED transport does not support queue length retrieval |
| 253 | * \retval QUEUE_ERROR transport was unable to retrieve the queue length |
| 254 | */ |
| 255 | virtual ssize_t |
Eric Newberry | 812d615 | 2018-06-06 15:06:01 -0700 | [diff] [blame] | 256 | getSendQueueLength() |
| 257 | { |
| 258 | return QUEUE_UNSUPPORTED; |
| 259 | } |
| 260 | |
| 261 | protected: // upper interface to be invoked by subclass |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 262 | /** \brief Pass a received link-layer packet to the upper layer for further processing |
| 263 | * \param packet the received packet, must be a valid and well-formed TLV block |
| 264 | * \param endpoint the source endpoint |
| 265 | * \warning Behavior is undefined if packet size exceeds the MTU limit |
Eric Newberry | 812d615 | 2018-06-06 15:06:01 -0700 | [diff] [blame] | 266 | */ |
| 267 | void |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 268 | receive(const Block& packet, const EndpointId& endpoint = 0); |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 269 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 270 | protected: // properties to be set by subclass |
| 271 | void |
| 272 | setLocalUri(const FaceUri& uri); |
| 273 | |
| 274 | void |
| 275 | setRemoteUri(const FaceUri& uri); |
| 276 | |
| 277 | void |
| 278 | setScope(ndn::nfd::FaceScope scope); |
| 279 | |
| 280 | void |
| 281 | setLinkType(ndn::nfd::LinkType linkType); |
| 282 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 283 | void |
| 284 | setMtu(ssize_t mtu); |
| 285 | |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 286 | void |
| 287 | setSendQueueCapacity(ssize_t sendQueueCapacity); |
| 288 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 289 | /** \brief set transport state |
| 290 | * |
| 291 | * Only the following transitions are valid: |
| 292 | * UP->DOWN, DOWN->UP, UP/DOWN->CLOSING/FAILED, CLOSING/FAILED->CLOSED |
| 293 | * |
| 294 | * \throw std::runtime_error transition is invalid. |
| 295 | */ |
| 296 | void |
| 297 | setState(TransportState newState); |
| 298 | |
Eric Newberry | c64d30a | 2015-12-26 11:07:27 -0700 | [diff] [blame] | 299 | void |
| 300 | setExpirationTime(const time::steady_clock::TimePoint& expirationTime); |
| 301 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 302 | protected: // to be overridden by subclass |
Yanbiao Li | 32dab97 | 2016-11-27 12:26:09 +0800 | [diff] [blame] | 303 | /** \brief invoked by canChangePersistencyTo to perform the check |
| 304 | * |
| 305 | * Base class implementation returns false. |
| 306 | * |
| 307 | * \param newPersistency the new persistency, guaranteed to be different from current persistency |
| 308 | */ |
| 309 | virtual bool |
| 310 | canChangePersistencyToImpl(ndn::nfd::FacePersistency newPersistency) const; |
| 311 | |
| 312 | /** \brief invoked after the persistency has been changed |
| 313 | * |
| 314 | * The base class implementation does nothing. |
| 315 | * When overridden in a subclass, the function should update internal states |
| 316 | * after persistency setting has been changed. |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 317 | */ |
| 318 | virtual void |
Yanbiao Li | 32dab97 | 2016-11-27 12:26:09 +0800 | [diff] [blame] | 319 | afterChangePersistency(ndn::nfd::FacePersistency oldPersistency); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 320 | |
| 321 | /** \brief performs Transport specific operations to close the transport |
| 322 | * |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 323 | * This is invoked once by \p close() after changing state to CLOSING. |
| 324 | * It will not be invoked by Transport class if the transport is already CLOSING or CLOSED. |
| 325 | * |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 326 | * When the cleanup procedure is complete, this method should change state to CLOSED. |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 327 | * This transition can happen synchronously or asynchronously. |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 328 | */ |
| 329 | virtual void |
| 330 | doClose() = 0; |
| 331 | |
| 332 | private: // to be overridden by subclass |
| 333 | /** \brief performs Transport specific operations to send a packet |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 334 | * \param packet the packet to be sent, can be assumed to be valid and well-formed |
Davide Pesavento | b3a23ca | 2019-05-04 20:40:21 -0400 | [diff] [blame] | 335 | * \pre transport state is either UP or DOWN |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 336 | */ |
| 337 | virtual void |
Teng Liang | 13d582a | 2020-07-21 20:23:11 -0700 | [diff] [blame^] | 338 | doSend(const Block& packet) = 0; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 339 | |
| 340 | private: |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 341 | Face* m_face; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 342 | LinkService* m_service; |
| 343 | FaceUri m_localUri; |
| 344 | FaceUri m_remoteUri; |
| 345 | ndn::nfd::FaceScope m_scope; |
| 346 | ndn::nfd::FacePersistency m_persistency; |
| 347 | ndn::nfd::LinkType m_linkType; |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 348 | ssize_t m_mtu; |
Davide Pesavento | 3e7fc83 | 2018-09-08 14:07:29 -0400 | [diff] [blame] | 349 | ssize_t m_sendQueueCapacity; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 350 | TransportState m_state; |
Eric Newberry | c64d30a | 2015-12-26 11:07:27 -0700 | [diff] [blame] | 351 | time::steady_clock::TimePoint m_expirationTime; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 352 | }; |
| 353 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 354 | inline const Face* |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 355 | Transport::getFace() const |
| 356 | { |
| 357 | return m_face; |
| 358 | } |
| 359 | |
| 360 | inline const LinkService* |
| 361 | Transport::getLinkService() const |
| 362 | { |
| 363 | return m_service; |
| 364 | } |
| 365 | |
| 366 | inline LinkService* |
| 367 | Transport::getLinkService() |
| 368 | { |
| 369 | return m_service; |
| 370 | } |
| 371 | |
Junxiao Shi | 57df288 | 2015-11-11 06:12:35 -0700 | [diff] [blame] | 372 | inline const Transport::Counters& |
| 373 | Transport::getCounters() const |
| 374 | { |
| 375 | return *this; |
| 376 | } |
| 377 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 378 | inline FaceUri |
| 379 | Transport::getLocalUri() const |
| 380 | { |
| 381 | return m_localUri; |
| 382 | } |
| 383 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 384 | inline void |
| 385 | Transport::setLocalUri(const FaceUri& uri) |
| 386 | { |
| 387 | m_localUri = uri; |
| 388 | } |
| 389 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 390 | inline FaceUri |
| 391 | Transport::getRemoteUri() const |
| 392 | { |
| 393 | return m_remoteUri; |
| 394 | } |
| 395 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 396 | inline void |
| 397 | Transport::setRemoteUri(const FaceUri& uri) |
| 398 | { |
| 399 | m_remoteUri = uri; |
| 400 | } |
| 401 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 402 | inline ndn::nfd::FaceScope |
| 403 | Transport::getScope() const |
| 404 | { |
| 405 | return m_scope; |
| 406 | } |
| 407 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 408 | inline void |
| 409 | Transport::setScope(ndn::nfd::FaceScope scope) |
| 410 | { |
| 411 | m_scope = scope; |
| 412 | } |
| 413 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 414 | inline ndn::nfd::FacePersistency |
| 415 | Transport::getPersistency() const |
| 416 | { |
| 417 | return m_persistency; |
| 418 | } |
| 419 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 420 | inline ndn::nfd::LinkType |
| 421 | Transport::getLinkType() const |
| 422 | { |
| 423 | return m_linkType; |
| 424 | } |
| 425 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 426 | inline void |
| 427 | Transport::setLinkType(ndn::nfd::LinkType linkType) |
| 428 | { |
| 429 | m_linkType = linkType; |
| 430 | } |
| 431 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 432 | inline ssize_t |
| 433 | Transport::getMtu() const |
| 434 | { |
| 435 | return m_mtu; |
| 436 | } |
| 437 | |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 438 | inline ssize_t |
| 439 | Transport::getSendQueueCapacity() const |
| 440 | { |
| 441 | return m_sendQueueCapacity; |
| 442 | } |
| 443 | |
| 444 | inline void |
| 445 | Transport::setSendQueueCapacity(ssize_t sendQueueCapacity) |
| 446 | { |
| 447 | m_sendQueueCapacity = sendQueueCapacity; |
| 448 | } |
| 449 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 450 | inline TransportState |
| 451 | Transport::getState() const |
| 452 | { |
| 453 | return m_state; |
| 454 | } |
| 455 | |
Eric Newberry | c64d30a | 2015-12-26 11:07:27 -0700 | [diff] [blame] | 456 | inline time::steady_clock::TimePoint |
| 457 | Transport::getExpirationTime() const |
| 458 | { |
| 459 | return m_expirationTime; |
| 460 | } |
| 461 | |
| 462 | inline void |
| 463 | Transport::setExpirationTime(const time::steady_clock::TimePoint& expirationTime) |
| 464 | { |
| 465 | m_expirationTime = expirationTime; |
| 466 | } |
| 467 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 468 | std::ostream& |
| 469 | operator<<(std::ostream& os, const FaceLogHelper<Transport>& flh); |
| 470 | |
| 471 | template<typename T> |
| 472 | typename std::enable_if<std::is_base_of<Transport, T>::value && |
| 473 | !std::is_same<Transport, T>::value, std::ostream&>::type |
| 474 | operator<<(std::ostream& os, const FaceLogHelper<T>& flh) |
| 475 | { |
| 476 | return os << FaceLogHelper<Transport>(flh.obj); |
| 477 | } |
| 478 | |
| 479 | } // namespace face |
| 480 | } // namespace nfd |
| 481 | |
| 482 | #endif // NFD_DAEMON_FACE_TRANSPORT_HPP |