26 #ifndef NFD_DAEMON_FACE_DATAGRAM_FACE_HPP 27 #define NFD_DAEMON_FACE_DATAGRAM_FACE_HPP 37 template<
class Protocol,
class Addressing = Unicast>
48 typename protocol::socket socket);
62 size_t nBytesReceived,
63 const
boost::system::error_code& error);
72 const
Block& payload);
76 size_t nBytesReceived);
100 bool m_hasBeenUsedRecently;
104 template<class T, class U>
115 boost::asio::placeholders::error,
116 boost::asio::placeholders::bytes_transferred));
119 template<
class T,
class U>
130 boost::asio::placeholders::error,
131 boost::asio::placeholders::bytes_transferred,
135 template<
class T,
class U>
146 boost::asio::placeholders::error,
147 boost::asio::placeholders::bytes_transferred,
151 template<
class T,
class U>
161 this->
fail(
"Face closed");
164 template<
class T,
class U>
168 if (error == boost::asio::error::operation_aborted)
177 this->
fail(
"Tunnel closed");
181 if (error != boost::asio::error::eof)
186 if (error == boost::asio::error::eof)
187 this->
fail(
"Tunnel closed");
189 this->
fail(error.message());
192 template<
class T,
class U>
196 const Block& payload)
206 template<
class T,
class U>
209 size_t nBytesReceived)
216 boost::asio::placeholders::error,
217 boost::asio::placeholders::bytes_transferred));
220 template<
class T,
class U>
223 size_t nBytesReceived,
224 const boost::system::error_code& error)
242 if (element.
size() != nBytesReceived)
244 NFD_LOG_FACE_WARN(
"Received datagram size and decoded element size don't match");
256 m_hasBeenUsedRecently =
true;
259 template<
class T,
class U>
266 template<
class T,
class U>
273 boost::system::error_code error;
274 m_socket.shutdown(protocol::socket::shutdown_both, error);
281 this, this->shared_from_this()));
284 template<
class T,
class U>
288 return m_hasBeenUsedRecently;
291 template<
class T,
class U>
295 m_hasBeenUsedRecently =
false;
300 #endif // NFD_DAEMON_FACE_DATAGRAM_FACE_HPP void processErrorCode(const boost::system::error_code &error)
Copyright (c) 2011-2015 Regents of the University of California.
static std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset)
Try to construct block from Buffer.
Copyright (c) 2013-2015 Regents of the University of California.
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
signal::Signal< Face, Interest > onSendInterest
fires when an Interest is sent out
represents the underlying protocol and address used by a Face
const ByteCounter & getNOutBytes() const
sent bytes
ndn::nfd::FacePersistency getPersistency() const
Get the persistency setting.
const uint8_t * wire() const
void sendData(const Data &data) 1
send a Data
bool decodeAndDispatchInput(const Block &element)
Class representing a wire element of NDN-TLV packet format.
represents an Interest packet
#define DECL_OVERRIDE
expands to 'override' if compiler supports this feature, otherwise expands to nothing ...
void sendInterest(const Interest &interest) 1
send an Interest
signal::Signal< Face, Data > onSendData
fires when a Data is sent out
void handleReceive(const boost::system::error_code &error, size_t nBytesReceived)
bool hasBeenUsedRecently() const
#define emitSignal(...)
(implementation detail)
#define NFD_LOG_FACE_DEBUG(msg)
Log a message at DEBUG level.
void close() 1
Close the face.
void fail(const std::string &reason)
fail the face and raise onFail event if it's UP; otherwise do nothing
#define NFD_LOG_FACE_INFO(msg)
Log a message at INFO level.
Copyright (c) 2011-2015 Regents of the University of California.
FaceCounters & getMutableCounters()
void handleSend(const boost::system::error_code &error, size_t nBytesSent, const Block &payload)
void keepFaceAliveUntilAllHandlersExecuted(const shared_ptr< Face > &face)
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
Fast encoding or block size estimation.
void receiveDatagram(const uint8_t *buffer, size_t nBytesReceived, const boost::system::error_code &error)
boost::asio::io_service & getGlobalIoService()
NFD_LOG_INCLASS_DECLARE()
const ByteCounter & getNInBytes() const
received bytes
DatagramFace(const FaceUri &remoteUri, const FaceUri &localUri, typename protocol::socket socket)
Construct datagram face.
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.
protocol::socket m_socket
const size_t MAX_NDN_PACKET_SIZE
practical limit of network layer packet size
void resetRecentUsage()
Set m_hasBeenUsedRecently to false.