23 #include "../transport/transport.hpp" 24 #include "../management/nfd-controller.hpp" 25 #include "../management/nfd-control-response.hpp" 68 encoder.appendByteArray(payload.
wire(), payload.
size());
70 this->
send(encoder.block());
73 boost::asio::io_service&
83 DummyClientFace::DummyClientFace(
const Options& options, shared_ptr<Transport> transport)
85 , m_transport(transport)
87 this->construct(options);
90 DummyClientFace::DummyClientFace(
const Options& options, shared_ptr<Transport> transport,
91 boost::asio::io_service& ioService)
92 :
Face(transport, ioService)
93 , m_transport(transport)
95 this->construct(options);
99 DummyClientFace::construct(
const Options& options)
101 m_transport->onSendBlock.connect([
this] (
const Block& blockFromDaemon) {
105 shared_ptr<Interest> interest = make_shared<Interest>(block);
106 if (&block != &blockFromDaemon)
107 interest->getLocalControlHeader().wireDecode(blockFromDaemon);
112 shared_ptr<Data> data = make_shared<Data>(block);
113 if (&block != &blockFromDaemon)
114 data->getLocalControlHeader().wireDecode(blockFromDaemon);
121 this->enablePacketLogging();
124 this->enableRegistrationReply();
128 DummyClientFace::enablePacketLogging()
139 DummyClientFace::enableRegistrationReply()
142 static const Name localhostRegistration(
"/localhost/nfd/rib");
155 resp.
setBody(params.wireEncode());
157 shared_ptr<Data> data = make_shared<Data>(interest.
getName());
167 template<
typename Packet>
174 Block header = packet.getLocalControlHeader().wireEncode(packet,
176 Block payload = packet.wireEncode();
180 encoder.appendByteArray(payload.
wire(), payload.
size());
182 m_transport->receive(encoder.block());
185 m_transport->receive(packet.wireEncode());
190 DummyClientFace::receive<Interest>(
const Interest& packet);
193 DummyClientFace::receive<Data>(
const Data& packet);
196 shared_ptr<DummyClientFace>
200 return shared_ptr<DummyClientFace>(
201 new DummyClientFace(options, make_shared<DummyClientFace::Transport>()));
204 shared_ptr<DummyClientFace>
209 return shared_ptr<DummyClientFace>(
210 new DummyClientFace(options, make_shared<DummyClientFace::Transport>(),
ControlParameters & setFaceId(uint64_t faceId)
const Name & getName() const
Copyright (c) 2011-2015 Regents of the University of California.
Signal< DummyClientFace, Interest > onSendInterest
emits whenever an Interest is sent
represents parameters in a ControlCommand request or response
std::vector< Interest > sentInterests
Interests sent out of this DummyClientFace.
Class representing a wire element of NDN-TLV packet format.
represents an Interest packet
use sha256 digest, no signer needs to be specified
bool enablePacketLogging
if true, packets sent out of DummyClientFace will be appended to a container
const Block & wireEncode() const
friend shared_ptr< DummyClientFace > makeDummyClientFace(const DummyClientFace::Options &options)
ReceiveCallback m_receiveCallback
Signing parameters passed to KeyChain.
boost::asio::io_service & getIoService()
Face()
Create a new Face using the default transport (UnixTransport)
virtual void send(const Block &wire)
Send block of data from.
EncodingImpl< EncoderTag > EncodingBuffer
Block blockFromValue() const
options for DummyClientFace
virtual void close()
Close the connection.
Abstraction to communicate with local or remote NDN forwarder.
std::vector< Data > sentDatas
Data sent out of this DummyClientFace.
boost::asio::io_service * m_ioService
Signal< DummyClientFace, Data > onSendData
emits whenever a Data packet is sent
Name abstraction to represent an absolute name.
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 receive(const Block &block)
const uint8_t * wire() const
ControlParameters & setOrigin(uint64_t origin)
static const Options DEFAULT_OPTIONS
default options
void receive(const Packet &packet)
cause the Face to receive a packet
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...
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 ...
const Component & get(ssize_t i) const
Get the component at the given index.
ControlResponse & setCode(uint32_t code)
Signal< Transport, Block > onSendBlock