net/sockopt: fix invalid option set
fix invalid option set if enable UDP without TCP Change-Id: I732893501a9b28749706d6f860c77ae9e14b358c Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
07f2a76f6e
commit
51efe468b9
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user