26 #ifndef NFD_DAEMON_FACE_DATAGRAM_TRANSPORT_HPP 27 #define NFD_DAEMON_FACE_DATAGRAM_TRANSPORT_HPP 44 template<
class Protocol,
class Addressing = Unicast>
60 receiveDatagram(
const uint8_t* buffer,
size_t nBytesReceived,
61 const boost::system::error_code& error);
71 handleSend(
const boost::system::error_code& error,
72 size_t nBytesSent,
const Block& payload);
75 handleReceive(
const boost::system::error_code& error,
76 size_t nBytesReceived);
79 processErrorCode(
const boost::system::error_code& error);
82 hasRecentlyReceived()
const;
85 resetRecentlyReceived();
88 makeEndpointId(
const typename protocol::endpoint& ep);
97 std::array<uint8_t, ndn::MAX_NDN_PACKET_SIZE> m_receiveBuffer;
98 bool m_hasRecentlyReceived;
102 template<
class T,
class U>
105 , m_hasRecentlyReceived(false)
109 boost::asio::placeholders::error,
110 boost::asio::placeholders::bytes_transferred));
113 template<
class T,
class U>
122 boost::system::error_code error;
134 template<
class T,
class U>
140 m_socket.async_send(boost::asio::buffer(packet.packet),
142 boost::asio::placeholders::error,
143 boost::asio::placeholders::bytes_transferred,
147 template<
class T,
class U>
150 const boost::system::error_code& error)
165 if (element.
size() != nBytesReceived) {
166 NFD_LOG_FACE_WARN(
"Received datagram size and decoded element size don't match");
170 m_hasRecentlyReceived =
true;
177 template<
class T,
class U>
180 size_t nBytesReceived)
187 boost::asio::placeholders::error,
188 boost::asio::placeholders::bytes_transferred));
191 template<
class T,
class U>
194 size_t nBytesSent,
const Block& payload)
203 template<
class T,
class U>
227 template<
class T,
class U>
231 return m_hasRecentlyReceived;
234 template<
class T,
class U>
238 m_hasRecentlyReceived =
false;
241 template<
class T,
class U>
251 #endif // NFD_DAEMON_FACE_DATAGRAM_TRANSPORT_HPP void doSend(Transport::Packet &&packet) override
performs Transport specific operations to send a packet
void handleSend(const boost::system::error_code &error, size_t nBytesSent, const Block &payload)
#define NFD_LOG_INCLASS_DECLARE()
static std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset)
Try to parse Block from a wire buffer.
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
protocol::socket m_socket
void doClose() override
performs Transport specific operations to close the transport
#define NFD_LOG_FACE_ERROR(msg)
Log a message at ERROR level.
void handleReceive(const boost::system::error_code &error, size_t nBytesReceived)
stores a packet along with the remote endpoint
detail::SimulatorIo & getGlobalIoService()
Represents a TLV element of NDN packet format.
Implements Transport for datagram-based protocols.
the transport is being closed due to a failure
static EndpointId makeEndpointId(const typename protocol::endpoint &ep)
void receiveDatagram(const uint8_t *buffer, size_t nBytesReceived, const boost::system::error_code &error)
Receive datagram, translate buffer into packet, deliver to parent class.
size_t size() const
Get size of encoded wire, including Type-Length-Value.
#define NFD_LOG_FACE_DEBUG(msg)
Log a message at DEBUG level.
protocol::endpoint m_sender
Copyright (c) 2011-2015 Regents of the University of California.
void processErrorCode(const boost::system::error_code &error)
EndpointId remoteEndpoint
identifies the remote endpoint
the transport is closed, and can be safely deallocated
void post(const std::function< void()> &callback)
void resetRecentlyReceived()
the transport is being closed gracefully, either by the peer or by a call to close() ...
bool hasRecentlyReceived() const
TransportState getState() const
void setState(TransportState newState)
set transport state
Catch-all error for socket component errors that don't fit in other categories.
DatagramTransport(typename protocol::socket &&socket)
Construct datagram transport.
void receive(Packet &&packet)
receive a link-layer packet
uint64_t EndpointId
identifies an endpoint on the link
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.
ndn::nfd::FacePersistency getPersistency() const