Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 2 | /* |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2024, Regents of the University of California, |
Alexander Afanasyev | 319f2c8 | 2015-01-07 14:56:53 -0800 | [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. |
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/>. |
Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 24 | */ |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 25 | |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 26 | #ifndef NFD_DAEMON_FACE_FACE_HPP |
| 27 | #define NFD_DAEMON_FACE_FACE_HPP |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 28 | |
Davide Pesavento | cb425e8 | 2019-07-14 21:48:22 -0400 | [diff] [blame] | 29 | #include "face-common.hpp" |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 30 | #include "link-service.hpp" |
| 31 | #include "transport.hpp" |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 32 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 33 | namespace nfd { |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 34 | namespace face { |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 35 | |
Alexander Afanasyev | 3a2339a | 2020-05-27 23:05:06 -0400 | [diff] [blame] | 36 | class Channel; |
| 37 | |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 38 | /** |
| 39 | * \brief Indicates the state of a face. |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 40 | */ |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 41 | using FaceState = TransportState; |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 42 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 43 | /** |
| 44 | * \brief Gives access to the counters provided by Face. |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 45 | * |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 46 | * This type is a facade that exposes common counters of a Face. |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 47 | * |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 48 | * get<T>() can be used to access extended counters provided by |
| 49 | * LinkService or Transport of the Face. |
| 50 | */ |
| 51 | class FaceCounters |
| 52 | { |
| 53 | public: |
| 54 | FaceCounters(const LinkService::Counters& linkServiceCounters, |
| 55 | const Transport::Counters& transportCounters); |
| 56 | |
| 57 | /** |
| 58 | * \brief Returns the counters provided by (a subclass of) LinkService. |
| 59 | * \tparam T The desired counters type |
| 60 | * \throw std::bad_cast counters type mismatch |
| 61 | */ |
| 62 | template<typename T> |
| 63 | std::enable_if_t<std::is_base_of_v<LinkService::Counters, T>, const T&> |
| 64 | get() const |
| 65 | { |
| 66 | return dynamic_cast<const T&>(m_linkServiceCounters); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * \brief Returns the counters provided by (a subclass of) Transport. |
| 71 | * \tparam T The desired counters type |
| 72 | * \throw std::bad_cast counters type mismatch |
| 73 | */ |
| 74 | template<typename T> |
| 75 | std::enable_if_t<std::is_base_of_v<Transport::Counters, T>, const T&> |
| 76 | get() const |
| 77 | { |
| 78 | return dynamic_cast<const T&>(m_transportCounters); |
| 79 | } |
| 80 | |
| 81 | public: |
| 82 | const PacketCounter& nInInterests; ///< \copydoc LinkService::Counters::nInInterests |
| 83 | const PacketCounter& nOutInterests; ///< \copydoc LinkService::Counters::nOutInterests |
| 84 | const PacketCounter& nInterestsExceededRetx; ///< \copydoc LinkService::Counters::nInterestsExceededRetx |
| 85 | const PacketCounter& nInData; ///< \copydoc LinkService::Counters::nInData |
| 86 | const PacketCounter& nOutData; ///< \copydoc LinkService::Counters::nOutData |
| 87 | const PacketCounter& nInNacks; ///< \copydoc LinkService::Counters::nInNacks |
| 88 | const PacketCounter& nOutNacks; ///< \copydoc LinkService::Counters::nOutNacks |
| 89 | |
| 90 | const PacketCounter& nInPackets; ///< \copydoc Transport::Counters::nInPackets |
| 91 | const PacketCounter& nOutPackets; ///< \copydoc Transport::Counters::nOutPackets |
| 92 | const ByteCounter& nInBytes; ///< \copydoc Transport::Counters::nInBytes |
| 93 | const ByteCounter& nOutBytes; ///< \copydoc Transport::Counters::nOutBytes |
| 94 | |
| 95 | /// Count of incoming Interests dropped due to HopLimit == 0. |
| 96 | PacketCounter nInHopLimitZero; |
| 97 | /// Count of outgoing Interests dropped due to HopLimit == 0 on non-local faces. |
| 98 | PacketCounter nOutHopLimitZero; |
| 99 | |
| 100 | private: |
| 101 | const LinkService::Counters& m_linkServiceCounters; |
| 102 | const Transport::Counters& m_transportCounters; |
| 103 | }; |
| 104 | |
| 105 | /** |
| 106 | * \brief Generalization of a network interface. |
| 107 | * |
| 108 | * A face generalizes a network interface. |
| 109 | * It provides best-effort network-layer packet delivery services |
| 110 | * on a physical interface, an overlay tunnel, or a link to a local application. |
| 111 | * |
| 112 | * A face combines two parts: LinkService and Transport. |
| 113 | * Transport is the lower part, which provides best-effort TLV block deliveries. |
| 114 | * LinkService is the upper part, which translates between network-layer packets |
| 115 | * and TLV blocks, and may provide additional services such as fragmentation and reassembly. |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 116 | */ |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 117 | class Face NFD_FINAL_UNLESS_WITH_TESTS : public std::enable_shared_from_this<Face>, noncopyable |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 118 | { |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 119 | public: |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 120 | Face(unique_ptr<LinkService> service, unique_ptr<Transport> transport); |
| 121 | |
| 122 | LinkService* |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 123 | getLinkService() const noexcept |
| 124 | { |
| 125 | return m_service.get(); |
| 126 | } |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 127 | |
| 128 | Transport* |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 129 | getTransport() const noexcept |
| 130 | { |
| 131 | return m_transport.get(); |
| 132 | } |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 133 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 134 | /** |
| 135 | * \brief Request that the face be closed. |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 136 | * |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 137 | * This operation is effective only if face is in the UP or DOWN state; otherwise, |
| 138 | * it has no effect. The face will change state to CLOSING, and then perform a |
| 139 | * cleanup procedure. When the cleanup is complete, the state will be changed to |
| 140 | * CLOSED, which may happen synchronously or asynchronously. |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 141 | * |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 142 | * \warning The face must not be deallocated until its state changes to CLOSED. |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 143 | */ |
| 144 | void |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 145 | close() |
| 146 | { |
| 147 | m_transport->close(); |
| 148 | } |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 149 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 150 | public: // upper interface connected to forwarding |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 151 | /** |
| 152 | * \brief Send Interest. |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 153 | */ |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 154 | void |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 155 | sendInterest(const Interest& interest) |
| 156 | { |
| 157 | m_service->sendInterest(interest); |
| 158 | } |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 159 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 160 | /** |
| 161 | * \brief Send Data. |
Alexander Afanasyev | a0a10fb | 2014-02-13 19:56:15 -0800 | [diff] [blame] | 162 | */ |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 163 | void |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 164 | sendData(const Data& data) |
| 165 | { |
| 166 | m_service->sendData(data); |
| 167 | } |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 168 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 169 | /** |
| 170 | * \brief Send Nack. |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 171 | */ |
| 172 | void |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 173 | sendNack(const lp::Nack& nack) |
| 174 | { |
| 175 | m_service->sendNack(nack); |
| 176 | } |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 177 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 178 | /// \copydoc LinkService::afterReceiveInterest |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 179 | signal::Signal<LinkService, Interest, EndpointId>& afterReceiveInterest; |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 180 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 181 | /// \copydoc LinkService::afterReceiveData |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 182 | signal::Signal<LinkService, Data, EndpointId>& afterReceiveData; |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 183 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 184 | /// \copydoc LinkService::afterReceiveNack |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 185 | signal::Signal<LinkService, lp::Nack, EndpointId>& afterReceiveNack; |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 186 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 187 | /// \copydoc LinkService::onDroppedInterest |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 188 | signal::Signal<LinkService, Interest>& onDroppedInterest; |
| 189 | |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 190 | public: // properties |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 191 | /** |
| 192 | * \brief Returns the face ID. |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 193 | */ |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 194 | FaceId |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 195 | getId() const noexcept |
| 196 | { |
| 197 | return m_id; |
| 198 | } |
Junxiao Shi | 7949416 | 2014-04-02 18:25:11 -0700 | [diff] [blame] | 199 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 200 | /** |
| 201 | * \brief Sets the face ID. |
| 202 | * \note Normally, this should only be invoked by FaceTable. |
Davide Pesavento | 9427941 | 2015-02-27 01:29:32 +0100 | [diff] [blame] | 203 | */ |
| 204 | void |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 205 | setId(FaceId id) noexcept |
| 206 | { |
| 207 | m_id = id; |
| 208 | } |
Davide Pesavento | 9427941 | 2015-02-27 01:29:32 +0100 | [diff] [blame] | 209 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 210 | /** |
| 211 | * \brief Returns a FaceUri representing the local endpoint. |
Davide Pesavento | 0ff10db | 2014-02-28 03:12:27 +0100 | [diff] [blame] | 212 | */ |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 213 | FaceUri |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 214 | getLocalUri() const noexcept |
| 215 | { |
| 216 | return m_transport->getLocalUri(); |
| 217 | } |
Davide Pesavento | 0ff10db | 2014-02-28 03:12:27 +0100 | [diff] [blame] | 218 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 219 | /** |
| 220 | * \brief Returns a FaceUri representing the remote endpoint. |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 221 | */ |
| 222 | FaceUri |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 223 | getRemoteUri() const noexcept |
| 224 | { |
| 225 | return m_transport->getRemoteUri(); |
| 226 | } |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 227 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 228 | /** |
| 229 | * \brief Returns whether the face is local or non-local for scope control purposes. |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 230 | */ |
| 231 | ndn::nfd::FaceScope |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 232 | getScope() const noexcept |
| 233 | { |
| 234 | return m_transport->getScope(); |
| 235 | } |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 236 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 237 | /** |
| 238 | * \brief Returns the current persistency setting of the face. |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 239 | */ |
Yukai Tu | 731f0d7 | 2015-07-04 11:14:44 +0800 | [diff] [blame] | 240 | ndn::nfd::FacePersistency |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 241 | getPersistency() const noexcept |
| 242 | { |
| 243 | return m_transport->getPersistency(); |
| 244 | } |
Davide Pesavento | 9427941 | 2015-02-27 01:29:32 +0100 | [diff] [blame] | 245 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 246 | /** |
| 247 | * \brief Changes the face persistency setting. |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 248 | */ |
| 249 | void |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 250 | setPersistency(ndn::nfd::FacePersistency persistency) |
| 251 | { |
| 252 | return m_transport->setPersistency(persistency); |
| 253 | } |
Junxiao Shi | 08d07a7 | 2014-06-09 23:17:57 -0700 | [diff] [blame] | 254 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 255 | /** |
| 256 | * \brief Returns the link type of the face (point-to-point, multi-access, ...). |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 257 | */ |
| 258 | ndn::nfd::LinkType |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 259 | getLinkType() const noexcept |
| 260 | { |
| 261 | return m_transport->getLinkType(); |
| 262 | } |
Davide Pesavento | 9427941 | 2015-02-27 01:29:32 +0100 | [diff] [blame] | 263 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 264 | /** |
| 265 | * \brief Returns the effective MTU of the face. |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 266 | * |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 267 | * This function is a wrapper. The effective MTU of a face is determined by the link service. |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 268 | */ |
| 269 | ssize_t |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 270 | getMtu() const |
| 271 | { |
| 272 | return m_service->getEffectiveMtu(); |
| 273 | } |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 274 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 275 | /** |
| 276 | * \brief Returns the face state. |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 277 | */ |
| 278 | FaceState |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 279 | getState() const noexcept |
| 280 | { |
| 281 | return m_transport->getState(); |
| 282 | } |
Junxiao Shi | c099ddb | 2014-12-25 20:53:20 -0700 | [diff] [blame] | 283 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 284 | /// \copydoc Transport::afterStateChange |
| 285 | signal::Signal<Transport, FaceState /*old*/, FaceState /*new*/>& afterStateChange; |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 286 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 287 | /** |
| 288 | * \brief Returns the expiration time of the face. |
| 289 | * \retval time::steady_clock::time_point::max() The face has an indefinite lifetime. |
Eric Newberry | c64d30a | 2015-12-26 11:07:27 -0700 | [diff] [blame] | 290 | */ |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 291 | time::steady_clock::time_point |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 292 | getExpirationTime() const noexcept |
| 293 | { |
| 294 | return m_transport->getExpirationTime(); |
| 295 | } |
Eric Newberry | c64d30a | 2015-12-26 11:07:27 -0700 | [diff] [blame] | 296 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 297 | const FaceCounters& |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 298 | getCounters() const noexcept |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 299 | { |
| 300 | return m_counters; |
| 301 | } |
| 302 | |
| 303 | FaceCounters& |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 304 | getCounters() noexcept |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 305 | { |
| 306 | return m_counters; |
| 307 | } |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 308 | |
Alexander Afanasyev | 3a2339a | 2020-05-27 23:05:06 -0400 | [diff] [blame] | 309 | /** |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 310 | * \brief Get channel on which face was created (unicast) or the associated channel (multicast). |
Alexander Afanasyev | 3a2339a | 2020-05-27 23:05:06 -0400 | [diff] [blame] | 311 | */ |
| 312 | weak_ptr<Channel> |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 313 | getChannel() const noexcept |
Alexander Afanasyev | 3a2339a | 2020-05-27 23:05:06 -0400 | [diff] [blame] | 314 | { |
| 315 | return m_channel; |
| 316 | } |
| 317 | |
| 318 | /** |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 319 | * \brief Set channel on which face was created (unicast) or the associated channel (multicast). |
Alexander Afanasyev | 3a2339a | 2020-05-27 23:05:06 -0400 | [diff] [blame] | 320 | */ |
| 321 | void |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame] | 322 | setChannel(weak_ptr<Channel> channel) noexcept |
Alexander Afanasyev | 3a2339a | 2020-05-27 23:05:06 -0400 | [diff] [blame] | 323 | { |
| 324 | m_channel = std::move(channel); |
| 325 | } |
| 326 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 327 | private: |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 328 | FaceId m_id = INVALID_FACEID; |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 329 | unique_ptr<LinkService> m_service; |
| 330 | unique_ptr<Transport> m_transport; |
| 331 | FaceCounters m_counters; |
Alexander Afanasyev | 3a2339a | 2020-05-27 23:05:06 -0400 | [diff] [blame] | 332 | weak_ptr<Channel> m_channel; |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 333 | }; |
| 334 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 335 | std::ostream& |
| 336 | operator<<(std::ostream& os, const FaceLogHelper<Face>& flh); |
Alexander Afanasyev | a39b90b | 2014-03-05 15:31:00 +0000 | [diff] [blame] | 337 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 338 | } // namespace face |
| 339 | |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 340 | using face::Face; |
| 341 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 342 | } // namespace nfd |
Junxiao Shi | 2c29f3a | 2014-01-24 19:59:00 -0700 | [diff] [blame] | 343 | |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 344 | #endif // NFD_DAEMON_FACE_FACE_HPP |