anchao commented on code in PR #7616:
URL: https://github.com/apache/nuttx/pull/7616#discussion_r1037777809


##########
net/devif/devif_send.c:
##########
@@ -65,10 +65,23 @@
  *
  ****************************************************************************/
 
-void devif_send(struct net_driver_s *dev, const void *buf, int len)
+void devif_send(struct net_driver_s *dev, const void *buf,

Review Comment:
   Done



##########
net/devif/devif_send.c:
##########
@@ -65,10 +65,23 @@
  *
  ****************************************************************************/
 
-void devif_send(struct net_driver_s *dev, const void *buf, int len)
+void devif_send(struct net_driver_s *dev, const void *buf,
+                int len, unsigned int offset)
 {
-  DEBUGASSERT(dev != NULL && len > 0 && len < NETDEV_PKTSIZE(dev));
+  unsigned int limit = NETDEV_PKTSIZE(dev) -
+                       CONFIG_NET_LL_GUARDSIZE - offset;
 
-  memcpy(dev->d_appdata, buf, len);
-  dev->d_sndlen = len;
+  if (dev == NULL || len == 0 || len > limit)
+    {
+      nerr("ERROR: devif_send fail: %p, sndlen: %u, pktlen: %u\n",
+            dev, len, limit);

Review Comment:
   Done



##########
net/devif/devif_send.c:
##########
@@ -65,10 +65,23 @@
  *
  ****************************************************************************/
 
-void devif_send(struct net_driver_s *dev, const void *buf, int len)
+void devif_send(struct net_driver_s *dev, const void *buf,
+                int len, unsigned int offset)
 {
-  DEBUGASSERT(dev != NULL && len > 0 && len < NETDEV_PKTSIZE(dev));
+  unsigned int limit = NETDEV_PKTSIZE(dev) -
+                       CONFIG_NET_LL_GUARDSIZE - offset;
 
-  memcpy(dev->d_appdata, buf, len);
-  dev->d_sndlen = len;
+  if (dev == NULL || len == 0 || len > limit)
+    {
+      nerr("ERROR: devif_send fail: %p, sndlen: %u, pktlen: %u\n",
+            dev, len, limit);
+      return;
+    }
+
+  iob_update_pktlen(dev->d_iob, offset);
+
+  /* Copy in iob to target device buffer */
+
+  dev->d_sndlen = (iob_copyin(dev->d_iob, buf, len, offset, false) == len) ?

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to