mirror of
https://github.com/apache/nuttx.git
synced 2026-08-20 21:18:23 +00:00
net: Forward socket option only when the socket type is usrsock
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com> Change-Id: I5e102c4c648936f96834120e2c508f7072436246
This commit is contained in:
parent
d3843bf334
commit
f8c5fe24fb
2 changed files with 33 additions and 20 deletions
|
|
@ -103,7 +103,7 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Process the option */
|
||||
/* Process the options always handled locally */
|
||||
|
||||
switch (option)
|
||||
{
|
||||
|
|
@ -142,8 +142,29 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||
*value_len = sizeof(struct timeval);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_NET_USRSOCK
|
||||
#ifdef CONFIG_NET_USRSOCK
|
||||
if (psock->s_type == SOCK_USRSOCK_TYPE)
|
||||
{
|
||||
if (option == SO_TYPE)
|
||||
{
|
||||
FAR struct usrsock_conn_s *conn = psock->s_conn;
|
||||
|
||||
/* Return the actual socket type */
|
||||
|
||||
*(FAR int *)value = conn->type;
|
||||
*value_len = sizeof(int);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
return -ENOPROTOOPT;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (option)
|
||||
{
|
||||
case SO_ACCEPTCONN: /* Reports whether socket listening is enabled */
|
||||
if (*value_len < sizeof(int))
|
||||
{
|
||||
|
|
@ -220,20 +241,6 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NET_USRSOCK
|
||||
if (psock->s_type == SOCK_USRSOCK_TYPE)
|
||||
{
|
||||
FAR struct usrsock_conn_s *conn = psock->s_conn;
|
||||
|
||||
/* Return the actual socket type */
|
||||
|
||||
*(FAR int *)value = conn->type;
|
||||
*value_len = sizeof(int);
|
||||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Return the socket type */
|
||||
|
||||
*(FAR int *)value = psock->s_type;
|
||||
|
|
@ -275,7 +282,6 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||
case SO_RCVLOWAT: /* Sets the minimum number of bytes to input */
|
||||
case SO_SNDBUF: /* Sets send buffer size */
|
||||
case SO_SNDLOWAT: /* Sets the minimum number of bytes to output */
|
||||
#endif
|
||||
|
||||
default:
|
||||
return -ENOPROTOOPT;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Process the option */
|
||||
/* Process the options always handled locally */
|
||||
|
||||
switch (option)
|
||||
{
|
||||
|
|
@ -149,9 +149,17 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_NET_USRSOCK
|
||||
#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 */
|
||||
|
|
@ -292,7 +300,6 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||
case SO_ERROR: /* Reports and clears error status. */
|
||||
case SO_TYPE: /* Reports the socket type */
|
||||
|
||||
#endif
|
||||
default:
|
||||
return -ENOPROTOOPT;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue