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