13#ifndef CMSIS_PLUS_POSIX_IO_NET_STACK_H_
14#define CMSIS_PLUS_POSIX_IO_NET_STACK_H_
18#if defined(__cplusplus)
22#if defined(OS_USE_OS_APP_CONFIG_H)
23#include <cmsis-plus/os-app-config.h>
36#pragma GCC diagnostic push
38#pragma clang diagnostic ignored "-Wc++98-compat"
63 socket (
int domain,
int type,
int protocol);
75#pragma GCC diagnostic push
77#elif defined(__GNUC__)
78#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
79#pragma GCC diagnostic ignored "-Wsuggest-final-types"
126 socket (
int domain,
int type,
int protocol);
135 utils::double_list_links, &socket::deferred_links_>;
146 template<typename T, typename L>
170 const char* name_ = nullptr;
205 utils::double_list_links, &net_stack::net_manager_links_>;
206 static net_list net_list__;
213#pragma GCC diagnostic pop
308 template<
typename ... Args>
368 template<
typename T,
typename L>
387 template<
typename ... Args>
469#pragma GCC diagnostic push
470#if defined(__clang__)
471#elif defined(__GNUC__)
472#pragma GCC diagnostic ignored "-Wuseless-cast"
473#pragma GCC diagnostic ignored "-Wnull-dereference"
476#pragma GCC diagnostic push
482 deferred_sockets_list_.link (*sock);
488 return deferred_sockets_list_;
495 using socket_type = T;
499 if (deferred_sockets_list_.empty ())
501 sock =
new socket_type (*
this);
506 static_cast<socket_type*
> (deferred_sockets_list_.unlink_head ());
509 sock->~socket_type ();
512 new (sock) socket_type (*
this);
515 while (!deferred_sockets_list_.empty ())
518 static_cast<socket_type*
> (deferred_sockets_list_.unlink_head ());
527 template<
typename T,
typename L>
531 using socket_type = T;
535 if (deferred_sockets_list_.empty ())
537 sock =
new socket_type (*
this, locker);
542 static_cast<socket_type*
> (deferred_sockets_list_.unlink_head ());
545 sock->~socket_type ();
548 new (sock) socket_type (*
this, locker);
551 while (!deferred_sockets_list_.empty ())
554 static_cast<socket_type*
> (deferred_sockets_list_.unlink_head ());
574 template<
typename ... Args>
576 const char* name,
net_interface& interface, Args&&... args) :
578 { impl_instance_,
name },
580 { interface, std::forward<Args>(args)... }
582#if defined(OS_TRACE_POSIX_IO_NET_STACK)
583 trace::printf (
"net_stack_implementable::%s(\"%s\")=@%p\n", __func__,
591#if defined(OS_TRACE_POSIX_IO_NET_STACK)
592 trace::printf (
"net_stack_implementable::%s() @%p %s\n", __func__,
this,
606 template<
typename T,
typename L>
607 template<
typename ... Args>
613 { impl_instance_,
name },
615 { interface, locker, std::forward<Args>(args)... }
617#if defined(OS_TRACE_POSIX_IO_NET_STACK)
618 trace::printf (
"net_stack_lockable::%s()=%p\n", __func__,
this);
622 template<
typename T,
typename L>
625#if defined(OS_TRACE_POSIX_IO_NET_STACK)
626 trace::printf (
"net_stack_lockable::%s() @%p\n", __func__,
this);
632 template<
typename T,
typename L>
643#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)