summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/sama5/sam_gmac.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-15 09:31:23 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-15 09:31:23 -0600
commit80c7601e254be30121a1b0922f70827d42ce262f (patch)
treeb9d7db8538c9721c05ee612bfac32b2340bdbf80 /nuttx/arch/arm/src/sama5/sam_gmac.c
parente466893e7f9302c1dfa0a6662320aba2f86ae0ef (diff)
downloadpx4-nuttx-80c7601e254be30121a1b0922f70827d42ce262f.tar.gz
px4-nuttx-80c7601e254be30121a1b0922f70827d42ce262f.tar.bz2
px4-nuttx-80c7601e254be30121a1b0922f70827d42ce262f.zip
Networking: All Ethernet drivers: Call ipv6_input if IPv6 is enabled and an IPv6 packet is received
Diffstat (limited to 'nuttx/arch/arm/src/sama5/sam_gmac.c')
-rw-r--r--nuttx/arch/arm/src/sama5/sam_gmac.c62
1 files changed, 52 insertions, 10 deletions
diff --git a/nuttx/arch/arm/src/sama5/sam_gmac.c b/nuttx/arch/arm/src/sama5/sam_gmac.c
index 69a1a62ab..ba5789324 100644
--- a/nuttx/arch/arm/src/sama5/sam_gmac.c
+++ b/nuttx/arch/arm/src/sama5/sam_gmac.c
@@ -1107,18 +1107,18 @@ static void sam_receive(struct sam_gmac_s *priv)
{
nlldbg("DROPPED: Too big: %d\n", dev->d_len);
}
+ else
/* We only accept IP packets of the configured type and ARP packets */
-#ifdef CONFIG_NET_IPv6
- else if (BUF->type == HTONS(ETHTYPE_IP6))
-#else
- else if (BUF->type == HTONS(ETHTYPE_IP))
-#endif
+#ifdef CONFIG_NET_IPv4
+ if (BUF->type == HTONS(ETHTYPE_IP))
{
- nllvdbg("IP frame\n");
+ nllvdbg("IPv4 frame\n");
- /* Handle ARP on input then give the IP packet to uIP */
+ /* Handle ARP on input then give the IPv4 packet to the network
+ * layer
+ */
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@@ -1128,12 +1128,54 @@ static void sam_receive(struct sam_gmac_s *priv)
*/
if (priv->dev.d_len > 0)
+ {
+ /* 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 */
+
+ sam_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)
{
- arp_out(&priv->dev);
- sam_transmit(priv);
- }
+#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 */
+
+ sam_transmit(priv);
+ }
}
else
+#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{