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

2020-10-30 Thread aguettouche
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 
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 
---
 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(_addr, 0, sizeof(ep_addr));
-
-  ret = _write_to_usock(fd, _addr, resp.valuelen);
+  ret = _write_to_usock(fd, _usock->raddr, resp.valuelen);
 
   if (0 > ret)
 {



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

2020-10-26 Thread jerpelea
This is an automated email from the ASF dual-hosted git repository.

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

commit 0e9594e1074efb5cc26ef6d58e20a87ef39e1ecc
Author: Masayuki Ishikawa 
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 
---
 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 628ea61..b95be57 100644
--- a/wireless/gs2200m/gs2200m_main.c
+++ b/wireless/gs2200m/gs2200m_main.c
@@ -1132,7 +1132,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 */
 
@@ -1173,6 +1172,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:
 
@@ -1185,8 +1185,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
@@ -1208,11 +1208,7 @@ prepare:
 {
   /* Send address (value) */
 
-  /* TODO: ep_addr should be set */
-
-  memset(_addr, 0, sizeof(ep_addr));
-
-  ret = _write_to_usock(fd, _addr, resp.valuelen);
+  ret = _write_to_usock(fd, _usock->raddr, resp.valuelen);
 
   if (0 > ret)
 {