Skip to content

Commit

Permalink
net/netdev: Add ioctl for SIOCGETCONTEXT and SIOCSETCONTEXT
Browse files Browse the repository at this point in the history
Added ioctl to get and set the socket context held by the usrsock daemon.
  • Loading branch information
SPRESENSE committed Aug 20, 2024
1 parent 4d4d8a6 commit 5038472
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/nuttx/net/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
/* Network socket control ***************************************************/

#define SIOCDENYINETSOCK _SIOC(0x003C) /* Deny network socket. */
#define SIOCGETCONTEXT _SIOC(0x003F) /* Get socket context */
#define SIOCSETCONTEXT _SIOC(0x0040) /* Set socket context */

/* Bridge calls *************************************************************/

Expand Down
20 changes: 20 additions & 0 deletions include/nuttx/net/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,26 @@ struct socket
FAR const struct sock_intf_s *s_sockif;
};

struct socket_ctx_data_s
{
uint8_t s_domain; /* IP domain */
uint8_t s_type; /* Protocol type */
uint8_t s_proto; /* Socket Protocol */
uint8_t s_priv[0]; /* Private socket context */
};

/* NETDEV ioctl command:
*
* Command: SIOCGETCONTEXT or SIOCSETCONTEXT
* Description: Get or Set socket context.
*/

struct socket_context_s
{
size_t ctx_size; /* Size of socket context */
struct socket_ctx_data_s *ctx; /* Buffer where socket context is stored */
};

/****************************************************************************
* Public Data
****************************************************************************/
Expand Down
4 changes: 4 additions & 0 deletions net/netdev/netdev_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,10 @@ ssize_t net_ioctl_arglen(uint8_t domain, int cmd)
case SIOCDENYINETSOCK:
return sizeof(uint8_t);

case SIOCGETCONTEXT:
case SIOCSETCONTEXT:
return sizeof(struct socket_context_s);

default:
#ifdef CONFIG_NETDEV_IOCTL
# ifdef CONFIG_NETDEV_WIRELESS_IOCTL
Expand Down

0 comments on commit 5038472

Please sign in to comment.