diff --git a/arch/arm/src/c5471/c5471_ethernet.c b/arch/arm/src/c5471/c5471_ethernet.c index 3f950c25ef6..7ea7e3d232b 100644 --- a/arch/arm/src/c5471/c5471_ethernet.c +++ b/arch/arm/src/c5471/c5471_ethernet.c @@ -62,6 +62,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "chip.h" #include "up_arch.h" #include "up_internal.h" @@ -1230,6 +1234,12 @@ static void c5471_receive(struct c5471_driver_s *c5471) nvdbg("Received packet, packetlen: %d type: %02x\n", packetlen, ntohs(BUF->type)); c5471_dumpbuffer("Received packet", dev->d_buf, dev->d_len); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index 08b273aa614..39aa02dea22 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -57,6 +57,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "chip.h" #include "kinetis_internal.h" @@ -514,6 +518,12 @@ static void kinetis_receive(FAR struct kinetis_driver_s *priv) putreg32(ENET_RDAR, KINETIS_ENET_RDAR); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/arm/src/lpc17xx/lpc17_ethernet.c b/arch/arm/src/lpc17xx/lpc17_ethernet.c index b37aed6c2d9..71ee88a435a 100644 --- a/arch/arm/src/lpc17xx/lpc17_ethernet.c +++ b/arch/arm/src/lpc17xx/lpc17_ethernet.c @@ -58,6 +58,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "chip.h" #include "chip/lpc17_syscon.h" @@ -872,6 +876,14 @@ static void lpc17_rxdone(struct lpc17_driver_s *priv) lpc17_dumppacket("Received packet", priv->lp_dev.d_buf, priv->lp_dev.d_len); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet + * tap. + */ + + pkt_input(&priv->lp_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c index 581a104c21e..45a3b333792 100644 --- a/arch/arm/src/sam34/sam_emac.c +++ b/arch/arm/src/sam34/sam_emac.c @@ -69,6 +69,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "up_internal.h" @@ -1136,8 +1140,14 @@ static void sam_receive(struct sam_emac_s *priv) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + continue; } - else + +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif /* We only accept IP packets of the configured type and ARP packets */ diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c index 51b1700fdd6..db362810741 100644 --- a/arch/arm/src/sama5/sam_emaca.c +++ b/arch/arm/src/sama5/sam_emaca.c @@ -70,6 +70,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "up_internal.h" #include "cache.h" @@ -1176,8 +1180,14 @@ static void sam_receive(struct sam_emac_s *priv) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + continue; } - else + +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif /* We only accept IP packets of the configured type and ARP packets */ diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c index 37fb8ea3388..7f0c3b4d60e 100644 --- a/arch/arm/src/sama5/sam_emacb.c +++ b/arch/arm/src/sama5/sam_emacb.c @@ -84,6 +84,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "up_internal.h" #include "cache.h" @@ -1502,8 +1506,14 @@ static void sam_receive(struct sam_emac_s *priv) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + continue; } - else + +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif /* We only accept IP packets of the configured type and ARP packets */ diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c index 1ed1e4b6029..689c614c4af 100644 --- a/arch/arm/src/sama5/sam_gmac.c +++ b/arch/arm/src/sama5/sam_gmac.c @@ -67,6 +67,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_arch.h" #include "up_internal.h" #include "cache.h" @@ -1106,8 +1110,14 @@ static void sam_receive(struct sam_gmac_s *priv) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + continue; } - else + +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif /* We only accept IP packets of the configured type and ARP packets */ diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index 4b3b982d909..22b22e43cbe 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -53,8 +53,8 @@ #include #include #include -#include +#include #include #include #if defined(CONFIG_NET_PKT) @@ -1612,8 +1612,14 @@ static void stm32_receive(FAR struct stm32_ethmac_s *priv) if (dev->d_len > CONFIG_NET_ETH_MTU) { nlldbg("DROPPED: Too big: %d\n", dev->d_len); + continue; } - else + +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif /* We only accept IP packets of the configured type and ARP packets */ diff --git a/arch/arm/src/tiva/lm3s_ethernet.c b/arch/arm/src/tiva/lm3s_ethernet.c index 6d1bdaa4fa1..bcfd7dd9c11 100644 --- a/arch/arm/src/tiva/lm3s_ethernet.c +++ b/arch/arm/src/tiva/lm3s_ethernet.c @@ -56,6 +56,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "chip.h" #include "up_arch.h" @@ -766,6 +770,12 @@ static void tiva_receive(struct tiva_driver_s *priv) priv->ld_dev.d_len = pktlen - 6; tiva_dumppacket("Received packet", priv->ld_dev.d_buf, priv->ld_dev.d_len); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->ld_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/hc/src/m9s12/m9s12_ethernet.c b/arch/hc/src/m9s12/m9s12_ethernet.c index caa25af5c93..bbba9d70993 100644 --- a/arch/hc/src/m9s12/m9s12_ethernet.c +++ b/arch/hc/src/m9s12/m9s12_ethernet.c @@ -55,6 +55,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + /**************************************************************************** * Definitions ****************************************************************************/ @@ -256,6 +260,12 @@ static void emac_receive(FAR struct emac_driver_s *priv) * amount of data in priv->d_dev.d_len */ +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->d_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/mips/src/pic32mx/pic32mx-ethernet.c b/arch/mips/src/pic32mx/pic32mx-ethernet.c index 872e68434f6..0d301db1d8d 100644 --- a/arch/mips/src/pic32mx/pic32mx-ethernet.c +++ b/arch/mips/src/pic32mx/pic32mx-ethernet.c @@ -60,6 +60,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include #include @@ -69,7 +73,7 @@ #include "pic32mx-ethernet.h" #include "pic32mx-internal.h" -/* Does this chip have and ethernet controller? */ +/* Does this chip have and Ethernet controller? */ #if CHIP_NETHERNET > 0 @@ -1429,6 +1433,14 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv) pic32mx_dumppacket("Received packet", priv->pd_dev.d_buf, priv->pd_dev.d_len); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet + * tap. + */ + + pkt_input(&priv->pd_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/sim/src/up_netdriver.c b/arch/sim/src/up_netdriver.c index 7f40cabb4bc..abffefc4326 100644 --- a/arch/sim/src/up_netdriver.c +++ b/arch/sim/src/up_netdriver.c @@ -56,6 +56,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "up_internal.h" /**************************************************************************** @@ -157,6 +161,14 @@ void netdriver_loop(void) if (g_sim_dev.d_len > ETH_HDRLEN && up_comparemac(BUF->ether_dhost, &g_sim_dev.d_mac) == 0) { +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet + * tap. + */ + + pkt_input(&g_sim_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/arch/z80/src/ez80/ez80_emac.c b/arch/z80/src/ez80/ez80_emac.c index 7c2e935d010..488dd18235e 100644 --- a/arch/z80/src/ez80/ez80_emac.c +++ b/arch/z80/src/ez80/ez80_emac.c @@ -60,6 +60,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include #include "chip.h" @@ -1268,6 +1272,12 @@ static int ez80emac_receive(struct ez80emac_driver_s *priv) ez80emac_rrp(), rwp, inp(EZ80_EMAC_BLKSLFT_H), inp(EZ80_EMAC_BLKSLFT_L)); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c index 16301cdf1d1..4002a078b7a 100644 --- a/drivers/net/cs89x0.c +++ b/drivers/net/cs89x0.c @@ -55,6 +55,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + /**************************************************************************** * Definitions ****************************************************************************/ @@ -387,10 +391,12 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq) { cd89x0->cs_stats.rx_lengtherrors++; } + if ((isq & RX_EXTRA_DATA) != 0) { cd89x0->cs_stats.rx_lengtherrors++; } + if (isq & RX_CRC_ERROR) != 0) { if (!(isq & (RX_EXTRA_DATA|RX_RUNT))) @@ -398,6 +404,7 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq) cd89x0->cs_stats.rx_crcerrors++; } } + if ((isq & RX_DRIBBLE) != 0) { cd89x0->cs_stats.rx_frameerrors++; @@ -431,6 +438,12 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq) cd89x0->cs_stats.rx_packets++; #endif +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&cs89x0->cs_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 @@ -454,7 +467,7 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq) /* Update the Ethernet header with the correct MAC address */ #ifdef CONFIG_NET_IPv6 - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(cs89x0->cs_dev.d_flags)) #endif { arp_out(&cs89x0->cs_dev); @@ -485,7 +498,7 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq) #ifdef CONFIG_NET_IPv4 /* Update the Ethernet header with the correct MAC address */ - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(cs89x0->cs_dev.d_flags)) { arp_out(&cs89x0->cs_dev); } diff --git a/drivers/net/dm90x0.c b/drivers/net/dm90x0.c index 1b2afdbb3c9..729cc3baaf7 100644 --- a/drivers/net/dm90x0.c +++ b/drivers/net/dm90x0.c @@ -68,6 +68,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + /**************************************************************************** * Definitions ****************************************************************************/ @@ -978,6 +982,12 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x) dm9x->dm_dev.d_len = rx.desc.rx_len; dm9x->dm_read(dm9x->dm_dev.d_buf, rx.desc.rx_len); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&dm9x->dm_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 @@ -1001,7 +1011,7 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x) /* Update the Ethernet header with the correct MAC address */ #ifdef CONFIG_NET_IPv6 - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(dm9x->dm_dev.d_flags)) #endif { arp_out(&dm9x->dm_dev); @@ -1032,7 +1042,7 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x) #ifdef CONFIG_NET_IPv4 /* Update the Ethernet header with the correct MAC address */ - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(dm9x->dm_dev.d_flags)) { arp_out(&dm9x->dm_dev); } diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 604bcaf51bf..543fa93b0a3 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -58,6 +58,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include #include #include @@ -565,6 +569,12 @@ static void e1000_receive(struct e1000_dev *e1000) memcpy(e1000->netdev.d_buf, cp, cnt); e1000->netdev.d_len = cnt; +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&e1000->netdev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 @@ -588,7 +598,7 @@ static void e1000_receive(struct e1000_dev *e1000) /* Update the Ethernet header with the correct MAC address */ #ifdef CONFIG_NET_IPv6 - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(e1000->netdev.d_flags)) #endif { arp_out(&e1000->netdev); @@ -619,7 +629,7 @@ static void e1000_receive(struct e1000_dev *e1000) #ifdef CONFIG_NET_IPv4 /* Update the Ethernet header with the correct MAC address */ - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(e1000->netdev.d_flags)) { arp_out(&e1000->netdev); } diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index defefb81c88..6516250c69a 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c @@ -66,6 +66,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "enc28j60.h" /**************************************************************************** @@ -1374,6 +1378,12 @@ static void enc_rxerif(FAR struct enc_driver_s *priv) static void enc_rxdispatch(FAR struct enc_driver_s *priv) { +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 @@ -1397,7 +1407,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv) /* Update the Ethernet header with the correct MAC address */ #ifdef CONFIG_NET_IPv6 - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(priv->dev.d_flags)) #endif { arp_out(&priv->dev); @@ -1428,7 +1438,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv) #ifdef CONFIG_NET_IPv4 /* Update the Ethernet header with the correct MAC address */ - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(priv->dev.d_flags)) { arp_out(&priv->dev); } diff --git a/drivers/net/encx24j600.c b/drivers/net/encx24j600.c index 035184cef44..e3dd1e8e725 100644 --- a/drivers/net/encx24j600.c +++ b/drivers/net/encx24j600.c @@ -72,6 +72,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include "encx24j600.h" /**************************************************************************** @@ -1493,6 +1497,12 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv) enc_rxldpkt(priv, descr); +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&priv->dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 @@ -1525,7 +1535,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv) /* Update the Ethernet header with the correct MAC address */ #ifdef CONFIG_NET_IPv6 - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(priv->dev.d_flags)) #endif { arp_out(&priv->dev); @@ -1565,7 +1575,7 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv) #ifdef CONFIG_NET_IPv4 /* Update the Ethernet header with the correct MAC address */ - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(priv->dev.d_flags)) { arp_out(&priv->dev); } diff --git a/drivers/net/skeleton.c b/drivers/net/skeleton.c index 61ac806d84e..38dc32181ce 100644 --- a/drivers/net/skeleton.c +++ b/drivers/net/skeleton.c @@ -60,6 +60,10 @@ # include #endif +#ifdef CONFIG_NET_PKT +# include +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -288,6 +292,12 @@ static void skel_receive(FAR struct skel_driver_s *skel) * amount of data in skel->sk_dev.d_len */ +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&skel->sk_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 @@ -311,7 +321,7 @@ static void skel_receive(FAR struct skel_driver_s *skel) /* Update the Ethernet header with the correct MAC address */ #ifdef CONFIG_NET_IPv6 - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(skel->sk_dev.d_flags)) #endif { arp_out(&skel->sk_dev); @@ -342,7 +352,7 @@ static void skel_receive(FAR struct skel_driver_s *skel) #ifdef CONFIG_NET_IPv4 /* Update the Ethernet header with the correct MAC address */ - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(skel->sk_dev.d_flags)) { arp_out(&skel->sk_dev); } diff --git a/drivers/net/vnet.c b/drivers/net/vnet.c index 02f348d74b9..db1665897e5 100644 --- a/drivers/net/vnet.c +++ b/drivers/net/vnet.c @@ -59,6 +59,10 @@ #include #include +#ifdef CONFIG_NET_PKT +# include +#endif + #include #include @@ -301,6 +305,12 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len) memcpy(vnet->sk_dev.d_buf, data, len); vnet->sk_dev.d_len = len; +#ifdef CONFIG_NET_PKT + /* When packet sockets are enabled, feed the frame into the packet tap */ + + pkt_input(&vnet->sk_dev); +#endif + /* We only accept IP packets of the configured type and ARP packets */ #ifdef CONFIG_NET_IPv4 @@ -324,7 +334,7 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len) /* Update the Ethernet header with the correct MAC address */ #ifdef CONFIG_NET_IPv6 - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(vnet->sk_dev.d_flags)) #endif { arp_out(&vnet->sk_dev); @@ -355,7 +365,7 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len) #ifdef CONFIG_NET_IPv4 /* Update the Ethernet header with the correct MAC address */ - if (BUF->type == HTONS(ETHTYPE_IP)) + if (IFF_IS_IPv4(vnet->sk_dev.d_flags)) { arp_out(&vnet->sk_dev); }