From 3eaac6307dff1e281f89fece521dc8a14078bf61 Mon Sep 17 00:00:00 2001 From: Ramon Fried Date: Thu, 18 Jul 2019 21:43:30 +0300 Subject: 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 Reviewed-by: Alex Marginean Tested-by: Alex Marginean Acked-by: Joe Hershberger --- net/eth_legacy.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'net/eth_legacy.c') 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 #include #include +#include #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) -- cgit