summaryrefslogtreecommitdiff
path: root/nuttx/drivers/net/enc28j60.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/drivers/net/enc28j60.c')
-rw-r--r--nuttx/drivers/net/enc28j60.c63
1 files changed, 55 insertions, 8 deletions
diff --git a/nuttx/drivers/net/enc28j60.c b/nuttx/drivers/net/enc28j60.c
index 547a148f6..defefb81c 100644
--- a/nuttx/drivers/net/enc28j60.c
+++ b/nuttx/drivers/net/enc28j60.c
@@ -1374,15 +1374,17 @@ static void enc_rxerif(FAR struct enc_driver_s *priv)
static void enc_rxdispatch(FAR struct enc_driver_s *priv)
{
- /* We only accept IP packets of the configured type and ARP packets */
+ /* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
+#ifdef CONFIG_NET_IPv4
if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
{
- nllvdbg("IP packet received (%02x)\n", BUF->type);
+ nllvdbg("IPv4 frame\n");
+
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
+
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@@ -1392,11 +1394,55 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv)
if (priv->dev.d_len > 0)
{
- arp_out(&priv->dev);
+ /* Update the Ethernet header with the correct MAC address */
+
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP))
+#endif
+ {
+ arp_out(&priv->dev);
+ }
+
+ /* And send the packet */
+
+ enc_transmit(priv);
+ }
+ }
+ else
+#endif
+#ifdef CONFIG_NET_IPv6
+ if (BUF->type == HTONS(ETHTYPE_IP6))
+ {
+ nllvdbg("Iv6 frame\n");
+
+ /* Give the IPv6 packet to the network layer */
+
+ ipv6_input(&priv->dev);
+
+ /* 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 (priv->dev.d_len > 0)
+ {
+#ifdef CONFIG_NET_IPv4
+ /* Update the Ethernet header with the correct MAC address */
+
+ if (BUF->type == HTONS(ETHTYPE_IP))
+ {
+ arp_out(&priv->dev);
+ }
+#endif
+
+ /* And send the packet */
+
enc_transmit(priv);
}
}
- else if (BUF->type == htons(ETHTYPE_ARP))
+ else
+#endif
+#ifdef CONFIG_NET_ARP
+ if (BUF->type == htons(ETHTYPE_ARP))
{
nllvdbg("ARP packet received (%02x)\n", BUF->type);
arp_arpin(&priv->dev);
@@ -1411,6 +1457,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv)
}
}
else
+#endif
{
nlldbg("Unsupported packet type dropped (%02x)\n", htons(BUF->type));
}