net/ieee802154: replace the common connect prologue
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
43ca28da36
commit
1b0f85c5bc
@ -31,6 +31,8 @@
|
||||
#include <queue.h>
|
||||
#include <netpacket/ieee802154.h>
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
|
||||
/****************************************************************************
|
||||
@ -40,9 +42,9 @@
|
||||
/* Allocate a new IEEE 802.15.4 socket data callback */
|
||||
|
||||
#define ieee802154_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 ieee802154_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)
|
||||
|
||||
/* Memory Pools */
|
||||
|
||||
@ -97,14 +99,7 @@ struct ieee802154_conn_s
|
||||
{
|
||||
/* Common prologue of all connection structures. */
|
||||
|
||||
dq_entry_t node; /* Supports a double linked list */
|
||||
|
||||
/* This is a list of IEEE 802.15.4 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;
|
||||
|
||||
/* IEEE 802.15.4-specific content follows */
|
||||
|
||||
|
@ -66,7 +66,8 @@ uint16_t ieee802154_callback(FAR struct radio_driver_s *radio,
|
||||
{
|
||||
/* Perform the callback */
|
||||
|
||||
flags = devif_conn_event(&radio->r_dev, conn, flags, conn->list);
|
||||
flags = devif_conn_event(&radio->r_dev, conn, flags,
|
||||
conn->sconn.list);
|
||||
}
|
||||
|
||||
return flags;
|
||||
|
@ -96,7 +96,7 @@ void ieee802154_conn_initialize(void)
|
||||
{
|
||||
/* Link each pre-allocated connection structure into the free list. */
|
||||
|
||||
dq_addlast(&g_ieee802154_connections[i].node,
|
||||
dq_addlast(&g_ieee802154_connections[i].sconn.node,
|
||||
&g_free_ieee802154_connections);
|
||||
}
|
||||
#endif
|
||||
@ -129,7 +129,8 @@ FAR struct ieee802154_conn_s *ieee802154_conn_alloc(void)
|
||||
{
|
||||
for (i = 0; i < CONFIG_NET_IEEE802154_NCONNS; i++)
|
||||
{
|
||||
dq_addlast(&conn[i].node, &g_free_ieee802154_connections);
|
||||
dq_addlast(&conn[i].sconn.node,
|
||||
&g_free_ieee802154_connections);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -139,7 +140,7 @@ FAR struct ieee802154_conn_s *ieee802154_conn_alloc(void)
|
||||
dq_remfirst(&g_free_ieee802154_connections);
|
||||
if (conn)
|
||||
{
|
||||
dq_addlast(&conn->node, &g_active_ieee802154_connections);
|
||||
dq_addlast(&conn->sconn.node, &g_active_ieee802154_connections);
|
||||
}
|
||||
|
||||
net_unlock();
|
||||
@ -167,7 +168,7 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn)
|
||||
/* Remove the connection from the active list */
|
||||
|
||||
net_lock();
|
||||
dq_rem(&conn->node, &g_active_ieee802154_connections);
|
||||
dq_rem(&conn->sconn.node, &g_active_ieee802154_connections);
|
||||
|
||||
/* Check if there any any frames attached to the container */
|
||||
|
||||
@ -196,7 +197,7 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn)
|
||||
|
||||
/* Free the connection */
|
||||
|
||||
dq_addlast(&conn->node, &g_free_ieee802154_connections);
|
||||
dq_addlast(&conn->sconn.node, &g_free_ieee802154_connections);
|
||||
net_unlock();
|
||||
}
|
||||
|
||||
@ -222,7 +223,7 @@ FAR struct ieee802154_conn_s *
|
||||
for (conn = (FAR struct ieee802154_conn_s *)
|
||||
g_active_ieee802154_connections.head;
|
||||
conn != NULL;
|
||||
conn = (FAR struct ieee802154_conn_s *)conn->node.flink)
|
||||
conn = (FAR struct ieee802154_conn_s *)conn->sconn.node.flink)
|
||||
{
|
||||
/* Does the destination address match the bound address of the socket.
|
||||
*
|
||||
@ -300,7 +301,7 @@ FAR struct ieee802154_conn_s *
|
||||
}
|
||||
else
|
||||
{
|
||||
return (FAR struct ieee802154_conn_s *)conn->node.flink;
|
||||
return (FAR struct ieee802154_conn_s *)conn->sconn.node.flink;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user