23 #include "../transport/transport.hpp" 24 #include "../management/nfd-controller.hpp" 25 #include "../management/nfd-control-response.hpp" 27 #include <boost/asio/io_service.hpp> 72 encoder.appendByteArray(payload.
wire(), payload.
size());
74 this->
send(encoder.block());
77 boost::asio::io_service&
93 this->construct(options);
103 this->construct(options);
107 DummyClientFace::construct(
const Options& options)
109 static_pointer_cast<
Transport>(getTransport())->onSendBlock.
connect([
this] (
const Block& blockFromDaemon) {
110 Block packet(blockFromDaemon);
112 lp::Packet lpPacket(packet);
114 Buffer::const_iterator begin, end;
115 std::tie(begin, end) = lpPacket.get<lp::FragmentField>();
116 Block block(&*begin, std::distance(begin, end));
118 if (block.type() == tlv::Interest) {
119 shared_ptr<Interest> interest = make_shared<Interest>(block);
120 if (lpPacket.has<lp::NackField>()) {
121 shared_ptr<lp::Nack> nack = make_shared<lp::Nack>(std::move(*interest));
122 nack->setHeader(lpPacket.get<lp::NackField>());
123 if (lpPacket.has<lp::NextHopFaceIdField>()) {
124 nack->setTag(make_shared<lp::NextHopFaceIdTag>(lpPacket.get<lp::NextHopFaceIdField>()));
129 if (lpPacket.has<lp::NextHopFaceIdField>()) {
130 interest->setTag(make_shared<lp::NextHopFaceIdTag>(lpPacket.get<lp::NextHopFaceIdField>()));
132 onSendInterest(*interest);
136 shared_ptr<Data> data = make_shared<Data>(block);
147 this->enablePacketLogging();
150 this->enableRegistrationReply();
154 DummyClientFace::enablePacketLogging()
168 DummyClientFace::enableRegistrationReply()
171 static const Name localhostRegistration(
"/localhost/nfd/rib");
184 resp.
setBody(params.wireEncode());
186 shared_ptr<Data> data = make_shared<Data>(interest.
getName());
196 template<
typename Packet>
202 shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag =
203 static_cast<const TagHost&
>(packet).getTag<lp::IncomingFaceIdTag>();
204 if (incomingFaceIdTag !=
nullptr) {
208 shared_ptr<lp::NextHopFaceIdTag> nextHopFaceIdTag =
209 static_cast<const TagHost&
>(packet).getTag<lp::NextHopFaceIdTag>();
210 if (nextHopFaceIdTag !=
nullptr) {
213 static_pointer_cast<
Transport>(getTransport())->
receive(lpPacket.wireEncode());
217 DummyClientFace::receive<Interest>(
const Interest& packet);
220 DummyClientFace::receive<Data>(
const Data& packet);
224 DummyClientFace::receive<lp::Nack>(
const lp::Nack& nack)
228 Block interest = nack.getInterest().wireEncode();
232 if (incomingFaceIdTag !=
nullptr) {
239 #ifdef NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED 241 shared_ptr<DummyClientFace>
248 shared_ptr<DummyClientFace>
253 return shared_ptr<DummyClientFace>(
new DummyClientFace(ref(ioService), options));
256 #endif // NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED virtual void connect(boost::asio::io_service &io_service, const ReceiveCallback &receiveCallback)
Connect transport.
ControlParameters & setFaceId(uint64_t faceId)
std::vector< lp::Nack > sentNacks
NACKs sent out of this DummyClientFace.
Copyright (c) 2011-2015 Regents of the University of California.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
append packet to encoder
Signal< DummyClientFace, Interest > onSendInterest
emits whenever an Interest is sent
represents parameters in a ControlCommand request or response
const Component & get(ssize_t i) const
Get the component at the given index.
Base class to store tag information (e.g., inside Interest and Data packets)
std::vector< Interest > sentInterests
Interests sent out of this DummyClientFace.
Packet & add(const typename FIELD::ValueType &value)
add a FIELD with value
The packet signing interface.
const uint8_t * wire() const
std::vector< Data > & sentDatas
deprecated alias to sentData
Class representing a wire element of NDN-TLV packet format.
represents an Interest packet
const Block & wireEncode() const
use sha256 digest, no signer needs to be specified
bool enablePacketLogging
if true, packets sent out of DummyClientFace will be appended to a container
std::vector< Data > sentData
Data sent out of this DummyClientFace.
void sign(Data &data, const SigningInfo ¶ms=DEFAULT_SIGNING_INFO)
Sign data according to the supplied signing information.
ReceiveCallback m_receiveCallback
provides a lightweight signal / event system
Signing parameters passed to KeyChain.
boost::asio::io_service & getIoService()
represents a Network Nack
provides a tag type for simple types
virtual void send(const Block &wire)
Send block of data from wire through the transport.
EncodingImpl< EncoderTag > EncodingBuffer
Signal< DummyClientFace, lp::Nack > onSendNack
emits whenever a NACK is sent
options for DummyClientFace
virtual void close()
Close the connection.
Abstraction to communicate with local or remote NDN forwarder.
boost::asio::io_service * m_ioService
shared_ptr< DummyClientFace > makeDummyClientFace(const DummyClientFace::Options &options)
Create a dummy face with internal IO service.
Signal< DummyClientFace, Data > onSendData
emits whenever a Data packet is sent
DummyClientFace(const Options &options=DummyClientFace::DEFAULT_OPTIONS)
Create a dummy face with internal IO service.
void receive(Block block)
Name abstraction to represent an absolute name.
bool isPrefixOf(const Name &name) const
Check if the N components of this name are the same as the first N components of the given name...
boost::asio::io_service & getIoService()
Return nullptr (cannot use IoService in simulations), preserved for API compatibility.
size_t appendByteArray(const uint8_t *array, size_t length)
Append a byte array array of length length.
a client-side face for unit testing
ControlParameters & setCost(uint64_t cost)
Component holds a read-only name component value.
ControlResponse & setBody(const Block &body)
void encode()
Encode subblocks into wire buffer.
Block blockFromValue() const
#define NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
Copyright (c) 2013-2015 Regents of the University of California.
ControlParameters & setOrigin(uint64_t origin)
static const Options DEFAULT_OPTIONS
default options
void receive(const Packet &packet)
cause the Face to receive a packet
virtual void send(const Block &header, const Block &payload)
Alternative version of sending data, applying scatter/gather I/O concept.
bool enableRegistrationReply
if true, prefix registration command will be automatically replied with a successful response ...
ControlResponse & setCode(uint32_t code)
Signal< Transport, Block > onSendBlock
const Name & getName() const