Skip to content

Commit 3f3e090

Browse files
masayuki2009jerpelea
authored andcommitted
Revert "include/sys/socket.h: Add SOCK_CTRL to socket type"
This reverts commit abba05a.
1 parent 916fa4d commit 3f3e090

File tree

11 files changed

+47
-74
lines changed

11 files changed

+47
-74
lines changed

include/nuttx/net/netconfig.h

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,52 @@
104104

105105
#define NET_SOCK_PROTOCOL 0
106106

107-
/* SOCK_CTRL is the preferred socket type to use when we just want a
108-
* socket for performing driver ioctls.
107+
/* SOCK_DGRAM is the preferred socket type to use when we just want a
108+
* socket for performing driver ioctls. However, we can't use SOCK_DRAM
109+
* if UDP is disabled.
110+
*
111+
* Pick a socket type (and perhaps protocol) compatible with the currently
112+
* selected address family.
109113
*/
110114

111-
#define NET_SOCK_TYPE SOCK_CTRL
112-
113115
#if NET_SOCK_FAMILY == AF_INET
114-
# if !defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_TCP) && \
115-
defined(CONFIG_NET_ICMP_SOCKET)
116+
# if defined(CONFIG_NET_UDP)
117+
# define NET_SOCK_TYPE SOCK_DGRAM
118+
# elif defined(CONFIG_NET_TCP)
119+
# define NET_SOCK_TYPE SOCK_STREAM
120+
# elif defined(CONFIG_NET_ICMP_SOCKET)
121+
# define NET_SOCK_TYPE SOCK_DGRAM
116122
# undef NET_SOCK_PROTOCOL
117123
# define NET_SOCK_PROTOCOL IPPROTO_ICMP
118124
# endif
119125
#elif NET_SOCK_FAMILY == AF_INET6
120-
# if !defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_TCP) && \
121-
defined(CONFIG_NET_ICMPv6_SOCKET)
126+
# if defined(CONFIG_NET_UDP)
127+
# define NET_SOCK_TYPE SOCK_DGRAM
128+
# elif defined(CONFIG_NET_TCP)
129+
# define NET_SOCK_TYPE SOCK_STREAM
130+
# elif defined(CONFIG_NET_ICMPv6_SOCKET)
131+
# define NET_SOCK_TYPE SOCK_DGRAM
122132
# undef NET_SOCK_PROTOCOL
123133
# define NET_SOCK_PROTOCOL IPPROTO_ICMP6
124134
# endif
135+
#elif NET_SOCK_FAMILY == AF_LOCAL
136+
# if defined(CONFIG_NET_LOCAL_DGRAM)
137+
# define NET_SOCK_TYPE SOCK_DGRAM
138+
# elif defined(CONFIG_NET_LOCAL_STREAM)
139+
# define NET_SOCK_TYPE SOCK_STREAM
140+
# endif
141+
#elif NET_SOCK_FAMILY == AF_PACKET
142+
# define NET_SOCK_TYPE SOCK_RAW
143+
#elif NET_SOCK_FAMILY == AF_CAN
144+
# define NET_SOCK_TYPE SOCK_RAW
145+
#elif NET_SOCK_FAMILY == AF_IEEE802154
146+
# define NET_SOCK_TYPE SOCK_DGRAM
147+
#elif NET_SOCK_FAMILY == AF_BLUETOOTH
148+
# define NET_SOCK_TYPE SOCK_RAW
149+
#elif NET_SOCK_FAMILY == AF_NETLINK
150+
# define NET_SOCK_TYPE SOCK_DGRAM
151+
#elif NET_SOCK_FAMILY == AF_RPMSG
152+
# define NET_SOCK_TYPE SOCK_STREAM
125153
#endif
126154

127155
/* Eliminate dependencies on other header files. This should not harm

include/sys/socket.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@
9292
* required to read an entire packet with each read
9393
* system call.
9494
*/
95-
#define SOCK_CTRL 6 /* SOCK_CTRL is the preferred socket type to use
96-
* when we just want a socket for performing driver
97-
* ioctls. This definition is not POSIX compliant.
98-
*/
9995
#define SOCK_PACKET 10 /* Obsolete and should not be used in new programs */
10096

10197
#define SOCK_CLOEXEC 02000000 /* Atomically set close-on-exec flag for the new

net/bluetooth/bluetooth_sockif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static int bluetooth_setup(FAR struct socket *psock, int protocol)
166166
* Only SOCK_RAW is supported
167167
*/
168168

169-
if (psock->s_type == SOCK_RAW || psock->s_type == SOCK_CTRL)
169+
if (psock->s_type == SOCK_RAW)
170170
{
171171
return bluetooth_sockif_alloc(psock);
172172
}

net/can/can_sockif.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ static int can_setup(FAR struct socket *psock, int protocol)
207207

208208
/* Verify the socket type (domain should always be PF_CAN here) */
209209

210-
if (domain == PF_CAN &&
211-
(type == SOCK_RAW || type == SOCK_DGRAM || type == SOCK_CTRL))
210+
if (domain == PF_CAN && (type == SOCK_RAW || type == SOCK_DGRAM))
212211
{
213212
/* Allocate the CAN socket connection structure and save it in the
214213
* new socket instance.

net/icmp/icmp_sockif.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ const struct sock_intf_s g_icmp_sockif =
110110

111111
static int icmp_setup(FAR struct socket *psock, int protocol)
112112
{
113-
/* Only SOCK_DGRAM or SOCK_CTRL and IPPROTO_ICMP are supported */
113+
/* Only SOCK_DGRAM and IPPROTO_ICMP are supported */
114114

115-
if ((psock->s_type == SOCK_DGRAM || psock->s_type == SOCK_CTRL) &&
116-
protocol == IPPROTO_ICMP)
115+
if (psock->s_type == SOCK_DGRAM && protocol == IPPROTO_ICMP)
117116
{
118117
/* Allocate the IPPROTO_ICMP socket connection structure and save in
119118
* the new socket instance.

net/icmpv6/icmpv6_sockif.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ const struct sock_intf_s g_icmpv6_sockif =
110110

111111
static int icmpv6_setup(FAR struct socket *psock, int protocol)
112112
{
113-
/* Only SOCK_DGRAM or SOCK_CTRL and IPPROTO_ICMP6 are supported */
113+
/* Only SOCK_DGRAM and IPPROTO_ICMP6 are supported */
114114

115-
if ((psock->s_type == SOCK_DGRAM || psock->s_type == SOCK_CTRL) &&
116-
protocol == IPPROTO_ICMP6)
115+
if (psock->s_type == SOCK_DGRAM && protocol == IPPROTO_ICMP6)
117116
{
118117
/* Allocate the IPPROTO_ICMP6 socket connection structure and save in
119118
* the new socket instance.

net/ieee802154/ieee802154_sockif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static int ieee802154_setup(FAR struct socket *psock, int protocol)
156156
* Only SOCK_DGRAM is supported (since the MAC header is stripped)
157157
*/
158158

159-
if (psock->s_type == SOCK_DGRAM || psock->s_type == SOCK_CTRL)
159+
if (psock->s_type == SOCK_DGRAM)
160160
{
161161
return ieee802154_sockif_alloc(psock);
162162
}

net/inet/inet_sockif.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -286,30 +286,6 @@ static int inet_setup(FAR struct socket *psock, int protocol)
286286
#endif
287287
#endif /* CONFIG_NET_UDP */
288288

289-
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
290-
case SOCK_CTRL:
291-
# ifdef NET_UDP_HAVE_STACK
292-
if (protocol == 0 || protocol == IPPROTO_UDP)
293-
{
294-
/* Allocate and attach the UDP connection structure */
295-
296-
return inet_udp_alloc(psock);
297-
}
298-
299-
# endif
300-
# ifdef NET_TCP_HAVE_STACK
301-
if (protocol == 0 || protocol == IPPROTO_TCP)
302-
{
303-
/* Allocate and attach the TCP connection structure */
304-
305-
return inet_tcp_alloc(psock);
306-
}
307-
308-
# endif
309-
nerr("ERROR: Unsupported control protocol: %d\n", protocol);
310-
return -EPROTONOSUPPORT;
311-
#endif /* CONFIG_NET_TCP || CONFIG_NET_UDP */
312-
313289
default:
314290
nerr("ERROR: Unsupported type: %d\n", psock->s_type);
315291
return -EPROTONOSUPPORT;
@@ -2334,8 +2310,7 @@ FAR const struct sock_intf_s *
23342310
#if defined(HAVE_PFINET_SOCKETS) && defined(CONFIG_NET_ICMP_SOCKET)
23352311
/* PF_INET, ICMP data gram sockets are a special case of raw sockets */
23362312

2337-
if (family == PF_INET && (type == SOCK_DGRAM || type == SOCK_CTRL) &&
2338-
protocol == IPPROTO_ICMP)
2313+
if (family == PF_INET && type == SOCK_DGRAM && protocol == IPPROTO_ICMP)
23392314
{
23402315
return &g_icmp_sockif;
23412316
}
@@ -2344,8 +2319,7 @@ FAR const struct sock_intf_s *
23442319
#if defined(HAVE_PFINET6_SOCKETS) && defined(CONFIG_NET_ICMPv6_SOCKET)
23452320
/* PF_INET, ICMP data gram sockets are a special case of raw sockets */
23462321

2347-
if (family == PF_INET6 && (type == SOCK_DGRAM || type == SOCK_CTRL) &&
2348-
protocol == IPPROTO_ICMP6)
2322+
if (family == PF_INET6 && type == SOCK_DGRAM && protocol == IPPROTO_ICMP6)
23492323
{
23502324
return &g_icmpv6_sockif;
23512325
}

net/local/local_sockif.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -205,27 +205,6 @@ static int local_setup(FAR struct socket *psock, int protocol)
205205
return local_sockif_alloc(psock);
206206
#endif /* CONFIG_NET_LOCAL_DGRAM */
207207

208-
case SOCK_CTRL:
209-
#ifdef CONFIG_NET_LOCAL_STREAM
210-
if (protocol == 0 || protocol == IPPROTO_TCP)
211-
{
212-
/* Allocate and attach the local connection structure */
213-
214-
return local_sockif_alloc(psock);
215-
}
216-
217-
#endif
218-
#ifdef CONFIG_NET_LOCAL_DGRAM
219-
if (protocol == 0 || protocol == IPPROTO_UDP)
220-
{
221-
/* Allocate and attach the local connection structure */
222-
223-
return local_sockif_alloc(psock);
224-
}
225-
226-
#endif
227-
return -EPROTONOSUPPORT;
228-
229208
default:
230209
return -EPROTONOSUPPORT;
231210
}

net/netlink/netlink_sockif.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ static int netlink_setup(FAR struct socket *psock, int protocol)
136136

137137
/* Verify the socket type (domain should always be PF_NETLINK here) */
138138

139-
if (domain == PF_NETLINK &&
140-
(type == SOCK_RAW || type == SOCK_DGRAM || type == SOCK_CTRL))
139+
if (domain == PF_NETLINK && (type == SOCK_RAW || type == SOCK_DGRAM))
141140
{
142141
/* Allocate the NetLink socket connection structure and save it in the
143142
* new socket instance.

0 commit comments

Comments
 (0)