mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
net: Forward socket option only when the socket type is usrsock
Change-Id: I5e102c4c648936f96834120e2c508f7072436246 Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
+25
-18
@@ -87,7 +87,7 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process the option */
|
/* Process the options always handled locally */
|
||||||
|
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
@@ -125,9 +125,31 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||||||
net_dsec2timeval(timeo, (struct timeval *)value);
|
net_dsec2timeval(timeo, (struct timeval *)value);
|
||||||
*value_len = sizeof(struct timeval);
|
*value_len = sizeof(struct timeval);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
#ifndef CONFIG_NET_USRSOCK
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 */
|
case SO_ACCEPTCONN: /* Reports whether socket listening is enabled */
|
||||||
if (*value_len < sizeof(int))
|
if (*value_len < sizeof(int))
|
||||||
{
|
{
|
||||||
@@ -204,20 +226,6 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||||||
return -EINVAL;
|
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 */
|
/* Return the socket type */
|
||||||
|
|
||||||
*(FAR int *)value = psock->s_type;
|
*(FAR int *)value = psock->s_type;
|
||||||
@@ -259,7 +267,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_RCVLOWAT: /* Sets the minimum number of bytes to input */
|
||||||
case SO_SNDBUF: /* Sets send buffer size */
|
case SO_SNDBUF: /* Sets send buffer size */
|
||||||
case SO_SNDLOWAT: /* Sets the minimum number of bytes to output */
|
case SO_SNDLOWAT: /* Sets the minimum number of bytes to output */
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -ENOPROTOOPT;
|
return -ENOPROTOOPT;
|
||||||
|
|||||||
+12
-4
@@ -82,7 +82,7 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process the option */
|
/* Process the options always handled locally */
|
||||||
|
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
@@ -132,10 +132,19 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||||||
_SO_SETOPT(psock->s_options, option);
|
_SO_SETOPT(psock->s_options, option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
#ifndef CONFIG_NET_USRSOCK
|
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_BROADCAST: /* Permits sending of broadcast messages */
|
||||||
case SO_DEBUG: /* Enables recording of debugging information */
|
case SO_DEBUG: /* Enables recording of debugging information */
|
||||||
case SO_DONTROUTE: /* Requests outgoing messages bypass standard routing */
|
case SO_DONTROUTE: /* Requests outgoing messages bypass standard routing */
|
||||||
@@ -276,7 +285,6 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||||||
case SO_ERROR: /* Reports and clears error status. */
|
case SO_ERROR: /* Reports and clears error status. */
|
||||||
case SO_TYPE: /* Reports the socket type */
|
case SO_TYPE: /* Reports the socket type */
|
||||||
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
return -ENOPROTOOPT;
|
return -ENOPROTOOPT;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user