net/local: add local_peerconn helper
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
1e078795fb
commit
ea82a0b638
|
@ -254,6 +254,19 @@ void local_free(FAR struct local_conn_s *conn);
|
||||||
|
|
||||||
FAR struct local_conn_s *local_nextconn(FAR struct local_conn_s *conn);
|
FAR struct local_conn_s *local_nextconn(FAR struct local_conn_s *conn);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: local_peerconn
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Traverse the connections list to find the peer
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* This function must be called with the network locked.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR struct local_conn_s *local_peerconn(FAR struct local_conn_s *conn);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: psock_local_bind
|
* Name: psock_local_bind
|
||||||
*
|
*
|
||||||
|
|
|
@ -82,6 +82,33 @@ FAR struct local_conn_s *local_nextconn(FAR struct local_conn_s *conn)
|
||||||
return (FAR struct local_conn_s *)conn->lc_node.flink;
|
return (FAR struct local_conn_s *)conn->lc_node.flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: local_peerconn
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Traverse the connections list to find the peer
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* This function must be called with the network locked.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR struct local_conn_s *local_peerconn(FAR struct local_conn_s *conn)
|
||||||
|
{
|
||||||
|
FAR struct local_conn_s *peer = NULL;
|
||||||
|
|
||||||
|
while ((peer = local_nextconn(peer)) != NULL)
|
||||||
|
{
|
||||||
|
if (conn->lc_proto == peer->lc_proto && conn != peer &&
|
||||||
|
!strncmp(conn->lc_path, peer->lc_path, UNIX_PATH_MAX - 1))
|
||||||
|
{
|
||||||
|
return peer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: local_alloc()
|
* Name: local_alloc()
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue