net/ioctl: add a socket interface for ioctl

Add a socket family for ioctl.

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
This commit is contained in:
gaohedong
2025-06-16 20:54:47 +08:00
committed by Xiang Xiao
parent b0ab56aca2
commit 7e6138f258
10 changed files with 105 additions and 157 deletions
+71
View File
@@ -43,6 +43,72 @@
#include "ieee802154/ieee802154.h"
#include "socket/socket.h"
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int ctrl_setup(FAR struct socket *psock);
static int ctrl_close(FAR struct socket *psock);
/****************************************************************************
* Private Data
****************************************************************************/
static const struct sock_intf_s g_ctrl_sockif =
{
ctrl_setup, /* si_setup */
NULL, /* si_sockcaps */
NULL, /* si_addref */
NULL, /* si_bind */
NULL, /* si_getsockname */
NULL, /* si_getpeername */
NULL, /* si_listen */
NULL, /* si_connect */
NULL, /* si_accept */
NULL, /* si_poll */
NULL, /* si_sendmsg */
NULL, /* si_recvmsg */
ctrl_close /* si_close */
};
static struct socket_conn_s g_ctrl_conn;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: ctrl_setup
*
* Description:
* Called for socket() to verify that the provided socket type and
* protocol are usable by this address family. Perform any family-
* specific socket fields.
*
* NOTE: This is common logic for SOCK_CTRL
*
* Input Parameters:
* psock A pointer to a user allocated socket structure to be
* initialized.
* protocol (see sys/socket.h)
*
* Returned Value:
* Zero (OK) is returned on success. Otherwise, a negated errno value is
* returned.
*
****************************************************************************/
static int ctrl_setup(FAR struct socket *psock)
{
psock->s_conn = &g_ctrl_conn;
return 0;
}
static int ctrl_close(FAR struct socket *psock)
{
return 0;
}
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -75,6 +141,11 @@ net_sockif(sa_family_t family, int type, int protocol)
* to be used for anything.
*/
if ((type & SOCK_TYPE_MASK) == SOCK_CTRL)
{
return &g_ctrl_sockif;
}
switch (family)
{
#if defined(HAVE_PFINET_SOCKETS) || defined(HAVE_PFINET6_SOCKETS)