You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/04/22 15:44:43 UTC
(nuttx) branch master updated: netdev_upperhalf: add L3 packet handle
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 92cd1c3742 netdev_upperhalf: add L3 packet handle
92cd1c3742 is described below
commit 92cd1c3742991ea3216b741beacf866f93c42288
Author: zhanghongyu <zh...@xiaomi.com>
AuthorDate: Mon Apr 22 14:46:29 2024 +0800
netdev_upperhalf: add L3 packet handle
To provide support for the received L3 network packets
Signed-off-by: zhanghongyu <zh...@xiaomi.com>
---
drivers/net/netdev_upperhalf.c | 68 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/drivers/net/netdev_upperhalf.c b/drivers/net/netdev_upperhalf.c
index 6130261748..a1f3997010 100644
--- a/drivers/net/netdev_upperhalf.c
+++ b/drivers/net/netdev_upperhalf.c
@@ -405,6 +405,69 @@ static void eth_input(FAR struct net_driver_s *dev)
}
#endif
+/****************************************************************************
+ * Name: ip_input
+ *
+ * Description:
+ * Handle L3 packet input.
+ *
+ * Input Parameters:
+ * dev - Reference to the NuttX network driver state structure
+ *
+ * Assumptions:
+ * Called with the network locked.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_MBIM
+static void ip_input(FAR struct net_driver_s *dev)
+{
+ /* We only accept IP packets of the configured type */
+
+#ifdef CONFIG_NET_IPv4
+ if ((IPv4BUF->vhl & IP_VERSION_MASK) == IPv4_VERSION)
+ {
+ ninfo("IPv4 frame\n");
+ NETDEV_RXIPV4(dev);
+
+ /* Receive an IPv4 packet from the network device */
+
+ ipv4_input(dev);
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if ((IPv6BUF->vtc & IP_VERSION_MASK) == IPv6_VERSION)
+ {
+ ninfo("IPv6 frame\n");
+ NETDEV_RXIPV6(dev);
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(dev);
+ }
+ else
+#endif
+ {
+ ninfo("INFO: Dropped, Unknown type\n");
+ NETDEV_RXDROPPED(dev);
+ dev->d_len = 0;
+ }
+
+ /* If the above function invocation resulted in data
+ * that should be sent out on the network,
+ * the field d_len will set to a value > 0.
+ */
+
+ if (dev->d_len > 0)
+ {
+ /* And send the packet */
+
+ netdev_upper_txpoll(dev);
+ }
+}
+#endif
+
/****************************************************************************
* Function: netdev_upper_rxpoll_work
*
@@ -465,6 +528,11 @@ static void netdev_upper_rxpoll_work(FAR struct netdev_upperhalf_s *upper)
eth_input(dev);
break;
#endif
+#ifdef CONFIG_NET_MBIM
+ case NET_LL_MBIM:
+ ip_input(dev);
+ break;
+#endif
#ifdef CONFIG_NET_CAN
case NET_LL_CAN:
ninfo("CAN frame");