net: Move NET_TCP/UDP_HAVE_STACK to netconfig.h

Now the HAVE_PFINET(6)_SOCKETS depends on NET_TCP/UDP_HAVE_STACK, which
is previously defined in net/ folder and cannot be included.
Considering many places use this check, maybe moving them to netconfig.h
could be better.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
Zhe Weng 2024-11-21 12:05:25 +08:00 committed by Xiang Xiao
parent 085830612c
commit 752245aca4
6 changed files with 22 additions and 16 deletions

View file

@ -64,6 +64,18 @@
* NET_SOCK_PROTOCOL); * NET_SOCK_PROTOCOL);
*/ */
/* The TCP/UDP stack, which is used for determining HAVE_PFINET(6)_SOCKETS */
#undef NET_TCP_HAVE_STACK
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
# define NET_TCP_HAVE_STACK 1
#endif
#undef NET_UDP_HAVE_STACK
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
# define NET_UDP_HAVE_STACK 1
#endif
/* The address family that we used to create the socket really does not /* The address family that we used to create the socket really does not
* matter. It should, however, be valid in the current configuration. * matter. It should, however, be valid in the current configuration.
*/ */

View file

@ -122,7 +122,7 @@ static const struct netprocfs_entry_s g_net_entries[] =
} }
}, },
# endif # endif
# if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK) # ifdef NET_TCP_HAVE_STACK
{ {
DTYPE_FILE, "tcp", DTYPE_FILE, "tcp",
{ {
@ -130,7 +130,7 @@ static const struct netprocfs_entry_s g_net_entries[] =
} }
}, },
# endif # endif
# if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK) # ifdef NET_UDP_HAVE_STACK
{ {
DTYPE_FILE, "udp", DTYPE_FILE, "udp",
{ {

View file

@ -188,4 +188,4 @@ ssize_t netprocfs_read_udpstats(FAR struct netprocfs_file_s *priv,
return len; return len;
} }
#endif /* CONFIG_NET_UDP && !CONFIG_NET_UDP_NO_STACK */ #endif /* NET_UDP_HAVE_STACK */

View file

@ -30,6 +30,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <nuttx/fs/procfs.h> #include <nuttx/fs/procfs.h>
#include <nuttx/net/netconfig.h>
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_NET) #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_NET)
@ -184,7 +185,7 @@ ssize_t netprocfs_read_mldstats(FAR struct netprocfs_file_s *priv,
* *
****************************************************************************/ ****************************************************************************/
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK) #ifdef NET_TCP_HAVE_STACK
ssize_t netprocfs_read_tcpstats(FAR struct netprocfs_file_s *priv, ssize_t netprocfs_read_tcpstats(FAR struct netprocfs_file_s *priv,
FAR char *buffer, size_t buflen); FAR char *buffer, size_t buflen);
#endif #endif
@ -207,7 +208,7 @@ ssize_t netprocfs_read_tcpstats(FAR struct netprocfs_file_s *priv,
* *
****************************************************************************/ ****************************************************************************/
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK) #ifdef NET_UDP_HAVE_STACK
ssize_t netprocfs_read_udpstats(FAR struct netprocfs_file_s *priv, ssize_t netprocfs_read_udpstats(FAR struct netprocfs_file_s *priv,
FAR char *buffer, size_t buflen); FAR char *buffer, size_t buflen);
#endif #endif

View file

@ -40,7 +40,7 @@
#include <nuttx/net/tcp.h> #include <nuttx/net/tcp.h>
#include <nuttx/wqueue.h> #include <nuttx/wqueue.h>
#ifdef CONFIG_NET_TCP #ifdef NET_TCP_HAVE_STACK
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
@ -51,10 +51,6 @@
#define TCPIPv4BUF ((FAR struct tcp_hdr_s *)IPBUF(IPv4_HDRLEN)) #define TCPIPv4BUF ((FAR struct tcp_hdr_s *)IPBUF(IPv4_HDRLEN))
#define TCPIPv6BUF ((FAR struct tcp_hdr_s *)IPBUF(IPv6_HDRLEN)) #define TCPIPv6BUF ((FAR struct tcp_hdr_s *)IPBUF(IPv6_HDRLEN))
#ifndef CONFIG_NET_TCP_NO_STACK
#define NET_TCP_HAVE_STACK 1
/* Allocate a new TCP data callback */ /* Allocate a new TCP data callback */
/* These macros allocate and free callback structures used for receiving /* These macros allocate and free callback structures used for receiving
@ -2354,6 +2350,5 @@ void tcp_cc_recv_ack(FAR struct tcp_conn_s *conn, FAR struct tcp_hdr_s *tcp);
void tcp_set_zero_probe(FAR struct tcp_conn_s *conn, uint16_t flags); void tcp_set_zero_probe(FAR struct tcp_conn_s *conn, uint16_t flags);
#endif /* !CONFIG_NET_TCP_NO_STACK */ #endif /* NET_TCP_HAVE_STACK */
#endif /* CONFIG_NET_TCP */
#endif /* __NET_TCP_TCP_H */ #endif /* __NET_TCP_TCP_H */

View file

@ -43,14 +43,12 @@
# include <nuttx/wqueue.h> # include <nuttx/wqueue.h>
#endif #endif
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK) #ifdef NET_UDP_HAVE_STACK
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#define NET_UDP_HAVE_STACK 1
#ifdef CONFIG_NET_UDP_WRITE_BUFFERS #ifdef CONFIG_NET_UDP_WRITE_BUFFERS
/* UDP write buffer dump macros */ /* UDP write buffer dump macros */
@ -1046,5 +1044,5 @@ uint16_t udpip_hdrsize(FAR struct udp_conn_s *conn);
} }
#endif #endif
#endif /* CONFIG_NET_UDP && !CONFIG_NET_UDP_NO_STACK */ #endif /* NET_UDP_HAVE_STACK */
#endif /* __NET_UDP_UDP_H */ #endif /* __NET_UDP_UDP_H */