From 6a69f0e96f20476d57a131f82c8fab9cac5c7c7c Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Thu, 29 Jun 2023 20:59:58 +0900 Subject: [PATCH] wireless/gs2200m: Add support SIOCDENYINETSOCK ioctl command Support SIOCDENYINETSOCK ioctl command to set usrsock status. If usock_enable is false, its means application wants to create a socket with other network stack. --- wireless/gs2200m/gs2200m_main.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/wireless/gs2200m/gs2200m_main.c b/wireless/gs2200m/gs2200m_main.c index 6ed411928..64cbd2b5c 100644 --- a/wireless/gs2200m/gs2200m_main.c +++ b/wireless/gs2200m/gs2200m_main.c @@ -90,6 +90,7 @@ struct gs2200m_s uint8_t mode; uint8_t ch; int gsfd; + int usock_enable; struct usock_s sockets[SOCKET_COUNT]; }; @@ -491,6 +492,16 @@ static int socket_request(int fd, FAR struct gs2200m_s *priv, { usockid = -EAFNOSUPPORT; } + else if (!priv->usock_enable && req->domain == AF_INET && + req->type != SOCK_CTRL) + { + /* If domain is AF_INET while usock_enable is false, + * set usockid to -ENOTSUP to fallback kernel + * network stack. + */ + + usockid = -ENOTSUP; + } else { /* Allocate socket. */ @@ -1550,6 +1561,7 @@ static int ioctl_request(int fd, FAR struct gs2200m_s *priv, struct usrsock_message_req_ack_s resp; struct usrsock_message_datareq_ack_s resp2; struct gs2200m_ifreq_msg imsg; + uint8_t sock_type; bool getreq = false; int ret = -EINVAL; @@ -1573,6 +1585,24 @@ static int ioctl_request(int fd, FAR struct gs2200m_s *priv, read(fd, &imsg.ifr, sizeof(imsg.ifr)); break; + case SIOCDENYINETSOCK: + + read(fd, &sock_type, sizeof(uint8_t)); + + if (sock_type == DENY_INET_SOCK_ENABLE) + { + /* Block to create INET socket */ + + priv->usock_enable = FALSE; + } + else + { + /* Allow to create INET socket */ + + priv->usock_enable = TRUE; + } + break; + default: break; } @@ -1779,6 +1809,8 @@ int main(int argc, FAR char *argv[]) } } + _daemon->usock_enable = TRUE; + if ((ap_mode && (4 != argc) && (5 != argc)) || (!ap_mode && 3 != argc)) {