Revert "include/sys/socket.h: Add SOCK_CTRL to socket type"
This reverts commit abba05a934
.
This commit is contained in:
parent
916fa4d759
commit
3f3e090716
@ -104,24 +104,52 @@
|
|||||||
|
|
||||||
#define NET_SOCK_PROTOCOL 0
|
#define NET_SOCK_PROTOCOL 0
|
||||||
|
|
||||||
/* SOCK_CTRL is the preferred socket type to use when we just want a
|
/* SOCK_DGRAM is the preferred socket type to use when we just want a
|
||||||
* socket for performing driver ioctls.
|
* 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 NET_SOCK_FAMILY == AF_INET
|
||||||
# if !defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_TCP) && \
|
# if defined(CONFIG_NET_UDP)
|
||||||
defined(CONFIG_NET_ICMP_SOCKET)
|
# 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
|
# undef NET_SOCK_PROTOCOL
|
||||||
# define NET_SOCK_PROTOCOL IPPROTO_ICMP
|
# define NET_SOCK_PROTOCOL IPPROTO_ICMP
|
||||||
# endif
|
# endif
|
||||||
#elif NET_SOCK_FAMILY == AF_INET6
|
#elif NET_SOCK_FAMILY == AF_INET6
|
||||||
# if !defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_TCP) && \
|
# if defined(CONFIG_NET_UDP)
|
||||||
defined(CONFIG_NET_ICMPv6_SOCKET)
|
# 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
|
# undef NET_SOCK_PROTOCOL
|
||||||
# define NET_SOCK_PROTOCOL IPPROTO_ICMP6
|
# define NET_SOCK_PROTOCOL IPPROTO_ICMP6
|
||||||
# endif
|
# 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
|
#endif
|
||||||
|
|
||||||
/* Eliminate dependencies on other header files. This should not harm
|
/* Eliminate dependencies on other header files. This should not harm
|
||||||
|
@ -92,10 +92,6 @@
|
|||||||
* required to read an entire packet with each read
|
* required to read an entire packet with each read
|
||||||
* system call.
|
* 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_PACKET 10 /* Obsolete and should not be used in new programs */
|
||||||
|
|
||||||
#define SOCK_CLOEXEC 02000000 /* Atomically set close-on-exec flag for the new
|
#define SOCK_CLOEXEC 02000000 /* Atomically set close-on-exec flag for the new
|
||||||
|
@ -166,7 +166,7 @@ static int bluetooth_setup(FAR struct socket *psock, int protocol)
|
|||||||
* Only SOCK_RAW is supported
|
* 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);
|
return bluetooth_sockif_alloc(psock);
|
||||||
}
|
}
|
||||||
|
@ -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) */
|
/* Verify the socket type (domain should always be PF_CAN here) */
|
||||||
|
|
||||||
if (domain == PF_CAN &&
|
if (domain == PF_CAN && (type == SOCK_RAW || type == SOCK_DGRAM))
|
||||||
(type == SOCK_RAW || type == SOCK_DGRAM || type == SOCK_CTRL))
|
|
||||||
{
|
{
|
||||||
/* Allocate the CAN socket connection structure and save it in the
|
/* Allocate the CAN socket connection structure and save it in the
|
||||||
* new socket instance.
|
* new socket instance.
|
||||||
|
@ -110,10 +110,9 @@ const struct sock_intf_s g_icmp_sockif =
|
|||||||
|
|
||||||
static int icmp_setup(FAR struct socket *psock, int protocol)
|
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) &&
|
if (psock->s_type == SOCK_DGRAM && protocol == IPPROTO_ICMP)
|
||||||
protocol == IPPROTO_ICMP)
|
|
||||||
{
|
{
|
||||||
/* Allocate the IPPROTO_ICMP socket connection structure and save in
|
/* Allocate the IPPROTO_ICMP socket connection structure and save in
|
||||||
* the new socket instance.
|
* the new socket instance.
|
||||||
|
@ -110,10 +110,9 @@ const struct sock_intf_s g_icmpv6_sockif =
|
|||||||
|
|
||||||
static int icmpv6_setup(FAR struct socket *psock, int protocol)
|
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) &&
|
if (psock->s_type == SOCK_DGRAM && protocol == IPPROTO_ICMP6)
|
||||||
protocol == IPPROTO_ICMP6)
|
|
||||||
{
|
{
|
||||||
/* Allocate the IPPROTO_ICMP6 socket connection structure and save in
|
/* Allocate the IPPROTO_ICMP6 socket connection structure and save in
|
||||||
* the new socket instance.
|
* the new socket instance.
|
||||||
|
@ -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)
|
* 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);
|
return ieee802154_sockif_alloc(psock);
|
||||||
}
|
}
|
||||||
|
@ -286,30 +286,6 @@ static int inet_setup(FAR struct socket *psock, int protocol)
|
|||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_NET_UDP */
|
#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:
|
default:
|
||||||
nerr("ERROR: Unsupported type: %d\n", psock->s_type);
|
nerr("ERROR: Unsupported type: %d\n", psock->s_type);
|
||||||
return -EPROTONOSUPPORT;
|
return -EPROTONOSUPPORT;
|
||||||
@ -2334,8 +2310,7 @@ FAR const struct sock_intf_s *
|
|||||||
#if defined(HAVE_PFINET_SOCKETS) && defined(CONFIG_NET_ICMP_SOCKET)
|
#if defined(HAVE_PFINET_SOCKETS) && defined(CONFIG_NET_ICMP_SOCKET)
|
||||||
/* PF_INET, ICMP data gram sockets are a special case of raw sockets */
|
/* PF_INET, ICMP data gram sockets are a special case of raw sockets */
|
||||||
|
|
||||||
if (family == PF_INET && (type == SOCK_DGRAM || type == SOCK_CTRL) &&
|
if (family == PF_INET && type == SOCK_DGRAM && protocol == IPPROTO_ICMP)
|
||||||
protocol == IPPROTO_ICMP)
|
|
||||||
{
|
{
|
||||||
return &g_icmp_sockif;
|
return &g_icmp_sockif;
|
||||||
}
|
}
|
||||||
@ -2344,8 +2319,7 @@ FAR const struct sock_intf_s *
|
|||||||
#if defined(HAVE_PFINET6_SOCKETS) && defined(CONFIG_NET_ICMPv6_SOCKET)
|
#if defined(HAVE_PFINET6_SOCKETS) && defined(CONFIG_NET_ICMPv6_SOCKET)
|
||||||
/* PF_INET, ICMP data gram sockets are a special case of raw sockets */
|
/* PF_INET, ICMP data gram sockets are a special case of raw sockets */
|
||||||
|
|
||||||
if (family == PF_INET6 && (type == SOCK_DGRAM || type == SOCK_CTRL) &&
|
if (family == PF_INET6 && type == SOCK_DGRAM && protocol == IPPROTO_ICMP6)
|
||||||
protocol == IPPROTO_ICMP6)
|
|
||||||
{
|
{
|
||||||
return &g_icmpv6_sockif;
|
return &g_icmpv6_sockif;
|
||||||
}
|
}
|
||||||
|
@ -205,27 +205,6 @@ static int local_setup(FAR struct socket *psock, int protocol)
|
|||||||
return local_sockif_alloc(psock);
|
return local_sockif_alloc(psock);
|
||||||
#endif /* CONFIG_NET_LOCAL_DGRAM */
|
#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:
|
default:
|
||||||
return -EPROTONOSUPPORT;
|
return -EPROTONOSUPPORT;
|
||||||
}
|
}
|
||||||
|
@ -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) */
|
/* Verify the socket type (domain should always be PF_NETLINK here) */
|
||||||
|
|
||||||
if (domain == PF_NETLINK &&
|
if (domain == PF_NETLINK && (type == SOCK_RAW || type == SOCK_DGRAM))
|
||||||
(type == SOCK_RAW || type == SOCK_DGRAM || type == SOCK_CTRL))
|
|
||||||
{
|
{
|
||||||
/* Allocate the NetLink socket connection structure and save it in the
|
/* Allocate the NetLink socket connection structure and save it in the
|
||||||
* new socket instance.
|
* new socket instance.
|
||||||
|
@ -154,7 +154,7 @@ static int pkt_setup(FAR struct socket *psock, int protocol)
|
|||||||
* Only SOCK_RAW is supported.
|
* 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);
|
return pkt_sockif_alloc(psock);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user