net: Simplify the tcp/udp existence check

Replace defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK) with NET_TCP_HAVE_STACK
Replace defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK) with NET_UDP_HAVE_STACK

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-03-07 00:55:34 +08:00 committed by Petro Karashchenko
parent 5de49d2939
commit 74e2b75857
6 changed files with 16 additions and 19 deletions

View file

@ -103,9 +103,6 @@ EXTERN const struct ether_addr g_ipv6_ethallrouters; /* All link local routers
* Public Function Prototypes
****************************************************************************/
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
struct tcp_conn_s; /* Forward reference */
#endif
struct socket; /* Forward reference */
/****************************************************************************

View file

@ -667,7 +667,7 @@ static int inet_get_socketlevel_option(FAR struct socket *psock, int option,
return -EINVAL;
}
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
#ifdef NET_TCP_HAVE_STACK
if (psock->s_type == SOCK_STREAM)
{
FAR struct tcp_conn_s *tcp = psock->s_conn;
@ -675,7 +675,7 @@ static int inet_get_socketlevel_option(FAR struct socket *psock, int option,
}
else
#endif
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
#ifdef NET_UDP_HAVE_STACK
if (psock->s_type == SOCK_DGRAM)
{
FAR struct udp_conn_s *udp = psock->s_conn;
@ -698,7 +698,7 @@ static int inet_get_socketlevel_option(FAR struct socket *psock, int option,
return -EINVAL;
}
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
#ifdef NET_TCP_HAVE_STACK
if (psock->s_type == SOCK_STREAM)
{
FAR struct tcp_conn_s *tcp = psock->s_conn;
@ -706,7 +706,7 @@ static int inet_get_socketlevel_option(FAR struct socket *psock, int option,
}
else
#endif
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
#ifdef NET_UDP_HAVE_STACK
if (psock->s_type == SOCK_DGRAM)
{
FAR struct udp_conn_s *udp = psock->s_conn;
@ -931,7 +931,7 @@ static int inet_set_socketlevel_option(FAR struct socket *psock, int option,
net_lock();
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
#ifdef NET_TCP_HAVE_STACK
if (psock->s_type == SOCK_STREAM)
{
FAR struct tcp_conn_s *tcp = psock->s_conn;
@ -942,7 +942,7 @@ static int inet_set_socketlevel_option(FAR struct socket *psock, int option,
}
else
#endif
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
#ifdef NET_UDP_HAVE_STACK
if (psock->s_type == SOCK_DGRAM)
{
FAR struct udp_conn_s *udp = psock->s_conn;
@ -988,7 +988,7 @@ static int inet_set_socketlevel_option(FAR struct socket *psock, int option,
net_lock();
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
#ifdef NET_TCP_HAVE_STACK
if (psock->s_type == SOCK_STREAM)
{
FAR struct tcp_conn_s *tcp = psock->s_conn;
@ -999,7 +999,7 @@ static int inet_set_socketlevel_option(FAR struct socket *psock, int option,
}
else
#endif
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
#ifdef NET_UDP_HAVE_STACK
if (psock->s_type == SOCK_DGRAM)
{
FAR struct udp_conn_s *udp = psock->s_conn;
@ -1904,7 +1904,7 @@ static int inet_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
return -EBADF;
}
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
#ifdef NET_TCP_HAVE_STACK
if (psock->s_type == SOCK_STREAM ||
(psock->s_type == SOCK_CTRL &&
(psock->s_proto == 0 || psock->s_proto == IPPROTO_TCP)))
@ -2123,7 +2123,7 @@ static ssize_t inet_sendfile(FAR struct socket *psock,
FAR struct file *infile, FAR off_t *offset,
size_t count)
{
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
#ifdef NET_TCP_HAVE_STACK
if (psock->s_type == SOCK_STREAM)
{
return tcp_sendfile(psock, infile, offset, count);

View file

@ -175,7 +175,7 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
}
break;
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
#ifdef NET_UDP_HAVE_STACK
case IP_MULTICAST_TTL: /* Set/read the time-to-live value of
* outgoing multicast packets */
{
@ -232,7 +232,7 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
break;
#endif /* CONFIG_NET_IGMP */
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
#ifdef NET_UDP_HAVE_STACK
case IP_PKTINFO:
{
FAR struct udp_conn_s *conn;

View file

@ -127,7 +127,7 @@ int ipv6_setsockopt(FAR struct socket *psock, int option,
ret = -ENOSYS;
break;
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
#ifdef NET_UDP_HAVE_STACK
case IPV6_PKTINFO:
case IPV6_RECVPKTINFO:
{

View file

@ -41,7 +41,7 @@
* Pre-processor Definitions
****************************************************************************/
#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK)
#ifdef NET_TCP_HAVE_STACK
#ifdef CONFIG_NET_IPv6
# define TCP_LINELEN 180
@ -215,4 +215,4 @@ ssize_t netprocfs_read_tcpstats(FAR struct netprocfs_file_s *priv,
return len;
}
#endif /* CONFIG_NET_TCP && !CONFIG_NET_TCP_NO_STACK */
#endif /* NET_TCP_HAVE_STACK */

View file

@ -41,7 +41,7 @@
* Pre-processor Definitions
****************************************************************************/
#if defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK)
#ifdef NET_UDP_HAVE_STACK
#ifdef CONFIG_NET_IPv6
# define UDP_LINELEN 180