net/pkt: replace the common connect prologue
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
e02711e114
commit
63173dadbb
@ -30,6 +30,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <queue.h>
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
|
||||
#ifdef CONFIG_NET_PKT
|
||||
|
||||
/****************************************************************************
|
||||
@ -39,9 +41,9 @@
|
||||
/* Allocate a new packet socket data callback */
|
||||
|
||||
#define pkt_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 pkt_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
|
||||
@ -55,14 +57,7 @@ struct pkt_conn_s
|
||||
{
|
||||
/* Common prologue of all connection structures. */
|
||||
|
||||
dq_entry_t node; /* Supports a double linked list */
|
||||
|
||||
/* This is a list of Pkt connection callbacks. Each callback represents
|
||||
* a thread that is stalled, waiting for a device-specific event.
|
||||
*/
|
||||
|
||||
struct devif_callback_s *list;
|
||||
struct devif_callback_s *list_tail;
|
||||
struct socket_conn_s sconn;
|
||||
|
||||
/* Pkt socket-specific content follows */
|
||||
|
||||
|
@ -63,7 +63,7 @@ uint16_t pkt_callback(FAR struct net_driver_s *dev,
|
||||
{
|
||||
/* Perform the callback */
|
||||
|
||||
flags = devif_conn_event(dev, conn, flags, conn->list);
|
||||
flags = devif_conn_event(dev, conn, flags, conn->sconn.list);
|
||||
}
|
||||
|
||||
return flags;
|
||||
|
@ -116,7 +116,7 @@ void pkt_initialize(void)
|
||||
#ifndef CONFIG_NET_ALLOC_CONNS
|
||||
for (i = 0; i < CONFIG_NET_PKT_CONNS; i++)
|
||||
{
|
||||
dq_addlast(&g_pkt_connections[i].node, &g_free_pkt_connections);
|
||||
dq_addlast(&g_pkt_connections[i].sconn.node, &g_free_pkt_connections);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -148,7 +148,7 @@ FAR struct pkt_conn_s *pkt_alloc(void)
|
||||
{
|
||||
for (i = 0; i < CONFIG_NET_PKT_CONNS; i++)
|
||||
{
|
||||
dq_addlast(&conn[i].node, &g_free_pkt_connections);
|
||||
dq_addlast(&conn[i].sconn.node, &g_free_pkt_connections);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -159,7 +159,7 @@ FAR struct pkt_conn_s *pkt_alloc(void)
|
||||
{
|
||||
/* Enqueue the connection into the active list */
|
||||
|
||||
dq_addlast(&conn->node, &g_active_pkt_connections);
|
||||
dq_addlast(&conn->sconn.node, &g_active_pkt_connections);
|
||||
}
|
||||
|
||||
_pkt_semgive(&g_free_sem);
|
||||
@ -185,7 +185,7 @@ void pkt_free(FAR struct pkt_conn_s *conn)
|
||||
|
||||
/* Remove the connection from the active list */
|
||||
|
||||
dq_rem(&conn->node, &g_active_pkt_connections);
|
||||
dq_rem(&conn->sconn.node, &g_active_pkt_connections);
|
||||
|
||||
/* Make sure that the connection is marked as uninitialized */
|
||||
|
||||
@ -193,7 +193,7 @@ void pkt_free(FAR struct pkt_conn_s *conn)
|
||||
|
||||
/* Free the connection */
|
||||
|
||||
dq_addlast(&conn->node, &g_free_pkt_connections);
|
||||
dq_addlast(&conn->sconn.node, &g_free_pkt_connections);
|
||||
_pkt_semgive(&g_free_sem);
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ FAR struct pkt_conn_s *pkt_active(FAR struct eth_hdr_s *buf)
|
||||
|
||||
/* Look at the next active connection */
|
||||
|
||||
conn = (FAR struct pkt_conn_s *)conn->node.flink;
|
||||
conn = (FAR struct pkt_conn_s *)conn->sconn.node.flink;
|
||||
}
|
||||
|
||||
return conn;
|
||||
@ -252,7 +252,7 @@ FAR struct pkt_conn_s *pkt_nextconn(FAR struct pkt_conn_s *conn)
|
||||
}
|
||||
else
|
||||
{
|
||||
return (FAR struct pkt_conn_s *)conn->node.flink;
|
||||
return (FAR struct pkt_conn_s *)conn->sconn.node.flink;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user