diff options
author | Ramon Fried <rfried.dev@gmail.com> | 2019-07-18 21:43:30 +0300 |
---|---|---|
committer | Joe Hershberger <joe.hershberger@ni.com> | 2019-09-04 11:37:19 -0500 |
commit | 3eaac6307dff1e281f89fece521dc8a14078bf61 (patch) | |
tree | 9bc58bd8fde06dc4fc92a2ecfc7270a55d95b906 /net/eth_legacy.c | |
parent | 1bad991205780cd9f7ebdbdeb0d3a7d118f9f247 (diff) | |
download | u-boot-3eaac6307dff1e281f89fece521dc8a14078bf61.tar.gz u-boot-3eaac6307dff1e281f89fece521dc8a14078bf61.tar.bz2 u-boot-3eaac6307dff1e281f89fece521dc8a14078bf61.zip |
net: introduce packet capture support
Add support for capturing ethernet packets and storing
them in memory in PCAP(2.4) format, later to be analyzed by
any PCAP viewer software (IE. Wireshark)
This feature greatly assist debugging network issues such
as detecting dropped packets, packet corruption etc.
Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Alex Marginean <alexm.osslist@gmail.com>
Tested-by: Alex Marginean <alexm.osslist@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'net/eth_legacy.c')
-rw-r--r-- | net/eth_legacy.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/net/eth_legacy.c b/net/eth_legacy.c index 850f362d87..41f5263526 100644 --- a/net/eth_legacy.c +++ b/net/eth_legacy.c @@ -11,6 +11,7 @@ #include <net.h> #include <phy.h> #include <linux/errno.h> +#include <net/pcap.h> #include "eth_internal.h" DECLARE_GLOBAL_DATA_PTR; @@ -352,10 +353,17 @@ int eth_is_active(struct eth_device *dev) int eth_send(void *packet, int length) { + int ret; + if (!eth_current) return -ENODEV; - return eth_current->send(eth_current, packet, length); + ret = eth_current->send(eth_current, packet, length); +#if defined(CONFIG_CMD_PCAP) + if (ret >= 0) + pcap_post(packet, lengeth, true); +#endif + return ret; } int eth_rx(void) |