Skip to content

Commit

Permalink
net: Copy out also can cmsg data into the end of packet
Browse files Browse the repository at this point in the history
This has been broken at some point. Just fix it by copying the can frame and
the cmsg data into IOB, and fix devif_poll to copy out the full data.

The can drivers expect to find the timeout timestamp in the end of the frame.

Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed Oct 16, 2024
1 parent 08c9f63 commit 2b887b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions net/can/can_sendmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
/* Copy the packet data into the device packet buffer and send it */

int ret = devif_send(dev, pstate->snd_buffer,
pstate->snd_buflen, 0);
dev->d_len = dev->d_sndlen;
pstate->snd_buflen + pstate->pr_msglen, 0);
dev->d_len = dev->d_sndlen - pstate->pr_msglen;
if (ret <= 0)
{
pstate->snd_sent = ret;
Expand All @@ -122,7 +122,6 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
{
memcpy(dev->d_buf + pstate->snd_buflen, pstate->pr_msgbuf,
pstate->pr_msglen);
dev->d_sndlen = pstate->snd_buflen + pstate->pr_msglen;
}
}

Expand Down
4 changes: 3 additions & 1 deletion net/devif/devif_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ static int devif_poll_callback(FAR struct net_driver_s *dev)

int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
{
unsigned len;
uint16_t llhdrlen;
FAR uint8_t *buf;
int bstop;
Expand All @@ -1054,7 +1055,8 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
{
/* Copy iob to flat buffer */

iob_copyout(buf, dev->d_iob, dev->d_len, -llhdrlen);
len = MAX(dev->d_len, dev->d_sndlen);
iob_copyout(buf, dev->d_iob, len, -llhdrlen);

/* Restore flat buffer pointer */

Expand Down

0 comments on commit 2b887b7

Please sign in to comment.