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 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 205 | public: // static properties |
| 206 | /** \return a FaceUri representing local endpoint |
| 207 | */ |
| 208 | FaceUri |
| 209 | getLocalUri() const; |
| 210 | |
| 211 | /** \return a FaceUri representing remote endpoint |
| 212 | */ |
| 213 | FaceUri |
| 214 | getRemoteUri() const; |
| 215 | |
| 216 | /** \return whether face is local or non-local for scope control purpose |
| 217 | */ |
| 218 | ndn::nfd::FaceScope |
| 219 | getScope() const; |
| 220 | |
| 221 | /** \return face persistency setting |
| 222 | */ |
| 223 | ndn::nfd::FacePersistency |
| 224 | getPersistency() const; |
| 225 | |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 226 | /** \brief check whether the face persistency can be changed to \p newPersistency |
Yanbiao Li | 32dab97 | 2016-11-27 12:26:09 +0800 | [diff] [blame] | 227 | * |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 228 | * This function serves as the external API, and invokes the protected function |
| 229 | * canChangePersistencyToImpl to perform further checks if \p newPersistency differs |
| 230 | * from the current persistency. |
Yanbiao Li | 32dab97 | 2016-11-27 12:26:09 +0800 | [diff] [blame] | 231 | * |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 232 | * \return true if the change can be performed, false otherwise |
Yanbiao Li | 32dab97 | 2016-11-27 12:26:09 +0800 | [diff] [blame] | 233 | */ |
| 234 | bool |
| 235 | canChangePersistencyTo(ndn::nfd::FacePersistency newPersistency) const; |
| 236 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 237 | /** \brief changes face persistency setting |
| 238 | */ |
| 239 | void |
Davide Pesavento | 3206565 | 2017-01-15 01:52:21 -0500 | [diff] [blame] | 240 | setPersistency(ndn::nfd::FacePersistency newPersistency); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 241 | |
| 242 | /** \return whether face is point-to-point or multi-access |
| 243 | */ |
| 244 | ndn::nfd::LinkType |
| 245 | getLinkType() const; |
| 246 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 247 | /** \return maximum payload size |
| 248 | * \retval MTU_UNLIMITED transport has no limit on payload size |
| 249 | * |
| 250 | * This size is the maximum packet size that can be sent or received through this transport. |
| 251 | * |
| 252 | * For a datagram-based transport, this is typically the Maximum Transmission Unit (MTU), |
| 253 | * after the overhead of headers introduced by the transport has been accounted for. |
| 254 | * For a stream-based transport, this is typically unlimited (MTU_UNLIMITED). |
| 255 | */ |
| 256 | ssize_t |
| 257 | getMtu() const; |
| 258 | |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 259 | /** \return capacity of the send queue (in bytes) |
| 260 | * \retval QUEUE_UNSUPPORTED transport does not support queue capacity retrieval |
| 261 | * \retval QUEUE_ERROR transport was unable to retrieve the queue capacity |
| 262 | */ |
| 263 | ssize_t |
| 264 | getSendQueueCapacity() const; |
| 265 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 266 | public: // dynamic properties |
| 267 | /** \return transport state |
| 268 | */ |
| 269 | TransportState |
| 270 | getState() const; |
| 271 | |
| 272 | /** \brief signals when transport state changes |
| 273 | */ |
| 274 | signal::Signal<Transport, TransportState/*old*/, TransportState/*new*/> afterStateChange; |
| 275 | |
Eric Newberry | c64d30a | 2015-12-26 11:07:27 -0700 | [diff] [blame] | 276 | /** \return expiration time of the transport |
| 277 | * \retval time::steady_clock::TimePoint::max() the transport has indefinite lifetime |
| 278 | */ |
| 279 | time::steady_clock::TimePoint |
| 280 | getExpirationTime() const; |
| 281 | |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 282 | /** \return current send queue length of the transport (in octets) |
| 283 | * \retval QUEUE_UNSUPPORTED transport does not support queue length retrieval |
| 284 | * \retval QUEUE_ERROR transport was unable to retrieve the queue length |
| 285 | */ |
| 286 | virtual ssize_t |
Eric Newberry | 812d615 | 2018-06-06 15:06:01 -0700 | [diff] [blame] | 287 | getSendQueueLength() |
| 288 | { |
| 289 | return QUEUE_UNSUPPORTED; |
| 290 | } |
| 291 | |
| 292 | protected: // upper interface to be invoked by subclass |
| 293 | /** \brief receive a link-layer packet |
| 294 | * \warning undefined behavior if packet size exceeds MTU limit |
| 295 | */ |
| 296 | void |
| 297 | receive(Packet&& packet); |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 298 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 299 | protected: // properties to be set by subclass |
| 300 | void |
| 301 | setLocalUri(const FaceUri& uri); |
| 302 | |
| 303 | void |
| 304 | setRemoteUri(const FaceUri& uri); |
| 305 | |
| 306 | void |
| 307 | setScope(ndn::nfd::FaceScope scope); |
| 308 | |
| 309 | void |
| 310 | setLinkType(ndn::nfd::LinkType linkType); |
| 311 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 312 | void |
| 313 | setMtu(ssize_t mtu); |
| 314 | |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 315 | void |
| 316 | setSendQueueCapacity(ssize_t sendQueueCapacity); |
| 317 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 318 | /** \brief set transport state |
| 319 | * |
| 320 | * Only the following transitions are valid: |
| 321 | * UP->DOWN, DOWN->UP, UP/DOWN->CLOSING/FAILED, CLOSING/FAILED->CLOSED |
| 322 | * |
| 323 | * \throw std::runtime_error transition is invalid. |
| 324 | */ |
| 325 | void |
| 326 | setState(TransportState newState); |
| 327 | |
Eric Newberry | c64d30a | 2015-12-26 11:07:27 -0700 | [diff] [blame] | 328 | void |
| 329 | setExpirationTime(const time::steady_clock::TimePoint& expirationTime); |
| 330 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 331 | protected: // to be overridden by subclass |
Yanbiao Li | 32dab97 | 2016-11-27 12:26:09 +0800 | [diff] [blame] | 332 | /** \brief invoked by canChangePersistencyTo to perform the check |
| 333 | * |
| 334 | * Base class implementation returns false. |
| 335 | * |
| 336 | * \param newPersistency the new persistency, guaranteed to be different from current persistency |
| 337 | */ |
| 338 | virtual bool |
| 339 | canChangePersistencyToImpl(ndn::nfd::FacePersistency newPersistency) const; |
| 340 | |
| 341 | /** \brief invoked after the persistency has been changed |
| 342 | * |
| 343 | * The base class implementation does nothing. |
| 344 | * When overridden in a subclass, the function should update internal states |
| 345 | * after persistency setting has been changed. |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 346 | */ |
| 347 | virtual void |
Yanbiao Li | 32dab97 | 2016-11-27 12:26:09 +0800 | [diff] [blame] | 348 | afterChangePersistency(ndn::nfd::FacePersistency oldPersistency); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 349 | |
| 350 | /** \brief performs Transport specific operations to close the transport |
| 351 | * |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 352 | * This is invoked once by \p close() after changing state to CLOSING. |
| 353 | * It will not be invoked by Transport class if the transport is already CLOSING or CLOSED. |
| 354 | * |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 355 | * 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] | 356 | * This transition can happen synchronously or asynchronously. |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 357 | */ |
| 358 | virtual void |
| 359 | doClose() = 0; |
| 360 | |
| 361 | private: // to be overridden by subclass |
| 362 | /** \brief performs Transport specific operations to send a packet |
| 363 | * \param packet the packet, which must be a well-formed TLV block |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 364 | * \pre state is either UP or DOWN |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 365 | */ |
| 366 | virtual void |
| 367 | doSend(Packet&& packet) = 0; |
| 368 | |
Eric Newberry | 812d615 | 2018-06-06 15:06:01 -0700 | [diff] [blame] | 369 | public: |
| 370 | /** \brief minimum MTU that may be set on a transport |
| 371 | * |
| 372 | * This is done to ensure the NDNLPv2 fragmentation feature functions properly. |
| 373 | */ |
| 374 | static constexpr ssize_t MIN_MTU = 64; |
| 375 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 376 | private: |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 377 | Face* m_face; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 378 | LinkService* m_service; |
| 379 | FaceUri m_localUri; |
| 380 | FaceUri m_remoteUri; |
| 381 | ndn::nfd::FaceScope m_scope; |
| 382 | ndn::nfd::FacePersistency m_persistency; |
| 383 | ndn::nfd::LinkType m_linkType; |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 384 | ssize_t m_mtu; |
Davide Pesavento | 3e7fc83 | 2018-09-08 14:07:29 -0400 | [diff] [blame] | 385 | ssize_t m_sendQueueCapacity; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 386 | TransportState m_state; |
Eric Newberry | c64d30a | 2015-12-26 11:07:27 -0700 | [diff] [blame] | 387 | time::steady_clock::TimePoint m_expirationTime; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 388 | }; |
| 389 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 390 | inline const Face* |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 391 | Transport::getFace() const |
| 392 | { |
| 393 | return m_face; |
| 394 | } |
| 395 | |
| 396 | inline const LinkService* |
| 397 | Transport::getLinkService() const |
| 398 | { |
| 399 | return m_service; |
| 400 | } |
| 401 | |
| 402 | inline LinkService* |
| 403 | Transport::getLinkService() |
| 404 | { |
| 405 | return m_service; |
| 406 | } |
| 407 | |
Junxiao Shi | 57df288 | 2015-11-11 06:12:35 -0700 | [diff] [blame] | 408 | inline const Transport::Counters& |
| 409 | Transport::getCounters() const |
| 410 | { |
| 411 | return *this; |
| 412 | } |
| 413 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 414 | inline FaceUri |
| 415 | Transport::getLocalUri() const |
| 416 | { |
| 417 | return m_localUri; |
| 418 | } |
| 419 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 420 | inline void |
| 421 | Transport::setLocalUri(const FaceUri& uri) |
| 422 | { |
| 423 | m_localUri = uri; |
| 424 | } |
| 425 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 426 | inline FaceUri |
| 427 | Transport::getRemoteUri() const |
| 428 | { |
| 429 | return m_remoteUri; |
| 430 | } |
| 431 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 432 | inline void |
| 433 | Transport::setRemoteUri(const FaceUri& uri) |
| 434 | { |
| 435 | m_remoteUri = uri; |
| 436 | } |
| 437 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 438 | inline ndn::nfd::FaceScope |
| 439 | Transport::getScope() const |
| 440 | { |
| 441 | return m_scope; |
| 442 | } |
| 443 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 444 | inline void |
| 445 | Transport::setScope(ndn::nfd::FaceScope scope) |
| 446 | { |
| 447 | m_scope = scope; |
| 448 | } |
| 449 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 450 | inline ndn::nfd::FacePersistency |
| 451 | Transport::getPersistency() const |
| 452 | { |
| 453 | return m_persistency; |
| 454 | } |
| 455 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 456 | inline ndn::nfd::LinkType |
| 457 | Transport::getLinkType() const |
| 458 | { |
| 459 | return m_linkType; |
| 460 | } |
| 461 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 462 | inline void |
| 463 | Transport::setLinkType(ndn::nfd::LinkType linkType) |
| 464 | { |
| 465 | m_linkType = linkType; |
| 466 | } |
| 467 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 468 | inline ssize_t |
| 469 | Transport::getMtu() const |
| 470 | { |
| 471 | return m_mtu; |
| 472 | } |
| 473 | |
| 474 | inline void |
| 475 | Transport::setMtu(ssize_t mtu) |
| 476 | { |
| 477 | BOOST_ASSERT(mtu == MTU_UNLIMITED || mtu > 0); |
| 478 | m_mtu = mtu; |
| 479 | } |
| 480 | |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 481 | inline ssize_t |
| 482 | Transport::getSendQueueCapacity() const |
| 483 | { |
| 484 | return m_sendQueueCapacity; |
| 485 | } |
| 486 | |
| 487 | inline void |
| 488 | Transport::setSendQueueCapacity(ssize_t sendQueueCapacity) |
| 489 | { |
| 490 | m_sendQueueCapacity = sendQueueCapacity; |
| 491 | } |
| 492 | |
Junxiao Shi | 1354611 | 2015-10-14 19:33:07 -0700 | [diff] [blame] | 493 | inline TransportState |
| 494 | Transport::getState() const |
| 495 | { |
| 496 | return m_state; |
| 497 | } |
| 498 | |
Eric Newberry | c64d30a | 2015-12-26 11:07:27 -0700 | [diff] [blame] | 499 | inline time::steady_clock::TimePoint |
| 500 | Transport::getExpirationTime() const |
| 501 | { |
| 502 | return m_expirationTime; |
| 503 | } |
| 504 | |
| 505 | inline void |
| 506 | Transport::setExpirationTime(const time::steady_clock::TimePoint& expirationTime) |
| 507 | { |
| 508 | m_expirationTime = expirationTime; |
| 509 | } |
| 510 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 511 | std::ostream& |
| 512 | operator<<(std::ostream& os, const FaceLogHelper<Transport>& flh); |
| 513 | |
| 514 | template<typename T> |
| 515 | typename std::enable_if<std::is_base_of<Transport, T>::value && |
| 516 | !std::is_same<Transport, T>::value, std::ostream&>::type |
| 517 | operator<<(std::ostream& os, const FaceLogHelper<T>& flh) |
| 518 | { |
| 519 | return os << FaceLogHelper<Transport>(flh.obj); |
| 520 | } |
| 521 | |
| 522 | } // namespace face |
| 523 | } // namespace nfd |
| 524 | |
| 525 | #endif // NFD_DAEMON_FACE_TRANSPORT_HPP |