The Pedigree Project
0.1
|
#include <NetworkStack.h>
Classes | |
class | Packet |
Public Member Functions | |
void | receive (size_t nBytes, uintptr_t packet, Network *pCard, uint32_t offset) |
void | registerDevice (Network *pDevice) |
Network * | getDevice (size_t n) |
size_t | getNumDevices () |
void | deRegisterDevice (Network *pDevice) |
void | setLoopback (Network *pCard) |
Network * | getLoopback () |
MemoryPool & | getMemPool () |
struct netif * | getInterface (Network *pCard) const |
Public Member Functions inherited from RequestQueue | |
RequestQueue (const String &name) | |
virtual void | initialise () |
virtual void | destroy () |
MUST_USE_RESULT uint64_t | addRequest (size_t priority, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
MUST_USE_RESULT uint64_t | addRequest (size_t priority, ActionOnDuplicate action, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
uint64_t | addAsyncRequest (size_t priority, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
void | halt () |
void | resume () |
Static Public Member Functions | |
static NetworkStack & | instance () |
Private Member Functions | |
virtual uint64_t | executeRequest (uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, uint64_t p5, uint64_t p6, uint64_t p7, uint64_t p8) |
Private Attributes | |
Network * | m_pLoopback |
Vector< Network * > | m_Children |
MemoryPool | m_MemPool |
Mutex | m_Lock |
Tree< Network *, struct netif * > | m_Interfaces |
size_t | m_NextInterfaceNumber |
Static Private Attributes | |
static NetworkStack * | stack = 0 |
Additional Inherited Members | |
Public Types inherited from RequestQueue | |
enum | ActionOnDuplicate { Block, NewRequest, ReturnImmediately } |
Protected Member Functions inherited from RequestQueue | |
RequestQueue (const RequestQueue &) | |
void | operator= (const RequestQueue &) |
virtual bool | compareRequests (const Request &a, const Request &b) |
bool | isRequestValid (const Request *r) |
int | work () |
Request * | getNextRequest () |
Static Protected Member Functions inherited from RequestQueue | |
static int | trampoline (void *p) |
static int | doAsync (void *p) |
Protected Attributes inherited from RequestQueue | |
Request * | m_pRequestQueue [REQUEST_QUEUE_NUM_PRIORITIES] |
volatile bool | m_Stop |
Mutex | m_RequestQueueMutex |
ConditionVariable | m_RequestQueueCondition |
ConditionVariable | m_AsyncRequestQueueCondition |
Thread * | m_pThread |
bool | m_Halted |
Mutex | m_HaltAcknowledged |
RequestQueueOverrunChecker | m_OverrunChecker |
size_t | m_nMaxAsyncRequests |
size_t | m_nAsyncRequests |
size_t | m_nTotalRequests |
String | m_Name |
The Pedigree network stack This function is the base for receiving packets, and provides functionality for keeping track of network devices in the system.
Definition at line 40 of file NetworkStack.h.
void NetworkStack::deRegisterDevice | ( | Network * | pDevice | ) |
Unregisters a given network device from the stack
Definition at line 272 of file NetworkStack.cc.
References MemoryPool::allocateNow(), Vector< T >::begin(), Vector< T >::end(), Vector< T >::erase(), MemoryPool::free(), instance(), Device::m_Children, m_MemPool, and netif_remove().
|
privatevirtual |
Callback - classes are expected to inherit and override this function. It's called when a request needs to be executed (by the worker thread).
Implements RequestQueue.
Definition at line 159 of file NetworkStack.cc.
References netif::input.
Network * NetworkStack::getDevice | ( | size_t | n | ) |
Returns the n'th registered network device
Definition at line 262 of file NetworkStack.cc.
References Device::m_Children.
Get an interface for a card.
Definition at line 126 of file NetworkStack.h.
|
inline |
Gets the loopback device for the stack
Definition at line 75 of file NetworkStack.h.
|
inline |
Grabs the memory pool for networking use
Definition at line 81 of file NetworkStack.h.
Referenced by Dm9601::initialiseDriver(), Dm9601::send(), and Ne2k::send().
size_t NetworkStack::getNumDevices | ( | ) |
Returns the number of devices registered with the stack
Definition at line 267 of file NetworkStack.cc.
References Vector< T >::count(), and Device::m_Children.
|
inlinestatic |
For access to the stack without declaring an instance of it
Definition at line 47 of file NetworkStack.h.
Referenced by CdiNet::CdiNet(), deRegisterDevice(), Dm9601::initialiseDriver(), Ne2k::Ne2k(), Nic3C90x::Nic3C90x(), Dm9601::send(), Rtl8139::send(), Loopback::send(), Ne2k::send(), and CdiNet::setStationInfo().
void NetworkStack::receive | ( | size_t | nBytes, |
uintptr_t | packet, | ||
Network * | pCard, | ||
uint32_t | offset | ||
) |
Called when a packet arrives
Definition at line 178 of file NetworkStack.cc.
References Network::droppedPacket(), ERROR, NetworkFilter::instance(), pbuf::len, pbuf::next, pbuf::payload, pbuf_alloc(), PBUF_POOL, and PBUF_RAW.
Referenced by Dm9601::initialiseDriver(), Nic3C90x::Nic3C90x(), Rtl8139::send(), Loopback::send(), Ne2k::send(), and CdiNet::setStationInfo().
void NetworkStack::registerDevice | ( | Network * | pDevice | ) |
Registers a given network device with the stack
Definition at line 226 of file NetworkStack.cc.
References FATAL, Device::m_Children, netif::name, netif_add(), netif::num, Vector< T >::pushBack(), and tcpip_input().
Referenced by CdiNet::CdiNet(), Dm9601::initialiseDriver(), Ne2k::Ne2k(), and Nic3C90x::Nic3C90x().
|
inline |
Sets the loopback device for the stack
Definition at line 69 of file NetworkStack.h.
Network devices registered with the stack.
Definition at line 142 of file NetworkStack.h.
lwIP interfaces for each of our cards.
Definition at line 152 of file NetworkStack.h.
|
private |
Networking memory pool
Definition at line 145 of file NetworkStack.h.
Referenced by deRegisterDevice().
|
private |
Next interface number to assign.
Definition at line 155 of file NetworkStack.h.
|
private |
Loopback device
Definition at line 139 of file NetworkStack.h.