net/inet: move socket timestamp into socket_conn_s

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2022-02-07 14:46:34 +08:00 committed by Alan Carvalho de Assis
parent 9317626c32
commit 0d19a3a248
5 changed files with 11 additions and 17 deletions

View File

@ -243,6 +243,9 @@ struct socket_conn_s
#ifdef CONFIG_NET_SOLINGER
socktimeo_t s_linger; /* Linger timeout value (in deciseconds) */
#endif
#ifdef CONFIG_NET_TIMESTAMP
int32_t s_timestamp; /* Socket timestamp enabled/disabled */
#endif
#endif
/* Connection-specific content may follow */
@ -259,15 +262,6 @@ struct socket
uint8_t s_domain; /* IP domain */
uint8_t s_type; /* Protocol type */
uint8_t s_proto; /* Socket Protocol */
/* Socket options */
#ifdef CONFIG_NET_SOCKOPTS
#ifdef CONFIG_NET_TIMESTAMP
int32_t s_timestamp; /* Socket timestamp enabled/disabled */
#endif
#endif
FAR void *s_conn; /* Connection inherits from struct socket_conn_s */
/* Socket interface */

View File

@ -123,7 +123,7 @@ uint16_t can_callback(FAR struct net_driver_s *dev,
#ifdef CONFIG_NET_TIMESTAMP
/* TIMESTAMP sockopt is activated, create timestamp and copy to iob */
if (conn->psock->s_timestamp)
if (conn->sconn.s_timestamp)
{
struct timespec *ts = (struct timespec *)
&dev->d_appdata[dev->d_len];

View File

@ -438,9 +438,9 @@ static uint16_t can_recvfrom_eventhandler(FAR struct net_driver_s *dev,
#endif
{
#if defined(CONFIG_NET_TIMESTAMP)
if ((conn->psock->s_timestamp && (dev->d_len >
if ((conn->sconn.s_timestamp && (dev->d_len >
sizeof(struct can_frame) + sizeof(struct timeval)))
|| (!conn->psock->s_timestamp && (dev->d_len >
|| (!conn->sconn.s_timestamp && (dev->d_len >
sizeof(struct can_frame))))
#else
if (dev->d_len > sizeof(struct can_frame))
@ -458,7 +458,7 @@ static uint16_t can_recvfrom_eventhandler(FAR struct net_driver_s *dev,
can_newdata(dev, pstate);
#ifdef CONFIG_NET_TIMESTAMP
if (pstate->pr_sock->s_timestamp)
if (conn->sconn.s_timestamp)
{
if (pstate->pr_msglen == sizeof(struct timeval))
{
@ -597,7 +597,7 @@ ssize_t can_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
state.pr_buffer = msg->msg_iov->iov_base;
#ifdef CONFIG_NET_TIMESTAMP
if (psock->s_timestamp && msg->msg_controllen >=
if (conn->sconn.s_timestamp && msg->msg_controllen >=
(sizeof(struct cmsghdr) + sizeof(struct timeval)))
{
struct cmsghdr *cmsg = CMSG_FIRSTHDR(msg);
@ -629,7 +629,7 @@ ssize_t can_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
if (ret > 0)
{
#ifdef CONFIG_NET_TIMESTAMP
if (psock->s_timestamp)
if (conn->sconn.s_timestamp)
{
if (state.pr_msglen == sizeof(struct timeval))
{

View File

@ -255,7 +255,7 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
return -EINVAL;
}
*(FAR int *)value = (int)psock->s_timestamp;
*(FAR int *)value = (int)conn->s_timestamp;
}
break;
#endif

View File

@ -392,7 +392,7 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
net_lock();
psock->s_timestamp = *((FAR int32_t *)value);
conn->s_timestamp = *((FAR int32_t *)value);
net_unlock();
}