23 #include "../detail/lp-field-tag.hpp"    24 #include "../lp/packet.hpp"    25 #include "../lp/tags.hpp"    26 #include "../mgmt/nfd/controller.hpp"    27 #include "../mgmt/nfd/control-response.hpp"    28 #include "../transport/transport.hpp"    30 #include <boost/asio/io_service.hpp>    73     encoder.appendByteArray(payload.
wire(), payload.
size());
    75     this->
send(encoder.block());
    78   boost::asio::io_service&
    91   , m_keyChain(*m_internalKeyChain)
    93   this->construct(options);
    99   , m_keyChain(keyChain)
   101   this->construct(options);
   108   , m_keyChain(*m_internalKeyChain)
   110   this->construct(options);
   116   , m_keyChain(keyChain)
   118   this->construct(options);
   122 DummyClientFace::construct(
const Options& options)
   124   static_pointer_cast<
Transport>(getTransport())->onSendBlock.
connect([
this] (
const Block& blockFromDaemon) {
   125     Block packet(blockFromDaemon);
   127     lp::Packet lpPacket(packet);
   129     Buffer::const_iterator begin, end;
   130     std::tie(begin, end) = lpPacket.get<lp::FragmentField>();
   131     Block block(&*begin, std::distance(begin, end));
   133     if (block.type() == tlv::Interest) {
   134       shared_ptr<Interest> interest = make_shared<Interest>(block);
   135       if (lpPacket.has<lp::NackField>()) {
   136         shared_ptr<lp::Nack> nack = make_shared<lp::Nack>(std::move(*interest));
   137         nack->setHeader(lpPacket.get<lp::NackField>());
   138         addTagFromField<lp::CongestionMarkTag, lp::CongestionMarkField>(*nack, lpPacket);
   142         addTagFromField<lp::NextHopFaceIdTag, lp::NextHopFaceIdField>(*interest, lpPacket);
   143         addTagFromField<lp::CongestionMarkTag, lp::CongestionMarkField>(*interest, lpPacket);
   144         onSendInterest(*interest);
   148       shared_ptr<Data> data = make_shared<Data>(block);
   149       addTagFromField<lp::CachePolicyTag, lp::CachePolicyField>(*data, lpPacket);
   150       addTagFromField<lp::CongestionMarkTag, lp::CongestionMarkField>(*data, lpPacket);
   156     this->enablePacketLogging();
   159     this->enableRegistrationReply();
   165 DummyClientFace::enablePacketLogging()
   179 DummyClientFace::enableRegistrationReply()
   182     static const Name localhostRegistration(
"/localhost/nfd/rib");
   195     resp.
setBody(params.wireEncode());
   197     shared_ptr<Data> data = make_shared<Data>(interest.
getName());
   211   addFieldFromTag<lp::IncomingFaceIdField, lp::IncomingFaceIdTag>(lpPacket, interest);
   212   addFieldFromTag<lp::NextHopFaceIdField, lp::NextHopFaceIdTag>(lpPacket, interest);
   213   addFieldFromTag<lp::CongestionMarkField, lp::CongestionMarkTag>(lpPacket, interest);
   215   static_pointer_cast<
Transport>(getTransport())->
receive(lpPacket.wireEncode());
   223   addFieldFromTag<lp::IncomingFaceIdField, lp::IncomingFaceIdTag>(lpPacket, data);
   224   addFieldFromTag<lp::CongestionMarkField, lp::CongestionMarkTag>(lpPacket, data);
   226   static_pointer_cast<
Transport>(getTransport())->
receive(lpPacket.wireEncode());
   237   addFieldFromTag<lp::IncomingFaceIdField, lp::IncomingFaceIdTag>(lpPacket, nack);
   238   addFieldFromTag<lp::CongestionMarkField, lp::CongestionMarkTag>(lpPacket, nack);
   240   static_pointer_cast<
Transport>(getTransport())->
receive(lpPacket.wireEncode());
   246   if (m_processEventsOverride != 
nullptr) {
   247     m_processEventsOverride(timeout);
 bool enableRegistrationReply
if true, prefix registration command will be automatically replied with a successful response ...
 
ControlParameters & setFaceId(uint64_t faceId)
 
std::vector< lp::Nack > sentNacks
Nacks sent out of this DummyClientFace. 
 
const Name & getName() const 
 
Copyright (c) 2011-2015 Regents of the University of California. 
 
virtual void doProcessEvents(time::milliseconds timeout, bool keepThread)
 
const NackHeader & getHeader() const 
 
Signal< DummyClientFace, Interest > onSendInterest
emits whenever an Interest is sent 
 
represents parameters in a ControlCommand request or response 
 
void resume() override
resume the transport 
 
std::vector< Interest > sentInterests
Interests sent out of this DummyClientFace. 
 
Packet & add(const typename FIELD::ValueType &value)
add a FIELD with value 
 
boost::posix_time::time_duration milliseconds(long duration)
 
void receive(Block block) const 
 
const Interest & getInterest() const 
 
Represents a TLV element of NDN packet format. 
 
represents an Interest packet 
 
use sha256 digest, no signer needs to be specified 
 
const Block & wireEncode() const 
 
std::vector< Data > sentData
Data sent out of this DummyClientFace. 
 
ReceiveCallback m_receiveCallback
 
Signing parameters passed to KeyChain. 
 
boost::asio::io_service & getIoService()
 
represents a Network Nack 
 
options for DummyClientFace 
 
size_t size() const 
Get size of encoded wire, including Type-Length-Value. 
 
void pause() override
pause the transport 
 
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const 
Fast encoding or block size estimation. 
 
DummyClientFace(const Options &options=Options())
Create a dummy face with internal IO service. 
 
Signal< DummyClientFace, lp::Nack > onSendNack
emits whenever a Nack is sent 
 
Block blockFromValue() const 
 
Provide a communication channel with local or remote NDN forwarder. 
 
size_t wireEncode(EncodingImpl< TAG > &encoder) const 
Fast encoding or block size estimation. 
 
boost::asio::io_service * m_ioService
 
Signal< DummyClientFace, Data > onSendData
emits whenever a Data packet is sent 
 
Represents an absolute name. 
 
void receive(const Interest &interest)
cause the Face to receive an interest 
 
bool isPrefixOf(const Name &other) const 
Check if this name is a prefix of another name. 
 
provides TLV-block delivery service 
 
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 send(const Block &wire) override
send a TLV block through the transport 
 
void encode()
Encode sub elements into TLV-VALUE. 
 
const uint8_t * wire() const 
Get pointer to encoded wire. 
 
ControlParameters & setOrigin(RouteOrigin origin)
 
void close() override
Close the connection. 
 
Represents a Data packet. 
 
void send(const Block &header, const Block &payload) override
send two memory blocks through the transport 
 
const Component & get(ssize_t i) const 
Get the component at the given index. 
 
ControlResponse & setCode(uint32_t code)
 
EncodingImpl< EncoderTag > EncodingBuffer
 
Signal< Transport, Block > onSendBlock
 
virtual void connect(boost::asio::io_service &ioService, const ReceiveCallback &receiveCallback)
asynchronously open the connection 
 
bool enablePacketLogging
if true, packets sent out of DummyClientFace will be appended to a container 
 
std::function< void(time::milliseconds)> processEventsOverride
if not empty, face.processEvents() will be overridden by this function