net/udp: replace the common connect prologue
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
1f4de9e13c
commit
2026450333
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <nuttx/semaphore.h>
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/net/ip.h>
|
#include <nuttx/net/ip.h>
|
||||||
|
#include <nuttx/net/net.h>
|
||||||
#include <nuttx/mm/iob.h>
|
#include <nuttx/mm/iob.h>
|
||||||
|
|
||||||
#ifdef CONFIG_NET_UDP_NOTIFIER
|
#ifdef CONFIG_NET_UDP_NOTIFIER
|
||||||
@ -61,9 +62,9 @@
|
|||||||
/* Allocate a new UDP data callback */
|
/* Allocate a new UDP data callback */
|
||||||
|
|
||||||
#define udp_callback_alloc(dev,conn) \
|
#define udp_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 udp_callback_free(dev,conn,cb) \
|
#define udp_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)
|
||||||
|
|
||||||
/* Definitions for the UDP connection struct flag field */
|
/* Definitions for the UDP connection struct flag field */
|
||||||
|
|
||||||
@ -99,14 +100,7 @@ struct udp_conn_s
|
|||||||
{
|
{
|
||||||
/* Common prologue of all connection structures. */
|
/* Common prologue of all connection structures. */
|
||||||
|
|
||||||
dq_entry_t node; /* Supports a doubly linked list */
|
struct socket_conn_s sconn;
|
||||||
|
|
||||||
/* This is a list of UDP connection 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;
|
|
||||||
|
|
||||||
/* UDP-specific content follows */
|
/* UDP-specific content follows */
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ uint16_t udp_callback(FAR struct net_driver_s *dev,
|
|||||||
{
|
{
|
||||||
/* Perform the callback */
|
/* Perform the callback */
|
||||||
|
|
||||||
flags = devif_conn_event(dev, conn, flags, conn->list);
|
flags = devif_conn_event(dev, conn, flags, conn->sconn.list);
|
||||||
|
|
||||||
if ((flags & UDP_NEWDATA) != 0)
|
if ((flags & UDP_NEWDATA) != 0)
|
||||||
{
|
{
|
||||||
|
@ -307,7 +307,7 @@ static inline FAR struct udp_conn_s *
|
|||||||
|
|
||||||
/* Look at the next active connection */
|
/* Look at the next active connection */
|
||||||
|
|
||||||
conn = (FAR struct udp_conn_s *)conn->node.flink;
|
conn = (FAR struct udp_conn_s *)conn->sconn.node.flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
@ -446,7 +446,7 @@ static inline FAR struct udp_conn_s *
|
|||||||
|
|
||||||
/* Look at the next active connection */
|
/* Look at the next active connection */
|
||||||
|
|
||||||
conn = (FAR struct udp_conn_s *)conn->node.flink;
|
conn = (FAR struct udp_conn_s *)conn->sconn.node.flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
@ -485,7 +485,7 @@ FAR struct udp_conn_s *udp_alloc_conn(void)
|
|||||||
/* Mark the connection closed and move it to the free list */
|
/* Mark the connection closed and move it to the free list */
|
||||||
|
|
||||||
conn[i].lport = 0;
|
conn[i].lport = 0;
|
||||||
dq_addlast(&conn[i].node, &g_free_udp_connections);
|
dq_addlast(&conn[i].sconn.node, &g_free_udp_connections);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,7 +594,7 @@ void udp_initialize(void)
|
|||||||
/* Mark the connection closed and move it to the free list */
|
/* Mark the connection closed and move it to the free list */
|
||||||
|
|
||||||
g_udp_connections[i].lport = 0;
|
g_udp_connections[i].lport = 0;
|
||||||
dq_addlast(&g_udp_connections[i].node, &g_free_udp_connections);
|
dq_addlast(&g_udp_connections[i].sconn.node, &g_free_udp_connections);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -650,7 +650,7 @@ FAR struct udp_conn_s *udp_alloc(uint8_t domain)
|
|||||||
#endif
|
#endif
|
||||||
/* Enqueue the connection into the active list */
|
/* Enqueue the connection into the active list */
|
||||||
|
|
||||||
dq_addlast(&conn->node, &g_active_udp_connections);
|
dq_addlast(&conn->sconn.node, &g_active_udp_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
_udp_semgive(&g_free_sem);
|
_udp_semgive(&g_free_sem);
|
||||||
@ -681,7 +681,7 @@ void udp_free(FAR struct udp_conn_s *conn)
|
|||||||
|
|
||||||
/* Remove the connection from the active list */
|
/* Remove the connection from the active list */
|
||||||
|
|
||||||
dq_rem(&conn->node, &g_active_udp_connections);
|
dq_rem(&conn->sconn.node, &g_active_udp_connections);
|
||||||
|
|
||||||
/* Release any read-ahead buffers attached to the connection */
|
/* Release any read-ahead buffers attached to the connection */
|
||||||
|
|
||||||
@ -706,7 +706,7 @@ void udp_free(FAR struct udp_conn_s *conn)
|
|||||||
|
|
||||||
/* Free the connection */
|
/* Free the connection */
|
||||||
|
|
||||||
dq_addlast(&conn->node, &g_free_udp_connections);
|
dq_addlast(&conn->sconn.node, &g_free_udp_connections);
|
||||||
_udp_semgive(&g_free_sem);
|
_udp_semgive(&g_free_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,7 +763,7 @@ FAR struct udp_conn_s *udp_nextconn(FAR struct udp_conn_s *conn)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (FAR struct udp_conn_s *)conn->node.flink;
|
return (FAR struct udp_conn_s *)conn->sconn.node.flink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user