esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
ndnph::PacketHandler Class Reference

Base class to receive packets from Face. More...

#include <packet-handler.hpp>

Inherited by esp8266ndn::UnixTime, ndnph::PingClient, ndnph::PingServer, ndnph::SegmentConsumerBase, ndnph::SegmentProducerBase, ndnph::ndncert::client::Client, ndnph::ndncert::server::Server, ndnph::rdr::RdrMetadataConsumer, and ndnph::rdr::RdrMetadataProducer.

Classes

class  OutgoingPendingInterest
 Helper to keep track an outgoing pending Interest. More...
 
class  WithEndpointId
 Set EndpointId of PacketInfo. More...
 
class  WithPitToken
 Set PIT token of PacketInfo. More...
 

Public Types

using PacketInfo = Face::PacketInfo
 

Public Member Functions

 PacketHandler ()=default
 Construct without adding to Face. More...
 
 PacketHandler (Face &face, int8_t prio=0)
 Construct and add handler to Face. More...
 

Protected Member Functions

virtual ~PacketHandler ()
 Remove handler from Face. More...
 
FacegetFace () const
 
const PacketInfogetCurrentPacketInfo () const
 Retrieve information about current processing packet. More...
 
template<typename Packet >
bool send (Region &region, const Packet &packet, PacketInfo pi={})
 Synchronously transmit a packet. More...
 
template<typename Packet , typename... PacketInfoModifier>
bool send (Region &region, const Packet &packet, const PacketInfoModifier &... pim)
 Synchronously transmit a packet. More...
 
template<typename Packet , typename... Arg, typename = typename std::enable_if< !std::is_base_of<Region, typename std::decay<Packet>::type>::value>::type>
bool send (const Packet &packet, Arg &&... arg)
 Synchronously transmit a packet. More...
 
template<typename... Arg>
bool reply (Arg &&... arg)
 Synchronously transmit a packet in reply to current processing packet. More...
 

Private Member Functions

virtual void loop ()
 Override to be invoked periodically. More...
 
virtual bool processInterest (Interest)
 Override to receive Interest packets. More...
 
virtual bool processData (Data)
 Override to receive Data packets. More...
 
virtual bool processNack (Nack)
 Override to receive Nack packets. More...
 

Detailed Description

Base class to receive packets from Face.

Member Typedef Documentation

◆ PacketInfo

Constructor & Destructor Documentation

◆ PacketHandler() [1/2]

ndnph::PacketHandler::PacketHandler ( )
explicitdefault

Construct without adding to Face.

◆ PacketHandler() [2/2]

ndnph::PacketHandler::PacketHandler ( Face face,
int8_t  prio = 0 
)
inlineexplicit

Construct and add handler to Face.

◆ ~PacketHandler()

virtual ndnph::PacketHandler::~PacketHandler ( )
inlineprotectedvirtual

Remove handler from Face.

Member Function Documentation

◆ getCurrentPacketInfo()

const PacketInfo* ndnph::PacketHandler::getCurrentPacketInfo ( ) const
inlineprotected

Retrieve information about current processing packet.

Precondition
one of processInterest, processData, or processNack is executing.

◆ getFace()

Face* ndnph::PacketHandler::getFace ( ) const
inlineprotected

◆ loop()

virtual void ndnph::PacketHandler::loop ( )
inlineprivatevirtual

Override to be invoked periodically.

◆ processData()

virtual bool ndnph::PacketHandler::processData ( Data  )
inlineprivatevirtual

Override to receive Data packets.

Return values
truepacket has been accepted by this handler.
falsepacket is not accepted, and should go to the next handler.

◆ processInterest()

virtual bool ndnph::PacketHandler::processInterest ( Interest  )
inlineprivatevirtual

Override to receive Interest packets.

Return values
truepacket has been accepted by this handler.
falsepacket is not accepted, and should go to the next handler.

◆ processNack()

virtual bool ndnph::PacketHandler::processNack ( Nack  )
inlineprivatevirtual

Override to receive Nack packets.

Return values
truepacket has been accepted by this handler.
falsepacket is not accepted, and should go to the next handler.

◆ reply()

template<typename... Arg>
bool ndnph::PacketHandler::reply ( Arg &&...  arg)
inlineprotected

Synchronously transmit a packet in reply to current processing packet.

Precondition
one of processInterest, processData, or processNack is executing.
Parameters
argeither `Region&, const Packet&` or `const Packet&`.

This is most useful in processInterest, replying a Data or Nack carrying the PIT token of current Interest to the endpointId of current Interest.

◆ send() [1/3]

template<typename Packet , typename... Arg, typename = typename std::enable_if< !std::is_base_of<Region, typename std::decay<Packet>::type>::value>::type>
bool ndnph::PacketHandler::send ( const Packet &  packet,
Arg &&...  arg 
)
inlineprotected

Synchronously transmit a packet.

Template Parameters
PacketInterest, Data, their signed variants, or Nack.
Argeither a sequence of `PacketInfoModifier` or `PacketInfo`.
send(interest);
send(interest, WithEndpointId(4688));
send(interest, WithPitToken(0x013CA61E013F0B7A), WithEndpointId(4688));
send(interest, myPacketInfo);
bool send(Region &region, const Packet &packet, PacketInfo pi={})
Synchronously transmit a packet.
Definition: packet-handler.hpp:49

◆ send() [2/3]

template<typename Packet , typename... PacketInfoModifier>
bool ndnph::PacketHandler::send ( Region region,
const Packet &  packet,
const PacketInfoModifier &...  pim 
)
inlineprotected

Synchronously transmit a packet.

Template Parameters
PacketInterest, Data, their signed variants, or Nack.
PacketInfoModifierWithEndpointId or WithPitToken

◆ send() [3/3]

template<typename Packet >
bool ndnph::PacketHandler::send ( Region region,
const Packet &  packet,
PacketInfo  pi = {} 
)
inlineprotected

Synchronously transmit a packet.

Template Parameters
PacketInterest, Data, their signed variants, or Nack.
Parameters
regionwhere to allocate temporary memory for packet encoding.
Returns
whether success.

The documentation for this class was generated from the following file: