From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Masahisa Kojima <masahisa.kojima@linaro.org>
Cc: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
Simon Glass <sjg@chromium.org>,
Takahiro Akashi <takahiro.akashi@linaro.org>,
Joe Hershberger <joe.hershberger@ni.com>,
Ramon Fried <rfried.dev@gmail.com>
Subject: Re: [PATCH v2 2/6] net: wget: add wget with dns utility function
Date: Thu, 14 Sep 2023 15:52:09 +0300 [thread overview]
Message-ID: <ZQMB+VZ6msAaK5da@hera> (raw)
In-Reply-To: <20230901102542.609239-3-masahisa.kojima@linaro.org>
Kojima-san
[...]
> }
> +
> +#if (IS_ENABLED(CONFIG_CMD_DNS))
> +int wget_with_dns(ulong dst_addr, char *uri)
> +{
> + int ret;
> + char *s, *host_name, *file_name, *str_copy;
> +
> + /*
> + * Download file using wget.
> + *
> + * U-Boot wget takes the target uri in this format.
> + * "<http server ip>:<file path>" e.g.) 192.168.1.1:/sample/test.iso
> + * Need to resolve the http server ip address before starting wget.
> + */
> + str_copy = strdup(uri);
> + if (!str_copy)
> + return -ENOMEM;
> +
> + s = str_copy + strlen("http://");
> + host_name = strsep(&s, "/");
> + if (!s) {
> + log_err("Error: invalied uri, no file path\n");
> + ret = -EINVAL;
> + goto out;
> + }
> + file_name = s;
> +
> + /* TODO: If the given uri has ip address for the http server, skip dns */
> + net_dns_resolve = host_name;
> + net_dns_env_var = "httpserverip";
This is not idea, but I understand this is how dns currently works. We
can take another look on improving this when LWIP lands
> + if (net_loop(DNS) < 0) {
> + log_err("Error: dns lookup of %s failed, check setup\n", net_dns_resolve);
> + ret = -EINVAL;
> + goto out;
> + }
> + s = env_get("httpserverip");
> + if (!s) {
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + strlcpy(net_boot_file_name, s, 1024);
sizeof(net_boot_file_name) here please
> + strlcat(net_boot_file_name, ":/", 1024); /* append '/' which is removed by strsep() */
> + strlcat(net_boot_file_name, file_name, 1024);
Don't you have to limit the size of subsequent writes depending on what
previous calls wrote? IOW that can't always be 1024.
> + image_load_addr = dst_addr;
> + ret = net_loop(WGET);
> +
> +out:
> + free(str_copy);
> +
> + return ret;
> +}
> +#endif
> --
> 2.34.1
>
Thanks
/Ilias
next prev parent reply other threads:[~2023-09-14 12:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-01 10:25 [PATCH v2 0/6] Add EFI HTTP boot support Masahisa Kojima
2023-09-01 10:25 ` [PATCH v2 1/6] net: wget: prevent overwriting reserved memory Masahisa Kojima
2023-09-02 0:09 ` Simon Glass
2023-09-05 7:13 ` Masahisa Kojima
2023-09-01 10:25 ` [PATCH v2 2/6] net: wget: add wget with dns utility function Masahisa Kojima
2023-09-14 12:52 ` Ilias Apalodimas [this message]
2023-09-14 23:20 ` Masahisa Kojima
2023-09-01 10:25 ` [PATCH v2 3/6] blk: blkmap: add ramdisk creation " Masahisa Kojima
2023-09-02 0:09 ` Simon Glass
2023-09-01 10:25 ` [PATCH v2 4/6] efi_loader: support boot from URI device path Masahisa Kojima
2023-09-14 13:56 ` Ilias Apalodimas
2023-09-15 4:15 ` Masahisa Kojima
2023-09-15 6:31 ` Ilias Apalodimas
2023-09-15 7:45 ` Masahisa Kojima
2023-09-15 8:11 ` Ilias Apalodimas
2023-09-14 14:55 ` Heinrich Schuchardt
2023-09-15 4:17 ` Masahisa Kojima
2023-09-01 10:25 ` [PATCH v2 5/6] cmd: efidebug: add uri " Masahisa Kojima
2023-09-01 10:25 ` [PATCH v2 6/6] doc: uefi: add HTTP Boot support Masahisa Kojima
2023-09-14 13:57 ` Ilias Apalodimas
2023-09-14 23:52 ` Masahisa Kojima
2023-09-15 6:09 ` Ilias Apalodimas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZQMB+VZ6msAaK5da@hera \
--to=ilias.apalodimas@linaro.org \
--cc=joe.hershberger@ni.com \
--cc=masahisa.kojima@linaro.org \
--cc=rfried.dev@gmail.com \
--cc=sjg@chromium.org \
--cc=takahiro.akashi@linaro.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox