Kea  2.1.2-git
isc::dhcp::PacketQueue< PacketTypePtr > Class Template Referenceabstract

Interface for managing a queue of inbound DHCP packets. More...

#include <packet_queue.h>

+ Inheritance diagram for isc::dhcp::PacketQueue< PacketTypePtr >:

Public Member Functions

 PacketQueue (const std::string &queue_type)
 Constructor. More...
 
virtual ~PacketQueue ()
 Virtual destructor. More...
 
virtual void clear ()=0
 Discards all packets currently in the buffer. More...
 
virtual PacketTypePtr dequeuePacket ()=0
 Dequeues the next packet from the queue. More...
 
virtual bool empty () const =0
 return True if the queue is empty. More...
 
virtual void enqueuePacket (PacketTypePtr packet, const SocketInfo &source)=0
 Adds a packet to the queue. More...
 
virtual data::ElementPtr getInfo () const
 Fetches operational information about the current state of the queue. More...
 
std::string getInfoStr () const
 Fetches a JSON string representation of queue operational info. More...
 
std::string getQueueType ()
 
virtual size_t getSize () const =0
 Returns the current number of packets in the buffer. More...
 

Detailed Description

template<typename PacketTypePtr>
class isc::dhcp::PacketQueue< PacketTypePtr >

Interface for managing a queue of inbound DHCP packets.

This class serves as the abstract interface for packet queue implementations which may be used by IfaceMgr to store inbound packets until they are a dequeued for processing.

Template Parameters
PacketTypePtrType of packet the queue contains. This expected to be either isc::dhcp::Pkt4Ptr or isc::dhcp::Pkt6Ptr
Note
Derivations of this class MUST BE thread-safe.

Definition at line 48 of file packet_queue.h.

Constructor & Destructor Documentation

◆ PacketQueue()

template<typename PacketTypePtr>
isc::dhcp::PacketQueue< PacketTypePtr >::PacketQueue ( const std::string &  queue_type)
inlineexplicit

Constructor.

Parameters
queue_typelogical name of the queue implementation Typically this is assigned by the factory that creates the queue. It is the logical name used to register queue implementations.

Definition at line 57 of file packet_queue.h.

◆ ~PacketQueue()

template<typename PacketTypePtr>
virtual isc::dhcp::PacketQueue< PacketTypePtr >::~PacketQueue ( )
inlinevirtual

Virtual destructor.

Definition at line 61 of file packet_queue.h.

Member Function Documentation

◆ clear()

template<typename PacketTypePtr>
virtual void isc::dhcp::PacketQueue< PacketTypePtr >::clear ( )
pure virtual

◆ dequeuePacket()

template<typename PacketTypePtr>
virtual PacketTypePtr isc::dhcp::PacketQueue< PacketTypePtr >::dequeuePacket ( )
pure virtual

Dequeues the next packet from the queue.

Dequeues the next packet (if any) and returns it. Derivations determine how packets are dequeued.

Returns
A pointer to dequeued packet, or an empty pointer if the queue is empty.

Implemented in isc::dhcp::PacketQueueRing< PacketTypePtr >, isc::dhcp::PacketQueueRing< Pkt4Ptr >, and isc::dhcp::PacketQueueRing< Pkt6Ptr >.

◆ empty()

template<typename PacketTypePtr>
virtual bool isc::dhcp::PacketQueue< PacketTypePtr >::empty ( ) const
pure virtual

◆ enqueuePacket()

template<typename PacketTypePtr>
virtual void isc::dhcp::PacketQueue< PacketTypePtr >::enqueuePacket ( PacketTypePtr  packet,
const SocketInfo source 
)
pure virtual

Adds a packet to the queue.

Adds the packet to the queue. Derivations determine which packets to queue and how to queue them.

Parameters
packetpacket to enqueue
sourcesocket the packet came from

Implemented in isc::dhcp::PacketQueueRing< PacketTypePtr >, isc::dhcp::PacketQueueRing< Pkt4Ptr >, and isc::dhcp::PacketQueueRing< Pkt6Ptr >.

◆ getInfo()

template<typename PacketTypePtr>
virtual data::ElementPtr isc::dhcp::PacketQueue< PacketTypePtr >::getInfo ( ) const
inlinevirtual

Fetches operational information about the current state of the queue.

Creates and returns an ElementPtr containing a single entry, "queue-type". Derivations are expected to call this method first and then add their own values. Since implementations may vary widely on data of interest, this is structured as an ElementPtr for broad latitude.

Returns
an ElementPtr containing elements for values of interest

Reimplemented in isc::dhcp::PacketQueueRing< PacketTypePtr >, isc::dhcp::PacketQueueRing< Pkt4Ptr >, and isc::dhcp::PacketQueueRing< Pkt6Ptr >.

Definition at line 100 of file packet_queue.h.

Referenced by isc::dhcp::PacketQueueRing< Pkt6Ptr >::getInfo().

◆ getInfoStr()

template<typename PacketTypePtr>
std::string isc::dhcp::PacketQueue< PacketTypePtr >::getInfoStr ( ) const
inline

Fetches a JSON string representation of queue operational info.

This method calls getInfo() and then converts that into JSON text.

Returns
string of JSON text

Definition at line 111 of file packet_queue.h.

◆ getQueueType()

template<typename PacketTypePtr>
std::string isc::dhcp::PacketQueue< PacketTypePtr >::getQueueType ( )
inline
Returns
Fetches the logical name of the type of this queue.

Definition at line 119 of file packet_queue.h.

◆ getSize()

template<typename PacketTypePtr>
virtual size_t isc::dhcp::PacketQueue< PacketTypePtr >::getSize ( ) const
pure virtual

Returns the current number of packets in the buffer.

Implemented in isc::dhcp::PacketQueueRing< PacketTypePtr >, isc::dhcp::PacketQueueRing< Pkt4Ptr >, and isc::dhcp::PacketQueueRing< Pkt6Ptr >.


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