mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 17:48:54 +08:00
net/sockopt: change the socket option style from Linux to BSD
Linux Programmer's Manual
...
IP(7)
...
NOTES
...
Using the SOL_IP socket options level isn't portable;
BSD-based stacks use the IPPROTO_IP level.
Change-Id: I63ea5ec7714481b5201608ec4449e522e2be3da2
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
a102922e12
commit
e7f2dc8173
@@ -375,11 +375,11 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
|
|||||||
|
|
||||||
switch (level)
|
switch (level)
|
||||||
{
|
{
|
||||||
case SOL_SOCKET: /* Socket-level options (see include/sys/socket.h) */
|
case SOL_SOCKET: /* Socket-level options (see include/sys/socket.h) */
|
||||||
ret = psock_socketlevel_option(psock, option, value, value_len);
|
ret = psock_socketlevel_option(psock, option, value, value_len);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOL_TCP: /* TCP protocol socket options (see include/netinet/tcp.h) */
|
case IPPROTO_TCP: /* TCP protocol socket options (see include/netinet/tcp.h) */
|
||||||
#ifdef CONFIG_NET_TCPPROTO_OPTIONS
|
#ifdef CONFIG_NET_TCPPROTO_OPTIONS
|
||||||
ret = tcp_getsockopt(psock, option, value, value_len);
|
ret = tcp_getsockopt(psock, option, value, value_len);
|
||||||
break;
|
break;
|
||||||
@@ -395,13 +395,13 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
|
|||||||
* implemented.
|
* implemented.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case SOL_IP: /* TCP protocol socket options (see include/netinet/ip.h) */
|
case IPPROTO_IP: /* TCP protocol socket options (see include/netinet/ip.h) */
|
||||||
case SOL_IPV6: /* TCP protocol socket options (see include/netinet/ip6.h) */
|
case IPPROTO_IPV6: /* TCP protocol socket options (see include/netinet/ip6.h) */
|
||||||
case SOL_UDP: /* TCP protocol socket options (see include/netinit/udp.h) */
|
case IPPROTO_UDP: /* TCP protocol socket options (see include/netinit/udp.h) */
|
||||||
ret = -ENOSYS;
|
ret = -ENOSYS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* The provided level is invalid */
|
default: /* The provided level is invalid */
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -399,26 +399,26 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option,
|
|||||||
ret = psock_socketlevel_option(psock, option, value, value_len);
|
ret = psock_socketlevel_option(psock, option, value, value_len);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOL_TCP: /* TCP protocol socket options (see include/netinet/tcp.h) */
|
case IPPROTO_TCP:/* TCP protocol socket options (see include/netinet/tcp.h) */
|
||||||
#ifdef CONFIG_NET_TCPPROTO_OPTIONS
|
#ifdef CONFIG_NET_TCPPROTO_OPTIONS
|
||||||
ret = tcp_setsockopt(psock, option, value, value_len);
|
ret = tcp_setsockopt(psock, option, value, value_len);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case SOL_UDP: /* UDP protocol socket options (see include/netinet/udp.h) */
|
case IPPROTO_UDP:/* UDP protocol socket options (see include/netinet/udp.h) */
|
||||||
#ifdef CONFIG_NET_UDPPROTO_OPTIONS
|
#ifdef CONFIG_NET_UDPPROTO_OPTIONS
|
||||||
ret = udp_setsockopt(psock, option, value, value_len);
|
ret = udp_setsockopt(psock, option, value, value_len);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
case SOL_IP: /* TCP protocol socket options (see include/netinet/in.h) */
|
case IPPROTO_IP:/* TCP protocol socket options (see include/netinet/in.h) */
|
||||||
ret = ipv4_setsockopt(psock, option, value, value_len);
|
ret = ipv4_setsockopt(psock, option, value, value_len);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
case SOL_IPV6: /* TCP protocol socket options (see include/netinet/in.h) */
|
case IPPROTO_IPV6:/* TCP protocol socket options (see include/netinet/in.h) */
|
||||||
ret = ipv6_setsockopt(psock, option, value, value_len);
|
ret = ipv6_setsockopt(psock, option, value, value_len);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user