FreeNOS
Data Structures | Public Types | Public Member Functions | Static Public Attributes | Private Attributes
NetworkQueue Class Reference

Networking packet queue implementation. More...

#include <NetworkQueue.h>

Data Structures

struct  Packet
 Represents a network packet. More...
 

Public Types

typedef struct NetworkQueue::Packet Packet
 Represents a network packet. More...
 

Public Member Functions

 NetworkQueue (const Size packetSize, const Size queueSize=MaxPackets)
 Constructor. More...
 
virtual ~NetworkQueue ()
 Destructor. More...
 
Packetget ()
 Get unused packet. More...
 
void release (Packet *packet)
 Put unused packet back. More...
 
void push (Packet *packet)
 Enqueue packet with data. More...
 
Packetpop ()
 Retrieve packet with data. More...
 
bool hasData () const
 Check if data packets are available. More...
 

Static Public Attributes

static const Size PayloadBufferSize = 2048
 Size of payload memory buffer. More...
 
static const Size MaxPackets = 64u
 Maximum number of packets available. More...
 

Private Attributes

Index< Packet, MaxPacketsm_free
 Contains unused packets. More...
 
Index< Packet, MaxPacketsm_data
 Contains packets with data. More...
 
Memory::Range m_payloadRange
 Defines the memory range of mapped payload data. More...
 

Detailed Description

Networking packet queue implementation.

Definition at line 37 of file NetworkQueue.h.

Member Typedef Documentation

◆ Packet

Represents a network packet.

Constructor & Destructor Documentation

◆ NetworkQueue()

NetworkQueue::NetworkQueue ( const Size  packetSize,
const Size  queueSize = MaxPackets 
)

Constructor.

Parameters
packetSizeThe size of each packet in bytes
queueSizeThe size of the queue in number of packets

Definition at line 23 of file NetworkQueue.cpp.

References Memory::Range::access, assert, NetworkQueue::Packet::data, ERROR, m_free, m_payloadRange, MapContiguous, MaxPackets, PAGESIZE, PayloadBufferSize, Memory::Range::phys, Memory::Readable, SELF, NetworkQueue::Packet::size, Memory::Range::size, API::Success, Memory::User, Memory::Range::virt, VMCtl(), Memory::Writable, and ZERO.

◆ ~NetworkQueue()

NetworkQueue::~NetworkQueue ( )
virtual

Destructor.

Definition at line 58 of file NetworkQueue.cpp.

References m_free, m_payloadRange, Release, SELF, and VMCtl().

Member Function Documentation

◆ get()

NetworkQueue::Packet * NetworkQueue::get ( )

Get unused packet.

Definition at line 72 of file NetworkQueue.cpp.

References m_free, NetworkQueue::Packet::size, and ZERO.

Referenced by Ethernet::getTransmitPacket(), UDPSocket::process(), and Sun8iEmac::resetReceive().

◆ hasData()

bool NetworkQueue::hasData ( ) const

Check if data packets are available.

Returns
Boolean

Definition at line 112 of file NetworkQueue.cpp.

References m_data.

Referenced by UDPSocket::canRead().

◆ pop()

NetworkQueue::Packet * NetworkQueue::pop ( )

Retrieve packet with data.

Definition at line 98 of file NetworkQueue.cpp.

References m_data, and ZERO.

Referenced by UDPSocket::read().

◆ push()

void NetworkQueue::push ( NetworkQueue::Packet packet)

Enqueue packet with data.

Definition at line 93 of file NetworkQueue.cpp.

References m_data.

Referenced by UDPSocket::process().

◆ release()

void NetworkQueue::release ( NetworkQueue::Packet packet)

Put unused packet back.

Definition at line 87 of file NetworkQueue.cpp.

References m_free, and NetworkQueue::Packet::size.

Referenced by Sun8iEmac::interrupt(), UDPSocket::read(), and Loopback::transmit().

Field Documentation

◆ m_data

Index<Packet, MaxPackets> NetworkQueue::m_data
private

Contains packets with data.

Definition at line 106 of file NetworkQueue.h.

Referenced by hasData(), pop(), and push().

◆ m_free

Index<Packet, MaxPackets> NetworkQueue::m_free
private

Contains unused packets.

Definition at line 103 of file NetworkQueue.h.

Referenced by get(), NetworkQueue(), release(), and ~NetworkQueue().

◆ m_payloadRange

Memory::Range NetworkQueue::m_payloadRange
private

Defines the memory range of mapped payload data.

Definition at line 109 of file NetworkQueue.h.

Referenced by NetworkQueue(), and ~NetworkQueue().

◆ MaxPackets

const Size NetworkQueue::MaxPackets = 64u
static

◆ PayloadBufferSize

const Size NetworkQueue::PayloadBufferSize = 2048
static

Size of payload memory buffer.

Definition at line 42 of file NetworkQueue.h.

Referenced by NetSend::exec(), NetworkQueue(), MpiProxy::processRecv(), and UDPSocket::write().


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