face-common.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2024, 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 #ifndef NFD_DAEMON_FACE_FACE_COMMON_HPP
27 #define NFD_DAEMON_FACE_FACE_COMMON_HPP
28 
29 #include "ethernet-protocol.hpp"
30 #include "udp-protocol.hpp"
31 #include "common/logger.hpp"
32 
33 #include <ndn-cxx/encoding/nfd-constants.hpp>
34 #include <ndn-cxx/net/face-uri.hpp>
35 
36 #include <boost/logic/tribool.hpp>
37 #include <variant>
38 
39 namespace nfd {
40 namespace face {
41 
42 class Face;
43 class LinkService;
44 
48 using FaceId = uint64_t;
49 
51 inline constexpr FaceId INVALID_FACEID = ndn::nfd::INVALID_FACE_ID;
53 inline constexpr FaceId FACEID_INTERNAL_FACE = 1;
55 inline constexpr FaceId FACEID_CONTENT_STORE = 254;
57 inline constexpr FaceId FACEID_NULL = 255;
59 inline constexpr FaceId FACEID_RESERVED_MAX = 255;
60 
66 inline constexpr ssize_t MIN_MTU = 64;
67 
78 using EndpointId = std::variant<std::monostate, ethernet::Address, udp::Endpoint>;
79 
86 struct FaceParams
87 {
88  ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT;
89  std::optional<time::nanoseconds> baseCongestionMarkingInterval;
90  std::optional<uint64_t> defaultCongestionThreshold;
91  std::optional<ssize_t> mtu;
92  bool wantLocalFields = false;
93  bool wantLpReliability = false;
94  boost::logic::tribool wantCongestionMarking = boost::logic::indeterminate;
95 };
96 
106 template<typename T>
108 {
109 public:
110  explicit
111  FaceLogHelper(const T& obj1) noexcept
112  : obj(obj1)
113  {
114  }
115 
116 public:
117  const T& obj;
118 };
119 
120 } // namespace face
121 
122 using face::EndpointId;
123 using face::FaceId;
124 using ::ndn::FaceUri;
125 
126 } // namespace nfd
127 
139 // implementation detail
140 #define NFD_LOG_FACE(level, msg) NFD_LOG_##level( \
141  ::nfd::face::FaceLogHelper< \
142  std::remove_cv_t<std::remove_reference_t<decltype(*this)>> \
143  >(*this) \
144  << msg)
148 #define NFD_LOG_FACE_TRACE(msg) NFD_LOG_FACE(TRACE, msg)
149 
151 #define NFD_LOG_FACE_DEBUG(msg) NFD_LOG_FACE(DEBUG, msg)
152 
154 #define NFD_LOG_FACE_INFO(msg) NFD_LOG_FACE(INFO, msg)
155 
157 #define NFD_LOG_FACE_WARN(msg) NFD_LOG_FACE(WARN, msg)
158 
160 #define NFD_LOG_FACE_ERROR(msg) NFD_LOG_FACE(ERROR, msg)
161 
164 #endif // NFD_DAEMON_FACE_FACE_COMMON_HPP
For internal use by FaceLogging macros.
FaceLogHelper(const T &obj1) noexcept
constexpr FaceId FACEID_NULL
Identifies the NullFace that drops every packet.
Definition: face-common.hpp:57
constexpr FaceId INVALID_FACEID
Indicates an invalid FaceId.
Definition: face-common.hpp:51
constexpr FaceId FACEID_CONTENT_STORE
Identifies a packet comes from the ContentStore.
Definition: face-common.hpp:55
std::variant< std::monostate, ethernet::Address, udp::Endpoint > EndpointId
Identifies a remote endpoint on the link.
Definition: face-common.hpp:78
constexpr FaceId FACEID_INTERNAL_FACE
Identifies the InternalFace used in management.
Definition: face-common.hpp:53
constexpr FaceId FACEID_RESERVED_MAX
Upper bound of reserved FaceIds.
Definition: face-common.hpp:59
constexpr ssize_t MIN_MTU
Minimum MTU that may be set.
Definition: face-common.hpp:66
uint64_t FaceId
Identifies a face.
Definition: face-common.hpp:48
-status-http-server
Definition: common.hpp:71
Parameters used to set Transport properties or LinkService options on a newly created face.
Definition: face-common.hpp:87
std::optional< uint64_t > defaultCongestionThreshold
Definition: face-common.hpp:90
std::optional< time::nanoseconds > baseCongestionMarkingInterval
Definition: face-common.hpp:89
std::optional< ssize_t > mtu
Definition: face-common.hpp:91
ndn::nfd::FacePersistency persistency
Definition: face-common.hpp:88
boost::logic::tribool wantCongestionMarking
Definition: face-common.hpp:94