µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os::posix::net_stack Class Reference

Network stack class. More...

#include <cmsis-plus/posix-io/net-stack.h>

+ Inheritance diagram for os::posix::net_stack:

Public Member Functions

Constructors & Destructor
 net_stack (net_stack_impl &impl, const char *name)
 
virtual ~net_stack ()
 

Public Static Member Functions

using deferred_sockets_list_t = utils::intrusive_list< class socket, utils::double_list_links, &socket::deferred_links_ >
 
virtual class socketsocket (int domain, int type, int protocol)
 
const char * name (void) const
 
void add_deferred_socket (class socket *sock)
 
deferred_sockets_list_tdeferred_sockets_list (void)
 
template<typename T >
T * allocate_socket (void)
 
template<typename T , typename L >
T * allocate_socket (L &locker)
 
net_interfaceinterface (void) const
 
net_stack_implimpl (void) const
 

Detailed Description

Definition at line 80 of file net-stack.h.

Member Typedef Documentation

◆ deferred_sockets_list_t

Definition at line 132 of file net-stack.h.

Constructor & Destructor Documentation

◆ net_stack()

os::posix::net_stack::net_stack ( net_stack_impl impl,
const char *  name 
)

Definition at line 81 of file net-stack.cpp.

82 : name_ (name), //
83 impl_ (impl)
84 {
85#if defined(OS_TRACE_POSIX_IO_NET_STACK)
86 trace::printf ("net_stack::%s(\"%s\")=%p\n", __func__, name_, this);
87#endif
88 deferred_sockets_list_.clear ();
89 }
net_stack_impl & impl(void) const
Definition net-stack.h:456
const char * name(void) const
Definition net-stack.h:450
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59

References os::trace::printf().

◆ ~net_stack()

os::posix::net_stack::~net_stack ( )
virtual

Definition at line 91 of file net-stack.cpp.

92 {
93#if defined(OS_TRACE_POSIX_IO_NET_STACK)
94 trace::printf ("net_stack::%s(\"%s\") %p\n", __func__, name_, this);
95#endif
96 }

References os::trace::printf().

Member Function Documentation

◆ add_deferred_socket()

void os::posix::net_stack::add_deferred_socket ( class socket sock)
inline

Definition at line 469 of file net-stack.h.

470 {
471 deferred_sockets_list_.link (*sock);
472 }

◆ allocate_socket() [1/2]

template<typename T , typename L >
T * os::posix::net_stack::allocate_socket ( L &  locker)

Definition at line 518 of file net-stack.h.

519 {
520 using socket_type = T;
521
522 socket_type* sock;
523
524 if (deferred_sockets_list_.empty ())
525 {
526 sock = new socket_type (*this, locker);
527 }
528 else
529 {
530 sock = static_cast<socket_type*> (
531 deferred_sockets_list_.unlink_head ());
532
533 // Call the constructor before reusing the object,
534 sock->~socket_type ();
535
536 // Placement new, run only the constructor.
537 new (sock) socket_type (*this, locker);
538
539 // Deallocate all remaining elements in the list.
540 while (!deferred_sockets_list_.empty ())
541 {
542 socket_type* s = static_cast<socket_type*> (
543 deferred_sockets_list_.unlink_head ());
544
545 // Call the destructor and the deallocator.
546 delete s;
547 }
548 }
549 return sock;
550 }

◆ allocate_socket() [2/2]

template<typename T >
T * os::posix::net_stack::allocate_socket ( void  )

Definition at line 482 of file net-stack.h.

483 {
484 using socket_type = T;
485
486 socket_type* sock;
487
488 if (deferred_sockets_list_.empty ())
489 {
490 sock = new socket_type (*this);
491 }
492 else
493 {
494 sock = static_cast<socket_type*> (
495 deferred_sockets_list_.unlink_head ());
496
497 // Call the constructor before reusing the object,
498 sock->~socket_type ();
499
500 // Placement new, run only the constructor.
501 new (sock) socket_type (*this);
502
503 // Deallocate all remaining elements in the list.
504 while (!deferred_sockets_list_.empty ())
505 {
506 socket_type* s = static_cast<socket_type*> (
507 deferred_sockets_list_.unlink_head ());
508
509 // Call the destructor and the deallocator.
510 delete s;
511 }
512 }
513 return sock;
514 }

◆ deferred_sockets_list()

net_stack::deferred_sockets_list_t & os::posix::net_stack::deferred_sockets_list ( void  )
inline

Definition at line 475 of file net-stack.h.

476 {
477 return deferred_sockets_list_;
478 }

◆ impl()

net_stack_impl & os::posix::net_stack::impl ( void  ) const
inline

Definition at line 456 of file net-stack.h.

457 {
458#pragma GCC diagnostic push
459#if defined(__clang__)
460#elif defined(__GNUC__)
461#pragma GCC diagnostic ignored "-Wuseless-cast"
462#pragma GCC diagnostic ignored "-Wnull-dereference"
463#endif
464 return static_cast<net_stack_impl&> (impl_);
465#pragma GCC diagnostic push
466 }

Referenced by socket().

◆ interface()

net_interface & os::posix::net_stack::interface ( void  ) const

◆ name()

const char * os::posix::net_stack::name ( void  ) const
inline

Definition at line 450 of file net-stack.h.

451 {
452 return name_;
453 }

◆ socket()

class socket * os::posix::net_stack::socket ( int  domain,
int  type,
int  protocol 
)
virtual

Definition at line 104 of file net-stack.cpp.

105 {
106 errno = 0;
107
108 return impl ().do_socket (domain, type, protocol);
109 }
virtual class socket * do_socket(int domain, int type, int protocol)=0

References os::posix::net_stack_impl::do_socket(), and impl().

Referenced by os::posix::socket().


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