net/icmpv6: replace the common connect prologue

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2022-02-07 11:37:39 +08:00 committed by Alan Carvalho de Assis
parent 2026450333
commit e02711e114
4 changed files with 15 additions and 19 deletions

View File

@ -34,6 +34,7 @@
#include <nuttx/mm/iob.h>
#include <nuttx/net/ip.h>
#include <nuttx/net/net.h>
#include <nuttx/net/netdev.h>
#include <nuttx/semaphore.h>
@ -48,9 +49,9 @@
/* Allocate a new ICMPv6 data callback */
#define icmpv6_callback_alloc(dev, conn) \
devif_callback_alloc((dev), &(conn)->list, &(conn)->list_tail)
devif_callback_alloc((dev), &(conn)->sconn.list, &(conn)->sconn.list_tail)
#define icmpv6_callback_free(dev, conn, cb) \
devif_conn_callback_free((dev), (cb), &(conn)->list, &(conn)->list_tail)
devif_conn_callback_free((dev), (cb), &(conn)->sconn.list, &(conn)->sconn.list_tail)
/****************************************************************************
* Public Type Definitions
@ -79,14 +80,7 @@ struct icmpv6_conn_s
{
/* Common prologue of all connection structures. */
dq_entry_t node; /* Supports a double linked list */
/* This is a list of ICMPV6 callbacks. Each callback represents a thread
* that is stalled, waiting for a device-specific event.
*/
FAR struct devif_callback_s *list;
FAR struct devif_callback_s *list_tail;
struct socket_conn_s sconn;
/* ICMPv6-specific content follows */

View File

@ -91,7 +91,8 @@ void icmpv6_sock_initialize(void)
{
/* Move the connection structure to the free list */
dq_addlast(&g_icmpv6_connections[i].node, &g_free_icmpv6_connections);
dq_addlast(&g_icmpv6_connections[i].sconn.node,
&g_free_icmpv6_connections);
}
#endif
}
@ -124,7 +125,8 @@ FAR struct icmpv6_conn_s *icmpv6_alloc(void)
{
for (ret = 0; ret < CONFIG_NET_ICMPv6_NCONNS; ret++)
{
dq_addlast(&conn[ret].node, &g_free_icmpv6_connections);
dq_addlast(&conn[ret].sconn.node,
&g_free_icmpv6_connections);
}
}
}
@ -136,7 +138,7 @@ FAR struct icmpv6_conn_s *icmpv6_alloc(void)
{
/* Enqueue the connection into the active list */
dq_addlast(&conn->node, &g_active_icmpv6_connections);
dq_addlast(&conn->sconn.node, &g_active_icmpv6_connections);
}
nxsem_post(&g_free_sem);
@ -166,7 +168,7 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn)
/* Remove the connection from the active list */
dq_rem(&conn->node, &g_active_icmpv6_connections);
dq_rem(&conn->sconn.node, &g_active_icmpv6_connections);
/* Clear the connection structure */
@ -174,7 +176,7 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn)
/* Free the connection */
dq_addlast(&conn->node, &g_free_icmpv6_connections);
dq_addlast(&conn->sconn.node, &g_free_icmpv6_connections);
nxsem_post(&g_free_sem);
}
@ -208,7 +210,7 @@ FAR struct icmpv6_conn_s *icmpv6_active(uint16_t id)
/* Look at the next active connection */
conn = (FAR struct icmpv6_conn_s *)conn->node.flink;
conn = (FAR struct icmpv6_conn_s *)conn->sconn.node.flink;
}
return conn;
@ -233,7 +235,7 @@ FAR struct icmpv6_conn_s *icmpv6_nextconn(FAR struct icmpv6_conn_s *conn)
}
else
{
return (FAR struct icmpv6_conn_s *)conn->node.flink;
return (FAR struct icmpv6_conn_s *)conn->sconn.node.flink;
}
}

View File

@ -460,7 +460,7 @@ void icmpv6_input(FAR struct net_driver_s *dev, unsigned int iplen)
/* Dispatch the ECHO reply to the waiting thread */
flags = devif_conn_event(dev, conn, flags, conn->list);
flags = devif_conn_event(dev, conn, flags, conn->sconn.list);
/* Was the ECHO reply consumed by any waiting thread? */

View File

@ -74,7 +74,7 @@ void icmpv6_poll(FAR struct net_driver_s *dev,
/* Perform the application callback */
devif_conn_event(dev, conn, ICMPv6_POLL,
conn ? conn->list : dev->d_conncb);
conn ? conn->sconn.list : dev->d_conncb);
}
#endif /* CONFIG_NET_ICMPv6_SOCKET || CONFIG_NET_ICMPv6_NEIGHBOR */