The Pedigree Project 0.1
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
LwipSocketSyscalls Class Reference
+ Inheritance diagram for LwipSocketSyscalls:
+ Collaboration diagram for LwipSocketSyscalls:

Classes

struct  LwipMetadata
 

Public Member Functions

 LwipSocketSyscalls (int domain, int type, int protocol)
 
virtual bool create ()
 Implementation-specific final socket creation logic.
 
virtual int connect (const struct sockaddr_storage *address, socklen_t addrlen)
 
virtual ssize_t sendto_msg (const struct msghdr *msghdr, const SharedPointer< SocketRights > &rights)
 
virtual ssize_t recvfrom_msg (struct msghdr *msghdr, SharedPointer< SocketRights > *rights)
 
virtual int listen (int backlog)
 
virtual int bind (const struct sockaddr_storage *address, socklen_t addrlen)
 
virtual int accept (struct sockaddr_storage *address, socklen_t *addrlen, int flags, DescriptorLease *accepted=nullptr)
 
virtual int shutdown (int how)
 
virtual int getpeername (struct sockaddr_storage *address, socklen_t *address_len)
 
virtual int getsockname (struct sockaddr_storage *address, socklen_t *address_len)
 
virtual int setsockopt (int level, int optname, const void *optvalue, socklen_t optlen)
 
virtual int getsockopt (int level, int optname, void *optvalue, socklen_t *optlen)
 
virtual bool canPoll () const
 
virtual bool poll (bool &read, bool &write, bool &error, Semaphore *waiter)
 
virtual void unPoll (Semaphore *waiter)
 
virtual ReadyMask queryReady (bool reading, bool writing)
 
ReadinessGenerations readinessGenerations () override
 
virtual void lastDescriptorClosed ()
 
virtual void setBlocking (bool blocking)
 
- Public Member Functions inherited from NetworkSyscalls
 NetworkSyscalls (int domain, int type, int protocol)
 
virtual MqueueNetlinkSocket * asMqueueNetlink ()
 
virtual ssize_t sendto (const void *buffer, size_t bufferlen, int flags, const struct sockaddr_storage *address, socklen_t addrlen)
 
virtual ssize_t recvfrom (void *buffer, size_t bufferlen, int flags, struct sockaddr_storage *address, socklen_t *addrlen)
 
ReadinessGenerations readinessGenerations () override
 
MUST_USE_RESULT bool addDescriptorOwner ()
 
void removeDescriptorOwner ()
 
void retainDescriptorLifetime (const SharedPointer< NetworkSyscalls > &lifetime)
 
virtual bool monitor (Thread *pThread, Event *pEvent)
 
virtual bool unmonitor (Event *pEvent)
 
void associate (FileDescriptor *fd)
 
int getDomain () const
 
int getType () const
 
int getProtocol () const
 
const NetworkNamespaceRef & networkNamespace () const
 
bool isBlocking () const
 
int takeReceiveError ()
 
void deferReceiveError (int error)
 
- Public Member Functions inherited from ReadinessSource
MUST_USE_RESULT bool subscribeReadiness (ReadyMask interest, const SharedPointer< ReadinessObserver > &observer, ReadinessSubscription &subscription)
 

Private Member Functions

void registerSocket ()
 
ReadyMask readinessLevelLocked () const
 
void recordReadinessRisesLocked (ReadyMask previous)
 

Static Private Member Functions

static void netconnCallback (struct netconn *conn, enum netconn_evt evt, uint16_t len)
 
static void lwipToSyscallError (err_t err)
 

Private Attributes

struct netconn * m_Socket
 
Mutex m_ReceiveLock
 
struct LwipSocketSyscalls::LwipMetadata m_Metadata
 

Static Private Attributes

static Tree< struct netconn *, LwipSocketSyscalls * > m_SyscallObjects
 
static Mutex m_SyscallObjectsLock
 

Additional Inherited Members

- Protected Member Functions inherited from NetworkSyscalls
virtual bool usesLocalEndpointLifetime () const
 
ReadyMask pendingReceiveReadiness () const
 
ReadinessGenerations withReceiveErrorGeneration (ReadinessGenerations generations) const
 
bool beginDescriptorClose ()
 
bool hasLastDescriptorClosed () const
 
SharedPointer< NetworkSyscalls > acquireDescriptorLifetime () const
 
SharedPointer< NetworkSyscalls > releaseDescriptorLifetime ()
 
- Protected Member Functions inherited from ReadinessSource
void notifyReadiness (ReadyMask mask)
 
void closeReadiness (ReadyMask mask=ReadyInvalid|ReadyHangup)
 
- Protected Attributes inherited from NetworkSyscalls
int m_Domain
 
int m_Type
 
int m_Protocol
 
NetworkNamespaceRef m_NetworkNamespace
 
Atomic< bool > m_Blocking
 
Mutex m_ReceiveErrorLock
 
int m_ReceiveError = 0
 
uint64_t m_ReceiveErrorGeneration = 0
 
OperationBarrier m_ReadinessNotifications
 

Detailed Description

Definition at line 207 of file net-syscalls.h.

Constructor & Destructor Documentation

◆ LwipSocketSyscalls()

LwipSocketSyscalls::LwipSocketSyscalls ( int  domain,
int  type,
int  protocol 
)

Definition at line 1703 of file net-syscalls.cc.

◆ ~LwipSocketSyscalls()

LwipSocketSyscalls::~LwipSocketSyscalls ( )
virtual

Definition at line 1706 of file net-syscalls.cc.

Member Function Documentation

◆ accept()

int LwipSocketSyscalls::accept ( struct sockaddr_storage *  address,
socklen_t *  addrlen,
int  flags,
DescriptorLease *  accepted = nullptr 
)
virtual
Todo:
handle other families

Implements NetworkSyscalls.

Definition at line 2325 of file net-syscalls.cc.

References create(), ERR_OK, and FileDescriptor::setNetworkImpl().

◆ bind()

int LwipSocketSyscalls::bind ( const struct sockaddr_storage *  address,
socklen_t  addrlen 
)
virtual

Implements NetworkSyscalls.

Definition at line 2306 of file net-syscalls.cc.

◆ canPoll()

bool LwipSocketSyscalls::canPoll ( ) const
virtual

Reimplemented from NetworkSyscalls.

Definition at line 2578 of file net-syscalls.cc.

◆ connect()

int LwipSocketSyscalls::connect ( const struct sockaddr_storage *  address,
socklen_t  addrlen 
)
virtual
Todo:
for accept() we need to do this too

Implements NetworkSyscalls.

Definition at line 1861 of file net-syscalls.cc.

References Dec, and ERR_OK.

◆ create()

bool LwipSocketSyscalls::create ( )
virtual

Implementation-specific final socket creation logic.

Todo:
need an error here...

Reimplemented from NetworkSyscalls.

Definition at line 1792 of file net-syscalls.cc.

References netconnCallback().

Referenced by accept().

+ Here is the caller graph for this function:

◆ getpeername()

int LwipSocketSyscalls::getpeername ( struct sockaddr_storage *  address,
socklen_t *  address_len 
)
virtual
Todo:
handle other families

Implements NetworkSyscalls.

Definition at line 2420 of file net-syscalls.cc.

References ERR_OK.

◆ getsockname()

int LwipSocketSyscalls::getsockname ( struct sockaddr_storage *  address,
socklen_t *  address_len 
)
virtual
Todo:
handle other families

Implements NetworkSyscalls.

Definition at line 2440 of file net-syscalls.cc.

References ERR_OK.

◆ getsockopt()

int LwipSocketSyscalls::getsockopt ( int  level,
int  optname,
void *  optvalue,
socklen_t *  optlen 
)
virtual

Implements NetworkSyscalls.

Definition at line 2519 of file net-syscalls.cc.

◆ lastDescriptorClosed()

void LwipSocketSyscalls::lastDescriptorClosed ( )
virtual

Retire the transport after the final descriptor alias closes.

Readiness users may retain this wrapper after the transport is gone, so implementations leave queryReady() returning a stable terminal state.

Reimplemented from NetworkSyscalls.

Definition at line 1710 of file net-syscalls.cc.

References NetworkSyscalls::beginDescriptorClose(), OperationBarrier::closeAndWait(), ReadinessSource::closeReadiness(), NetworkSyscalls::m_ReadinessNotifications, pbuf_free(), and Tree< K, E >::remove().

◆ listen()

int LwipSocketSyscalls::listen ( int  backlog)
virtual

Implements NetworkSyscalls.

Definition at line 2290 of file net-syscalls.cc.

◆ lwipToSyscallError()

void LwipSocketSyscalls::lwipToSyscallError ( err_t  err)
staticprivate

Definition at line 2783 of file net-syscalls.cc.

◆ netconnCallback()

void LwipSocketSyscalls::netconnCallback ( struct netconn *  conn,
enum netconn_evt  evt,
uint16_t  len 
)
staticprivate
Todo:
need a way to do this with lwip when threads are off

Definition at line 2702 of file net-syscalls.cc.

References EMIT_IF, ERR_IF, ERR_OK, Tree< K, E >::lookup(), NetworkSyscalls::m_ReadinessNotifications, ReadinessSource::notifyReadiness(), and OperationBarrier::tryAcquire().

Referenced by create().

+ Here is the caller graph for this function:

◆ poll()

bool LwipSocketSyscalls::poll ( bool &  read,
bool &  write,
bool &  error,
Semaphore *  waiter 
)
virtual
Todo:
this is buggy as it'll return for the wrong events!

Reimplemented from NetworkSyscalls.

Definition at line 2656 of file net-syscalls.cc.

References ERR_OK, and List< T, nodePoolSize >::pushBack().

◆ queryReady()

ReadyMask LwipSocketSyscalls::queryReady ( bool  reading,
bool  writing 
)
virtual

Return a level-triggered snapshot for the requested I/O directions.

Reimplemented from NetworkSyscalls.

Definition at line 2623 of file net-syscalls.cc.

References NetworkSyscalls::m_ReadinessNotifications, and OperationBarrier::tryAcquire().

◆ readinessGenerations()

ReadinessGenerations LwipSocketSyscalls::readinessGenerations ( )
overridevirtual

Return source-serialized rising-edge sequences where available.

A source increments the corresponding sequence while holding the same lock which changes its readiness predicate. Consumers can then recover a drain/refill transition even if the two callback deliveries are reordered.

Reimplemented from ReadinessSource.

Definition at line 2646 of file net-syscalls.cc.

References NetworkSyscalls::m_ReadinessNotifications, and OperationBarrier::tryAcquire().

◆ readinessLevelLocked()

ReadyMask LwipSocketSyscalls::readinessLevelLocked ( ) const
private

Definition at line 2582 of file net-syscalls.cc.

◆ recordReadinessRisesLocked()

void LwipSocketSyscalls::recordReadinessRisesLocked ( ReadyMask  previous)
private

Definition at line 2604 of file net-syscalls.cc.

◆ recvfrom_msg()

ssize_t LwipSocketSyscalls::recvfrom_msg ( struct msghdr *  msghdr,
SharedPointer< SocketRights > *  rights 
)
virtual

Implements NetworkSyscalls.

Definition at line 2045 of file net-syscalls.cc.

◆ registerSocket()

void LwipSocketSyscalls::registerSocket ( )
private

Definition at line 1771 of file net-syscalls.cc.

◆ sendto_msg()

ssize_t LwipSocketSyscalls::sendto_msg ( const struct msghdr *  msghdr,
const SharedPointer< SocketRights > &  rights 
)
virtual

Implements NetworkSyscalls.

Definition at line 1899 of file net-syscalls.cc.

◆ setBlocking()

void LwipSocketSyscalls::setBlocking ( bool  blocking)
virtual

Reimplemented from NetworkSyscalls.

Definition at line 1764 of file net-syscalls.cc.

◆ setsockopt()

int LwipSocketSyscalls::setsockopt ( int  level,
int  optname,
const void *  optvalue,
socklen_t  optlen 
)
virtual

Implements NetworkSyscalls.

Definition at line 2459 of file net-syscalls.cc.

◆ shutdown()

int LwipSocketSyscalls::shutdown ( int  how)
virtual

Reimplemented from NetworkSyscalls.

Definition at line 2378 of file net-syscalls.cc.

◆ unPoll()

void LwipSocketSyscalls::unPoll ( Semaphore *  waiter)
virtual

Reimplemented from NetworkSyscalls.

Definition at line 2690 of file net-syscalls.cc.

Member Data Documentation

◆ m_ReceiveLock

Mutex LwipSocketSyscalls::m_ReceiveLock
private

Definition at line 253 of file net-syscalls.h.

◆ m_Socket

struct netconn* LwipSocketSyscalls::m_Socket
private

Definition at line 252 of file net-syscalls.h.

◆ m_SyscallObjects

Tree< struct netconn *, LwipSocketSyscalls * > LwipSocketSyscalls::m_SyscallObjects
staticprivate

Definition at line 243 of file net-syscalls.h.

◆ m_SyscallObjectsLock

Mutex LwipSocketSyscalls::m_SyscallObjectsLock
staticprivate

Definition at line 244 of file net-syscalls.h.


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