Skip to content

Commit

Permalink
netutils/wiznet: Fix bug that sent wrong ack messages
Browse files Browse the repository at this point in the history
The specification of the DATA Ack Response message has
changed with the upgrade to NuttX 11. If the length of
payload 1 and 2 are both 0, the Ack/Nack Response
message must be used instead of this message.
  • Loading branch information
SPRESENSE committed Mar 7, 2023
1 parent 2990473 commit 921b5bc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion netutils/wiznet/wiznet_main.c
Expand Up @@ -865,6 +865,7 @@ static int recvfrom_request(int fd, FAR struct wiznet_s *priv,
FAR struct usrsock_request_recvfrom_s *req
= (FAR struct usrsock_request_recvfrom_s *)hdrbuf;
struct usrsock_message_datareq_ack_s resp;
struct usrsock_message_req_ack_s reqack;
struct wiznet_recv_msg cmsg;
struct sockaddr_in *addr = (struct sockaddr_in *)&cmsg.addr;
FAR struct usock_s *usock;
Expand Down Expand Up @@ -927,11 +928,19 @@ static int recvfrom_request(int fd, FAR struct wiznet_s *priv,
resp.valuelen = MIN(resp.valuelen_nontrunc,
req->max_addrlen);

if (0 == ret)
if ((0 == ret) && (0 != cmsg.len))
{
usock_send_event(fd, priv, usock,
USRSOCK_EVENT_REMOTE_CLOSED
);

/* Send ack only */

memset(&reqack, 0, sizeof(reqack));
reqack.result = ret;
ret = f_send_ack_common(fd, req->head.xid, &reqack);

goto err_out;
}
}

Expand Down

0 comments on commit 921b5bc

Please sign in to comment.