From patchwork Sat Jun 22 18:49:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramon Fried X-Patchwork-Id: 1120713 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="o69W5W/k"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45WPkf47Shz9s3C for ; Sun, 23 Jun 2019 04:50:16 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EB262C21E2C; Sat, 22 Jun 2019 18:50:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3DEFEC21C93; Sat, 22 Jun 2019 18:50:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4EB15C21C93; Sat, 22 Jun 2019 18:50:07 +0000 (UTC) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by lists.denx.de (Postfix) with ESMTPS id 02BCDC21C57 for ; Sat, 22 Jun 2019 18:50:07 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id f17so9558608wme.2 for ; Sat, 22 Jun 2019 11:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZyUWq40GfYk5tJADYOFEGAhOJf0SRFofST8DewfkGTk=; b=o69W5W/khVRlKSm3qhVCuhkCFBgeBvOKCb86zVo1C7QhXQFfSduqgv4yRFsnJBoUTU uLTxMpXoI2KAXWx/VuAyJYWb3Cf/PeIOkI9Af7Q7BkP6t6/eD6sEQj0nIKObG/1SgOOg w2Npcm62IsTBsfySqx4zLY18ZeGDIX6moH2dZ20hEbgAhDIWLNbhvxel/6QAHDFlCFe6 u/H414Xtpzbnq2Gj43NbijAwu9ljukArgrbdfI9oI6mwNAeXhZfMXrW7K/Q4rIiZiKMa qI/p9Wk+QknctCFKm/UZqNlFpnCLLpq3SfLJ0NaBhjgakibNRR1MJOn9ol3mtuAvaWbM voow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZyUWq40GfYk5tJADYOFEGAhOJf0SRFofST8DewfkGTk=; b=te3lH6xYOmYMrcfKjXNbwanvNv8fA3TKleznidezf+mgSIuRwkD7UQzXqT5KOw05Aw 1HfiIAp604ewHnqdho3vNF8sKICWkRGbkGIrA8QubJKUd9HG4ZCD691OLbAPmck8DyB7 XsF5UpHL+mRlMUBfVy3SnZTmY1HffSp/CLXwBxKJdpYFIPBOqKfBLCTaLW/FCzyMTmwH U3I2u9cJSJo5OI9RtsMpIF27wvq5E0cHzKZG4BJ41uO3fvCAybWXPGz3eKjEaGM3qVDK Wp9tyJcuHuCD4RwZ5OTmdmGcxQOyrzl4bxHRLpS6wOjatkDugg1RSwwgPDKxShEwi5Hb hwVA== X-Gm-Message-State: APjAAAUM5A76L/0Nc2+a+Rwo3Ah0Rr/7MB5c+WV3isun5OoLLnDJERsJ hol0Lk8Os0uKhzSAbUQI9yc= X-Google-Smtp-Source: APXvYqysB3PWWRjctD1ASE6JoRwMRnODZi3SuytZsNo3P8Gkc83TpPjFadTcVqle14nn4p4ZL5cPhQ== X-Received: by 2002:a1c:a019:: with SMTP id j25mr8960766wme.95.1561229406420; Sat, 22 Jun 2019 11:50:06 -0700 (PDT) Received: from localhost.localdomain ([141.226.31.91]) by smtp.gmail.com with ESMTPSA id u25sm5434367wmc.3.2019.06.22.11.50.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 22 Jun 2019 11:50:05 -0700 (PDT) From: Ramon Fried To: joe.hershberger@ni.com Date: Sat, 22 Jun 2019 21:49:49 +0300 Message-Id: <20190622184950.16454-1-rfried.dev@gmail.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Cc: DH@Synoia.com, u-boot@lists.denx.de, lothar.felten@gmail.com, judge.packham@gmail.com Subject: [U-Boot] [PATCH v3 1/2] net: introduce packet capture support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- v2: Fix type assignmnet to header.ts_sec v3: Several suggestion changes by Bin and Alex: * Change to implementation to command based. * Added counters for incoming/outgoing packets. * Support clearing the capture for multiple captures. * Added documentation (separate patch). cmd/Kconfig | 7 +++ cmd/net.c | 63 +++++++++++++++++++++ include/net.h | 56 +++++++++++++++++++ net/Makefile | 1 + net/net.c | 8 +++ net/pcap.c | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 287 insertions(+) create mode 100644 net/pcap.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 0badcb3fe0..638f979f28 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1239,6 +1239,13 @@ config BOOTP_NTPSERVER bool "Request & store 'ntpserverip' from BOOTP/DHCP server" depends on CMD_BOOTP +config CMD_PCAP + bool "pcap capture" + help + Selecting this will allow capturing all Ethernet packets and store + them in physical memory in a PCAP formated file, + later to be analyzed by PCAP reader application (IE. WireShark). + config BOOTP_PXE bool "Send PXE client arch to BOOTP/DHCP server" default y diff --git a/cmd/net.c b/cmd/net.c index 89721b8f8b..5022f1dbcc 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -457,3 +457,66 @@ U_BOOT_CMD( ); #endif /* CONFIG_CMD_LINK_LOCAL */ + +#if defined(CONFIG_CMD_PCAP) +static int do_pcap_init(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + phys_addr_t addr; + unsigned int size; + + if (argc != 3) + return CMD_RET_USAGE; + + addr = simple_strtoul(argv[1], NULL, 16); + size = simple_strtoul(argv[2], NULL, 10); + + return pcap_init(addr, size) ? CMD_RET_FAILURE : CMD_RET_SUCCESS; +} + +static int do_pcap_start(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + return pcap_start_stop(true) ? CMD_RET_FAILURE : CMD_RET_SUCCESS; +} + +static int do_pcap_stop(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + return pcap_start_stop(false) ? CMD_RET_FAILURE : CMD_RET_SUCCESS; +} + +static int do_pcap_status(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + return pcap_print_status() ? CMD_RET_FAILURE : CMD_RET_SUCCESS; +} + +static int do_pcap_clear(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + return pcap_clear() ? CMD_RET_FAILURE : CMD_RET_SUCCESS; +} + +static char pcap_help_text[] = + "- network packet capture\n\n" + "pcap\n" + "pcap init\t\t\t \n" + "pcap start\t\t\tstart capture\n" + "pcap stop\t\t\tstop capture\n" + "pcap status\t\t\tprint status\n" + "pcap clear\t\t\tclear capture buffer\n" + "\n" + "With:\n" + "\t: user address to which pcap will be stored (hexedcimal)\n" + "\t: Maximum size of pcap file (decimal)\n" + "\n"; + +U_BOOT_CMD_WITH_SUBCMDS(pcap, "pcap", pcap_help_text, + U_BOOT_SUBCMD_MKENT(init, 3, 0, do_pcap_init), + U_BOOT_SUBCMD_MKENT(start, 1, 0, do_pcap_start), + U_BOOT_SUBCMD_MKENT(stop, 1, 0, do_pcap_stop), + U_BOOT_SUBCMD_MKENT(status, 1, 0, do_pcap_status), + U_BOOT_SUBCMD_MKENT(clear, 1, 0, do_pcap_clear), +); +#endif /* CONFIG_CMD_PCAP */ diff --git a/include/net.h b/include/net.h index 44b32385c4..f0289c3cde 100644 --- a/include/net.h +++ b/include/net.h @@ -630,6 +630,58 @@ bool arp_is_waiting(void); /* Waiting for ARP reply? */ void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */ void net_set_timeout_handler(ulong, thand_f *);/* Set timeout handler */ +/* PCAP extension */ + +/** + * pcap_init() - Initialize PCAP memory buffer + * + * @paddr physicaly memory address to store buffer + * @size maximum size of capture file in memory + * + * @return 0 on success, -ERROR on error + */ +int pcap_init(phys_addr_t paddr, unsigned long size); + +/** + * pcap_start_stop() - start / stop pcap capture + * + * @start if true, start capture if false stop capture + * + * @return 0 on success, -ERROR on error + */ +int pcap_start_stop(bool start); + +/** + * pcap_clear() - clear pcap capture buffer and statistics + * + * @return 0 on success, -ERROR on error + */ +int pcap_clear(void); + +/** + * pcap_print_status() - print status of pcap capture + * + * @return 0 on success, -ERROR on error + */ +int pcap_print_status(void); + +/** + * pcap_active() - check if pcap is enabled + * + * @return TRUE if active, FALSE if not. + */ +bool pcap_active(void); + +/** + * pcap_post() - Post a packet to PCAP file + * + * @packet: packet to post + * @len: packet length in bytes + * @outgoing packet direction (outgoing/incoming) + * @return 0 on success, -ERROR on error + */ +int pcap_post(const void *packet, size_t len, bool outgoing); + /* Network loop state */ enum net_loop_state { NETLOOP_CONTINUE, @@ -658,6 +710,10 @@ static inline void net_send_packet(uchar *pkt, int len) { /* Currently no way to return errors from eth_send() */ (void) eth_send(pkt, len); + +#if defined(CONFIG_CMD_PCAP) + pcap_post(pkt, len, true); +#endif } /* diff --git a/net/Makefile b/net/Makefile index ce36362168..d70a7c6834 100644 --- a/net/Makefile +++ b/net/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_NET) += net.o obj-$(CONFIG_CMD_NFS) += nfs.o obj-$(CONFIG_CMD_PING) += ping.o +obj-$(CONFIG_CMD_PCAP) += pcap.o obj-$(CONFIG_CMD_RARP) += rarp.o obj-$(CONFIG_CMD_SNTP) += sntp.o obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o diff --git a/net/net.c b/net/net.c index 58b0417cbe..b6b5a49153 100644 --- a/net/net.c +++ b/net/net.c @@ -671,6 +671,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; } @@ -1083,6 +1088,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; diff --git a/net/pcap.c b/net/pcap.c new file mode 100644 index 0000000000..071bfeb510 --- /dev/null +++ b/net/pcap.c @@ -0,0 +1,152 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 Ramon Fried + */ + +#include +#include +#include +#include + +#define LINKTYPE_ETHERNET 1 + +static bool initialized; +static bool running; +static bool buffer_full; +static void *buf; +static unsigned int max_size; +static unsigned int pos; + +static unsigned long incoming_count; +static unsigned long outgoing_count; + +struct pcap_header { + u32 magic; + u16 version_major; + u16 version_minor; + s32 thiszone; + u32 sigfigs; + u32 snaplen; + u32 network; +}; + +struct pcap_packet_header { + u32 ts_sec; + u32 ts_usec; + u32 incl_len; + u32 orig_len; +}; + +static struct pcap_header file_header = { + .magic = 0xa1b2c3d4, + .version_major = 2, + .version_minor = 4, + .snaplen = 65535, + .network = LINKTYPE_ETHERNET, +}; + +int pcap_init(phys_addr_t paddr, unsigned long size) +{ + buf = map_physmem(paddr, size, 0); + if (!buf) { + printf("Failed mapping PCAP memory\n"); + return -ENOMEM; + } + + printf("PCAP capture initialized: addr: 0x%lx max length: %lu\n", + (unsigned long)buf, size); + + memcpy(buf, &file_header, sizeof(file_header)); + pos = sizeof(file_header); + max_size = size; + initialized = true; + running = false; + buffer_full = false; + incoming_count = 0; + outgoing_count = 0; + return 0; +} + +int pcap_start_stop(bool start) +{ + if (!initialized) { + printf("error: pcap was not initialized\n"); + return -ENODEV; + } + + running = start; + + return 0; +} + +int pcap_clear(void) +{ + if (!initialized) { + printf("error: pcap was not initialized\n"); + return -ENODEV; + } + + pos = sizeof(file_header); + incoming_count = 0; + outgoing_count = 0; + buffer_full = false; + + printf("pcap capture cleared\n"); + return 0; +} + +int pcap_post(const void *packet, size_t len, bool outgoing) +{ + struct pcap_packet_header header; + u64 cur_time = timer_get_us(); + + if (!initialized || !running || !buf) + return -ENODEV; + + if ((pos + len + sizeof(header)) >= max_size) { + buffer_full = true; + return -ENOMEM; + } + + header.ts_sec = cur_time / 1000000; + header.ts_usec = cur_time % 1000000; + header.incl_len = len; + header.orig_len = len; + + memcpy(buf + pos, &header, sizeof(header)); + pos += sizeof(header); + memcpy(buf + pos, packet, len); + pos += len; + + if (outgoing) + outgoing_count++; + else + incoming_count++; + + return 0; +} + +int pcap_print_status(void) +{ + if (!initialized) { + printf("pcap was not initialized\n"); + return -ENODEV; + } + printf("PCAP status:\n"); + printf("\tInitialized addr: 0x%lx\tmax length: %u\n", + (unsigned long)buf, max_size); + printf("\tStatus: %s.\t file size: %u\n", running ? "Active" : "Idle", + pos); + printf("\tIncoming packets: %lu Outgoing packets: %lu\n", + incoming_count, outgoing_count); + + if (buffer_full) + printf("\t!!! Buffer is full, consider increasing buffer size !!!\n"); + + return 0; +} + +bool pcap_active(void) +{ + return running; +} From patchwork Sat Jun 22 18:49:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramon Fried X-Patchwork-Id: 1120714 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vhmdrsIa"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45WPlD6yqGz9s3C for ; Sun, 23 Jun 2019 04:50:48 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 7868FC21E62; Sat, 22 Jun 2019 18:50:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E6704C21E73; Sat, 22 Jun 2019 18:50:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8481EC21E42; Sat, 22 Jun 2019 18:50:19 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by lists.denx.de (Postfix) with ESMTPS id 69732C21E3B for ; Sat, 22 Jun 2019 18:50:14 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id v14so9662241wrr.4 for ; Sat, 22 Jun 2019 11:50:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UFzSg1YOBvJ+vEK2GtiUYS1FYjBEaghhGilisIed0VI=; b=vhmdrsIaj1bFfe6EkVS2NtnfQRe4JQ8PlmP/ooCROMxWlG50sGgUualj20a2CLcJmR E6WjZJma/vkyTIO8DOga30jni9HRe/TijOdHo9D1CsWwC5yczTyEDzAOJKhwQfqgv7IP kc+eaB3wJKUBM9yvm9uLGZ2p4/OiST/BpMyt7qbDDUQe+8CzkjocXsgqv63cT7J/WDrd tFz/qJJeiqgtG+sDAqsdJ3jssW/dj3YhmI3a7mmSTnAeh34BEijAxYM4otqHulFVLdKG cc7hmWXDSYaqRweGMBBpUQHiJGMBRd1M2rHQvQXn1sKrHTmqvaNXxpKUpFYNARDVnKKB G03w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UFzSg1YOBvJ+vEK2GtiUYS1FYjBEaghhGilisIed0VI=; b=jZ6tGnChfi89r9DhVaWjt4ydtJxlBPryQmATeHJrJ2s5xbSl4/UWrVsJbUovAUFG7R lupBnYHxQ1o2gkzR5tu6rheVLgga/swVturxxOryoSkqmHtaUblF5Oq70JidddE9QzPY qCmnapl36sPybzowE/piW4gwXL7UFamLVOeKTxBIftFSYZTf6Lb44ivp2ebxG/GE8gT6 USlGCfPRccPr9Vu52yfPP0aud/3/yvFJt03CYZic5kkFbiFXDW96XOazSIphz4MmsYBA dTUAghI0GGERQtGv2rVwYh3JvjXB88Ayx2oVhLjY4FGrxbZ/7FTDWJGwbh7J3l625OO7 /8SA== X-Gm-Message-State: APjAAAUOyo4p0wa5HEoOibmENB0oCCbgrGI4Zd9H7YhblFUtAqdW9+h5 RL6EevSV0OjPnAqiH2BNEw4= X-Google-Smtp-Source: APXvYqxZXHwAhCrLc3wA8mGR97m7fwItK9eKFZ5HRkr6LFc3heuc9W/tH5QO1/48fEjt1+1jsc/wJg== X-Received: by 2002:adf:f181:: with SMTP id h1mr6156161wro.18.1561229414063; Sat, 22 Jun 2019 11:50:14 -0700 (PDT) Received: from localhost.localdomain ([141.226.31.91]) by smtp.gmail.com with ESMTPSA id u25sm5434367wmc.3.2019.06.22.11.50.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 22 Jun 2019 11:50:13 -0700 (PDT) From: Ramon Fried To: joe.hershberger@ni.com Date: Sat, 22 Jun 2019 21:49:50 +0300 Message-Id: <20190622184950.16454-2-rfried.dev@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190622184950.16454-1-rfried.dev@gmail.com> References: <20190622184950.16454-1-rfried.dev@gmail.com> MIME-Version: 1.0 Cc: DH@Synoia.com, u-boot@lists.denx.de, lothar.felten@gmail.com, judge.packham@gmail.com Subject: [U-Boot] [PATCH 2/2] doc: pcap: add pcap cmd documentation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add documentation for new "pcap" command. Signed-off-by: Ramon Fried --- doc/README.pcap | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 doc/README.pcap diff --git a/doc/README.pcap b/doc/README.pcap new file mode 100644 index 0000000000..25c85ae271 --- /dev/null +++ b/doc/README.pcap @@ -0,0 +1,61 @@ +PCAP: + +U-boot supports live ethernet packet capture in PCAP(2.4) format. +This is enabled by CONFIG_CMD_PCAP. + +The capture is stored on physical memory, and should be copied to +a machine capabale of parsing and displaying PCAP files (IE. wireshark) +If networking works properly one can copy the capture file from physical memory +using tftpput, or save it to local storage with (sf write, mmc write, fatwrite, etc) + +the pcap capturing requires maximum buffer size. +when the buffer is full, packets will silently drop. +check the status using "pcap status" to see if the buffer is full, +if so, consider increasing the buffer size. + +Usage example: + +# Initialize pcap capture to physical address (0x100000) with maximum size of 100000. +# Start capture +pcap start + +# Initialize network activity +env set ipaddr 10.0.2.15; env set serverip 10.0.2.2; tftp uImage64 + +# Stop capture +pcap stop + +# pcap init 0x100000 100000 +PCAP capture initialized: addr: 0xffffffff80100000 max length: 100000 + +# pcap start +# env set ipaddr 10.0.2.15; env set serverip 10.0.2.2; tftp uImage64 +eth0@10000000: PHY present at 0 +eth0@10000000: link up, 1000Mbps full-duplex (lpa: 0x7c00) +Using eth0@10000000 device +TFTP from server 10.0.2.2; our IP address is 10.0.2.15 +Filename 'uImage64'. +Load address: 0xffffffff88000000 +Loading: ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + # + 18.2 MiB/s +done +Bytes transferred = 8359376 (7f8dd0 hex) +PCAP status: + Initialized addr: 0xffffffff80100000 max length: 100000 + Status: Active. file size: 99991 + Incoming packets: 66 Outgoing packets: 67 + !!! Buffer is full, consider increasing buffer size !!! + + +# pcap stop +# tftpput 0xffffffff80100000 100000 10.0.2.2:capture.pcap +