You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/10/30 09:59:12 UTC

[incubator-nuttx-apps] branch releases/10.0 updated (eaeb551 -> 56486d9)

This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a change to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git.


    from eaeb551  system/cu: do not reset baud rate to zero when parity options are used
     new 6da9f53  wireless: gs2200m: Fix to handle UDP connect() with bind()
     new 9276b66  wireless: gs2200m: Fix to handle address info in accept()
     new c69bc30  wireless: gs2200m: Implement getpeername_request()
     new 56486d9  wireless: gs2200m: Add support for ioctl(fd, SIOCGIFADDR, ...)

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 wireless/gs2200m/gs2200m_main.c | 166 ++++++++++++++++++++++++++++++++++------
 1 file changed, 142 insertions(+), 24 deletions(-)


[incubator-nuttx-apps] 01/04: wireless: gs2200m: Fix to handle UDP connect() with bind()

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 6da9f532d6b233856d3c098a3f55b62edcbf1c04
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Fri Oct 9 21:18:29 2020 +0900

    wireless: gs2200m: Fix to handle UDP connect() with bind()
    
    Summary:
    - This commit fixes to handle UDP connect() with bind() to local port
    - NOTE: GS2200M does not support TCP connect() with bind to local port
    
    Impact:
    - All UDP cases which use connect() with gs2200m
    - Need to update nuttx as well
    
    Testing:
    - Tested with spresense:wifi
    - Create a UDP socket and bind() to local port.
    - Then connect() to remote address with port and send()
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 wireless/gs2200m/gs2200m_main.c | 74 +++++++++++++++++++++++++++++++++--------
 1 file changed, 61 insertions(+), 13 deletions(-)

diff --git a/wireless/gs2200m/gs2200m_main.c b/wireless/gs2200m/gs2200m_main.c
index fe58160..e381a93 100644
--- a/wireless/gs2200m/gs2200m_main.c
+++ b/wireless/gs2200m/gs2200m_main.c
@@ -77,9 +77,11 @@ enum sock_state_e
 
 struct usock_s
 {
-  int8_t  type;
-  char    cid;
+  int8_t   type;
+  char     cid;
   enum sock_state_e state;
+  uint16_t lport;           /* local port */
+  struct sockaddr_in raddr; /* remote addr */
 };
 
 struct gs2200m_s
@@ -581,6 +583,35 @@ static int connect_request(int fd, FAR struct gs2200m_s *priv,
       goto prepare;
     }
 
+  memset(&cmsg, 0, sizeof(cmsg));
+
+  /* Check if this socket is already connected. */
+
+  if (BOUND == usock->state)
+    {
+      if (usock->type == SOCK_STREAM)
+        {
+          ret = -EISCONN;
+          goto prepare;
+        }
+      else
+        {
+          /* Firstly, close the socket */
+
+          struct gs2200m_close_msg clmsg;
+          memset(&clmsg, 0, sizeof(clmsg));
+          clmsg.cid = usock->cid;
+
+          ioctl(priv->gsfd, GS2200M_IOC_CLOSE, (unsigned long)&clmsg);
+
+          /* Copy the local port info */
+
+          cmsg.lport = usock->lport;
+
+          usock->state = OPENED;
+        }
+    }
+
   /* Check if address size ok. */
 
   if (req->addrlen > sizeof(addr))
@@ -622,6 +653,7 @@ static int connect_request(int fd, FAR struct gs2200m_s *priv,
     {
       usock->cid   = cmsg.cid;
       usock->state = CONNECTED;
+      usock->raddr = addr;
     }
   else
     {
@@ -704,26 +736,41 @@ static int sendto_request(int fd, FAR struct gs2200m_s *priv,
       goto prepare;
     }
 
+  memset(&smsg, 0, sizeof(smsg));
+
   smsg.is_tcp = (usock->type == SOCK_STREAM) ? true : false;
 
   /* For UDP, addlen must be provided */
 
-  if (usock->type == SOCK_DGRAM && CONNECTED != usock->state)
+  if (usock->type == SOCK_DGRAM)
     {
-      if (req->addrlen == 0)
+      if (CONNECTED != usock->state)
         {
-          ret = -EINVAL;
-          goto prepare;
-        }
+          if (req->addrlen == 0)
+            {
+              ret = -EINVAL;
+              goto prepare;
+            }
 
-      /* In UDP case, read the address. */
+          /* In UDP case, read the address. */
 
-      rlen = read(fd, &smsg.addr, sizeof(smsg.addr));
+          rlen = read(fd, &smsg.addr, sizeof(smsg.addr));
 
-      if (rlen < 0 || rlen < req->addrlen)
+          if (rlen < 0 || rlen < req->addrlen)
+            {
+              ret = -EFAULT;
+              goto prepare;
+            }
+        }
+      else if (CONNECTED == usock->state)
         {
-          ret = -EFAULT;
-          goto prepare;
+          /* Copy remote address */
+
+          smsg.addr = usock->raddr;
+        }
+      else
+        {
+          ASSERT(false);
         }
 
       gs2200m_printf("%s: addr: %s:%d",
@@ -1007,7 +1054,8 @@ static int bind_request(int fd, FAR struct gs2200m_s *priv,
 
   if (0 == ret)
     {
-      usock->cid = bmsg.cid;
+      usock->cid   = bmsg.cid;
+      usock->lport = ntohs(addr.sin_port);
       usock->state = BOUND;
     }
 


[incubator-nuttx-apps] 02/04: wireless: gs2200m: Fix to handle address info in accept()

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 9276b6612b4add518680ce32ccaec5db67487b42
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Mon Oct 12 14:02:18 2020 +0900

    wireless: gs2200m: Fix to handle address info in accept()
    
    Summary:
    - This commit fixes to handle address info in accept()
    
    Impact:
    - All use cases which use accept() with gs2200m
    - Need to update nuttx as well
    
    Testing:
    - Tested with spresene:wifi
    - Tested with telnet daemon
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 wireless/gs2200m/gs2200m_main.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/wireless/gs2200m/gs2200m_main.c b/wireless/gs2200m/gs2200m_main.c
index e381a93..116b06a 100644
--- a/wireless/gs2200m/gs2200m_main.c
+++ b/wireless/gs2200m/gs2200m_main.c
@@ -1129,7 +1129,6 @@ static int accept_request(int fd, FAR struct gs2200m_s *priv,
   struct gs2200m_accept_msg amsg;
   FAR struct usock_s *usock;
   FAR struct usock_s *new_usock = NULL;
-  struct sockaddr_in ep_addr;
   int ret = 0;
   int16_t usockid; /* usockid for new client */
 
@@ -1170,6 +1169,7 @@ static int accept_request(int fd, FAR struct gs2200m_s *priv,
 
   new_usock->cid   = amsg.cid;
   new_usock->state = CONNECTED;
+  new_usock->raddr = amsg.addr;
 
 prepare:
 
@@ -1182,8 +1182,8 @@ prepare:
 
   if (0 == ret)
     {
-      resp.reqack.result = 2; /* ep_addr + usock */
-      resp.valuelen_nontrunc = sizeof(ep_addr);
+      resp.reqack.result = 2; /* new_usock->raddr + usock */
+      resp.valuelen_nontrunc = sizeof(new_usock->raddr);
       resp.valuelen = resp.valuelen_nontrunc;
     }
   else
@@ -1205,11 +1205,7 @@ prepare:
     {
       /* Send address (value) */
 
-      /* TODO: ep_addr should be set */
-
-      memset(&ep_addr, 0, sizeof(ep_addr));
-
-      ret = _write_to_usock(fd, &ep_addr, resp.valuelen);
+      ret = _write_to_usock(fd, &new_usock->raddr, resp.valuelen);
 
       if (0 > ret)
         {


[incubator-nuttx-apps] 03/04: wireless: gs2200m: Implement getpeername_request()

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit c69bc30ff64543522b1528fe72a4794896a0fe03
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Mon Oct 12 11:47:57 2020 +0900

    wireless: gs2200m: Implement getpeername_request()
    
    Summary:
    - This commit adds getperrname_request() to gs2200m_main.c
    
    Impact:
    - Affects gs2200m only
    - Need to update nuttx as well
    
    Testing:
    - Tested with spresense:wifi
    - Modify telnetd and add getpeername() to show a client address
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 wireless/gs2200m/gs2200m_main.c | 79 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 76 insertions(+), 3 deletions(-)

diff --git a/wireless/gs2200m/gs2200m_main.c b/wireless/gs2200m/gs2200m_main.c
index 116b06a..28010ed 100644
--- a/wireless/gs2200m/gs2200m_main.c
+++ b/wireless/gs2200m/gs2200m_main.c
@@ -1412,14 +1412,87 @@ err_out:
 }
 
 /****************************************************************************
- * Name: getsockname_request
+ * Name: getpeername_request
  ****************************************************************************/
 
 static int getpeername_request(int fd, FAR struct gs2200m_s *priv,
                                FAR void *hdrbuf)
 {
-  DEBUGASSERT(false);
-  return -ENOSYS;
+  FAR struct usrsock_request_getpeername_s *req = hdrbuf;
+  struct usrsock_message_datareq_ack_s resp;
+  FAR struct usock_s *usock;
+  int ret = 0;
+
+  DEBUGASSERT(priv);
+  DEBUGASSERT(req);
+
+  gs2200m_printf("%s: called **** \n", __func__);
+
+  /* Check if this socket exists. */
+
+  usock = gs2200m_socket_get(priv, req->usockid);
+
+  if (!usock)
+    {
+      ret = -EBADFD;
+      goto prepare;
+    }
+
+  if (CONNECTED != usock->state)
+    {
+      ret = -ENOTCONN;
+    }
+
+prepare:
+
+  /* Prepare response. */
+
+  memset(&resp, 0, sizeof(resp));
+  resp.reqack.xid = req->head.xid;
+  resp.reqack.head.msgid = USRSOCK_MESSAGE_RESPONSE_DATA_ACK;
+  resp.reqack.head.flags = 0;
+  resp.reqack.result = ret;
+
+  if (0 == ret)
+    {
+      resp.valuelen_nontrunc = sizeof(usock->raddr);
+      resp.valuelen = resp.valuelen_nontrunc;
+
+      if (resp.valuelen > req->max_addrlen)
+        {
+          resp.valuelen = req->max_addrlen;
+        }
+    }
+  else
+    {
+      resp.valuelen_nontrunc = 0;
+      resp.valuelen = 0;
+    }
+
+  /* Send response. */
+
+  ret = _write_to_usock(fd, &resp, sizeof(resp));
+
+  if (0 > ret)
+    {
+      goto err_out;
+    }
+
+  if (resp.valuelen > 0)
+    {
+      /* Send address (value) */
+
+      ret = _write_to_usock(fd, &usock->raddr, resp.valuelen);
+
+      if (0 > ret)
+        {
+          goto err_out;
+        }
+    }
+
+err_out:
+  gs2200m_printf("%s: end \n", __func__);
+  return ret;
 }
 
 /****************************************************************************


[incubator-nuttx-apps] 04/04: wireless: gs2200m: Add support for ioctl(fd, SIOCGIFADDR, ...)

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 56486d960084354a5d1055275caee3fa27be4c7a
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Mon Oct 12 19:53:30 2020 +0900

    wireless: gs2200m: Add support for ioctl(fd, SIOCGIFADDR, ...)
    
    Summary:
    - This commit adds support for ioctl(fd, SIOCGIFADDR, ...) to gs2200m_main.c
    
    Impact:
    - Only affects ioctl(fd, SIOCGIFADDR, ...) with gs2200m
    - Need to update nuttx as well
    
    Testing:
    - Tested with spresense:wifi
    - Tested with dhcpc
    
    Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
 wireless/gs2200m/gs2200m_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/wireless/gs2200m/gs2200m_main.c b/wireless/gs2200m/gs2200m_main.c
index 28010ed..8f41018 100644
--- a/wireless/gs2200m/gs2200m_main.c
+++ b/wireless/gs2200m/gs2200m_main.c
@@ -1513,6 +1513,7 @@ static int ioctl_request(int fd, FAR struct gs2200m_s *priv,
 
   switch (req->cmd)
     {
+      case SIOCGIFADDR:
       case SIOCGIFHWADDR:
         getreq = true;
         break;