NFD: Named Data Networking Forwarding Daemon 24.07-28-gdcc0e6e0
Loading...
Searching...
No Matches
link-service.cpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014-2022, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
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#include "link-service.hpp"
27#include "face.hpp"
28
29namespace nfd::face {
30
31NFD_LOG_INIT(LinkService);
32
34
35void
37{
38 BOOST_ASSERT(m_face == nullptr);
39 BOOST_ASSERT(m_transport == nullptr);
40
41 m_face = &face;
42 m_transport = &transport;
43}
44
45void
46LinkService::sendInterest(const Interest& interest)
47{
48 BOOST_ASSERT(m_transport != nullptr);
49 NFD_LOG_FACE_TRACE(__func__);
50
51 ++this->nOutInterests;
52
53 doSendInterest(interest);
54}
55
56void
57LinkService::sendData(const Data& data)
58{
59 BOOST_ASSERT(m_transport != nullptr);
60 NFD_LOG_FACE_TRACE(__func__);
61
62 ++this->nOutData;
63
64 doSendData(data);
65}
66
67void
68LinkService::sendNack(const ndn::lp::Nack& nack)
69{
70 BOOST_ASSERT(m_transport != nullptr);
71 NFD_LOG_FACE_TRACE(__func__);
72
73 ++this->nOutNacks;
74
75 doSendNack(nack);
76}
77
78void
79LinkService::receiveInterest(const Interest& interest, const EndpointId& endpoint)
80{
81 NFD_LOG_FACE_TRACE(__func__);
82
83 ++this->nInInterests;
84
85 afterReceiveInterest(interest, endpoint);
86}
87
88void
89LinkService::receiveData(const Data& data, const EndpointId& endpoint)
90{
91 NFD_LOG_FACE_TRACE(__func__);
92
93 ++this->nInData;
94
95 afterReceiveData(data, endpoint);
96}
97
98void
99LinkService::receiveNack(const ndn::lp::Nack& nack, const EndpointId& endpoint)
100{
101 NFD_LOG_FACE_TRACE(__func__);
102
103 ++this->nInNacks;
104
105 afterReceiveNack(nack, endpoint);
106}
107
108void
109LinkService::notifyDroppedInterest(const Interest& interest)
110{
112 onDroppedInterest(interest);
113}
114
115std::ostream&
116operator<<(std::ostream& os, const FaceLogHelper<LinkService>& flh)
117{
118 const Face* face = flh.obj.getFace();
119 if (face == nullptr) {
120 os << "[id=0,local=unknown,remote=unknown] ";
121 }
122 else {
123 os << "[id=" << face->getId() << ",local=" << face->getLocalUri()
124 << ",remote=" << face->getRemoteUri() << "] ";
125 }
126 return os;
127}
128
129} // namespace nfd::face
Generalization of a network interface.
Definition face.hpp:118
FaceUri getLocalUri() const noexcept
Returns a FaceUri representing the local endpoint.
Definition face.hpp:214
FaceUri getRemoteUri() const noexcept
Returns a FaceUri representing the remote endpoint.
Definition face.hpp:223
FaceId getId() const noexcept
Returns the face ID.
Definition face.hpp:195
For internal use by FaceLogging macros.
The lower half of a Face.
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
#define NFD_LOG_INIT(name)
Definition logger.hpp:31
std::ostream & operator<<(std::ostream &os, const FaceLogHelper< Face > &flh)
Definition face.cpp:63
std::variant< std::monostate, ethernet::Address, udp::Endpoint > EndpointId
Identifies a remote endpoint on the link.