net/inet: move socket options into socket_conn_s
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
1659513edb
commit
cc6add58dc
@ -237,6 +237,7 @@ struct socket_conn_s
|
||||
|
||||
#ifdef CONFIG_NET_SOCKOPTS
|
||||
int16_t s_error; /* Last error that occurred on this socket */
|
||||
sockopt_t s_options; /* Selected socket options */
|
||||
#endif
|
||||
|
||||
/* Connection-specific content may follow */
|
||||
@ -257,7 +258,6 @@ struct socket
|
||||
/* Socket options */
|
||||
|
||||
#ifdef CONFIG_NET_SOCKOPTS
|
||||
sockopt_t s_options; /* Selected socket options */
|
||||
socktimeo_t s_rcvtimeo; /* Receive timeout value (in deciseconds) */
|
||||
socktimeo_t s_sndtimeo; /* Send timeout value (in deciseconds) */
|
||||
#ifdef CONFIG_NET_SOLINGER
|
||||
|
@ -194,7 +194,7 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
||||
* a macro will do.
|
||||
*/
|
||||
|
||||
optionset = psock->s_options;
|
||||
optionset = conn->s_options;
|
||||
*(FAR int *)value = _SO_GETOPT(optionset, option);
|
||||
*value_len = sizeof(int);
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ int psock_dup2(FAR struct socket *psock1, FAR struct socket *psock2)
|
||||
psock2->s_type = psock1->s_type; /* Protocol type: Only SOCK_STREAM or SOCK_DGRAM */
|
||||
psock2->s_sockif = psock1->s_sockif; /* Socket interface */
|
||||
#ifdef CONFIG_NET_SOCKOPTS
|
||||
psock2->s_options = psock1->s_options; /* Selected socket options */
|
||||
psock2->s_rcvtimeo = psock1->s_rcvtimeo; /* Receive timeout value (in deciseconds) */
|
||||
psock2->s_sndtimeo = psock1->s_sndtimeo; /* Send timeout value (in deciseconds) */
|
||||
#ifdef CONFIG_NET_SOLINGER
|
||||
|
@ -75,6 +75,8 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
||||
FAR const void *value,
|
||||
socklen_t value_len)
|
||||
{
|
||||
FAR struct socket_conn_s *conn = psock->s_conn;
|
||||
|
||||
/* Verify that the socket option if valid (but might not be supported ) */
|
||||
|
||||
if (!_SO_SETVALID(option) || !value)
|
||||
@ -125,11 +127,11 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
||||
|
||||
if (timeo)
|
||||
{
|
||||
_SO_CLROPT(psock->s_options, option);
|
||||
_SO_CLROPT(conn->s_options, option);
|
||||
}
|
||||
else
|
||||
{
|
||||
_SO_SETOPT(psock->s_options, option);
|
||||
_SO_SETOPT(conn->s_options, option);
|
||||
}
|
||||
|
||||
return OK;
|
||||
@ -304,11 +306,11 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
||||
|
||||
if (setting)
|
||||
{
|
||||
_SO_SETOPT(psock->s_options, option);
|
||||
_SO_SETOPT(conn->s_options, option);
|
||||
}
|
||||
else
|
||||
{
|
||||
_SO_CLROPT(psock->s_options, option);
|
||||
_SO_CLROPT(conn->s_options, option);
|
||||
}
|
||||
|
||||
net_unlock();
|
||||
@ -360,12 +362,12 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
||||
|
||||
if (setting->l_onoff)
|
||||
{
|
||||
_SO_SETOPT(psock->s_options, option);
|
||||
_SO_SETOPT(conn->s_options, option);
|
||||
psock->s_linger = 10 * setting->l_linger;
|
||||
}
|
||||
else
|
||||
{
|
||||
_SO_CLROPT(psock->s_options, option);
|
||||
_SO_CLROPT(conn->s_options, option);
|
||||
psock->s_linger = 0;
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ static inline int tcp_close_disconnect(FAR struct socket *psock)
|
||||
* state of the option and linger interval.
|
||||
*/
|
||||
|
||||
if (_SO_GETOPT(psock->s_options, SO_LINGER))
|
||||
if (_SO_GETOPT(conn->sconn.s_options, SO_LINGER))
|
||||
{
|
||||
/* Wait until for the buffered TX data to be sent. */
|
||||
|
||||
|
@ -87,7 +87,7 @@ int udp_close(FAR struct socket *psock)
|
||||
* state of the option and linger interval.
|
||||
*/
|
||||
|
||||
if (_SO_GETOPT(psock->s_options, SO_LINGER))
|
||||
if (_SO_GETOPT(conn->sconn.s_options, SO_LINGER))
|
||||
{
|
||||
timeout = _SO_TIMEOUT(psock->s_linger);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user