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:
chao.an 2020-06-29 14:05:38 +08:00 committed by Alan Carvalho de Assis
parent a102922e12
commit e7f2dc8173
2 changed files with 10 additions and 10 deletions

View File

@ -379,7 +379,7 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
ret = psock_socketlevel_option(psock, option, value, value_len);
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
ret = tcp_getsockopt(psock, option, value, value_len);
break;
@ -395,9 +395,9 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
* implemented.
*/
case SOL_IP: /* TCP protocol socket options (see include/netinet/ip.h) */
case SOL_IPV6: /* TCP protocol socket options (see include/netinet/ip6.h) */
case SOL_UDP: /* TCP protocol socket options (see include/netinit/udp.h) */
case IPPROTO_IP: /* TCP protocol socket options (see include/netinet/ip.h) */
case IPPROTO_IPV6: /* TCP protocol socket options (see include/netinet/ip6.h) */
case IPPROTO_UDP: /* TCP protocol socket options (see include/netinit/udp.h) */
ret = -ENOSYS;
break;

View File

@ -399,26 +399,26 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option,
ret = psock_socketlevel_option(psock, option, value, value_len);
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
ret = tcp_setsockopt(psock, option, value, value_len);
break;
#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
ret = udp_setsockopt(psock, option, value, value_len);
break;
#endif
#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);
break;
#endif
#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);
break;
#endif