From patchwork Wed Nov 6 13:02:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adriano Cordova X-Patchwork-Id: 2007569 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=E4QDFPga; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xk6dY2z2Nz1xyW for ; Thu, 7 Nov 2024 01:14:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5A400891E3; Wed, 6 Nov 2024 15:13:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E4QDFPga"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1766788C7C; Wed, 6 Nov 2024 14:03:04 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D9E9A891BC for ; Wed, 6 Nov 2024 14:03:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=adrianox@gmail.com Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-71ec997ad06so5388101b3a.3 for ; Wed, 06 Nov 2024 05:03:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730898180; x=1731502980; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2ZlPUz7aCKgGULHI6YF2jOoKlukgWCucAuSDsUlQjlQ=; b=E4QDFPgaKKZXKVLKRqzRQI1DYt3xWwGIY6TD6dkIZA7qJFSMHMSxgDkw8eYEdJA+ml IUWHzvWztfFlCJUKpXWHfA7elXtEkNak78uPtqzLmufT9dUbjWf59I72QcwBVLJhAy9k Ch8U+QlpQ1D/a0y6ko5SXRbfdUDkb2N9G4rkNJXLq2zrs9zN7FvtX/2qLS7gyCAMT0E9 0lk2QUzdzaAsS9aRY7xnYF26UqcxCs5NZfMy1Uf0nAoguUcWov3dlx14mHOOeZV9XGes 3an1fedw/dRgLBG8gJagR+x/g1C2oUNRwJVrm9I7Vrt/pQpalpv3313VgxxzhRHij3f0 BTqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730898180; x=1731502980; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2ZlPUz7aCKgGULHI6YF2jOoKlukgWCucAuSDsUlQjlQ=; b=fjLleFK+QklLdfjJWJSTxQ7siXjgKaJJ4E0PNqUqrN+vr72IBYCX9ZOABqd/+6HdCU ULRlVlJ5WPzfWKuvBIevdUlDRqTTn1yRJPdtfHeAzkbwqEL+gWkK6hzcYJsTmChmYgEV IZiLL8hIa1yMPJoLwwUKTnD0Qh3x/XO6y3W4zKmHlgZ5eF+UL0pWgvlYkZC9aSiKgNbR buUkKAK64x0acbpPSCsor7EGXRWJgR7abt12S+BECgTwf2SqopVjOkWanvlvAzz0CYXe a+Wjv7ly4EnXqZevtIKVlxDbpmjlvWMf3NNmTZGQxnkAeOcO8zi2OyrB9uEf+tAUn8p1 LDaw== X-Gm-Message-State: AOJu0YzOPVKwcSjEfRhZuoR1cTwASqHoAF/v+hJohXiAwhDUUoH8dc9q yHqJQaKenpgNiWg234KVsKlLEi6zniiNAyDoMOwZNWzrbB0ATQIAo4klfM9Ia7E= X-Google-Smtp-Source: AGHT+IH/YZqQZ5OUd3hZu1BlF3PDNhZgihFHTyGbJGeYeK7Y7wyhs0KIbGqdvUrIVYlFXTaQUCaqcw== X-Received: by 2002:a05:6a00:4644:b0:71e:7636:3323 with SMTP id d2e1a72fcca58-720ab3babdemr34706090b3a.7.1730898180248; Wed, 06 Nov 2024 05:03:00 -0800 (PST) Received: from adriano.. ([191.119.55.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-720bc1c9fd4sm11650134b3a.22.2024.11.06.05.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 05:02:59 -0800 (PST) From: Adriano Cordova To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, rfried.dev@gmail.com, jerome.forissier@linaro.org, xypron.glpk@gmx.de, Adriano Cordova Subject: [PATCH 1/7] net: Kconfig: add CONFIG_WGET symbol Date: Wed, 6 Nov 2024 10:02:55 -0300 Message-ID: <20241106130255.211041-1-adrianox@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 06 Nov 2024 15:13:43 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Let net/wget.c and net/lwip/wget.c depend on CONFIG_WGET, and cmd/wget.c depend on CONFIG_CMD_WGET. This way, the wget code can be used regardless of whether the wget command is available. Signed-off-by: Adriano Cordova --- cmd/Kconfig | 5 +---- net/Kconfig | 9 +++++++++ net/Makefile | 2 +- net/lwip/Makefile | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 636833646f..8f3ad94089 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2115,11 +2115,8 @@ config CMD_TFTPBOOT config CMD_WGET bool "wget" - depends on CMD_NET default y if SANDBOX - select PROT_TCP if NET - select PROT_TCP_LWIP if NET_LWIP - select PROT_DNS_LWIP if NET_LWIP + select WGET help wget is a simple command to download kernel, or other files, from a http server over TCP. diff --git a/net/Kconfig b/net/Kconfig index 76ab7d91ee..b4bb68dd61 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -244,6 +244,15 @@ config NET_RANDOM_ETHADDR generated. It will be saved to the appropriate environment variable, too. +config WGET + bool "Enable wget" + select PROT_TCP if NET + select PROT_TCP_LWIP if NET_LWIP + select PROT_DNS_LWIP if NET_LWIP + help + Selecting this will enable wget, an interface to send HTTP requests + via the network stack. + config TFTP_BLOCKSIZE int "TFTP block size" default 1468 diff --git a/net/Makefile b/net/Makefile index 209377aeb2..7c917b318c 100644 --- a/net/Makefile +++ b/net/Makefile @@ -29,7 +29,7 @@ obj-$(CONFIG_$(PHASE_)TCP_FUNCTION_FASTBOOT) += fastboot_tcp.o obj-$(CONFIG_CMD_WOL) += wol.o obj-$(CONFIG_PROT_UDP) += udp.o obj-$(CONFIG_PROT_TCP) += tcp.o -obj-$(CONFIG_CMD_WGET) += wget.o +obj-$(CONFIG_WGET) += wget.o # Disable this warning as it is triggered by: # sprintf(buf, index ? "foo%d" : "foo", index) diff --git a/net/lwip/Makefile b/net/lwip/Makefile index f2558f8763..79dd6b3fb5 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -5,4 +5,4 @@ obj-$(CONFIG_CMD_DHCP) += dhcp.o obj-$(CONFIG_CMD_DNS) += dns.o obj-$(CONFIG_CMD_PING) += ping.o obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o -obj-$(CONFIG_CMD_WGET) += wget.o +obj-$(CONFIG_WGET) += wget.o From patchwork Wed Nov 6 13:03:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adriano Cordova X-Patchwork-Id: 2007570 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=cWTryvzT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xk6dj1xSVz1xyW for ; Thu, 7 Nov 2024 01:14:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ADF2F891E9; Wed, 6 Nov 2024 15:13:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cWTryvzT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C31D891D2; Wed, 6 Nov 2024 14:03:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 50686891BC for ; Wed, 6 Nov 2024 14:03:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=adrianox@gmail.com Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-21116b187c4so48005615ad.3 for ; Wed, 06 Nov 2024 05:03:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730898207; x=1731503007; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nTcq1xsSMSqUo9ODZN+EvP0e3Vg3LWs2Mru9xD3rYU0=; b=cWTryvzTzBpG2PiZZLOmMoA6gGbs0UVTkCI2QW2rnrVBGJeydQb6cbIPlI0ozn7Mch jdYvuV512dOyjqBEFKeGQjDAKG8qImEQAycui97AJFTckS5L0n/hiu7IY02js9V54s4Z eNloys6xjsri5PS4XYOx8i5PeB7x28o0de/jqzzJb0lHe7C1bzjid/71tYvlMV4KmJus FgW/YEr/92/XzMd+25qdwkKT5QSzSH729XQitjJZexgN54ZPxpGO9k95EYgu47E7HxFO 3sE0mijKORVXE4IQbrI3kT7lT/907WxC+LPVRvjmkn2Kj0o5jakqBqDBuAay+/Scl/mG KdDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730898207; x=1731503007; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nTcq1xsSMSqUo9ODZN+EvP0e3Vg3LWs2Mru9xD3rYU0=; b=Hy6ROpl7S9xRNkzwSFxEKPki+6TC+ivykwlDmgZVklkxbpsio+VLUB2OTHOUJHzicR bYP8DjxLNwBJ+5gdJURbr9jJDySY47CUCRDuVF3XaMNbQGYeiTNUlutEh0wqxfvHk9q3 jxmc+MAiLFcc1FlquFCzvebxAW9d9sDLVZ+NRbSxCChnh/9cxjPFRtIaQcpImjAVnE7k kb+QsRyQWuzpFzSx51RnomUF+1rmPtgQcydkAFQaU5WhRJEeZOort4GtNS9HuQuU8C1z ggzd/RbbMoJ+E6qBWiyrOTi9ZfWZgOkS8JhdhP5ZvhZ4bK86ukNZGb/dgiN1H0g1+ePT esZQ== X-Gm-Message-State: AOJu0YwaKPQ+8nCvoMR+7/AirTAyAkNzBz2MBYcIVO1vjelaQE+49iRF R5yz0sV3eyNIuJDB6LtyUpvsnTKqKysfj/dUKMo/q+J2Qon/J5pJQ7OXyU/xwYE= X-Google-Smtp-Source: AGHT+IGaiaITR2X5ZWA3PdVGEROn+P5FPwBbeK8kzHu2TGR1fLpoF3Px/b+DEOzSkfM6HxzHyJFK4w== X-Received: by 2002:a17:902:ce85:b0:20c:a1a3:5373 with SMTP id d9443c01a7336-2111b01c640mr277755555ad.55.1730898206580; Wed, 06 Nov 2024 05:03:26 -0800 (PST) Received: from adriano.. ([191.119.55.5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a62bfb6sm1411296a91.43.2024.11.06.05.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 05:03:26 -0800 (PST) From: Adriano Cordova To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, rfried.dev@gmail.com, jerome.forissier@linaro.org, xypron.glpk@gmx.de, Adriano Cordova Subject: [PATCH 2/7] net: wget: add definition of struct wget_http_info Date: Wed, 6 Nov 2024 10:03:18 -0300 Message-ID: <20241106130318.211072-1-adrianox@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 06 Nov 2024 15:13:43 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The struct wget_http_info exposes the HTTP information of the last HTTP request issued by wget, and it controls whether the efi bootdevice is set, and whether the buffer size needs to be checked (lwip stack only). This information is otherwise discarded. The wget_http_info struct can be used by HTTP drivers to have more control over HTTP requests. Signed-off-by: Adriano Cordova --- include/net-common.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/net-common.h b/include/net-common.h index fd7c5e7b48..38ba95cf60 100644 --- a/include/net-common.h +++ b/include/net-common.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -506,4 +507,30 @@ int wget_with_dns(ulong dst_addr, char *uri); bool wget_validate_uri(char *uri); //int do_wget(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); +enum wget_http_method { + WGET_HTTP_METHOD_GET, + WGET_HTTP_METHOD_POST, + WGET_HTTP_METHOD_PATCH, + WGET_HTTP_METHOD_OPTIONS, + WGET_HTTP_METHOD_CONNECT, + WGET_HTTP_METHOD_HEAD, + WGET_HTTP_METHOD_PUT, + WGET_HTTP_METHOD_DELETE, + WGET_HTTP_METHOD_TRACE, + WGET_HTTP_METHOD_MAX +}; + +#define MAX_HTTP_HEADERS_SIZE SZ_64K + +struct wget_http_info { + enum wget_http_method method; + ulong status_code; + ulong file_size; + ulong buffer_size; + bool set_bootdev; + bool check_buffer_size; + u32 hdr_cont_len; + char *headers; +}; + #endif /* __NET_COMMON_H__ */ From patchwork Wed Nov 6 13:03:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adriano Cordova X-Patchwork-Id: 2007571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=L/N2Vk39; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xk6ds2pqxz1xyW for ; Thu, 7 Nov 2024 01:14:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0E543891F4; Wed, 6 Nov 2024 15:13:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="L/N2Vk39"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2EEC9891BC; Wed, 6 Nov 2024 14:03:48 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 03CCA88C7C for ; Wed, 6 Nov 2024 14:03:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=adrianox@gmail.com Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-720c286bcd6so5634256b3a.3 for ; Wed, 06 Nov 2024 05:03:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730898224; x=1731503024; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=L2L8BQBiTVxExJxLBDz3DtKccrCP37UkZBNwKAeluWc=; b=L/N2Vk39XSqWXrX8KIs9ZRqc/f11iyEQzQqmfbvsIcKalno1y4J35VJt+Z702AKfyf wB3jCzRdC9BJgFivz7o9bILeuYOlCy3xgfntwhEMKB6vhf2s+NvDrdVx+Dx6O9tD0Teu rcRE0esru6sSfKd/nhVFw4hdEfztEDyeimnoyJWorqYg7kCDS5OBpa9a8xNXk6OE2Vw3 Hl0MziZ4M7MM4I+9qGpDAqGsUM6gDqo2Cq5yUQylWhviVsPrJJa2yCSn8GhZ4UUqBwTL MhlzGuQqplTY786EFNvnGYlljcO53CgYgPX7V4bJpexOoWE/FTYuwY9F+o05LIgLEItw h4Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730898224; x=1731503024; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=L2L8BQBiTVxExJxLBDz3DtKccrCP37UkZBNwKAeluWc=; b=qBUj3wSf1rYE7O7OveFgsF/nob5xxbKsCQmBs73QgqjCd/7ax5NEE7rPkGK4A8BkGi appVrQqLPW2sUk3deMC3qM9pFuX6dVaKDNXyuRW25BbqPFp53HAlkbrNlgC27SghvQnk m3JFX5iT5qct+HODSLRQGnSwc1tT4kLeB48c4/ABEBUkVBTDfIUplVrEGGgjVei7SLuP XvO8081DgU5O2KXL7NZBJ9Yp7sgQVax+WAxlsvcrC2QphCjQ5a8O+LxjnAN+ksVeNPJf nlMUn0IDGXEpciZO9BSY2BM3FPnWXzUjoDzTaGKr30emekk87ljrcwjB3RnKUwqYpz7d QAhQ== X-Gm-Message-State: AOJu0YyGljrRVGo9euTGZWD8p3bfcFq3fSuW1QIcySKLrKqDLWT2NqV9 EfRqnKspj1QGYWP+pQ4GY16IvrEBiksp46vsWZWi99CrymFq3XHIkiCHD9+H9hM= X-Google-Smtp-Source: AGHT+IE4ixSoKNDBbIRr0MaFMAvVOhNt76bHdtgcCeU+23PnFtp7pIJhBhQyZDR49FpDp6N7LWO5Mg== X-Received: by 2002:a05:6a20:12c4:b0:1db:ee7e:6e4a with SMTP id adf61e73a8af0-1dbee7e78d4mr9480454637.14.1730898224389; Wed, 06 Nov 2024 05:03:44 -0800 (PST) Received: from adriano.. ([191.119.55.5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7ee455a7ee3sm11116155a12.55.2024.11.06.05.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 05:03:44 -0800 (PST) From: Adriano Cordova To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, rfried.dev@gmail.com, jerome.forissier@linaro.org, xypron.glpk@gmx.de, Adriano Cordova Subject: [PATCH 3/7] net: wget: Add a global struct wget_http_info Date: Wed, 6 Nov 2024 10:03:37 -0300 Message-ID: <20241106130337.211101-1-adrianox@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 06 Nov 2024 15:13:43 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Declare and define a global struct wget_http_info. The default values are so that wget works as it used to, but they can be changed by an application before issuing an http request using wget, and restored afterwards. This struct is common to legacy wget and lwip wget. Signed-off-by: Adriano Cordova --- include/net-common.h | 2 ++ net/net-common.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/net-common.h b/include/net-common.h index 38ba95cf60..3039dfdce7 100644 --- a/include/net-common.h +++ b/include/net-common.h @@ -533,4 +533,6 @@ struct wget_http_info { char *headers; }; +extern struct wget_http_info wget_info; + #endif /* __NET_COMMON_H__ */ diff --git a/net/net-common.c b/net/net-common.c index a7f767d5e9..e969d508cc 100644 --- a/net/net-common.c +++ b/net/net-common.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include void copy_filename(char *dst, const char *src, int size) { @@ -11,3 +12,12 @@ void copy_filename(char *dst, const char *src, int size) *dst++ = *src++; *dst = '\0'; } + +struct wget_http_info wget_info = { + .method = WGET_HTTP_METHOD_GET, + .file_size = 0, + .buffer_size = 0, + .set_bootdev = true, + .check_buffer_size = false, + .headers = NULL, +}; From patchwork Wed Nov 6 13:03:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adriano Cordova X-Patchwork-Id: 2007572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=TFllq44q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xk6f31Xwtz1xyW for ; Thu, 7 Nov 2024 01:14:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6C1B189207; Wed, 6 Nov 2024 15:13:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TFllq44q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 12DC1891BC; Wed, 6 Nov 2024 14:04:04 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BC1E388E5C for ; Wed, 6 Nov 2024 14:04:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=adrianox@gmail.com Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-20c70abba48so59721905ad.0 for ; Wed, 06 Nov 2024 05:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730898240; x=1731503040; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8MljCW/4VjEEMFhZ8Tc9+coNuSq0Ec+/A7IN2HEQoyM=; b=TFllq44qDgYVtjvfdH2G16cCBgfrw/zooZKKknZbCJktmJvlAvN1HWUJUi2DtmsD1c wgjKm90XAqabPjmPNsPZGtKfd39NFwUbZrRzHtRzFCsYhAJuHahmM44ye0LEwXaA2gf/ /30UfofY0aq4s8g9QQqhe3YvbS1Puy1XYRpX02twpoYt3/cMc0AxAj2yOSlOQSqLxE7g 1N+aeTuJfb7Tt088JyNslmvwqGhaa3AtDhHvdSz8SixBUMGaekO8izllVb/P+8zs4Tu9 6mpreEQbfVkaf9SQiQeFHUCC1QEg+irFwE5u9f3UPc4AO3tayiE9Qlaz9V8GBazyyLA9 HNjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730898240; x=1731503040; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8MljCW/4VjEEMFhZ8Tc9+coNuSq0Ec+/A7IN2HEQoyM=; b=ikOIgyIro9sSrZlQrPLw+6feOUaDPG/mYZ5+bRbCFPZT7WrAT2YGWLIp1JgnxX3XFJ U4bvmQyapItvX/mN29jSG479Mkrnz0WFOvL/SiEQCX9oN/P6i5OVsMNdOTVv6ua9W2V7 pMR/1+OmC7GD328WSaLX8SvrNO1gyuhdPPlQWhEjeXD1FB/9A29vZrgGCnpxhAb3SrPW 6QrDIeWEyT6bDFPhEnQ4334KSnLd3UdBqeF47zkKXiADGlGXQReSgGh5hqrQe606DLL1 9CglZ24MSFFvvalN/+ZaBFUpnW4V3iZsFfYOTh++4rF3zOG0SXrABFQg4h1OGBayWjvx mOkQ== X-Gm-Message-State: AOJu0Yxn0IzXP9jWH8tqI+25Ny3PSjOm570dQ30+JM7PDG520K0zHajT vpUwHnLP9uqygw5FqYv1o3fKN23f440L/82D6mtVM0bJYuj4RJ6OMs/7mxJnRVM= X-Google-Smtp-Source: AGHT+IEMoj8xQ3t3uQf7091v3EhwkE8UwgRTR5cGA0yHD4bHzD36gYy4sYIVRDzmSuQVThq1ZGyqzw== X-Received: by 2002:a17:902:cec7:b0:20c:8763:b3f7 with SMTP id d9443c01a7336-2111af3bc88mr273662455ad.17.1730898240112; Wed, 06 Nov 2024 05:04:00 -0800 (PST) Received: from adriano.. ([191.119.55.5]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057a22d5sm94513845ad.132.2024.11.06.05.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 05:03:59 -0800 (PST) From: Adriano Cordova To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, rfried.dev@gmail.com, jerome.forissier@linaro.org, xypron.glpk@gmx.de, Adriano Cordova Subject: [PATCH 4/7] net: wget: integrate struct wget_info into legacy wget code Date: Wed, 6 Nov 2024 10:03:55 -0300 Message-ID: <20241106130355.211132-1-adrianox@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 06 Nov 2024 15:13:43 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Each wget request now fills the struct wget_info. Also, the efi bootdevice is now set conditionally to the set_bootdevice variable in wget_info, and the same holds for lmb memory check. Signed-off-by: Adriano Cordova --- net/wget.c | 88 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 21 deletions(-) diff --git a/net/wget.c b/net/wget.c index 635f82efbb..24be0a4932 100644 --- a/net/wget.c +++ b/net/wget.c @@ -22,10 +22,10 @@ DECLARE_GLOBAL_DATA_PTR; /* The default, change with environment variable 'httpdstp' */ #define SERVER_PORT 80 -static const char bootfile1[] = "GET "; +static const char bootfileGET[] = "GET "; +static const char bootfileHEAD[] = "HEAD "; static const char bootfile3[] = " HTTP/1.0\r\n\r\n"; static const char http_eom[] = "\r\n\r\n"; -static const char http_ok[] = "200"; static const char content_len[] = "Content-Length"; static const char linefeed[] = "\r\n"; static struct in_addr web_server_ip; @@ -77,7 +77,7 @@ static inline int store_block(uchar *src, unsigned int offset, unsigned int len) ulong newsize = offset + len; uchar *ptr; - if (CONFIG_IS_ENABLED(LMB)) { + if (CONFIG_IS_ENABLED(LMB) && wget_info.set_bootdev) { if (store_addr < image_load_addr || lmb_read_check(store_addr, len)) { printf("\nwget error: "); @@ -132,8 +132,17 @@ static void wget_send_stored(void) IP_TCP_HDR_SIZE + TCP_TSOPT_SIZE + 2; offset = ptr; - memcpy(offset, &bootfile1, strlen(bootfile1)); - offset += strlen(bootfile1); + switch (wget_info.method) { + case WGET_HTTP_METHOD_HEAD: + memcpy(offset, &bootfileHEAD, strlen(bootfileHEAD)); + offset += strlen(bootfileHEAD); + break; + case WGET_HTTP_METHOD_GET: + default: + memcpy(offset, &bootfileGET, strlen(bootfileGET)); + offset += strlen(bootfileGET); + break; + } memcpy(offset, image_url, strlen(image_url)); offset += strlen(image_url); @@ -193,6 +202,47 @@ static void wget_timeout_handler(void) #define PKT_QUEUE_OFFSET 0x20000 #define PKT_QUEUE_PACKET_SIZE 0x800 +static void wget_fill_info(const uchar *pkt, int hlen, struct wget_http_info *info) +{ + const char *first_space; + const char *second_space; + char *pos, *end; + + if (info->headers && hlen < MAX_HTTP_HEADERS_SIZE) + strncpy(info->headers, pkt, hlen); + + //Get status code + first_space = strchr(pkt, ' '); + if (!first_space) { + info->status_code = -1; + return; + } + + second_space = strchr(first_space + 1, ' '); + if (!second_space) { + info->status_code = -1; + return; + } + + info->status_code = simple_strtoul(first_space + 1, &end, 10); + + if (second_space != end) + info->status_code = -1; + + pos = strstr((char *)pkt, content_len); + + if (pos) { + pos += sizeof(content_len) + 1; + while (*pos == ' ') + pos++; + content_length = simple_strtoul(pos, &end, 10); + debug_cond(DEBUG_WGET, + "wget: Connected Len %lu\n", + content_length); + wget_info.hdr_cont_len = content_length; + } +} + static void wget_connected(uchar *pkt, unsigned int tcp_seq_num, u8 action, unsigned int tcp_ack_num, unsigned int len) { @@ -241,7 +291,11 @@ static void wget_connected(uchar *pkt, unsigned int tcp_seq_num, initial_data_seq_num = tcp_seq_num + hlen; next_data_seq_num = tcp_seq_num + len; - if (strstr((char *)pkt, http_ok) == 0) { + wget_fill_info(pkt, hlen, &wget_info); + debug_cond(DEBUG_WGET, + "wget: HTTP Status Code %ld\n", wget_info.status_code); + + if (wget_info.status_code != 200) { debug_cond(DEBUG_WGET, "wget: Connected Bad Xfer\n"); wget_loop_state = NETLOOP_FAIL; @@ -251,17 +305,6 @@ static void wget_connected(uchar *pkt, unsigned int tcp_seq_num, "wget: Connected Pkt %p hlen %x\n", pkt, hlen); - pos = strstr((char *)pkt, content_len); - if (!pos) { - content_length = -1; - } else { - pos += sizeof(content_len) + 2; - strict_strtoul(pos, 10, &content_length); - debug_cond(DEBUG_WGET, - "wget: Connected Len %lu\n", - content_length); - } - net_boot_file_size = 0; if (len > hlen) { @@ -397,10 +440,13 @@ static void wget_handler(uchar *pkt, u16 dport, case WGET_TRANSFERRED: printf("Packets received %d, Transfer Successful\n", packets); net_set_state(wget_loop_state); - efi_set_bootdev("Net", "", image_url, - map_sysmem(image_load_addr, 0), - net_boot_file_size); - env_set_hex("filesize", net_boot_file_size); + wget_info.file_size = net_boot_file_size; + if (wget_info.method == WGET_HTTP_METHOD_GET && wget_info.set_bootdev) { + efi_set_bootdev("Net", "", image_url, + map_sysmem(image_load_addr, 0), + net_boot_file_size); + env_set_hex("filesize", net_boot_file_size); + } break; } } From patchwork Wed Nov 6 13:04:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adriano Cordova X-Patchwork-Id: 2007573 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MdY/QUFv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xk6fC44jvz1xyW for ; Thu, 7 Nov 2024 01:14:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C005B8920B; Wed, 6 Nov 2024 15:13:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MdY/QUFv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 321B5891CF; Wed, 6 Nov 2024 14:04:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0BE1E88E5C for ; Wed, 6 Nov 2024 14:04:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=adrianox@gmail.com Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-2e2e87153a3so4619954a91.3 for ; Wed, 06 Nov 2024 05:04:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730898256; x=1731503056; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=F1FZy94mJYqvsulwmggbwrBJzPKrXy9n9+myRLsHZpo=; b=MdY/QUFvnR+mZ9hFQr4GooqluSJ6UHd2fUY2uFvsTdD0IpozdGHxmeiR9E8j0qZqAU B2dPvQLVlmEOUIRU/CdCfJLAKUMAZ6AoehNIFUBURctnZkbG1YDXW4K5hRkAegii0tvH PPnBXx4ZFA9LxH7ljGp8vdekMmFnZcOC9Muwsn4mEFG8mZATqpTuFnA7/ABhDQSFBwf5 HFZGaMy49cWqS+0eGD96pOAg0Fj+MX30gstHAieUwrwVwCLymy9S2XSWxHOi+BDaKpP1 yyZHoKixsPx8gQfcL9297fz8VRVePvc659fF8ASSHvVmmf+PkbGwZk2B6JLWMxVfYmKZ XzLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730898256; x=1731503056; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=F1FZy94mJYqvsulwmggbwrBJzPKrXy9n9+myRLsHZpo=; b=jzCrdPZiJs6CCPgFc2xwR4KuaZAbheT9cI3NpYQNbtD0Movlvoyb9TNCI51qSPiK3B q0abXZZXbktQPz9ZjjKARlHcy9uG980q0VrA/fWJFJexYqEMtmPbnnholLGuiYEfnaIy HAJnubzdXkfkilB9dZMyp8LvGlKWGz/PBi2fKPoX6E5lA+IQHmhZ8C3dA6u6+Sr5dps1 CwSw1aTW/T4Tfe967Rtj3jWQp/qEwqqv/QWuswpAdNjYej32fjHYjfc7Xb16fb7OXiuF XsqoSbuKHniBu87CG4QXDe39GMr1+XcBRWB+4V+YirhiuD+Gym+b4dSwSC4lGI0KBwUF exWQ== X-Gm-Message-State: AOJu0YyuxylUVd1rLclI4TZ5rFL6Omg2RAPRzBfBjt2lRn0ItbI0sEeD 9gadppOxtMaND2Kaj1Hu6frg09cv/JkJViPsgHpogLT8jOA0SbxOLEA4M6hyWBA= X-Google-Smtp-Source: AGHT+IFBECN8AtdFOUC0qCy9/HZEAgYbl78uQrmenkRdU1V/oCEhWQDyv/G7Fx8yLBuqJWOLsNxmEA== X-Received: by 2002:a17:90b:5286:b0:2e2:cf5c:8edf with SMTP id 98e67ed59e1d1-2e94c2abc33mr26904197a91.9.1730898256373; Wed, 06 Nov 2024 05:04:16 -0800 (PST) Received: from adriano.. ([191.119.55.5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a62d6acsm1422783a91.53.2024.11.06.05.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 05:04:16 -0800 (PST) From: Adriano Cordova To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, rfried.dev@gmail.com, jerome.forissier@linaro.org, xypron.glpk@gmx.de, Adriano Cordova Subject: [PATCH 5/7] net: wget: make wget_with_dns return value compatible with its lwip version Date: Wed, 6 Nov 2024 10:04:11 -0300 Message-ID: <20241106130411.211160-1-adrianox@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 06 Nov 2024 15:13:43 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean There are two wget_with_dns functions, one in the legacy network stack and one in lwip, but the return values are not compatible. This commit modifies the legacy version of wget_with_dns so that the return values are compatible: 0 on success, otherwise a negative error. This way wget_with_dns can be called in a network stack agnostic way. Signed-off-by: Adriano Cordova --- net/wget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/wget.c b/net/wget.c index 24be0a4932..6cf721070b 100644 --- a/net/wget.c +++ b/net/wget.c @@ -576,7 +576,7 @@ int wget_with_dns(ulong dst_addr, char *uri) out: free(str_copy); - return ret; + return ret < 0 ? ret : 0; } #endif From patchwork Wed Nov 6 13:04:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adriano Cordova X-Patchwork-Id: 2007574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=FiVamSDq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xk6fQ1Kjmz1xyW for ; Thu, 7 Nov 2024 01:14:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 33B7189218; Wed, 6 Nov 2024 15:13:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FiVamSDq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 644BD891CF; Wed, 6 Nov 2024 14:04:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3BC8C88E5C for ; Wed, 6 Nov 2024 14:04:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=adrianox@gmail.com Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2e2e23f2931so5075942a91.0 for ; Wed, 06 Nov 2024 05:04:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730898274; x=1731503074; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mlAUx/Sg1Pgrp45uD0MJl22B+NV7fG9Ab8N3G+2s8tQ=; b=FiVamSDqyIGtIWIBw5eAjsxsS+j+i7AWDgpUIFgtCDp7j/0zeNRNGWr8a/n47D92Ux gi3Y1iBoJt8uy2+kxJoB1fUVDItP7TsxJJ6S/FgIXpVx8ABtiM5b2l9qz6Bx3qrAG4U2 S2LVsb6hmZZQdT4dLTbCbq4xHF5mE46XheDTBlis7rYPGCYfqQJQ/ohRI/5RNi8Xa87w fdu91G3nta7iLE68bKuBH8kT+ThGBwXqno8UUxnIpW5VhXO1QBF321HxddeiBq7n4iuQ 8JsliMpdqF6+GhaBFEQdwks3d7VqvPEwRbyLKbzs+052yJ4xzgZDI+DPgCck+yftQwQH CW2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730898274; x=1731503074; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mlAUx/Sg1Pgrp45uD0MJl22B+NV7fG9Ab8N3G+2s8tQ=; b=rxSZphI5G8Ko7lVSGPGQTgH6Wxm3DOv/cAzDOuEZc2Cdhrm7yOfmQA6jBBaWH8VsEZ QrFGp93stp1SL5nuWE011ldLHhrU1D9q2kbu5nEI63Jmt8BH7ZGhap/BeqXGZghcPJRS YsJHBal3VeMOnzIltbSXU1Yi6Xx7sZxOCTZ6vv7bPeq75x40gheWMoJqJD0OoNhMDIbB jI0H4WFrziCbIZ95RQnBtQnFnUULU70yu4NObuRqnLiGzZhZm78l85rPRmaMHFQDNfU3 4qnWfVaN/TEK2+a2xlRm27324gwf/fauISDbBDmNhkgz8Iu9zlcUm50QU9qTTgAUYg5L pfqQ== X-Gm-Message-State: AOJu0YwWiwQ8nLWR62bA2sCSdOCdy684/H8DeJLGdEd9InkrXg9hbFmb Dku5fXw9PqwEDby0HjoVftCTOVjAD4kuKPNYT3cAOz1POrf9wolkW4cUGeP26/c= X-Google-Smtp-Source: AGHT+IEBNwyjMjEKpwA1vAYgJBlCbqiUwmy2itEBTkoM8nd5WH8ogUsN/+dgqHCGYUNIpmsanktYlw== X-Received: by 2002:a17:90b:2781:b0:2e5:5e55:7f18 with SMTP id 98e67ed59e1d1-2e94c2e77f5mr27974470a91.24.1730898273715; Wed, 06 Nov 2024 05:04:33 -0800 (PST) Received: from adriano.. ([191.119.55.5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e99a4f6c96sm1555903a91.2.2024.11.06.05.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 05:04:33 -0800 (PST) From: Adriano Cordova To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, rfried.dev@gmail.com, jerome.forissier@linaro.org, xypron.glpk@gmx.de, Adriano Cordova Subject: [PATCH 6/7] net/lwip: wget: put server_name and port into wget_ctx Date: Wed, 6 Nov 2024 10:04:28 -0300 Message-ID: <20241106130428.211190-1-adrianox@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 06 Nov 2024 15:13:43 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Currently server_name and port are local variables in wget_loop. This commit puts them inside ctx, so that they are accessible from the http callbacks. Signed-off-by: Adriano Cordova --- net/lwip/wget.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/lwip/wget.c b/net/lwip/wget.c index b495ebd1aa..4add520045 100644 --- a/net/lwip/wget.c +++ b/net/lwip/wget.c @@ -23,6 +23,8 @@ enum done_state { }; struct wget_ctx { + char server_name[SERVER_NAME_SIZE]; + u16 port; char *path; ulong daddr; ulong saved_daddr; @@ -209,13 +211,11 @@ static void httpc_result_cb(void *arg, httpc_result_t httpc_result, static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri) { - char server_name[SERVER_NAME_SIZE]; httpc_connection_t conn; httpc_state_t *state; struct netif *netif; struct wget_ctx ctx; char *path; - u16 port; ctx.daddr = dst_addr; ctx.saved_daddr = dst_addr; @@ -224,7 +224,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri) ctx.prevsize = 0; ctx.start_time = 0; - if (parse_url(uri, server_name, &port, &path)) + if (parse_url(uri, ctx.server_name, &ctx.port, &path)) return CMD_RET_USAGE; netif = net_lwip_new_netif(udev); @@ -234,7 +234,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri) memset(&conn, 0, sizeof(conn)); conn.result_fn = httpc_result_cb; ctx.path = path; - if (httpc_get_file_dns(server_name, port, path, &conn, httpc_recv_cb, + if (httpc_get_file_dns(ctx.server_name, ctx.port, path, &conn, httpc_recv_cb, &ctx, &state)) { net_lwip_remove_netif(netif); return CMD_RET_FAILURE; From patchwork Wed Nov 6 13:04:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adriano Cordova X-Patchwork-Id: 2007575 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=mKq1ihtz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xk6fY3MY9z1xyW for ; Thu, 7 Nov 2024 01:15:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8544E8921E; Wed, 6 Nov 2024 15:13:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mKq1ihtz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 22E47891CF; Wed, 6 Nov 2024 14:04:55 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DC63888E5C for ; Wed, 6 Nov 2024 14:04:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=adrianox@gmail.com Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-20cbcd71012so76116295ad.3 for ; Wed, 06 Nov 2024 05:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730898291; x=1731503091; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WQXUQ87baf6VUD4sk+fZshBlW38IUXZZNKLreXcrq7Y=; b=mKq1ihtzAz+kzVTj8c7k3OCQiHWwsj5um6TfLRjyw/n+Qyg/jOZyl/AIbprVllU1sn RthH1mDZI4HaZ7SmUVIbrnlOErJ7U6U4wUfUhpRRekr6NHWojrrAqOkO1eeDPNeKHS3z MmgQwoJE0Xbpd9DyOviQj8kjl8k3/tsUUaLYEBoGRC7wHAV1gf8Syg0NOuKCjrmwok02 BAcdc19BBsxVtnwfc4e739eD8NU4l8P+dFtymqG4nJyhTsO2w3d6hEenDiGUOlUN+54/ F4DCrcekdiDWYKhsoejuxgu9M7LF9ZM9tlftCCz01fCRDffLrv4xUuAiPz1w3lgGb6iO pqow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730898291; x=1731503091; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WQXUQ87baf6VUD4sk+fZshBlW38IUXZZNKLreXcrq7Y=; b=WHkblHbEfsl+yjDj/GXaAzaxsmhEGrhPNv89VG0h88j+D/t/6Q51Vq6/7lNT6FIJVI Z8sk/r68ZhJ7de1nzi8haH4vckjFImPbcIdYQ32QZo47mPdmlV7PdXB8miwfPxy2EVUA v1f2UY6xIOL2xCFDXbzBgnKa7sFpED3ugxdIOZrbAGFLlEe0N5aHoH35TrT6ZTrkdsAW iu0lYd4QIOJVhuCqC7OZT5ZxuFAjzMm3Qk1IYGI4mckGkY0UUr2/2FNRkGDQc4dl3IcP 24IYKvZQUdKJfvW4RxCMlLmLCHa9eYBjXa1zW1DVbwnFLa8YVIHTQZ+nDf6twyqr1Ze7 +FDA== X-Gm-Message-State: AOJu0Yz2ZnG925mmLLEMZCi0n0+AAxmZcRA6LebKNGElC/uQ5adEsslQ KKiQBqMGuNLaU+Q7KiDqVf9SDsLKeavVUYAeMRhq1qRbkMFC8UbXpMaZHrwnvLk= X-Google-Smtp-Source: AGHT+IFp/xRbUi/UhKHOtvS+W6xA+4Q4d3jzKuuIiu838F2TfRENV/ZHrJLePe9vvbiYAnOxIPI6Sw== X-Received: by 2002:a17:902:db11:b0:20b:b238:9d02 with SMTP id d9443c01a7336-2111af31802mr294573175ad.33.1730898291340; Wed, 06 Nov 2024 05:04:51 -0800 (PST) Received: from adriano.. ([191.119.55.5]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057a2a8asm95603295ad.180.2024.11.06.05.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 05:04:50 -0800 (PST) From: Adriano Cordova To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, rfried.dev@gmail.com, jerome.forissier@linaro.org, xypron.glpk@gmx.de, Adriano Cordova Subject: [PATCH 7/7] net/lwip: wget: integrate struct wget_info into wget code Date: Wed, 6 Nov 2024 10:04:46 -0300 Message-ID: <20241106130446.211222-1-adrianox@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 06 Nov 2024 15:13:43 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Each wget request now fills the struct wget_info. Also, the efi bootdevice is now set conditionally to the set_bootdevice variable in wget_info and a buffer size check is performed if check_buffer_size is set. Signed-off-by: Adriano Cordova --- net/lwip/wget.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/net/lwip/wget.c b/net/lwip/wget.c index 4add520045..bc0ecfe5b7 100644 --- a/net/lwip/wget.c +++ b/net/lwip/wget.c @@ -34,6 +34,19 @@ struct wget_ctx { enum done_state done; }; +static void wget_lwip_fill_info(struct pbuf *hdr, u16_t hdr_len, + struct wget_http_info *info, u32_t hdr_cont_len) +{ + if (info->headers && hdr_len < MAX_HTTP_HEADERS_SIZE) + pbuf_copy_partial(hdr, (void *)info->headers, hdr_len, 0); + info->hdr_cont_len = (u32)hdr_cont_len; +} + +static void wget_lwip_set_file_size(u32_t rx_content_len, struct wget_http_info *info) +{ + info->file_size = (ulong)rx_content_len; +} + static int parse_url(char *url, char *host, u16 *port, char **path) { char *p, *pp; @@ -178,6 +191,13 @@ static void httpc_result_cb(void *arg, httpc_result_t httpc_result, struct wget_ctx *ctx = arg; ulong elapsed; + wget_info.status_code = (ulong)srv_res; + + if (err == ERR_BUF) { + ctx->done = FAILURE; + return; + } + if (httpc_result != HTTPC_RESULT_OK) { log_err("\nHTTP client error %d\n", httpc_result); ctx->done = FAILURE; @@ -197,8 +217,11 @@ static void httpc_result_cb(void *arg, httpc_result_t httpc_result, printf("%u bytes transferred in %lu ms (", rx_content_len, elapsed); print_size(rx_content_len / elapsed * 1000, "/s)\n"); printf("Bytes transferred = %lu (%lx hex)\n", ctx->size, ctx->size); - efi_set_bootdev("Net", "", ctx->path, map_sysmem(ctx->saved_daddr, 0), - rx_content_len); + if (wget_info.set_bootdev) { + efi_set_bootdev("Net", "", ctx->path, map_sysmem(ctx->saved_daddr, 0), + rx_content_len); + } + wget_lwip_set_file_size(rx_content_len, &wget_info); if (env_set_hex("filesize", rx_content_len) || env_set_hex("fileaddr", ctx->saved_daddr)) { log_err("Could not set filesize or fileaddr\n"); @@ -209,6 +232,17 @@ static void httpc_result_cb(void *arg, httpc_result_t httpc_result, ctx->done = SUCCESS; } +static err_t httpc_headers_done_cb(httpc_state_t *connection, void *arg, struct pbuf *hdr, + u16_t hdr_len, u32_t content_len) +{ + wget_lwip_fill_info(hdr, hdr_len, &wget_info, content_len); + + if (wget_info.check_buffer_size && (ulong)content_len > wget_info.buffer_size) + return ERR_BUF; + + return ERR_OK; +} + static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri) { httpc_connection_t conn; @@ -233,6 +267,7 @@ static int wget_loop(struct udevice *udev, ulong dst_addr, char *uri) memset(&conn, 0, sizeof(conn)); conn.result_fn = httpc_result_cb; + conn.headers_done_fn = httpc_headers_done_cb; ctx.path = path; if (httpc_get_file_dns(ctx.server_name, ctx.port, path, &conn, httpc_recv_cb, &ctx, &state)) {