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/net.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/net.c')
-rw-r--r-- | net/net.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -96,6 +96,9 @@ #include <net.h> #include <net/fastboot.h> #include <net/tftp.h> +#if defined(CONFIG_CMD_PCAP) +#include <net/pcap.h> +#endif #if defined(CONFIG_LED_STATUS) #include <miiphy.h> #include <status_led.h> @@ -672,6 +675,11 @@ done: net_set_icmp_handler(NULL); #endif net_set_state(prev_net_state); + +#if defined(CONFIG_CMD_PCAP) + if (pcap_active()) + pcap_print_status(); +#endif return ret; } @@ -1084,6 +1092,9 @@ void net_process_received_packet(uchar *in_packet, int len) debug_cond(DEBUG_NET_PKT, "packet received\n"); +#if defined(CONFIG_CMD_PCAP) + pcap_post(in_packet, len, false); +#endif net_rx_packet = in_packet; net_rx_packet_len = len; et = (struct ethernet_hdr *)in_packet; |