Kea 2.7.6
|
Provides a ring-buffer implementation of the PacketQueue interface. More...
#include <packet_queue_ring.h>
Public Member Functions | |
PacketQueueRing (const std::string &queue_type, size_t capacity) | |
Constructor. | |
virtual | ~PacketQueueRing () |
virtual Destructor | |
virtual void | clear () |
Discards all packets currently in the buffer. | |
virtual PacketTypePtr | dequeuePacket () |
Dequeues the next packet from the queue. | |
virtual int | eatPackets (const QueueEnd &) |
Discards packets from one end of the queue. | |
virtual bool | empty () const |
Returns True if the queue is empty. | |
virtual void | enqueuePacket (PacketTypePtr packet, const SocketInfo &source) |
Adds a packet to the queue. | |
virtual size_t | getCapacity () const |
Returns the maximum number of packets allowed in the buffer. | |
virtual data::ElementPtr | getInfo () const |
Fetches pertinent information. | |
virtual size_t | getSize () const |
Returns the current number of packets in the buffer. | |
virtual const PacketTypePtr | peek (const QueueEnd &from=QueueEnd::FRONT) const |
Gets the packet currently at one end of the queue. | |
virtual PacketTypePtr | popPacket (const QueueEnd &from=QueueEnd::FRONT) |
Pops a packet from the queue. | |
virtual void | pushPacket (PacketTypePtr &packet, const QueueEnd &to=QueueEnd::BACK) |
Pushes a packet onto the queue. | |
virtual void | setCapacity (size_t capacity) |
Sets the maximum number of packets allowed in the buffer. | |
virtual bool | shouldDropPacket (PacketTypePtr, const SocketInfo &) |
Determines if a packet should be discarded. | |
Public Member Functions inherited from isc::dhcp::PacketQueue< PacketTypePtr > | |
PacketQueue (const std::string &queue_type) | |
Constructor. | |
virtual | ~PacketQueue () |
Virtual destructor. | |
std::string | getInfoStr () const |
Fetches a JSON string representation of queue operational info. | |
std::string | getQueueType () |
Static Public Attributes | |
static const size_t | MIN_RING_CAPACITY = 5 |
Minimum queue capacity permitted. | |
Provides a ring-buffer implementation of the PacketQueue interface.
PacketTypePtr | Type of packet the queue contains. This expected to be either isc::dhcp::Pkt4Ptr or isc::dhcp::Pkt6Ptr |
Definition at line 26 of file packet_queue_ring.h.
|
inline |
Constructor.
queue_type | logical name of the queue implementation |
capacity | maximum number of packets the queue can hold |
Definition at line 36 of file packet_queue_ring.h.
|
inlinevirtual |
virtual Destructor
Definition at line 43 of file packet_queue_ring.h.
|
inlinevirtual |
Discards all packets currently in the buffer.
Implements isc::dhcp::PacketQueue< PacketTypePtr >.
Definition at line 198 of file packet_queue_ring.h.
|
inlinevirtual |
Dequeues the next packet from the queue.
Dequeues the next packet (if any) and returns it.
Implements isc::dhcp::PacketQueue< PacketTypePtr >.
Definition at line 65 of file packet_queue_ring.h.
References isc::dhcp::PacketQueueRing< PacketTypePtr >::eatPackets(), isc::dhcp::FRONT, and isc::dhcp::PacketQueueRing< PacketTypePtr >::popPacket().
|
inlinevirtual |
Discards packets from one end of the queue.
This function is called at the beginning of dequeuePacket
and provides an opportunity to examine and discard packets from the queue prior to dequeuing the next packet to be processed. Derivations are expected to provide implementations based on their own requirements. The default implementation is to to simply return without skipping any packets.
Definition at line 97 of file packet_queue_ring.h.
Referenced by isc::dhcp::PacketQueueRing< PacketTypePtr >::dequeuePacket().
|
inlinevirtual |
Returns True if the queue is empty.
Implements isc::dhcp::PacketQueue< PacketTypePtr >.
Definition at line 165 of file packet_queue_ring.h.
|
inlinevirtual |
Adds a packet to the queue.
Calls shouldDropPacket
to determine if the packet should be queued or dropped. If it should be queued it is added to the end of the queue specified by the "to" parameter.
packet | packet to enqueue |
source | socket the packet came from |
Implements isc::dhcp::PacketQueue< PacketTypePtr >.
Definition at line 53 of file packet_queue_ring.h.
References isc::dhcp::PacketQueueRing< PacketTypePtr >::pushPacket(), and isc::dhcp::PacketQueueRing< PacketTypePtr >::shouldDropPacket().
|
inlinevirtual |
Returns the maximum number of packets allowed in the buffer.
Definition at line 171 of file packet_queue_ring.h.
Referenced by isc::dhcp::PacketQueueRing< PacketTypePtr >::getInfo().
|
inlinevirtual |
Fetches pertinent information.
Reimplemented from isc::dhcp::PacketQueue< PacketTypePtr >.
Definition at line 203 of file packet_queue_ring.h.
References isc::data::Element::create(), isc::dhcp::PacketQueueRing< PacketTypePtr >::getCapacity(), isc::dhcp::PacketQueue< PacketTypePtr >::getInfo(), isc::dhcp::PacketQueueRing< PacketTypePtr >::getSize(), and isc::db::info.
|
inlinevirtual |
Returns the current number of packets in the buffer.
Implements isc::dhcp::PacketQueue< PacketTypePtr >.
Definition at line 193 of file packet_queue_ring.h.
Referenced by isc::dhcp::PacketQueueRing< PacketTypePtr >::getInfo().
|
inlinevirtual |
Gets the packet currently at one end of the queue.
Returns a pointer the packet at the specified end of the queue without dequeuing it.
from | specifies which end of the queue to examine. |
Definition at line 155 of file packet_queue_ring.h.
References isc::dhcp::FRONT.
|
inlinevirtual |
Pops a packet from the queue.
Removes a packet from the end of the queue specified and returns it.
from | specifies the end of the queue from which the packet should be taken. It locks the queue's Mutex upon entry. |
Definition at line 126 of file packet_queue_ring.h.
References isc::dhcp::FRONT.
Referenced by isc::dhcp::PacketQueueRing< PacketTypePtr >::dequeuePacket().
|
inlinevirtual |
Pushes a packet onto the queue.
Adds a packet onto the end of queue specified.
packet | packet to add to the queue |
to | specifies the end of the queue to which the packet should be added. |
Definition at line 108 of file packet_queue_ring.h.
References isc::dhcp::BACK.
Referenced by isc::dhcp::PacketQueueRing< PacketTypePtr >::enqueuePacket().
|
inlinevirtual |
Sets the maximum number of packets allowed in the buffer.
BadValue | if capacity is too low. |
Definition at line 181 of file packet_queue_ring.h.
References isc_throw, and isc::dhcp::PacketQueueRing< PacketTypePtr >::MIN_RING_CAPACITY.
|
inlinevirtual |
Determines if a packet should be discarded.
This function is called in enqueuePackets
for each packet in its packet list. It provides an opportunity to examine the packet and its source and decide whether it should be dropped or added to the queue. Derivations are expected to provide implementations based on their own requirements. Bear in mind that the packet has NOT been unpacked at this point. The default implementation simply returns false (i.e. keep the packet).
Definition at line 82 of file packet_queue_ring.h.
Referenced by isc::dhcp::PacketQueueRing< PacketTypePtr >::enqueuePacket().
|
static |
Minimum queue capacity permitted.
Below five is pretty much nonsensical.
Definition at line 30 of file packet_queue_ring.h.
Referenced by isc::dhcp::PacketQueueRing< PacketTypePtr >::setCapacity().