diff --git a/net/socket/getsockopt.c b/net/socket/getsockopt.c index b3a575ff3e..11932ba1b8 100644 --- a/net/socket/getsockopt.c +++ b/net/socket/getsockopt.c @@ -379,17 +379,17 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option, ret = psock_socketlevel_option(psock, option, value, value_len); break; - case IPPROTO_TCP: /* TCP protocol socket options (see include/netinet/tcp.h) */ #ifdef CONFIG_NET_TCPPROTO_OPTIONS + case IPPROTO_TCP: /* TCP protocol socket options (see include/netinet/tcp.h) */ ret = tcp_getsockopt(psock, option, value, value_len); break; #endif - case SOL_CAN_RAW:/* CAN protocol socket options (see include/netpacket/can.h) */ #ifdef CONFIG_NET_CANPROTO_OPTIONS + case SOL_CAN_RAW:/* CAN protocol socket options (see include/netpacket/can.h) */ ret = can_getsockopt(psock, option, value, value_len); -#endif break; +#endif /* These levels are defined in sys/socket.h, but are not yet * implemented. @@ -398,11 +398,8 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option, 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; - default: /* The provided level is invalid */ - ret = -EINVAL; + ret = -ENOPROTOOPT; break; } diff --git a/net/socket/setsockopt.c b/net/socket/setsockopt.c index 9a9892b236..bddd9c6414 100644 --- a/net/socket/setsockopt.c +++ b/net/socket/setsockopt.c @@ -399,14 +399,14 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, ret = psock_socketlevel_option(psock, option, value, value_len); break; - case IPPROTO_TCP:/* TCP protocol socket options (see include/netinet/tcp.h) */ #ifdef CONFIG_NET_TCPPROTO_OPTIONS + case IPPROTO_TCP:/* TCP protocol socket options (see include/netinet/tcp.h) */ ret = tcp_setsockopt(psock, option, value, value_len); break; #endif - case IPPROTO_UDP:/* UDP protocol socket options (see include/netinet/udp.h) */ #ifdef CONFIG_NET_UDPPROTO_OPTIONS + case IPPROTO_UDP:/* UDP protocol socket options (see include/netinet/udp.h) */ ret = udp_setsockopt(psock, option, value, value_len); break; #endif @@ -430,7 +430,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, #endif default: /* The provided level is invalid */ - ret = -EINVAL; + ret = -ENOPROTOOPT; break; }