32 #include <netinet/in.h>
33 #include <sys/socket.h>
40 "UnicastUdpTransport");
43 ndn::nfd::FacePersistency persistency,
44 time::nanoseconds idleTimeout)
46 , m_idleTimeout(idleTimeout)
50 this->
setScope(ndn::nfd::FACE_SCOPE_NON_LOCAL);
52 this->
setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT);
70 const int value = IP_PMTUDISC_DONT;
71 if (::setsockopt(
m_socket.native_handle(), IPPROTO_IP,
72 IP_MTU_DISCOVER, &value,
sizeof(value)) < 0) {
73 NFD_LOG_FACE_WARN(
"Failed to disable path MTU discovery: " << std::strerror(errno));
78 m_idleTimeout > time::nanoseconds::zero()) {
79 scheduleClosureWhenIdle();
86 if (newPersistency == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND &&
87 m_idleTimeout > time::nanoseconds::zero()) {
88 scheduleClosureWhenIdle();
91 m_closeIfIdleEvent.
cancel();
97 UnicastUdpTransport::scheduleClosureWhenIdle()
106 scheduleClosureWhenIdle();
void setLocalUri(const FaceUri &uri)
void setScope(ndn::nfd::FaceScope scope)
protocol::socket m_socket
void setPersistency(ndn::nfd::FacePersistency persistency)
changes face persistency setting
virtual void beforeChangePersistency(ndn::nfd::FacePersistency newPersistency) final
invoked before persistency is changed
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
bool hasBeenUsedRecently() const
boost::asio::ip::udp protocol
#define NFD_LOG_FACE_INFO(msg)
Log a message at INFO level.
#define NFD_LOG_INCLASS_TEMPLATE_SPECIALIZATION_DEFINE(cls, specialization, name)
void setLinkType(ndn::nfd::LinkType linkType)
void close()
request the transport to be closed
ndn::nfd::FacePersistency getPersistency() const
EventId schedule(const time::nanoseconds &after, const Scheduler::Event &event)
schedule an event
ssize_t computeMtu(const boost::asio::ip::udp::endpoint &localEndpoint)
computes maximum payload size in a UDP packet
Implements Transport for datagram-based protocols.
void setRemoteUri(const FaceUri &uri)
void cancel()
cancels the event manually
UnicastUdpTransport(protocol::socket &&socket, ndn::nfd::FacePersistency persistency, time::nanoseconds idleTimeout)
void setExpirationTime(const time::steady_clock::TimePoint &expirationTime)