net/usrsock: fix get/setsockopt issue about usrsock protocol

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1 2022-11-23 18:11:11 +08:00 committed by Masayuki Ishikawa
parent 9c6971279d
commit d5b08a7ef1
4 changed files with 27 additions and 8 deletions

View File

@ -33,6 +33,7 @@
#include <errno.h>
#include "socket/socket.h"
#include "usrsock/usrsock.h"
#include "utils/utils.h"
/****************************************************************************
@ -123,9 +124,19 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
net_dsec2timeval(timeo, (struct timeval *)value);
*value_len = sizeof(struct timeval);
return OK;
}
break;
}
#ifdef CONFIG_NET_USRSOCK
if (psock->s_type == SOCK_USRSOCK_TYPE)
{
return -ENOPROTOOPT;
}
#endif
switch (option)
{
case SO_ACCEPTCONN: /* Reports whether socket listening is enabled */
{
if (*value_len < sizeof(int))

View File

@ -38,6 +38,7 @@
#include <netdev/netdev.h>
#include "socket/socket.h"
#include "usrsock/usrsock.h"
#include "utils/utils.h"
/****************************************************************************
@ -130,9 +131,20 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
{
_SO_SETOPT(conn->s_options, option);
}
}
break;
return OK;
}
}
#ifdef CONFIG_NET_USRSOCK
if (psock->s_type == SOCK_USRSOCK_TYPE)
{
return -ENOPROTOOPT;
}
#endif
switch (option)
{
case SO_BROADCAST: /* Permits sending of broadcast messages */
case SO_DEBUG: /* Enables recording of debugging information */
case SO_DONTROUTE: /* Requests outgoing messages bypass standard routing */

View File

@ -189,7 +189,7 @@ int usrsock_getsockopt(FAR struct socket *psock, int level, int option,
*value_len = sizeof(int);
return OK;
}
else
else if (option == SO_RCVTIMEO || option == SO_SNDTIMEO)
{
return -ENOPROTOOPT;
}

View File

@ -174,10 +174,6 @@ int usrsock_setsockopt(FAR struct socket *psock, int level, int option,
{
return -ENOPROTOOPT;
}
else
{
return -EINVAL;
}
}
net_lock();