forked from nuttx/nuttx-update
Networking: All Ethernet drivers: Call ipv6_input if IPv6 is enabled and an IPv6 packet is received
This commit is contained in:
parent
168beae53c
commit
b648733589
7 changed files with 396 additions and 49 deletions
|
@ -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);
|
||||
|
||||
|
@ -446,12 +450,56 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq)
|
|||
*/
|
||||
|
||||
if (cs89x0->cs_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(&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);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -994,12 +997,56 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x)
|
|||
*/
|
||||
|
||||
if (dm9x->dm_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(&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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -581,12 +584,56 @@ static void e1000_receive(struct e1000_dev *e1000)
|
|||
*/
|
||||
|
||||
if (e1000->netdev.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(&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:
|
||||
|
|
|
@ -1376,13 +1376,15 @@ 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("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);
|
||||
|
||||
|
@ -1391,12 +1393,56 @@ static void enc_rxdispatch(FAR struct enc_driver_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 */
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
||||
|
@ -1520,12 +1521,65 @@ static void enc_rxdispatch(FAR struct enc_driver_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 */
|
||||
|
||||
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 */
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
/* 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 */
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -317,12 +320,56 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len)
|
|||
*/
|
||||
|
||||
if (vnet->sk_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(&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 */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue