28#ifndef CMSIS_PLUS_POSIX_IO_NET_STACK_H_
29#define CMSIS_PLUS_POSIX_IO_NET_STACK_H_
33#if defined(__cplusplus)
37#if defined(OS_USE_OS_APP_CONFIG_H)
38#include <cmsis-plus/os-app-config.h>
51#pragma GCC diagnostic push
54#pragma clang diagnostic ignored "-Wc++98-compat"
79 socket (
int domain,
int type,
int protocol);
136 socket (
int domain,
int type,
int protocol);
145 utils::double_list_links, &socket::deferred_links_>;
156 template<typename T, typename L>
180 const char* name_ = nullptr;
215 utils::double_list_links, &net_stack::net_manager_links_>;
216 static net_list net_list__;
317 template<
typename ... Args>
377 template<
typename T,
typename L>
396 template<
typename ... Args>
484 deferred_sockets_list_.link (*sock);
490 return deferred_sockets_list_;
497 using socket_type = T;
501 if (deferred_sockets_list_.empty ())
503 sock =
new socket_type (*
this);
508 static_cast<socket_type*
> (deferred_sockets_list_.unlink_head ());
511 sock->~socket_type ();
514 new (sock) socket_type (*
this);
517 while (!deferred_sockets_list_.empty ())
520 static_cast<socket_type*
> (deferred_sockets_list_.unlink_head ());
529 template<
typename T,
typename L>
533 using socket_type = T;
537 if (deferred_sockets_list_.empty ())
539 sock =
new socket_type (*
this, locker);
544 static_cast<socket_type*
> (deferred_sockets_list_.unlink_head ());
547 sock->~socket_type ();
550 new (sock) socket_type (*
this, locker);
553 while (!deferred_sockets_list_.empty ())
556 static_cast<socket_type*
> (deferred_sockets_list_.unlink_head ());
576 template<
typename ... Args>
578 const char* name,
net_interface& interface, Args&&... args) :
580 { impl_instance_,
name },
582 { interface, std::forward<Args>(args)... }
584#if defined(OS_TRACE_POSIX_IO_NET_STACK)
585 trace::printf (
"net_stack_implementable::%s(\"%s\")=@%p\n", __func__,
593#if defined(OS_TRACE_POSIX_IO_NET_STACK)
594 trace::printf (
"net_stack_implementable::%s() @%p %s\n", __func__,
this,
608 template<
typename T,
typename L>
609 template<
typename ... Args>
615 { impl_instance_,
name },
617 { interface, locker, std::forward<Args>(args)... }
619#if defined(OS_TRACE_POSIX_IO_NET_STACK)
620 trace::printf (
"net_stack_lockable::%s()=%p\n", __func__,
this);
624 template<
typename T,
typename L>
627#if defined(OS_TRACE_POSIX_IO_NET_STACK)
628 trace::printf (
"net_stack_lockable::%s() @%p\n", __func__,
this);
634 template<
typename T,
typename L>
645#pragma GCC diagnostic pop
virtual class socket * do_socket(int domain, int type, int protocol)=0
net_interface & interface(void) const
virtual ~net_stack_implementable()
net_stack_implementable(const char *name, net_interface &interface, Args &&... args)
value_type & impl(void) const
net_stack_lockable(const char *name, net_interface &interface, lockable_type &locker, Args &&... args)
value_type & impl(void) const
virtual ~net_stack_lockable()
net_stack_impl & impl(void) const
T * allocate_socket(void)
net_interface & interface(void) const
void add_deferred_socket(class socket *sock)
const char * name(void) const
deferred_sockets_list_t & deferred_sockets_list(void)
The core of a double linked list, pointers to next, previous.
int printf(const char *format,...)
Write a formatted string to the trace device.
int socket(int domain, int type, int protocol)