33 #include <netinet/in.h>
34 #include <sys/socket.h>
39 namespace ip = boost::asio::ip;
44 ndn::nfd::FacePersistency persistency,
45 time::nanoseconds idleTimeout)
47 , m_idleTimeout(idleTimeout)
51 this->
setScope(ndn::nfd::FACE_SCOPE_NON_LOCAL);
53 this->
setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT);
71 const int value = IP_PMTUDISC_DONT;
72 if (::setsockopt(
m_socket.native_handle(), IPPROTO_IP,
73 IP_MTU_DISCOVER, &value,
sizeof(value)) < 0) {
74 NFD_LOG_FACE_WARN(
"Failed to disable path MTU discovery: " << std::strerror(errno));
79 m_idleTimeout > time::nanoseconds::zero()) {
80 scheduleClosureWhenIdle();
94 m_idleTimeout > time::nanoseconds::zero()) {
95 scheduleClosureWhenIdle();
98 m_closeIfIdleEvent.cancel();
104 UnicastUdpTransport::scheduleClosureWhenIdle()
106 m_closeIfIdleEvent =
getScheduler().schedule(m_idleTimeout, [
this] {
113 scheduleClosureWhenIdle();
Implements a Transport for datagram-based protocols.
bool hasRecentlyReceived() const
void resetRecentlyReceived()
protocol::socket m_socket
void setScope(ndn::nfd::FaceScope scope) noexcept
void setPersistency(ndn::nfd::FacePersistency newPersistency)
Changes the persistency setting of the transport.
ndn::nfd::FacePersistency getPersistency() const noexcept
Returns the current persistency setting of the transport.
void setMtu(ssize_t mtu) noexcept
void setExpirationTime(const time::steady_clock::time_point &expirationTime) noexcept
void setLocalUri(const FaceUri &uri) noexcept
void setLinkType(ndn::nfd::LinkType linkType) noexcept
void setRemoteUri(const FaceUri &uri) noexcept
void close()
Request the transport to be closed.
UnicastUdpTransport(boost::asio::ip::udp::socket &&socket, ndn::nfd::FacePersistency persistency, time::nanoseconds idleTimeout)
void afterChangePersistency(ndn::nfd::FacePersistency oldPersistency) final
Invoked after the persistency has been changed.
bool canChangePersistencyToImpl(ndn::nfd::FacePersistency newPersistency) const final
Invoked by canChangePersistencyTo to perform the check.
#define NFD_LOG_FACE_DEBUG(msg)
Log a message at DEBUG level.
#define NFD_LOG_FACE_INFO(msg)
Log a message at INFO level.
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.
#define NFD_LOG_MEMBER_INIT_SPECIALIZED(cls, name)
ssize_t computeMtu(const Endpoint &localEndpoint)
Computes the maximum payload size in a UDP packet.
ndn::Scheduler & getScheduler()
Returns the global Scheduler instance for the calling thread.