42 return os <<
"CLOSING";
44 return os <<
"FAILED";
46 return os <<
"CLOSED";
59 BOOST_ASSERT(m_face ==
nullptr);
60 BOOST_ASSERT(m_service ==
nullptr);
82 BOOST_ASSERT(packet.isValid());
84 packet.size() <=
static_cast<size_t>(this->getMtu()));
103 BOOST_ASSERT(packet.isValid());
105 packet.size() <=
static_cast<size_t>(this->getMtu()));
133 if (m_persistency == newPersistency || m_persistency == ndn::nfd::FACE_PERSISTENCY_NONE) {
137 if (newPersistency == ndn::nfd::FACE_PERSISTENCY_NONE) {
156 if (m_persistency == newPersistency) {
160 auto oldPersistency = m_persistency;
161 m_persistency = newPersistency;
163 if (oldPersistency != ndn::nfd::FACE_PERSISTENCY_NONE) {
164 NFD_LOG_FACE_INFO(
"setPersistency " << oldPersistency <<
" -> " << newPersistency);
177 if (m_state == newState) {
181 bool isValid =
false;
202 NDN_THROW(std::runtime_error(
"Invalid state transition"));
221 os <<
"[id=" << faceId <<
",local=" << transport.
getLocalUri()
Generalization of a network interface.
FaceId getId() const noexcept
Returns the face ID.
For internal use by FaceLogging macros.
The upper half of a Face.
void receivePacket(const Block &packet, const EndpointId &endpoint)
Performs LinkService-specific operations to receive a lower-layer packet.
ByteCounter nInBytes
Total bytes received.
PacketCounter nInPackets
Count of incoming packets.
PacketCounter nOutPackets
Count of outgoing packets.
ByteCounter nOutBytes
Total bytes sent.
The lower half of a Face.
void receive(const Block &packet, const EndpointId &endpoint={})
Pass a received link-layer packet to the upper layer for further processing.
void setPersistency(ndn::nfd::FacePersistency newPersistency)
Changes the persistency setting of the transport.
ssize_t getMtu() const noexcept
Returns the maximum payload size.
FaceUri getLocalUri() const noexcept
Returns a FaceUri representing the local endpoint.
virtual void afterChangePersistency(ndn::nfd::FacePersistency oldPersistency)
Invoked after the persistency has been changed.
void setMtu(ssize_t mtu) noexcept
void send(const Block &packet)
Send a link-layer packet.
void setFaceAndLinkService(Face &face, LinkService &service) noexcept
Set Face and LinkService for this transport.
signal::Signal< Transport, TransportState, TransportState > afterStateChange
Called when the transport state changes.
const Face * getFace() const noexcept
Returns the Face to which this transport is attached.
TransportState getState() const noexcept
Returns the current transport state.
virtual void doClose()=0
Performs Transport specific operations to close the transport.
bool canChangePersistencyTo(ndn::nfd::FacePersistency newPersistency) const
Check whether the persistency can be changed to newPersistency.
FaceUri getRemoteUri() const noexcept
Returns a FaceUri representing the remote endpoint.
Transport()
Default constructor.
virtual bool canChangePersistencyToImpl(ndn::nfd::FacePersistency newPersistency) const
Invoked by canChangePersistencyTo to perform the check.
void setState(TransportState newState)
Set transport state.
void close()
Request the transport to be closed.
#define NFD_LOG_FACE_INFO(msg)
Log a message at INFO level.
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
#define NFD_LOG_INIT(name)
std::ostream & operator<<(std::ostream &os, const FaceLogHelper< Face > &flh)
TransportState
Indicates the state of a transport.
@ CLOSED
the transport is closed, and can be safely deallocated
@ CLOSING
the transport is being closed gracefully, either by the peer or by a call to close()
@ FAILED
the transport is being closed due to a failure
@ DOWN
the transport is temporarily down, and is being recovered
@ UP
the transport is up and can transmit packets
constexpr FaceId INVALID_FACEID
Indicates an invalid FaceId.
constexpr ssize_t MTU_INVALID
(for internal use) Indicates that the MTU field is unset.
std::variant< std::monostate, ethernet::Address, udp::Endpoint > EndpointId
Identifies a remote endpoint on the link.
constexpr ssize_t MTU_UNLIMITED
Indicates that the transport has no limit on payload size.
uint64_t FaceId
Identifies a face.