diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c index d779d40f3a..16301cdf1d 100644 --- a/drivers/net/cs89x0.c +++ b/drivers/net/cs89x0.c @@ -430,14 +430,18 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq) #ifdef CONFIG_C89x0_STATISTICS cd89x0->cs_stats.rx_packets++; #endif + /* 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(&cs89x0->cs_dev); ipv4_input(&cs89x0->cs_dev); @@ -447,11 +451,55 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq) if (cs89x0->cs_dev.d_len > 0) { - arp_out(&cs89x0->cs_dev); + /* Update the Ethernet header with the correct MAC address */ + +#ifdef CONFIG_NET_IPv6 + if (BUF->type == HTONS(ETHTYPE_IP)) +#endif + { + arp_out(&cs89x0->cs_dev); + } + + /* And send the packet */ + cs89x0_transmit(cs89x0); } } - else if (BUF->type == htons(ETHTYPE_ARP)) + 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(&cs89x0->cs_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 (cs89x0->cs_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(&cs89x0->cs_dev); + } +#endif + + /* And send the packet */ + + cs89x0_transmit(cs89x0); + } + } + else +#endif +#ifdef CONFIG_NET_ARP + if (BUF->type == htons(ETHTYPE_ARP)) { arp_arpin(&cs89x0->cs_dev); @@ -464,6 +512,11 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq) cs89x0_transmit(cs89x0); } } + else +#endif + { + nllvdbg("Unrecognized packet type %02x\n", BUF->type); + } } /**************************************************************************** diff --git a/drivers/net/dm90x0.c b/drivers/net/dm90x0.c index f911a408fd..1b2afdbb3c 100644 --- a/drivers/net/dm90x0.c +++ b/drivers/net/dm90x0.c @@ -980,12 +980,15 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x) /* 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(&dm9x->dm_dev); ipv4_input(&dm9x->dm_dev); @@ -995,11 +998,55 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x) if (dm9x->dm_dev.d_len > 0) { - arp_out(&dm9x->dm_dev); + /* Update the Ethernet header with the correct MAC address */ + +#ifdef CONFIG_NET_IPv6 + if (BUF->type == HTONS(ETHTYPE_IP)) +#endif + { + arp_out(&dm9x->dm_dev); + } + + /* And send the packet */ + dm9x_transmit(dm9x); } } - else if (BUF->type == htons(ETHTYPE_ARP)) + 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(&dm9x->dm_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 (dm9x->dm_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(&dm9x->dm_dev); + } +#endif + + /* And send the packet */ + + dm9x_transmit(dm9x); + } + } + else +#endif +#ifdef CONFIG_NET_ARP + if (BUF->type == htons(ETHTYPE_ARP)) { arp_arpin(&dm9x->dm_dev); @@ -1012,6 +1059,7 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x) dm9x_transmit(dm9x); } } +#endif } #if defined(CONFIG_DM9X_STATS) diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 017df480da..604bcaf51b 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -567,12 +567,15 @@ static void e1000_receive(struct e1000_dev *e1000) /* 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(&e1000->netdev); ipv4_input(&e1000->netdev); @@ -582,11 +585,55 @@ static void e1000_receive(struct e1000_dev *e1000) if (e1000->netdev.d_len > 0) { - arp_out(&e1000->netdev); + /* Update the Ethernet header with the correct MAC address */ + +#ifdef CONFIG_NET_IPv6 + if (BUF->type == HTONS(ETHTYPE_IP)) +#endif + { + arp_out(&e1000->netdev); + } + + /* And send the packet */ + e1000_transmit(e1000); } } - else if (BUF->type == htons(ETHTYPE_ARP)) + 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(&e1000->netdev); + + /* 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 (e1000->netdev.d_len > 0) + { +#ifdef CONFIG_NET_IPv4 + /* Update the Ethernet header with the correct MAC address */ + + if (BUF->type == HTONS(ETHTYPE_IP)) + { + arp_out(&e1000->netdev); + } +#endif + + /* And send the packet */ + + e1000_transmit(e1000); + } + } + else +#endif +#ifdef CONFIG_NET_ARP + if (BUF->type == htons(ETHTYPE_ARP)) { arp_arpin(&e1000->netdev); @@ -598,6 +645,7 @@ static void e1000_receive(struct e1000_dev *e1000) { e1000_transmit(e1000); } +#endif } next: diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index 547a148f6b..defefb81c8 100644 --- a/drivers/net/enc28j60.c +++ b/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 if (BUF->type == htons(ETHTYPE_ARP)) + 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 +#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)); } diff --git a/drivers/net/encx24j600.c b/drivers/net/encx24j600.c index ae7d141d53..035184cef4 100644 --- a/drivers/net/encx24j600.c +++ b/drivers/net/encx24j600.c @@ -1495,20 +1495,21 @@ static void enc_rxdispatch(FAR struct enc_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("Try to process IP packet (%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); ret = ipv4_input(&priv->dev); if (ret == OK || (clock_systimer() - descr->ts) > ENC_RXTIMEOUT) { - /* If packet has been sucessfully processed or has timed out, + /* If packet has been successfully processed or has timed out, * free it. */ @@ -1521,11 +1522,64 @@ 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_txenqueue(priv); } } - else if (BUF->type == htons(ETHTYPE_ARP)) + else +#endif +#ifdef CONFIG_NET_IPv6 + if (BUF->type == HTONS(ETHTYPE_IP6)) + { + nllvdbg("Iv6 frame\n"); + + /* Give the IPv6 packet to the network layer */ + + ret = ipv6_input(&priv->dev); + + if (ret == OK || (clock_systimer() - descr->ts) > ENC_RXTIMEOUT) + { + /* If packet has been successfully processed or has timed out, + * free it. + */ + + enc_rxrmpkt(priv, descr); + } + + /* 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_txenqueue(priv); + } + } + else +#endif +#ifdef CONFIG_NET_ARP + if (BUF->type == htons(ETHTYPE_ARP)) { nllvdbg("ARP packet received (%02x)\n", BUF->type); arp_arpin(&priv->dev); @@ -1544,6 +1598,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv) } } else +#endif { /* free unsupported packet */ diff --git a/drivers/net/skeleton.c b/drivers/net/skeleton.c index e61fe61117..1a932c0566 100644 --- a/drivers/net/skeleton.c +++ b/drivers/net/skeleton.c @@ -286,12 +286,15 @@ static void skel_receive(FAR struct skel_driver_s *skel) /* 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(&skel->sk_dev); ipv4_input(&skel->sk_dev); @@ -300,12 +303,56 @@ static void skel_receive(FAR struct skel_driver_s *skel) */ if (skel->sk_dev.d_len > 0) - { - arp_out(&skel->sk_dev); - skel_transmit(skel); - } + { + /* Update the Ethernet header with the correct MAC address */ + +#ifdef CONFIG_NET_IPv6 + if (BUF->type == HTONS(ETHTYPE_IP)) +#endif + { + arp_out(&skel->sk_dev); + } + + /* And send the packet */ + + skel_transmit(skel); + } } - else if (BUF->type == htons(ETHTYPE_ARP)) + 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(&skel->sk_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 (skel->sk_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(&skel->sk_dev); + } +#endif + + /* And send the packet */ + + skel_transmit(skel); + } + } + else +#endif +#ifdef CONFIG_NET_ARP + if (BUF->type == htons(ETHTYPE_ARP)) { arp_arpin(&skel->sk_dev); @@ -318,6 +365,7 @@ static void skel_receive(FAR struct skel_driver_s *skel) skel_transmit(skel); } } +#endif } while (); /* While there are more packets to be processed */ } diff --git a/drivers/net/vnet.c b/drivers/net/vnet.c index 5190099a97..02f348d74b 100644 --- a/drivers/net/vnet.c +++ b/drivers/net/vnet.c @@ -303,12 +303,15 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len) /* 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(&vnet->sk_dev); ipv4_input(&vnet->sk_dev); @@ -318,11 +321,55 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len) if (vnet->sk_dev.d_len > 0) { - arp_out(&vnet->sk_dev); + /* Update the Ethernet header with the correct MAC address */ + +#ifdef CONFIG_NET_IPv6 + if (BUF->type == HTONS(ETHTYPE_IP)) +#endif + { + arp_out(&vnet->sk_dev); + } + + /* And send the packet */ + vnet_transmit(vnet); } } - else if (BUF->type == htons(ETHTYPE_ARP)) + 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(&vnet->sk_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 (vnet->sk_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(&vnet->sk_dev); + } +#endif + + /* And send the packet */ + + vnet_transmit(vnet); + } + } + else +#endif +#ifdef CONFIG_NET_ARP + if (BUF->type == htons(ETHTYPE_ARP)) { arp_arpin(&vnet->sk_dev); @@ -335,6 +382,7 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len) vnet_transmit(vnet); } } +#endif } while (0); /* While there are more packets to be processed */ }