Networking: All Ethernet drivers: Call ipv6_input if IPv6 is enabled and an IPv6 packet is received

This commit is contained in:
Gregory Nutt 2015-01-15 09:31:23 -06:00
parent 836a8b1625
commit ac69e11a5f
14 changed files with 772 additions and 133 deletions

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/c5471/c5471_ethernet.c
*
* Copyright (C) 2007, 2009-2010, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009-2010, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Based one a C5471 Linux driver and released under this BSD license with
@ -1232,12 +1232,15 @@ static void c5471_receive(struct c5471_driver_s *c5471)
/* 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("IPv4 frame\n");
/* Handle ARP on input then give the IPv4 packet to the network
* layer
*/
arp_ipin(dev);
ipv4_input(dev);
@ -1250,10 +1253,56 @@ static void c5471_receive(struct c5471_driver_s *c5471)
if (dev->d_len > 0 &&
(EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
{
arp_out(dev);
c5471_transmit(c5471);
/* Update the Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv6
if (BUF->type == HTONS(ETHTYPE_IP))
#endif
{
arp_out(dev);
}
/* And send the packet */
c5471_transmit(c5471);
}
}
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(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.
* Send that data now if ESM has let go of the RX descriptor giving us
* access rights to submit another Ethernet frame.
*/
if (dev->d_len > 0 &&
(EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
{
#ifdef CONFIG_NET_IPv4
/* Update the Ethernet header with the correct MAC address */
if (BUF->type == HTONS(ETHTYPE_IP))
{
arp_out(dev);
}
#endif
/* And send the packet */
c5471_transmit(c5471);
}
}
else
#endif
#ifdef CONFIG_NET_ARP
else if (BUF->type == HTONS(ETHTYPE_ARP))
{

View File

@ -516,12 +516,15 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv)
/* 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("IPv4 frame\n");
/* Handle ARP on input then give the IPv4 packet to the network
* layer
*/
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@ -531,12 +534,55 @@ static void kinetis_receive(FAR struct kinetis_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 */
kinetis_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 */
kinetis_transmit(priv);
}
}
else
#endif
#ifdef CONFIG_NET_ARP
else if (BUF->type == htons(ETHTYPE_ARP))
if (BUF->type == htons(ETHTYPE_ARP))
{
arp_arpin(&priv->dev);

View File

@ -230,7 +230,12 @@ struct lpc17_statistics_s
uint32_t rx_ovrerrors; /* Number of Rx overrun error interrupts */
uint32_t rx_errors; /* Number of Rx error interrupts (OR of other errors) */
uint32_t rx_packets; /* Number of packets received (sum of the following): */
uint32_t rx_ip; /* Number of Rx IP packets received */
#ifdef CONFIG_NET_IPv4
uint32_t rx_ip; /* Number of Rx IPv4 packets received */
#endif
#ifdef CONFIG_NET_IPv6
uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */
#endif
uint32_t rx_arp; /* Number of Rx ARP packets received */
uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */
uint32_t rx_pkterr; /* Number of dropped, error in Rx descriptor */
@ -869,13 +874,14 @@ static void lpc17_rxdone(struct lpc17_driver_s *priv)
/* 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
{
/* Handle the incoming Rx packet */
nllvdbg("IPv4 frame\n");
/* Handle ARP on input then give the IPv4 packet to the
* network layer
*/
EMAC_STAT(priv, rx_ip);
arp_ipin(&priv->lp_dev);
@ -888,11 +894,55 @@ static void lpc17_rxdone(struct lpc17_driver_s *priv)
if (priv->lp_dev.d_len > 0)
{
arp_out(&priv->lp_dev);
/* Update the Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv6
if (BUF->type == HTONS(ETHTYPE_IP))
#endif
{
arp_out(&priv->lp_dev);
}
/* And send the packet */
lpc17_response(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 */
EMAC_STAT(priv, rx_ipv6);
ipv6_input(&priv->lp_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->lp_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->lp_dev);
}
#endif
/* And send the packet */
lpc17_response(priv);
}
}
else
#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{

View File

@ -1137,18 +1137,18 @@ static void sam_receive(struct sam_emac_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);
@ -1158,12 +1158,54 @@ static void sam_receive(struct sam_emac_s *priv)
*/
if (priv->dev.d_len > 0)
{
arp_out(&priv->dev);
sam_transmit(priv);
}
{
/* 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)
{
#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))
{

View File

@ -1177,33 +1177,75 @@ static void sam_receive(struct sam_emac_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);
/* 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)
{
/* 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);
#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))
{

View File

@ -1503,18 +1503,18 @@ static void sam_receive(struct sam_emac_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);
@ -1524,12 +1524,54 @@ static void sam_receive(struct sam_emac_s *priv)
*/
if (priv->dev.d_len > 0)
{
arp_out(&priv->dev);
sam_transmit(priv);
}
{
/* 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)
{
#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))
{

View File

@ -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)
{
arp_out(&priv->dev);
sam_transmit(priv);
}
{
/* 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)
{
#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))
{

View File

@ -1613,18 +1613,18 @@ static void stm32_receive(FAR struct stm32_ethmac_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);
@ -1634,12 +1634,54 @@ static void stm32_receive(FAR struct stm32_ethmac_s *priv)
*/
if (priv->dev.d_len > 0)
{
arp_out(&priv->dev);
stm32_transmit(priv);
}
{
/* 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 */
stm32_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 */
stm32_transmit(priv);
}
}
else
#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{

View File

@ -172,7 +172,12 @@ struct tiva_statistics_s
{
uint32_t rx_int; /* Number of Rx interrupts received */
uint32_t rx_packets; /* Number of packets received (sum of the following): */
uint32_t rx_ip; /* Number of Rx IP packets received */
#ifdef CONFIG_NET_IPv4
uint32_t rx_ip; /* Number of Rx IPv4 packets received */
#endif
#ifdef CONFIG_NET_IPv6
uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */
#endif
uint32_t rx_arp; /* Number of Rx ARP packets received */
uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */
uint32_t rx_pktsize; /* Number of dropped, too small or too big */
@ -763,15 +768,16 @@ static void tiva_receive(struct tiva_driver_s *priv)
/* We only accept IP packets of the configured type and ARP packets */
#ifdef CONFIG_NET_IPv6
if (ETHBUF->type == HTONS(ETHTYPE_IP6))
#else
#ifdef CONFIG_NET_IPv4
if (ETHBUF->type == HTONS(ETHTYPE_IP))
#endif
{
nllvdbg("IP packet received (%02x)\n", ETHBUF->type);
EMAC_STAT(priv, rx_ip);
nllvdbg("IPv4 frame\n");
/* Handle ARP on input then give the IPv4 packet to the network
* layer
*/
EMAC_STAT(priv, rx_ip);
arp_ipin(&priv->ld_dev);
ipv4_input(&priv->ld_dev);
@ -781,11 +787,55 @@ static void tiva_receive(struct tiva_driver_s *priv)
if (priv->ld_dev.d_len > 0)
{
arp_out(&priv->ld_dev);
/* Update the Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv6
if (ETHBUF->type == HTONS(ETHTYPE_IP))
#endif
{
arp_out(&priv->ld_dev);
}
/* And send the packet */
tiva_transmit(priv);
}
}
else
#endif
#ifdef CONFIG_NET_IPv6
if (ETHBUF->type == HTONS(ETHTYPE_IP6))
{
nllvdbg("Iv6 frame\n");
/* Give the IPv6 packet to the network layer */
EMAC_STAT(priv, rx_ipv6);
arp_ipin(&priv->ld_dev);
ipv6_input(&priv->ld_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 (ETHBUF->type == HTONS(ETHTYPE_IP))
{
arp_out(&priv->ld_dev);
}
#endif
/* And send the packet */
tiva_transmit(priv);
}
}
else
#endif
#ifdef CONFIG_NET_ARP
if (ETHBUF->type == htons(ETHTYPE_ARP))
{

View File

@ -1680,18 +1680,18 @@ static void tiva_receive(FAR struct tiva_ethmac_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))
{
nvdbg("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);
@ -1701,12 +1701,54 @@ static void tiva_receive(FAR struct tiva_ethmac_s *priv)
*/
if (priv->dev.d_len > 0)
{
arp_out(&priv->dev);
tiva_transmit(priv);
}
{
/* 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 */
tiva_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 */
tiva_transmit(priv);
}
}
else
#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{

View File

@ -1,7 +1,7 @@
/****************************************************************************
* drivers/net/m9s12_ethernet.c
*
* Copyright (C) 2011, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -258,12 +258,15 @@ static void emac_receive(FAR struct emac_driver_s *priv)
/* 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("IPv4 frame\n");
/* Handle ARP on input then give the IPv4 packet to the network
* layer
*/
arp_ipin(&priv->d_dev);
ipv4_input(&priv->d_dev);
@ -272,13 +275,56 @@ static void emac_receive(FAR struct emac_driver_s *priv)
*/
if (priv->d_dev.d_len > 0)
{
arp_out(&priv->d_dev);
emac_transmit(priv);
}
{
/* Update the Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv6
if (BUF->type == HTONS(ETHTYPE_IP))
#endif
{
arp_out(&priv->d_dev);
}
/* And send the packet */
emac_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->d_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->d_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->d_dev);
}
#endif
/* And send the packet */
emac_transmit(priv);
}
}
else
#endif
#ifdef CONFIG_NET_ARP
else if (BUF->type == htons(ETHTYPE_ARP))
if (BUF->type == htons(ETHTYPE_ARP))
{
arp_arpin(&priv->d_dev);

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/pic32mx/pic32mx_ethernet.c
*
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* This driver derives from the PIC32MX Ethernet Driver
@ -297,7 +297,12 @@ struct pic32mx_statistics_s
uint32_t rx_bufna; /* Number of Rx buffer not available errors */
uint32_t rx_buse; /* Number of Rx BVCI bus errors */
uint32_t rx_packets; /* Number of packets received (sum of the following): */
uint32_t rx_ip; /* Number of Rx IP packets received */
#ifdef CONFIG_NET_IPv4
uint32_t rx_ip; /* Number of Rx IPv4 packets received */
#endif
#ifdef CONFIG_NET_IPv6
uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */
#endif
uint32_t rx_arp; /* Number of Rx ARP packets received */
uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */
uint32_t rx_pkterr; /* Number of dropped, error in Rx descriptor */
@ -1426,13 +1431,14 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv)
/* 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
{
/* Handle the incoming IP packet */
nllvdbg("IPv4 frame\n");
/* Handle ARP on input then give the IPv4 packet to the network
* layer
*/
EMAC_STAT(priv, rx_ip);
arp_ipin(&priv->pd_dev);
@ -1445,11 +1451,55 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv)
if (priv->pd_dev.d_len > 0)
{
arp_out(&priv->pd_dev);
/* Update the Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv6
if (BUF->type == HTONS(ETHTYPE_IP))
#endif
{
arp_out(&priv->pd_dev);
}
/* And send the packet */
pic32mx_response(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 */
EMAC_STAT(priv, rx_ipv6);
ipv6_input(&priv->pd_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->pd_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->pd_dev);
}
#endif
/* And send the packet */
pic32mx_response(priv);
}
}
else
#endif
#ifdef CONFIG_NET_ARP
if (BUF->type == htons(ETHTYPE_ARP))
{

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/sim/src/up_netdriver.c
*
* Copyright (C) 2007, 2009-2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009-2012, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Based on code from uIP which also has a BSD-like license:
@ -159,12 +159,15 @@ void netdriver_loop(void)
{
/* We only accept IP packets of the configured type and ARP packets */
#ifdef CONFIG_NET_IPv6
if (BUF->ether_type == htons(ETHTYPE_IP6))
#else
if (BUF->ether_type == htons(ETHTYPE_IP))
#endif
#ifdef CONFIG_NET_IPv4
if (BUF->type == HTONS(ETHTYPE_IP))
{
nllvdbg("IPv4 frame\n");
/* Handle ARP on input then give the IPv4 packet to the network
* layer
*/
arp_ipin(&g_sim_dev);
ipv4_input(&g_sim_dev);
@ -175,12 +178,56 @@ void netdriver_loop(void)
if (g_sim_dev.d_len > 0)
{
arp_out(&g_sim_dev);
/* Update the Ethernet header with the correct MAC address */
#ifdef CONFIG_NET_IPv6
if (BUF->type == HTONS(ETHTYPE_IP))
#endif
{
arp_out(&g_sim_dev);
}
/* And send the packet */
netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
}
}
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(&g_sim_dev);
/* If the above function invocation resulted in data that
* should be sent out on the network, the global variable
* d_len is set to a value > 0.
*/
if (g_sim_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(&g_sim_dev);
}
#endif
/* And send the packet */
netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
}
}
else
#endif
#ifdef CONFIG_NET_ARP
else if (BUF->ether_type == htons(ETHTYPE_ARP))
if (BUF->ether_type == htons(ETHTYPE_ARP))
{
arp_arpin(&g_sim_dev);

View File

@ -1,7 +1,7 @@
/****************************************************************************
* drivers/net/ez80_emac.c
*
* Copyright (C) 2009-2010, 2012, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2010, 2012, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* References:
@ -246,18 +246,23 @@ struct ez80mac_statistics_s
{
uint32_t rx_int; /* Number of Rx interrupts received */
uint32_t rx_packets; /* Number of packets received (sum of the following): */
uint32_t rx_ip; /* Number of Rx IP packets received */
uint32_t rx_arp; /* Number of Rx ARP packets received */
uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */
uint32_t rx_nok; /* Number of Rx packets received without OK bit */
#ifdef CONFIG_NET_IPv4
uint32_t rx_ip; /* Number of Rx IPv4 packets received */
#endif
#ifdef CONFIG_NET_IPv6
uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */
#endif
uint32_t rx_arp; /* Number of Rx ARP packets received */
uint32_t rx_dropped; /* Number of dropped, unsupported Rx packets */
uint32_t rx_nok; /* Number of Rx packets received without OK bit */
uint32_t rx_errors; /* Number of Rx errors (rx_overerrors + rx_nok) */
uint32_t rx_ovrerrors; /* Number of FIFO overrun errors */
uint32_t rx_ovrerrors; /* Number of FIFO overrun errors */
uint32_t tx_int; /* Number of Tx interrupts received */
uint32_t tx_packets; /* Number of Tx descriptors queued */
uint32_t tx_errors; /* Number of Tx errors (sum of the following) */
uint32_t tx_abterrors; /* Number of aborted Tx descriptors */
uint32_t tx_fsmerrors; /* Number of Tx state machine errors */
uint32_t tx_timeouts; /* Number of Tx timeout errors */
uint32_t tx_abterrors; /* Number of aborted Tx descriptors */
uint32_t tx_fsmerrors; /* Number of Tx state machine errors */
uint32_t tx_timeouts; /* Number of Tx timeout errors */
uint32_t sys_int; /* Number of system interrupts received */
};
# define _MKFIELD(a,b,c) a->b##c
@ -1265,15 +1270,16 @@ static int ez80emac_receive(struct ez80emac_driver_s *priv)
/* We only accept IP packets of the configured type and ARP packets */
#ifdef CONFIG_NET_IPv6
if (ETHBUF->type == HTONS(ETHTYPE_IP6))
#else
#ifdef CONFIG_NET_IPv4
if (ETHBUF->type == HTONS(ETHTYPE_IP))
#endif
{
nvdbg("IP packet received (%02x)\n", ETHBUF->type);
EMAC_STAT(priv, rx_ip);
nllvdbg("IPv4 frame\n");
/* Handle ARP on input then give the IPv4 packet to the network
* layer
*/
EMAC_STAT(priv, rx_ip);
arp_ipin(&priv->dev);
ipv4_input(&priv->dev);
@ -1283,11 +1289,54 @@ static int ez80emac_receive(struct ez80emac_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 (ETHBUF->type == HTONS(ETHTYPE_IP))
#endif
{
arp_out(&priv->dev);
}
/* And send the packet */
ez80emac_transmit(priv);
}
}
else
#endif
#ifdef CONFIG_NET_IPv6
if (ETHBUF->type == HTONS(ETHTYPE_IP6))
{
nllvdbg("Iv6 frame\n");
/* Give the IPv6 packet to the network layer */
EMAC_STAT(priv, rx_ip);
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 (ETHBUF->type == HTONS(ETHTYPE_IP))
{
arp_out(&priv->dev);
}
#endif
/* And send the packet */
ez80emac_transmit(priv);
}
}
else
#endif
#ifdef CONFIG_NET_ARP
if (ETHBUF->type == htons(ETHTYPE_ARP))
{