diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2015-01-15 10:25:53 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2015-01-15 10:25:53 -0600 |
commit | 4379476f527df2c50023d6b5cb2fce1ad15fc6e3 (patch) | |
tree | a3a293150b56c21c42904409a30c580662583975 /nuttx/drivers/net/enc28j60.c | |
parent | 20005a3c607ae8cf232e0cf2953471fc45ccf10d (diff) | |
download | px4-nuttx-4379476f527df2c50023d6b5cb2fce1ad15fc6e3.tar.gz px4-nuttx-4379476f527df2c50023d6b5cb2fce1ad15fc6e3.tar.bz2 px4-nuttx-4379476f527df2c50023d6b5cb2fce1ad15fc6e3.zip |
Networking: All Ethernet drivers: Call ipv6_input if IPv6 is enabled and an IPv6 packet is received
Diffstat (limited to 'nuttx/drivers/net/enc28j60.c')
-rw-r--r-- | nuttx/drivers/net/enc28j60.c | 63 |
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)); } |