You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2023/02/08 13:41:23 UTC
[nuttx] 01/01: Revert "include/sys/socket.h: Add SOCK_CTRL to socket type"
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch revert-8370-pullrequest-658
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 6ea739f6f2bbd2d97c9526ae06a99a5a1e949a9c
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Wed Feb 8 22:41:15 2023 +0900
Revert "include/sys/socket.h: Add SOCK_CTRL to socket type"
This reverts commit abba05a934aba3e4bf67568be558c3b7da5d90a1.
---
include/nuttx/net/netconfig.h | 44 +++++++++++++++++++++++++++++++-------
include/sys/socket.h | 4 ----
net/bluetooth/bluetooth_sockif.c | 2 +-
net/can/can_sockif.c | 3 +--
net/icmp/icmp_sockif.c | 5 ++---
net/icmpv6/icmpv6_sockif.c | 5 ++---
net/ieee802154/ieee802154_sockif.c | 2 +-
net/inet/inet_sockif.c | 30 ++------------------------
net/local/local_sockif.c | 21 ------------------
net/netlink/netlink_sockif.c | 3 +--
net/pkt/pkt_sockif.c | 2 +-
11 files changed, 47 insertions(+), 74 deletions(-)
diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h
index b2e1b072d2..e9f3839408 100644
--- a/include/nuttx/net/netconfig.h
+++ b/include/nuttx/net/netconfig.h
@@ -104,24 +104,52 @@
#define NET_SOCK_PROTOCOL 0
-/* SOCK_CTRL is the preferred socket type to use when we just want a
- * socket for performing driver ioctls.
+/* SOCK_DGRAM is the preferred socket type to use when we just want a
+ * socket for performing driver ioctls. However, we can't use SOCK_DRAM
+ * if UDP is disabled.
+ *
+ * Pick a socket type (and perhaps protocol) compatible with the currently
+ * selected address family.
*/
-#define NET_SOCK_TYPE SOCK_CTRL
-
#if NET_SOCK_FAMILY == AF_INET
-# if !defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_TCP) && \
- defined(CONFIG_NET_ICMP_SOCKET)
+# if defined(CONFIG_NET_UDP)
+# define NET_SOCK_TYPE SOCK_DGRAM
+# elif defined(CONFIG_NET_TCP)
+# define NET_SOCK_TYPE SOCK_STREAM
+# elif defined(CONFIG_NET_ICMP_SOCKET)
+# define NET_SOCK_TYPE SOCK_DGRAM
# undef NET_SOCK_PROTOCOL
# define NET_SOCK_PROTOCOL IPPROTO_ICMP
# endif
#elif NET_SOCK_FAMILY == AF_INET6
-# if !defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_TCP) && \
- defined(CONFIG_NET_ICMPv6_SOCKET)
+# if defined(CONFIG_NET_UDP)
+# define NET_SOCK_TYPE SOCK_DGRAM
+# elif defined(CONFIG_NET_TCP)
+# define NET_SOCK_TYPE SOCK_STREAM
+# elif defined(CONFIG_NET_ICMPv6_SOCKET)
+# define NET_SOCK_TYPE SOCK_DGRAM
# undef NET_SOCK_PROTOCOL
# define NET_SOCK_PROTOCOL IPPROTO_ICMP6
# endif
+#elif NET_SOCK_FAMILY == AF_LOCAL
+# if defined(CONFIG_NET_LOCAL_DGRAM)
+# define NET_SOCK_TYPE SOCK_DGRAM
+# elif defined(CONFIG_NET_LOCAL_STREAM)
+# define NET_SOCK_TYPE SOCK_STREAM
+# endif
+#elif NET_SOCK_FAMILY == AF_PACKET
+# define NET_SOCK_TYPE SOCK_RAW
+#elif NET_SOCK_FAMILY == AF_CAN
+# define NET_SOCK_TYPE SOCK_RAW
+#elif NET_SOCK_FAMILY == AF_IEEE802154
+# define NET_SOCK_TYPE SOCK_DGRAM
+#elif NET_SOCK_FAMILY == AF_BLUETOOTH
+# define NET_SOCK_TYPE SOCK_RAW
+#elif NET_SOCK_FAMILY == AF_NETLINK
+# define NET_SOCK_TYPE SOCK_DGRAM
+#elif NET_SOCK_FAMILY == AF_RPMSG
+# define NET_SOCK_TYPE SOCK_STREAM
#endif
/* Eliminate dependencies on other header files. This should not harm
diff --git a/include/sys/socket.h b/include/sys/socket.h
index b27df12f68..2226797ec4 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -92,10 +92,6 @@
* required to read an entire packet with each read
* system call.
*/
-#define SOCK_CTRL 6 /* SOCK_CTRL is the preferred socket type to use
- * when we just want a socket for performing driver
- * ioctls. This definition is not POSIX compliant.
- */
#define SOCK_PACKET 10 /* Obsolete and should not be used in new programs */
#define SOCK_CLOEXEC 02000000 /* Atomically set close-on-exec flag for the new
diff --git a/net/bluetooth/bluetooth_sockif.c b/net/bluetooth/bluetooth_sockif.c
index d9619e8a2a..b224a03d20 100644
--- a/net/bluetooth/bluetooth_sockif.c
+++ b/net/bluetooth/bluetooth_sockif.c
@@ -166,7 +166,7 @@ static int bluetooth_setup(FAR struct socket *psock, int protocol)
* Only SOCK_RAW is supported
*/
- if (psock->s_type == SOCK_RAW || psock->s_type == SOCK_CTRL)
+ if (psock->s_type == SOCK_RAW)
{
return bluetooth_sockif_alloc(psock);
}
diff --git a/net/can/can_sockif.c b/net/can/can_sockif.c
index 926e308eb5..9855e3b5fd 100644
--- a/net/can/can_sockif.c
+++ b/net/can/can_sockif.c
@@ -207,8 +207,7 @@ static int can_setup(FAR struct socket *psock, int protocol)
/* Verify the socket type (domain should always be PF_CAN here) */
- if (domain == PF_CAN &&
- (type == SOCK_RAW || type == SOCK_DGRAM || type == SOCK_CTRL))
+ if (domain == PF_CAN && (type == SOCK_RAW || type == SOCK_DGRAM))
{
/* Allocate the CAN socket connection structure and save it in the
* new socket instance.
diff --git a/net/icmp/icmp_sockif.c b/net/icmp/icmp_sockif.c
index 2b1383410a..311bce0847 100644
--- a/net/icmp/icmp_sockif.c
+++ b/net/icmp/icmp_sockif.c
@@ -110,10 +110,9 @@ const struct sock_intf_s g_icmp_sockif =
static int icmp_setup(FAR struct socket *psock, int protocol)
{
- /* Only SOCK_DGRAM or SOCK_CTRL and IPPROTO_ICMP are supported */
+ /* Only SOCK_DGRAM and IPPROTO_ICMP are supported */
- if ((psock->s_type == SOCK_DGRAM || psock->s_type == SOCK_CTRL) &&
- protocol == IPPROTO_ICMP)
+ if (psock->s_type == SOCK_DGRAM && protocol == IPPROTO_ICMP)
{
/* Allocate the IPPROTO_ICMP socket connection structure and save in
* the new socket instance.
diff --git a/net/icmpv6/icmpv6_sockif.c b/net/icmpv6/icmpv6_sockif.c
index 5ff1a4fb44..9b7015da9d 100644
--- a/net/icmpv6/icmpv6_sockif.c
+++ b/net/icmpv6/icmpv6_sockif.c
@@ -110,10 +110,9 @@ const struct sock_intf_s g_icmpv6_sockif =
static int icmpv6_setup(FAR struct socket *psock, int protocol)
{
- /* Only SOCK_DGRAM or SOCK_CTRL and IPPROTO_ICMP6 are supported */
+ /* Only SOCK_DGRAM and IPPROTO_ICMP6 are supported */
- if ((psock->s_type == SOCK_DGRAM || psock->s_type == SOCK_CTRL) &&
- protocol == IPPROTO_ICMP6)
+ if (psock->s_type == SOCK_DGRAM && protocol == IPPROTO_ICMP6)
{
/* Allocate the IPPROTO_ICMP6 socket connection structure and save in
* the new socket instance.
diff --git a/net/ieee802154/ieee802154_sockif.c b/net/ieee802154/ieee802154_sockif.c
index 9f54251a56..d2b0303499 100644
--- a/net/ieee802154/ieee802154_sockif.c
+++ b/net/ieee802154/ieee802154_sockif.c
@@ -156,7 +156,7 @@ static int ieee802154_setup(FAR struct socket *psock, int protocol)
* Only SOCK_DGRAM is supported (since the MAC header is stripped)
*/
- if (psock->s_type == SOCK_DGRAM || psock->s_type == SOCK_CTRL)
+ if (psock->s_type == SOCK_DGRAM)
{
return ieee802154_sockif_alloc(psock);
}
diff --git a/net/inet/inet_sockif.c b/net/inet/inet_sockif.c
index 87d79099ee..61843db855 100644
--- a/net/inet/inet_sockif.c
+++ b/net/inet/inet_sockif.c
@@ -286,30 +286,6 @@ static int inet_setup(FAR struct socket *psock, int protocol)
#endif
#endif /* CONFIG_NET_UDP */
-#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
- case SOCK_CTRL:
-# ifdef NET_UDP_HAVE_STACK
- if (protocol == 0 || protocol == IPPROTO_UDP)
- {
- /* Allocate and attach the UDP connection structure */
-
- return inet_udp_alloc(psock);
- }
-
-# endif
-# ifdef NET_TCP_HAVE_STACK
- if (protocol == 0 || protocol == IPPROTO_TCP)
- {
- /* Allocate and attach the TCP connection structure */
-
- return inet_tcp_alloc(psock);
- }
-
-# endif
- nerr("ERROR: Unsupported control protocol: %d\n", protocol);
- return -EPROTONOSUPPORT;
-#endif /* CONFIG_NET_TCP || CONFIG_NET_UDP */
-
default:
nerr("ERROR: Unsupported type: %d\n", psock->s_type);
return -EPROTONOSUPPORT;
@@ -2334,8 +2310,7 @@ FAR const struct sock_intf_s *
#if defined(HAVE_PFINET_SOCKETS) && defined(CONFIG_NET_ICMP_SOCKET)
/* PF_INET, ICMP data gram sockets are a special case of raw sockets */
- if (family == PF_INET && (type == SOCK_DGRAM || type == SOCK_CTRL) &&
- protocol == IPPROTO_ICMP)
+ if (family == PF_INET && type == SOCK_DGRAM && protocol == IPPROTO_ICMP)
{
return &g_icmp_sockif;
}
@@ -2344,8 +2319,7 @@ FAR const struct sock_intf_s *
#if defined(HAVE_PFINET6_SOCKETS) && defined(CONFIG_NET_ICMPv6_SOCKET)
/* PF_INET, ICMP data gram sockets are a special case of raw sockets */
- if (family == PF_INET6 && (type == SOCK_DGRAM || type == SOCK_CTRL) &&
- protocol == IPPROTO_ICMP6)
+ if (family == PF_INET6 && type == SOCK_DGRAM && protocol == IPPROTO_ICMP6)
{
return &g_icmpv6_sockif;
}
diff --git a/net/local/local_sockif.c b/net/local/local_sockif.c
index d84fef519d..754ef7757f 100644
--- a/net/local/local_sockif.c
+++ b/net/local/local_sockif.c
@@ -205,27 +205,6 @@ static int local_setup(FAR struct socket *psock, int protocol)
return local_sockif_alloc(psock);
#endif /* CONFIG_NET_LOCAL_DGRAM */
- case SOCK_CTRL:
-#ifdef CONFIG_NET_LOCAL_STREAM
- if (protocol == 0 || protocol == IPPROTO_TCP)
- {
- /* Allocate and attach the local connection structure */
-
- return local_sockif_alloc(psock);
- }
-
-#endif
-#ifdef CONFIG_NET_LOCAL_DGRAM
- if (protocol == 0 || protocol == IPPROTO_UDP)
- {
- /* Allocate and attach the local connection structure */
-
- return local_sockif_alloc(psock);
- }
-
-#endif
- return -EPROTONOSUPPORT;
-
default:
return -EPROTONOSUPPORT;
}
diff --git a/net/netlink/netlink_sockif.c b/net/netlink/netlink_sockif.c
index bf1a94b849..88dd30a9af 100644
--- a/net/netlink/netlink_sockif.c
+++ b/net/netlink/netlink_sockif.c
@@ -136,8 +136,7 @@ static int netlink_setup(FAR struct socket *psock, int protocol)
/* Verify the socket type (domain should always be PF_NETLINK here) */
- if (domain == PF_NETLINK &&
- (type == SOCK_RAW || type == SOCK_DGRAM || type == SOCK_CTRL))
+ if (domain == PF_NETLINK && (type == SOCK_RAW || type == SOCK_DGRAM))
{
/* Allocate the NetLink socket connection structure and save it in the
* new socket instance.
diff --git a/net/pkt/pkt_sockif.c b/net/pkt/pkt_sockif.c
index dfc9c70839..4309e82363 100644
--- a/net/pkt/pkt_sockif.c
+++ b/net/pkt/pkt_sockif.c
@@ -154,7 +154,7 @@ static int pkt_setup(FAR struct socket *psock, int protocol)
* Only SOCK_RAW is supported.
*/
- if (psock->s_type == SOCK_RAW || psock->s_type == SOCK_CTRL)
+ if (psock->s_type == SOCK_RAW)
{
return pkt_sockif_alloc(psock);
}