This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 752245aca4 net: Move NET_TCP/UDP_HAVE_STACK to netconfig.h
752245aca4 is described below
commit 752245aca47e8b8a7feff8a1f180d081cf494887
Author: Zhe Weng <[email protected]>
AuthorDate: Thu Nov 21 12:05:25 2024 +0800
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 <[email protected]>
---
include/nuttx/net/netconfig.h | 12 ++++++++++++
net/procfs/net_procfs.c | 4 ++--
net/procfs/net_udp.c | 2 +-
net/procfs/procfs.h | 5 +++--
net/tcp/tcp.h | 9 ++-------
net/udp/udp.h | 6 ++----
6 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h
index 5c42c4fe27..806703971d 100644
--- a/include/nuttx/net/netconfig.h
+++ b/include/nuttx/net/netconfig.h
@@ -64,6 +64,18 @@
* 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
* matter. It should, however, be valid in the current configuration.
*/
diff --git a/net/procfs/net_procfs.c b/net/procfs/net_procfs.c
index ade2c74653..bd670961c6 100644
--- a/net/procfs/net_procfs.c
+++ b/net/procfs/net_procfs.c
@@ -122,7 +122,7 @@ static const struct netprocfs_entry_s g_net_entries[] =
}
},
# endif
-# if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
+# ifdef NET_TCP_HAVE_STACK
{
DTYPE_FILE, "tcp",
{
@@ -130,7 +130,7 @@ static const struct netprocfs_entry_s g_net_entries[] =
}
},
# endif
-# if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
+# ifdef NET_UDP_HAVE_STACK
{
DTYPE_FILE, "udp",
{
diff --git a/net/procfs/net_udp.c b/net/procfs/net_udp.c
index fa7e7e4a3a..ebff83e3a8 100644
--- a/net/procfs/net_udp.c
+++ b/net/procfs/net_udp.c
@@ -188,4 +188,4 @@ ssize_t netprocfs_read_udpstats(FAR struct netprocfs_file_s
*priv,
return len;
}
-#endif /* CONFIG_NET_UDP && !CONFIG_NET_UDP_NO_STACK */
+#endif /* NET_UDP_HAVE_STACK */
diff --git a/net/procfs/procfs.h b/net/procfs/procfs.h
index a1aac5e2e0..9400679b7c 100644
--- a/net/procfs/procfs.h
+++ b/net/procfs/procfs.h
@@ -30,6 +30,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/fs/procfs.h>
+#include <nuttx/net/netconfig.h>
#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,
FAR char *buffer, size_t buflen);
#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,
FAR char *buffer, size_t buflen);
#endif
diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h
index 9926125078..14dcdeee3a 100644
--- a/net/tcp/tcp.h
+++ b/net/tcp/tcp.h
@@ -40,7 +40,7 @@
#include <nuttx/net/tcp.h>
#include <nuttx/wqueue.h>
-#ifdef CONFIG_NET_TCP
+#ifdef NET_TCP_HAVE_STACK
/****************************************************************************
* Pre-processor Definitions
@@ -51,10 +51,6 @@
#define TCPIPv4BUF ((FAR struct tcp_hdr_s *)IPBUF(IPv4_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 */
/* 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);
-#endif /* !CONFIG_NET_TCP_NO_STACK */
-#endif /* CONFIG_NET_TCP */
+#endif /* NET_TCP_HAVE_STACK */
#endif /* __NET_TCP_TCP_H */
diff --git a/net/udp/udp.h b/net/udp/udp.h
index de28a43fc3..ab2f076434 100644
--- a/net/udp/udp.h
+++ b/net/udp/udp.h
@@ -43,14 +43,12 @@
# include <nuttx/wqueue.h>
#endif
-#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
+#ifdef NET_UDP_HAVE_STACK
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-#define NET_UDP_HAVE_STACK 1
-
#ifdef CONFIG_NET_UDP_WRITE_BUFFERS
/* UDP write buffer dump macros */
@@ -1046,5 +1044,5 @@ uint16_t udpip_hdrsize(FAR struct udp_conn_s *conn);
}
#endif
-#endif /* CONFIG_NET_UDP && !CONFIG_NET_UDP_NO_STACK */
+#endif /* NET_UDP_HAVE_STACK */
#endif /* __NET_UDP_UDP_H */